X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2FAPI.pm;h=6ca2b553be3622690954daec16b453adfd8e254d;hp=32400f7c3c9743aee075f14d55885ce4b176d79f;hb=ff27c3f36240aee48ed50153dd5d8fe3ac3f2443;hpb=53846367793e58f00ce32b2fcbd05e9f0ddd179e diff --git a/FS/FS/API.pm b/FS/FS/API.pm index 32400f7c3..6ca2b553b 100644 --- a/FS/FS/API.pm +++ b/FS/FS/API.pm @@ -8,6 +8,7 @@ use FS::cust_location; use FS::cust_pay; use FS::cust_credit; use FS::cust_refund; +use FS::cust_pkg; =head1 NAME @@ -65,6 +66,10 @@ Amount paid Option date for payment +=item order_number + +Optional order number + =back Example: @@ -77,6 +82,7 @@ Example: #optional '_date' => 1397977200, #UNIX timestamp + 'order_number' => '12345', ); if ( $result->{'error'} ) { @@ -556,6 +562,87 @@ sub location_info { return \%return; } +=item change_package_location + +Updates package location. Takes a list of keys and values +as paramters with the following keys: + +pkgnum + +secret + +locationnum - pass this, or the following keys (don't pass both) + +locationname + +address1 + +address2 + +city + +county + +state + +zip + +addr_clean + +country + +censustract + +censusyear + +location_type + +location_number + +location_kind + +incorporated + +On error, returns a hashref with an 'error' key. +On success, returns a hashref with 'pkgnum' and 'locationnum' keys, +containing the new values. + +=cut + +sub change_package_location { + my $class = shift; + my %opt = @_; + return _shared_secret_error() unless _check_shared_secret($opt{'secret'}); + + my $cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $opt{'pkgnum'} }) + or return { 'error' => 'Unknown pkgnum' }; + + my %changeopt; + + foreach my $field ( qw( + locationnum + locationname + address1 + address2 + city + county + state + zip + addr_clean + country + censustract + censusyear + location_type + location_number + location_kind + incorporated + )) { + $changeopt{$field} = $opt{$field} if $opt{$field}; + } + + $cust_pkg->API_change(%changeopt); +} + =item bill_now OPTION => VALUE, ... Bills a single customer now, in the same fashion as the "Bill now" link in the