X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=eg%2Fexport_template.pm;h=22eb36a420b54961d14ee463fd934cf0c152873c;hp=f2a5a19f7c484fc1888aa3e2c787fa48e910a426;hb=e638cca7c5be9bc9b98eabbf41babc2e58671aac;hpb=9bf26ed4b065b12826fc2980ff277a2f3be25c1d diff --git a/eg/export_template.pm b/eg/export_template.pm index f2a5a19f7..22eb36a42 100644 --- a/eg/export_template.pm +++ b/eg/export_template.pm @@ -1,16 +1,42 @@ package FS::part_export::myexport; -use vars qw(@ISA); +use vars qw(@ISA %info); +use Tie::IxHash; use FS::part_export; @ISA = qw(FS::part_export); +tie my %options, 'Tie::IxHash', + 'regular_option' => { label => 'Option description', default => 'value' }, + 'select_option' => { label => 'Select option description', + type => 'select', options=>[qw(chocolate vanilla)], + default => 'vanilla', + }, + 'textarea_option' => { label => 'Textarea option description', + type => 'textarea', + default => 'Default text.', + }, + 'checkbox_option' => { label => 'Checkbox label', type => 'checkbox' }, +; + +%info = ( + 'svc' => 'svc_acct', + #'svc' => [qw( svc_acct svc_forward )], + 'desc' => + 'Export short description', + 'options' => \%options, + 'nodomain' => 'Y', + 'notes' => <<'END' +HTML notes about this export. +END + sub rebless { shift; } sub _export_insert { my($self, $svc_something) = (shift, shift); - $self->myexport_queue( $svc_acct->svcnum, 'insert', + $err_or_queue = $self->myexport_queue( $svc_something->svcnum, 'insert', $svc_something->username, $svc_something->_password ); + ref($err_or_queue) ? '' : $err_or_queue; } sub _export_replace { @@ -18,16 +44,43 @@ sub _export_replace { #return "can't change username with myexport" # if $old->username ne $new->username; #return '' unless $old->_password ne $new->_password; - $self->myexport_queue( $new->svcnum, + $err_or_queue = $self->myexport_queue( $new->svcnum, 'replace', $new->username, $new->_password ); + ref($err_or_queue) ? '' : $err_or_queue; } sub _export_delete { my( $self, $svc_something ) = (shift, shift); - $self->myexport_queue( $svc_acct->svcnum, + $err_or_queue = $self->myexport_queue( $svc_something->svcnum, 'delete', $svc_something->username ); + ref($err_or_queue) ? '' : $err_or_queue; +} + +#these three are optional +# fallback for svc_acct will change and restore password +sub _export_suspend { + my( $self, $svc_something ) = (shift, shift); + $err_or_queue = $self->myexport_queue( $svc_something->svcnum, + 'suspend', $svc_something->username ); + ref($err_or_queue) ? '' : $err_or_queue; +} + +sub _export_unsuspend { + my( $self, $svc_something ) = (shift, shift); + $err_or_queue = $self->myexport_queue( $svc_something->svcnum, + 'unsuspend', $svc_something->username ); + ref($err_or_queue) ? '' : $err_or_queue; +} + +sub export_links { + my($self, $svc_something, $arrayref) = (shift, shift, shift); + #push @$arrayref, qq!!. $svc_something->username. qq!!; + ''; } +### + #a good idea to queue anything that could fail or take any time sub myexport_queue { my( $self, $svcnum, $method ) = (shift, shift, shift); @@ -35,13 +88,26 @@ sub myexport_queue { 'svcnum' => $svcnum, 'job' => "FS::part_export::myexport::myexport_$method", }; - $queue->insert( @_ ); + $queue->insert( @_ ) or $queue; } sub myexport_insert { #subroutine, not method + my( $username, $password ) = @_; + #do things with $username and $password } + sub myexport_replace { #subroutine, not method } + sub myexport_delete { #subroutine, not method + my( $username ) = @_; + #do things with $username } +sub myexport_suspend { #subroutine, not method +} + +sub myexport_unsuspend { #subroutine, not method +} + +