2 % $cgi->param('error', $error);
3 % $cgi->redirect(popurl(3). 'misc/detach_pkg.html?'. $cgi->query_string );
6 <% header(emt("Package detached")) %>
7 <SCRIPT TYPE="text/javascript">
8 window.top.location.reload();
16 my $curuser = $FS::CurrentUser::CurrentUser;
19 unless $curuser->access_right('Change customer package');
21 my $cust_pkg = qsearchs({
22 'table' => 'cust_pkg',
23 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
24 'hashref' => { 'pkgnum' => scalar($cgi->param('pkgnum')), },
25 'extra_sql' => ' AND '. $curuser->agentnums_sql,
27 die 'unknown pkgnum' unless $cust_pkg;
29 my $cust_location = new FS::cust_location {
30 map { $_ => scalar($cgi->param($_)) } FS::cust_main->location_fields
33 my $cust_main = new FS::cust_main {
34 ( map { ( $_, scalar($cgi->param($_)) ) } fields('cust_main') ),
35 ( map { ( "ship_$_", '' ) } FS::cust_main->location_fields ),
36 'bill_location' => $cust_location,
37 'ship_location' => $cust_location,
40 my $pkg_or_error = $cust_pkg->change( {
42 'cust_main' => $cust_main,
45 my $error = ref($pkg_or_error) ? '' : $pkg_or_error;