New refnum (see L<FS::part_referral>).
+=item quantity
+
+New quantity; if unspecified, the new package will have the same quantity
+as the old.
+
=item cust_pkg
"New" (existing) FS::cust_pkg object. The package's services and other
my $self = shift;
my $opt = ref($_[0]) ? shift : { @_ };
-# my ($custnum, $pkgparts, $remove_pkgnum, $return_cust_pkg, $refnum) = @_;
-#
-
my $conf = new FS::Conf;
# Transactionize this whole mess
my $time = time;
- #$hash{$_} = $self->$_() foreach qw( last_bill bill );
-
- #$hash{$_} = $self->$_() foreach qw( setup );
-
$hash{'setup'} = $time if $self->setup;
$hash{'change_date'} = $time;
}
$hash{'contactnum'} = $opt->{'contactnum'} if $opt->{'contactnum'};
+ $hash{'quantity'} = $opt->{'quantity'} || $self->quantity;
my $cust_pkg;
if ( $opt->{'cust_pkg'} ) {
=item locationnum
-The pkgpart and locationnum of the new package, with the same
+=item quantity
+
+The pkgpart. locationnum, and quantity of the new package, with the same
meaning as in C<change>.
=back
if $opt->{'pkgpart'} and $opt->{'pkgpart'} != $change_to->pkgpart;
my $new_locationnum = $opt->{'locationnum'}
if $opt->{'locationnum'} and $opt->{'locationnum'} != $change_to->locationnum;
- if ( $new_pkgpart or $new_locationnum ) {
+ my $new_quantity = $opt->{'quantity'}
+ if $opt->{'quantity'} and $opt->{'quantity'} != $change_to->quantity;
+ if ( $new_pkgpart or $new_locationnum or $new_quantity ) {
# it hasn't been billed yet, so in principle we could just edit
# it in place (w/o a package change), but that's bad form.
# So change the package according to the new options...
if $opt->{'pkgpart'} and $opt->{'pkgpart'} != $self->pkgpart;
my $new_locationnum = $opt->{'locationnum'}
if $opt->{'locationnum'} and $opt->{'locationnum'} != $self->locationnum;
- return '' unless $new_pkgpart or $new_locationnum; # wouldn't do anything
+ my $new_quantity = $opt->{'quantity'}
+ if $opt->{'quantity'} and $opt->{'quantity'} != $self->quantity;
+
+ return '' unless $new_pkgpart or $new_locationnum or $new_quantity; # wouldn't do anything
my %hash = (
'custnum' => $self->custnum,
'pkgpart' => ($opt->{'pkgpart'} || $self->pkgpart),
'locationnum' => ($opt->{'locationnum'} || $self->locationnum),
+ 'quantity' => ($opt->{'quantity'} || $self->quantity),
'start_date' => $date,
);
my $new = FS::cust_pkg->new(\%hash);
'cust_main' => $cust_main,
&>
+ <& /elements/tr-input-pkg-quantity.html,
+ 'curr_value' => $cust_pkg->quantity
+ &>
+
<& /elements/tr-select-cust_location.html,
'cgi' => $cgi,
'cust_main' => $cust_main,
if ( $cust_pkg->change_to_pkgnum ) {
my $change_to = FS::cust_pkg->by_key($cust_pkg->change_to_pkgnum);
$cgi->param('delay', 1);
- foreach(qw( start_date pkgpart locationnum )) {
+ foreach(qw( start_date pkgpart locationnum quantity )) {
$cgi->param($_, $change_to->get($_));
}
$title = "Edit Scheduled Package Change";