summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Prykop <jonathan@freeside.biz>2015-02-12 13:30:03 -0600
committerJonathan Prykop <jonathan@freeside.biz>2015-02-12 13:30:03 -0600
commit9954eac1ec11d4bf1d6e7925895ce675fcdc6e22 (patch)
tree5d37c627aee36d0bd2c708abfe1463a24cc1ae81
parent6e3c1b8915c39e82a9a1ac48acc5b0c360daadb7 (diff)
parent342e1472c53f4718b6600fe52be3068f2caba61a (diff)
Merge branch 'FREESIDE_3_BRANCH' of git.freeside.biz:/home/git/freeside into FREESIDE_3_BRANCH
-rw-r--r--FS/FS/ClientAPI/MyAccount.pm30
-rw-r--r--FS/FS/cust_location.pm2
-rw-r--r--FS/FS/cust_main/Packages.pm30
-rw-r--r--FS/FS/quotation_pkg.pm9
-rw-r--r--FS/FS/quotation_pkg_discount.pm12
-rw-r--r--fs_selfservice/FS-SelfService/SelfService.pm19
-rw-r--r--httemplate/edit/process/elements/process.html6
-rw-r--r--httemplate/elements/tr-select-inventory_item.html5
8 files changed, 71 insertions, 42 deletions
diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm
index 279acb256..023c1d6cf 100644
--- a/FS/FS/ClientAPI/MyAccount.pm
+++ b/FS/FS/ClientAPI/MyAccount.pm
@@ -46,8 +46,9 @@ use FS::payby;
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 );
@@ -2268,11 +2269,23 @@ sub order_pkg {
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;
@@ -2331,11 +2344,12 @@ sub order_pkg {
}
- 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;
diff --git a/FS/FS/cust_location.pm b/FS/FS/cust_location.pm
index 23dbce909..ad6d706bb 100644
--- a/FS/FS/cust_location.pm
+++ b/FS/FS/cust_location.pm
@@ -322,7 +322,7 @@ sub check {
$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')
diff --git a/FS/FS/cust_main/Packages.pm b/FS/FS/cust_main/Packages.pm
index 7bb32726c..19ee63aa4 100644
--- a/FS/FS/cust_main/Packages.pm
+++ b/FS/FS/cust_main/Packages.pm
@@ -59,6 +59,15 @@ jobs will have a dependancy on the supplied job (they will not run until the
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
@@ -81,6 +90,8 @@ sub order_pkg {
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'} || [];
@@ -184,18 +195,14 @@ sub order_pkg {
'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;
@@ -235,7 +242,8 @@ on the supplied jobnum (they will not run until the specific job completes).
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
diff --git a/FS/FS/quotation_pkg.pm b/FS/FS/quotation_pkg.pm
index 88147bc99..6c8aa463b 100644
--- a/FS/FS/quotation_pkg.pm
+++ b/FS/FS/quotation_pkg.pm
@@ -105,11 +105,8 @@ otherwise returns false.
=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;
@@ -318,7 +315,7 @@ sub insert_discount {
#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
@@ -329,7 +326,7 @@ sub insert_discount {
'setup' => $self->discountnum_setup,
} );
- $cust_pkg_discount->insert;
+ $quotation_pkg_discount->insert;
}
sub _item_discount {
@@ -351,7 +348,7 @@ 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};
diff --git a/FS/FS/quotation_pkg_discount.pm b/FS/FS/quotation_pkg_discount.pm
index 19a7bceb4..87ac6bd04 100644
--- a/FS/FS/quotation_pkg_discount.pm
+++ b/FS/FS/quotation_pkg_discount.pm
@@ -118,18 +118,6 @@ sub check {
=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).
diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm
index 8227e5789..adbf32f83 100644
--- a/fs_selfservice/FS-SelfService/SelfService.pm
+++ b/fs_selfservice/FS-SelfService/SelfService.pm
@@ -832,6 +832,25 @@ Session identifier
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>).
diff --git a/httemplate/edit/process/elements/process.html b/httemplate/edit/process/elements/process.html
index 698540b79..5b79c21bb 100644
--- a/httemplate/edit/process/elements/process.html
+++ b/httemplate/edit/process/elements/process.html
@@ -219,7 +219,7 @@ my %hash =
my @values = ( 1 );
if ( $bfield ) {
@values = $cgi->param($bfield);
- warn join(',', @values);
+ #warn join(',', @values);
}
my @uploaded_files;
@@ -308,7 +308,7 @@ foreach my $value ( @values ) {
warn "$me processing m2m:\n". Dumper( %$process_m2m )
if $opt{'debug'};
- $error = $new->process_m2m( %$process_m2m );
+ $error ||= $new->process_m2m( %$process_m2m );
}
}
@@ -350,7 +350,7 @@ foreach my $value ( @values ) {
);
}
- $error = $new->process_o2m( %{ $process_o2m },
+ $error ||= $new->process_o2m( %{ $process_o2m },
'params' => scalar($cgi->Vars),
);
}
diff --git a/httemplate/elements/tr-select-inventory_item.html b/httemplate/elements/tr-select-inventory_item.html
index 669e85f27..d7a14ec95 100644
--- a/httemplate/elements/tr-select-inventory_item.html
+++ b/httemplate/elements/tr-select-inventory_item.html
@@ -12,7 +12,6 @@
<& tr-td-label.html, %opt &>
<TD>
<& select-tiered.html,
- 'prefix' => $opt{'field'}.'_',
'tiers' => [
{
field => $opt{'field'}.'_classnum',
@@ -32,12 +31,15 @@
},
],
%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'} };
@@ -45,4 +47,5 @@ if (ref($opt{'classnum'})) {
@classnums = split(',', $opt{'classnum'});
}
my $classnum_sql = 'classnum IN('.join(',', @classnums).')';
+
</%init>