1 <& /elements/header-popup.html, emt("Package contact $past_method") &>
2 <SCRIPT TYPE="text/javascript">
10 unless $FS::CurrentUser::CurrentUser->access_right('Change customer package');
13 my $pkgnum = $cgi->param('pkgnum');
14 $pkgnum =~ /^(\d+)$/ or die "Illegal pkgnum";
17 my $cust_pkg = qsearchs( 'cust_pkg', {'pkgnum'=>$pkgnum} ); #needs agent virt
19 my $contactnum = $cgi->param('contactnum');
20 $contactnum =~ /^(-?\d*)$/ or die "Illegal contactnum";
23 my $past_method = $cust_pkg->contactnum ? 'changed' : 'added';
27 if ( $contactnum == -1 ) {
29 #little false laziness w/edit/process/quick-cust_pkg.cgi, also the whole
30 # thing should be a single transaction
31 my $contact = new FS::contact {
32 'custnum' => $cust_pkg->custnum,
33 map { $_ => scalar($cgi->param("contactnum_$_")) } qw( first last )
35 $error = $contact->insert;
36 $cust_pkg->contactnum( $contact->contactnum );
39 $cust_pkg->contactnum($contactnum);
42 $error ||= $cust_pkg->replace;
45 $cgi->param('error', $error);
46 print $cgi->redirect(popurl(2). "change_pkg_contact.html?". $cgi->query_string );