use FS::acct_rt_transaction;
use FS::msg_template;
use FS::contact;
+use FS::cust_location;
-$DEBUG = 1;
+$DEBUG = 0;
$me = '[FS::ClientAPI::MyAccount]';
use vars qw( @cust_main_editable_fields @location_editable_fields );
or return { 'error' => "unknown custnum $custnum" };
my $status = $cust_main->status;
+
+ my %order_pkg_options = ());
+ if ( $p->{locationnum} > 0 ) {
+ $order_pkg_options{locationnum} = delete($p->{locationnum});
+ } elsif ( $p->{address1} ) {
+ $order_pkg_options{'cust_location'} = new FS::cust_location {
+ map { $_ => $p->{$_} }
+ qw( address1 address2 city county state zip country )
+ };
+ }
+
#false laziness w/ClientAPI/Signup.pm
my $cust_pkg = new FS::cust_pkg ( {
- 'custnum' => $custnum,
- 'pkgpart' => $p->{'pkgpart'},
+ 'custnum' => $custnum,
+ 'pkgpart' => $p->{'pkgpart'},
+ 'quantity' => $p->{'quantity'} || 1,
} );
my $error = $cust_pkg->check;
return { 'error' => $error } if $error;
}
- use Tie::RefHash;
- tie my %hash, 'Tie::RefHash';
- %hash = ( $cust_pkg => \@svc );
- #msgcat
- $error = $cust_main->order_pkgs( \%hash, 'noexport' => 1 );
+ $error = $cust_main->order_pkg(
+ 'cust_pkg' => $cust_pkg,
+ 'svcs' => \@svc,
+ 'noexport' => 1,
+ %order_pkg_options,
+ );
return { 'error' => $error } if $error;
my $conf = new FS::Conf;
$self->ut_numbern('locationnum')
|| $self->ut_foreign_keyn('prospectnum', 'prospect_main', 'prospectnum')
|| $self->ut_foreign_keyn('custnum', 'cust_main', 'custnum')
- || $self->ut_alphan('locationname')
+ || $self->ut_textn('locationname')
|| $self->ut_text('address1')
|| $self->ut_textn('address2')
|| $self->ut_text('city')
specific job completes). This can be used to defer provisioning until some
action completes (such as running the customer's credit card successfully).
+=item noexport
+
+This option is option is deprecated but still works for now (use
+I<depend_jobnum> instead for new code). If I<noexport> is set true, no
+provisioning jobs (exports) are scheduled. (You can schedule them later with
+the B<reexport> method for each cust_pkg object. Using the B<reexport> method
+on the cust_main object is not recommended, as existing services will also be
+reexported.)
+
=item ticket_subject
Optional subject for a ticket created and attached to this customer
join(', ', map { "$_: $opt->{$_}" } keys %$opt ). "\n"
if $DEBUG;
+ local $FS::svc_Common::noexport_hack = 1 if $opt->{'noexport'};
+
my $cust_pkg = $opt->{'cust_pkg'};
my $svcs = $opt->{'svcs'} || [];
'custnum' => $self->custnum,
'main_pkgnum' => $cust_pkg->pkgnum,
# try to prevent as many surprises as possible
- 'pkgbatch' => $cust_pkg->pkgbatch,
- 'start_date' => $cust_pkg->start_date,
- 'order_date' => $cust_pkg->order_date,
- 'expire' => $cust_pkg->expire,
- 'adjourn' => $cust_pkg->adjourn,
- 'contract_end' => $cust_pkg->contract_end,
- 'refnum' => $cust_pkg->refnum,
- 'discountnum' => $cust_pkg->discountnum,
- 'waive_setup' => $cust_pkg->waive_setup,
'allow_pkgpart' => $opt->{'allow_pkgpart'},
+ map { $_ => $cust_pkg->$_() }
+ qw( pkgbatch
+ start_date order_date expire adjourn contract_end
+ refnum discountnum waive_setup
+ )
});
- $error = $self->order_pkg('cust_pkg' => $pkg,
+ $error = $self->order_pkg('cust_pkg' => $pkg,
'locationnum' => $cust_pkg->locationnum);
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
This can be used to defer provisioning until some action completes (such
as running the customer's credit card successfully).
-The I<noexport> option is deprecated. If I<noexport> is set true, no
+The I<noexport> option is deprecated but still works for now (use
+I<depend_jobnum> instead for new code). If I<noexport> is set true, no
provisioning jobs (exports) are scheduled. (You can schedule them later with
the B<reexport> method for each cust_pkg object. Using the B<reexport> method
on the cust_main object is not recommended, as existing services will also be
=cut
-use Data::Dumper; #XXX DEBUG
sub insert {
my ($self, %options) = @_;
- warn Dumper($self);
- warn Dumper(\%options);
my $dbh = dbh;
my $oldAutoCommit = $FS::UID::AutoCommit;
#my ($self, %options) = @_;
my $self = shift;
- my $cust_pkg_discount = FS::quotation_pkg_discount->new( {
+ my $quotation_pkg_discount = FS::quotation_pkg_discount->new( {
'quotationpkgnum' => $self->quotationpkgnum,
'discountnum' => $self->discountnum,
#for the create a new discount case
'setup' => $self->discountnum_setup,
} );
- $cust_pkg_discount->insert;
+ $quotation_pkg_discount->insert;
}
sub _item_discount {
push @ext, $pkg_discount->description;
$d->{setup_amount} -= $pkg_discount->setup_amount;
$d->{recur_amount} -= $pkg_discount->recur_amount;
- }
+ }
$d->{setup_amount} *= $self->quantity || 1;
$d->{recur_amount} *= $self->quantity || 1;
$d->{amount} = $d->{setup_amount} + $d->{recur_amount};
=back
-=item amount
-
-Returns the total amount of this discount (setup + recur), for compatibility
-with L<FS::cust_bill_pkg_discount>.
-
-=cut
-
-sub amount {
- my $self = shift;
- return $self->get('setup_amount') + $self->get('recur_amount');
-}
-
=item description
Returns a string describing the discount (for use on the quotation).
Package to order (see L<FS::part_pkg>).
+=item quantity
+
+Quantity for this package order (default 1).
+
+=item locationnum
+
+Optional locationnum for this package order, for existing locations.
+
+Or, for new locations, pass the following fields: address1*, address2, city*,
+county, state*, zip*, country. (* = required in this case)
+
+=item address1
+
+=item address 2
+
+=item city
+
+=item
+
=item svcpart
Service to order (see L<FS::part_svc>).
my @values = ( 1 );
if ( $bfield ) {
@values = $cgi->param($bfield);
- warn join(',', @values);
+ #warn join(',', @values);
}
my @uploaded_files;
warn "$me processing m2m:\n". Dumper( %$process_m2m )
if $opt{'debug'};
- $error = $new->process_m2m( %$process_m2m );
+ $error ||= $new->process_m2m( %$process_m2m );
}
}
);
}
- $error = $new->process_o2m( %{ $process_o2m },
+ $error ||= $new->process_o2m( %{ $process_o2m },
'params' => scalar($cgi->Vars),
);
}
<& tr-td-label.html, %opt &>
<TD>
<& select-tiered.html,
- 'prefix' => $opt{'field'}.'_',
'tiers' => [
{
field => $opt{'field'}.'_classnum',
},
],
%opt,
+ 'prefix' => $opt{'prefix'}. $opt{'field'}. '_', #after %opt so it overrides
&>
</TD>
</TR>
% }
<%init>
+
my %opt = @_;
+
my @classnums;
if (ref($opt{'classnum'})) {
@classnums = @{ $opt{'classnum'} };
@classnums = split(',', $opt{'classnum'});
}
my $classnum_sql = 'classnum IN('.join(',', @classnums).')';
+
</%init>