pick/enter a location when ordering a package, RT#4499
[freeside.git] / FS / FS / cust_main.pm
index da1d3e1..fb68081 100644 (file)
@@ -36,6 +36,7 @@ use FS::cust_credit;
 use FS::cust_refund;
 use FS::part_referral;
 use FS::cust_main_county;
+use FS::cust_location;
 use FS::tax_rate;
 use FS::cust_tax_location;
 use FS::part_pkg_taxrate;
@@ -135,101 +136,181 @@ FS::Record.  The following fields are currently supported:
 
 =over 4
 
-=item custnum - primary key (assigned automatically for new customers)
+=item custnum
 
-=item agentnum - agent (see L<FS::agent>)
+Primary key (assigned automatically for new customers)
 
-=item refnum - Advertising source (see L<FS::part_referral>)
+=item agentnum
+
+Agent (see L<FS::agent>)
+
+=item refnum
+
+Advertising source (see L<FS::part_referral>)
+
+=item first
+
+First name
+
+=item last
 
-=item first - name
+Last name
 
-=item last - name
+=item ss
 
-=item ss - social security number (optional)
+Cocial security number (optional)
 
-=item company - (optional)
+=item company
+
+(optional)
 
 =item address1
 
-=item address2 - (optional)
+=item address2
+
+(optional)
 
 =item city
 
-=item county - (optional, see L<FS::cust_main_county>)
+=item county
+
+(optional, see L<FS::cust_main_county>)
 
-=item state - (see L<FS::cust_main_county>)
+=item state
+
+(see L<FS::cust_main_county>)
 
 =item zip
 
-=item country - (see L<FS::cust_main_county>)
+=item country
+
+(see L<FS::cust_main_county>)
+
+=item daytime
 
-=item daytime - phone (optional)
+phone (optional)
 
-=item night - phone (optional)
+=item night
 
-=item fax - phone (optional)
+phone (optional)
 
-=item ship_first - name
+=item fax
 
-=item ship_last - name
+phone (optional)
 
-=item ship_company - (optional)
+=item ship_first
+
+Shipping first name
+
+=item ship_last
+
+Shipping last name
+
+=item ship_company
+
+(optional)
 
 =item ship_address1
 
-=item ship_address2 - (optional)
+=item ship_address2
+
+(optional)
 
 =item ship_city
 
-=item ship_county - (optional, see L<FS::cust_main_county>)
+=item ship_county
+
+(optional, see L<FS::cust_main_county>)
 
-=item ship_state - (see L<FS::cust_main_county>)
+=item ship_state
+
+(see L<FS::cust_main_county>)
 
 =item ship_zip
 
-=item ship_country - (see L<FS::cust_main_county>)
+=item ship_country
+
+(see L<FS::cust_main_county>)
+
+=item ship_daytime
+
+phone (optional)
+
+=item ship_night
+
+phone (optional)
 
-=item ship_daytime - phone (optional)
+=item ship_fax
 
-=item ship_night - phone (optional)
+phone (optional)
 
-=item ship_fax - phone (optional)
+=item payby
+
+Payment Type (See L<FS::payinfo_Mixin> for valid payby values)
 
-=item payby - Payment Type (See L<FS::payinfo_Mixin> for valid payby values)
+=item payinfo
 
-=item payinfo - Payment Information (See L<FS::payinfo_Mixin> for data format)
+Payment Information (See L<FS::payinfo_Mixin> for data format)
 
-=item paymask - Masked payinfo (See L<FS::payinfo_Mixin> for how this works)
+=item paymask
+
+Masked payinfo (See L<FS::payinfo_Mixin> for how this works)
 
 =item paycvv
 
 Card Verification Value, "CVV2" (also known as CVC2 or CID), the 3 or 4 digit number on the back (or front, for American Express) of the credit card
 
-=item paydate - expiration date, mm/yyyy, m/yyyy, mm/yy or m/yy
+=item paydate
+
+Expiration date, mm/yyyy, m/yyyy, mm/yy or m/yy
+
+=item paystart_month
+
+Start date month (maestro/solo cards only)
+
+=item paystart_year
+
+Start date year (maestro/solo cards only)
+
+=item payissue
+
+Issue number (maestro/solo cards only)
+
+=item payname
+
+Name on card or billing name
+
+=item payip
 
-=item paystart_month - start date month (maestro/solo cards only)
+IP address from which payment information was received
 
-=item paystart_year - start date year (maestro/solo cards only)
+=item tax
 
-=item payissue - issue number (maestro/solo cards only)
+Tax exempt, empty or `Y'
 
-=item payname - name on card or billing name
+=item otaker
 
-=item payip - IP address from which payment information was received
+Order taker (assigned automatically, see L<FS::UID>)
 
-=item tax - tax exempt, empty or `Y'
+=item comments
 
-=item otaker - order taker (assigned automatically, see L<FS::UID>)
+Comments (optional)
 
-=item comments - comments (optional)
+=item referral_custnum
 
-=item referral_custnum - referring customer number
+Referring customer number
 
-=item spool_cdr - Enable individual CDR spooling, empty or `Y'
+=item spool_cdr
 
-=item dundate - a suggestion to events (see L<FS::part_bill_event">) to delay until this unix timestamp
+Enable individual CDR spooling, empty or `Y'
 
-=item squelch_cdr - Discourage individual CDR printing, empty or `Y'
+=item dundate
+
+A suggestion to events (see L<FS::part_bill_event">) to delay until this unix timestamp
+
+=item squelch_cdr
+
+Discourage individual CDR printing, empty or `Y'
 
 =back
 
@@ -1641,6 +1722,17 @@ sub cust_pkg {
   shift->all_pkgs(@_);
 }
 
+=item cust_location
+
+Returns all locations (see L<FS::cust_location>) for this customer.
+
+=cut
+
+sub cust_location {
+  my $self = shift;
+  qsearch('cust_location', { 'custnum' => $self->custnum } );
+}
+
 =item ncancelled_pkgs
 
 Returns all non-cancelled packages (see L<FS::cust_pkg>) for this customer.
@@ -2905,6 +2997,11 @@ Only return events for the specified eventtable (by default, events of all event
 
 Explicitly pass the objects to be tested (typically used with eventtable).
 
+=item testonly
+
+Set to true to return the objects, but not actually insert them into the
+database.
+
 =back
 
 =cut
@@ -2935,7 +3032,8 @@ sub due_cust_event {
   local $FS::UID::AutoCommit = 0;
   my $dbh = dbh;
 
-  $self->select_for_update; #mutex
+  $self->select_for_update #mutex
+    unless $opt{testonly};
 
   ###
   # 1: find possible events (initial search)