This commit was generated by cvs2svn to compensate for changes in r11022,
[freeside.git] / httemplate / edit / process / change-cust_pkg.html
1 % if ($error) {
2 %   $cgi->param('error', $error);
3 %   $cgi->redirect(popurl(3). 'misc/change_pkg.cgi?'. $cgi->query_string );
4 % } else {
5
6     <% header("Package changed") %>
7       <SCRIPT TYPE="text/javascript">
8         window.top.location.reload();
9       </SCRIPT>
10     </BODY>
11     </HTML>
12
13 % }
14 <%init>
15
16 my $curuser = $FS::CurrentUser::CurrentUser;
17
18 die "access denied"
19   unless $curuser->access_right('Change customer package');
20
21 my $cust_pkg = qsearchs({
22   #'select'    => 'cust_pkg.*',
23   'table'     => 'cust_pkg',
24   'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
25   'hashref'   => { 'pkgnum' => scalar($cgi->param('pkgnum')), },
26   'extra_sql' => ' AND '. $curuser->agentnums_sql,
27 });
28 die 'unknown pkgnum' unless $cust_pkg;
29
30 my %change = map { $_ => scalar($cgi->param($_)) }
31                  qw( locationnum pkgpart );
32
33 $change{'keep_dates'} = 1;
34
35 if ( $cgi->param('locationnum') == -1 ) {
36   my $cust_location = new FS::cust_location {
37     'custnum' => $cust_pkg->custnum,
38     map { $_ => scalar($cgi->param($_)) }
39         qw( address1 address2 city county state zip country )
40   };
41   $change{'cust_location'} = $cust_location;
42 }
43
44 my $pkg_or_error = $cust_pkg->change( \%change );
45
46 my $error = ref($pkg_or_error) ? '' : $pkg_or_error;
47
48 </%init>