diff options
Diffstat (limited to 'bin')
| -rw-r--r-- | bin/cust_main-email_and_rebill | 73 | ||||
| -rwxr-xr-x | bin/freeside-debian-releases.sh | 24 | ||||
| -rwxr-xr-x | bin/recover-cust_location | 33 | ||||
| -rwxr-xr-x | bin/xmlrpc-advertising_sources-add.pl | 28 | ||||
| -rwxr-xr-x | bin/xmlrpc-advertising_sources-edit.pl | 30 | ||||
| -rwxr-xr-x | bin/xmlrpc-advertising_sources-list.pl | 22 | ||||
| -rwxr-xr-x | bin/xmlrpc-order_package.php | 81 |
7 files changed, 279 insertions, 12 deletions
diff --git a/bin/cust_main-email_and_rebill b/bin/cust_main-email_and_rebill new file mode 100644 index 000000000..dea1319d6 --- /dev/null +++ b/bin/cust_main-email_and_rebill @@ -0,0 +1,73 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use Date::Parse; +use FS::UID qw( adminsuidsetup ); +use FS::Record qw( qsearchs ); +use FS::cust_pkg; +use FS::msg_template; + +adminsuidsetup shift or die 'Usage: cust_main-email_and_rebill username\n'; + +my $DRY_RUN = 1; +my $msgnum = 17; + +my $sep1 = str2time('9/1/2017'); +my $aug15 = str2time('8/15/2017') + 1802; + +my $msg_template = qsearchs('msg_template', { 'msgnum' => $msgnum } ) + or die "unknown msg_template $msgnum\n"; + +while (<>) { + chomp; + my $pkgnum = $_; + + #find the package + my $cust_pkg = qsearchs('cust_pkg', { 'pkgnum'=>$pkgnum } ) + or die "pkgnum $pkgnum not found\n"; + + #reset its next bill date back to sep 1 + $cust_pkg->set('bill', $sep1); + unless ( $DRY_RUN ) { + warn "updating cust_pkg $pkgnum bill to $sep1\n"; + my $error = $cust_pkg->replace; + die $error if $error; + } else { + warn "DRY RUN: would update cust_pkg $pkgnum bill to $sep1\n"; + } + + #customer + my $cust_main = $cust_pkg->cust_main; + my $custnum = $cust_main->custnum; + + #send the custoemr a notice + unless ( $DRY_RUN ) { + warn "emailing msg_template $msgnum to customer $custnum\n"; + $msg_template->send( 'cust_main' => $cust_main, + 'object' => $cust_main, + ); + } else { + warn "DRY RUN: emailing msg_template $msgnum to customer $custnum\n"; + } + + #bill the package + unless ( $DRY_RUN ) { + warn "billing customer $custnum for package $pkgnum as of $sep1\n"; + $cust_main->bill( 'time' => $sep1, + 'invoice_time' => $aug15, + 'pkg_list' => [ $cust_pkg ], + ); + } else { + warn "DRY RUN: billing customer $custnum for package $pkgnum as of $sep1\n"; + } + + #something about removing their pending batch payment?? + #hmm, there doesn't appear to be anything in a batch + #dating the invoices aug 15th will ensure payments for them are batched + + #events will take care of the rest... + +} + +1; diff --git a/bin/freeside-debian-releases.sh b/bin/freeside-debian-releases.sh index c774dd868..84d4e92dc 100755 --- a/bin/freeside-debian-releases.sh +++ b/bin/freeside-debian-releases.sh @@ -12,7 +12,7 @@ fi DATE=`date +"%Y%m%d"` DIR="/home/autobuild/packages/staging/freeside$FS_VERSION/$FS_REPO" -TARGET="/home/jeremyd/public_html/freeside$FS_VERSION-$DISTRO-$FS_REPO" +TARGET="/home/autobuild/public_html/freeside$FS_VERSION-$DISTRO-$FS_REPO" if [ ! -d "$DIR" -a -d $TARGET ]; then @@ -31,13 +31,6 @@ git checkout -- debian/changelog git pull #STATUS=`git pull` -#Assign the proper config files for freeside-ng-selfservice -if [ $DISTRO = "wheezy" ]; then - ln -s $DIR/freeside/debian/freeside-ng-selfservice.deb7 $DIR/freeside/debian/freeside-ng-selfservice.conffiles -else - ln -s $DIR/freeside/debian/freeside-ng-selfservice.deb8 $DIR/freeside/debian/freeside-ng-selfservice.conffiles -fi - # Add the build information to changelog if [ $FS_REPO != "stable" ]; then dch -b --newversion $GIT_VERSION-$DATE "Auto-Build" @@ -49,7 +42,14 @@ pdebuild --pbuilderroot sudo --debbuildopts "-b -rfakeroot -uc -us" --buildresul #--buildresult gets the file where it needs to be, may need to clean up DIR -cd $DIR; rm -f freeside_* -cd $TARGET; rm -f *.gz - -$TARGET/APT +cd $DIR && rm -f freeside_* +cd $TARGET && rm -f *.gz + +apt-ftparchive -qq packages ./ >Packages +gzip -c Packages >Packages.gz +#bzip2 -c Packages >Packagez.bz2 +apt-ftparchive -qq sources ./ >Sources +gzip -c Sources >Sources.gz +#bzip2 -c Sources >Sources.bz2 +rm *bz2 || true +apt-ftparchive -qq release ./ >Release diff --git a/bin/recover-cust_location b/bin/recover-cust_location new file mode 100755 index 000000000..6318eb343 --- /dev/null +++ b/bin/recover-cust_location @@ -0,0 +1,33 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use FS::UID qw( adminsuidsetup ); +use FS::Record qw( qsearchs ); +use FS::h_cust_location; +use FS::cust_location; + +adminsuidsetup shift or &usage; +my $start = shift or &usage; +my $end = shift or &usage; + +for my $locationnum ( $start .. $end ) { + + my $h_cust_location = qsearchs({ + 'table' => 'h_cust_location', + 'hashref' => { 'locationnum' => $locationnum, }, + 'extra_sql' => " AND ( history_action = 'insert' OR history_action = 'replace_new' )", + 'order_by' => 'ORDER BY historynum DESC LIMIT 1', + }) + or die "h_cust_location for $locationnum not found\n"; + + warn "recovering cust_locaiton $locationnum\n"; + my $cust_location = new FS::cust_location { $h_cust_location->hash }; + my $error = $cust_location->insert; + die $error if $error; + +} + +sub usage { + die "Usage: recover-cust_location username start_locationnum end_locationnum\n"; +} diff --git a/bin/xmlrpc-advertising_sources-add.pl b/bin/xmlrpc-advertising_sources-add.pl new file mode 100755 index 000000000..4800ad0c7 --- /dev/null +++ b/bin/xmlrpc-advertising_sources-add.pl @@ -0,0 +1,28 @@ +#!/usr/bin/perl + +use strict; +use Frontier::Client; +use Data::Dumper; + +my $uri = new URI 'http://localhost:8008/'; + +my $server = new Frontier::Client ( 'url' => $uri ); + +my $result = $server->call( + 'FS.API.add_advertising_source', + 'secret' => 'MySecretCode', + 'source' => { + 'referral' => 'API test referral', + 'disabled' => '', + 'agentnum' => '', + 'title' => 'API test title', + }, +); + +die $result->{'error'} if $result->{'error'}; + +print Dumper($result); + +print "\nAll Done\n"; + +exit;
\ No newline at end of file diff --git a/bin/xmlrpc-advertising_sources-edit.pl b/bin/xmlrpc-advertising_sources-edit.pl new file mode 100755 index 000000000..80f9139c1 --- /dev/null +++ b/bin/xmlrpc-advertising_sources-edit.pl @@ -0,0 +1,30 @@ +#!/usr/bin/perl + +use strict; +use Frontier::Client; +use Data::Dumper; + +my $uri = new URI 'http://localhost:8008/'; + +my $server = new Frontier::Client ( 'url' => $uri ); + +my $result = $server->call( + 'FS.API.edit_advertising_source', + 'secret' => 'MySecretCode', + 'refnum' => '4', + 'source' => { + 'referral' => 'Edit referral', + 'title' => 'Edit Referral title', + #'disabled' => 'Y', + #'disabled' => '', + #'agentnum' => '2', + }, +); + +die $result->{'error'} if $result->{'error'}; + +print Dumper($result); + +print "\nAll Done\n"; + +exit;
\ No newline at end of file diff --git a/bin/xmlrpc-advertising_sources-list.pl b/bin/xmlrpc-advertising_sources-list.pl new file mode 100755 index 000000000..317a38b7b --- /dev/null +++ b/bin/xmlrpc-advertising_sources-list.pl @@ -0,0 +1,22 @@ +#!/usr/bin/perl + +use strict; +use Frontier::Client; +use Data::Dumper; + +my $uri = new URI 'http://localhost:8008/'; + +my $server = new Frontier::Client ( 'url' => $uri ); + +my $result = $server->call( + 'FS.API.list_advertising_sources', + 'secret' => 'MySecretCode', +); + +die $result->{'error'} if $result->{'error'}; + +print Dumper($result); + +print "\nAll Done\n"; + +exit;
\ No newline at end of file diff --git a/bin/xmlrpc-order_package.php b/bin/xmlrpc-order_package.php new file mode 100755 index 000000000..fccf77a63 --- /dev/null +++ b/bin/xmlrpc-order_package.php @@ -0,0 +1,81 @@ +#!/usr/bin/php5 + +<?php + +$freeside = new FreesideAPI(); + +$result = $freeside->order_package( array( + 'secret' => 'sharingiscaring', #config setting api_shared_secret + 'custnum' => 619797, + 'pkgpart' => 2, + + #the rest is optional + 'quantity' => 5, + 'start_date' => '12/1/2017', + 'invoice_details' => [ 'detail', 'even more detail' ], + 'address1' => '5432 API Lane', + 'city' => 'API Town', + 'state' => 'AZ', + 'zip' => '54321', + 'country' => 'US', + 'setup_fee' => '23', + 'recur_fee' => '19000', +)); + +var_dump($result); + +#pre-php 5.4 compatible version? +function flatten($hash) { + if ( !is_array($hash) ) return $hash; + $flat = array(); + + array_walk($hash, function($value, $key, &$to) { + array_push($to, $key, $value); + }, $flat); + + if ( PHP_VERSION_ID >= 50400 ) { + + #php 5.4+ (deb 7+) + foreach ($hash as $key => $value) { + $flat[] = $key; + $flat[] = $value; + } + + } + + return($flat); +} + +class FreesideAPI { + + //Change this to match the location of your backoffice XML-RPC interface + #var $URL = 'https://localhost/selfservice/xmlrpc.cgi'; + var $URL = 'http://localhost:8008/'; + + function FreesideAPI() { + $this; + } + + public function __call($name, $arguments) { + + error_log("[FreesideAPI] $name called, sending to ". $this->URL); + + $request = xmlrpc_encode_request("FS.API.$name", flatten($arguments[0])); + $context = stream_context_create( array( 'http' => array( + 'method' => "POST", + 'header' => "Content-Type: text/xml", + 'content' => $request + ))); + $file = file_get_contents($this->URL, false, $context); + $response = xmlrpc_decode($file); + if (isset($response) && is_array($response) && xmlrpc_is_fault($response)) { + trigger_error("[FreesideAPI] XML-RPC communication error: $response[faultString] ($response[faultCode])"); + } else { + //error_log("[FreesideAPI] $response"); + return $response; + } + } + +} + +?> |
