diff options
Diffstat (limited to 'eg')
-rwxr-xr-x | eg/TEMPLATE_cust_main.import | 198 | ||||
-rw-r--r-- | eg/export_template.pm | 81 | ||||
-rw-r--r-- | eg/table_template-svc.pm | 161 | ||||
-rw-r--r-- | eg/table_template.pm | 112 |
4 files changed, 0 insertions, 552 deletions
diff --git a/eg/TEMPLATE_cust_main.import b/eg/TEMPLATE_cust_main.import deleted file mode 100755 index e91a2f1d2..000000000 --- a/eg/TEMPLATE_cust_main.import +++ /dev/null @@ -1,198 +0,0 @@ -#!/usr/bin/perl -w -# -# Template for importing legacy customer data -# -# $Id: TEMPLATE_cust_main.import,v 1.4 2001-08-21 02:44:47 ivan Exp $ - -use strict; -use Date::Parse; -use FS::UID qw(adminsuidsetup datasrc); -use FS::Record qw(fields qsearch qsearchs); -use FS::cust_main; -use FS::cust_pkg; -use FS::cust_svc; -use FS::svc_acct; -use FS::pkg_svc; - -my $user = shift or die &usage; -adminsuidsetup $user; - -# use these for the imported cust_main records (unless you have these in legacy -# data) -my($agentnum)=4; -my($refnum)=5; - -# map from legacy billing data to pkgpart, maps imported field -# LegacyBillingData to pkgpart. your names and pkgparts will be different -my(%pkgpart)=( - 'Employee' => 10, - 'Business' => 11, - 'Individual' => 12, - 'Basic PPP' => 13, - 'Slave' => 14, - 'Co-Located Server' => 15, - 'Virtual Web' => 16, - 'Perk Mail' => 17, - 'Credit Hold' => 18, -); - -my($file)="legacy_file"; - -open(CLIENT,$file) - or die "Can't open $file: $!"; - -# put a tab-separated header atop the file, or define @fields -# (use these names or change them below) -# -# for cust_main -# custnum - unique -# last - (name) -# first - (name) -# company -# address1 -# address2 -# city -# state -# zip -# country -# daytime - (phone) -# night - (phone) -# fax -# payby - CARD, BILL or COMP -# payinfo - Credit card #, P.O. # or COMP authorization -# paydate - Expiration -# tax - 'Y' for tax exempt -# for cust_pkg -# LegacyBillingData - maps via %pkgpart above to a pkgpart -# for svc_acct -# username - -my($header); -$header=<CLIENT>; -chop $header; -my(@fields)=map { /^\s*(.*[^\s]+)\s*$/; $1 } split(/\t/,$header); -#print join("\n",@fields); - -my($error); -my($link,$line)=(0,0); -while (<CLIENT>) { - chop; - next if /^[\s\t]*$/; #skip any blank lines - - #define %svc hash for this record - my(@record)=split(/\t/); - my(%svc); - foreach (@fields) { - $svc{$_}=shift @record; - } - - # might need to massage some data like this - $svc{'payby'} =~ s/^Credit Card$/CARD/io; - $svc{'payby'} =~ s/^Check$/BILL/io; - $svc{'payby'} =~ s/^Cash$/BILL/io; - $svc{'payby'} =~ s/^$/BILL/o; - $svc{'First'} =~ s/&/and/go; - $svc{'Zip'} =~ s/\s+$//go; - - my($cust_main) = new FS::cust_main ( { - 'custnum' => $svc{'custnum'}, - 'agentnum' => $agentnum, - 'last' => $svc{'last'}, - 'first' => $svc{'first'}, - 'company' => $svc{'company'}, - 'address1' => $svc{'address1'}, - 'address2' => $svc{'address2'}, - 'city' => $svc{'city'}, - 'state' => $svc{'state'}, - 'zip' => $svc{'zip'}, - 'country' => $svc{'country'}, - 'daytime' => $svc{'daytime'}, - 'night' => $svc{'night'}, - 'fax' => $svc{'fax'}, - 'payby' => $svc{'payby'}, - 'payinfo' => $svc{'payinfo'}, - 'paydate' => $svc{'paydate'}, - 'payname' => $svc{'payname'}, - 'tax' => $svc{'tax'}, - 'refnum' => $refnum, - } ); - - $error=$cust_main->insert; - - if ( $error ) { - warn $cust_main->_dump; - warn map "$_: ". $svc{$_}. "|\n", keys %svc; - die $error; - } - - my($cust_pkg)=new FS::cust_pkg ( { - 'custnum' => $svc{'custnum'}, - 'pkgpart' => $pkgpart{$svc{'LegacyBillingData'}}, - 'setup' => '', - 'bill' => '', - 'susp' => '', - 'expire' => '', - 'cancel' => '', - } ); - - $error=$cust_pkg->insert; - if ( $error ) { - warn $svc{'LegacyBillingData'}; - die $error; - } - - unless ( $svc{'username'} ) { - warn "Empty login"; - } else { - #find svc_acct record (imported with bin/svc_acct.import) for this username - my($svc_acct)=qsearchs('svc_acct',{'username'=>$svc{'username'}}); - unless ( $svc_acct ) { - warn "username ", $svc{'username'}, " not found\n"; - } else { - #link to the cust_pkg record we created above - - #find cust_svc record for this svc_acct record - my($o_cust_svc)=qsearchs('cust_svc',{ - 'svcnum' => $svc_acct->svcnum, - 'pkgnum' => '', - } ); - unless ( $o_cust_svc ) { - warn "No unlinked cust_svc for svcnum ", $svc_acct->svcnum; - } else { - - #make sure this svcpart is in pkgpart - my($pkg_svc)=qsearchs('pkg_svc',{ - 'pkgpart' => $pkgpart{$svc{'LegacyBillingData'}}, - 'svcpart' => $o_cust_svc->svcpart, - 'quantity' => 1, - }); - unless ( $pkg_svc ) { - warn "login ", $svc{'username'}, ": No svcpart ", $o_cust_svc->svcpart, - " for pkgpart ", $pkgpart{$svc{'Acct. Type'}}, "\n" ; - } else { - - #create new cust_svc record linked to cust_pkg record - my($n_cust_svc) = new FS::cust_svc ({ - 'svcnum' => $o_cust_svc->svcnum, - 'pkgnum' => $cust_pkg->pkgnum, - 'svcpart' => $pkg_svc->svcpart, - }); - my($error) = $n_cust_svc->replace($o_cust_svc); - die $error if $error; - $link++; - } - } - } - } - - $line++; - -} - -warn "\n$link of $line lines linked\n"; - -# --- - -sub usage { - die "Usage:\n\n cust_main.import user\n"; -} diff --git a/eg/export_template.pm b/eg/export_template.pm deleted file mode 100644 index 2c199db85..000000000 --- a/eg/export_template.pm +++ /dev/null @@ -1,81 +0,0 @@ -package FS::part_export::myexport; - -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); - $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 { - my( $self, $new, $old ) = (shift, shift, shift); - #return "can't change username with myexport" - # if $old->username ne $new->username; - #return '' unless $old->_password ne $new->_password; - $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); - $err_or_queue = $self->myexport_queue( $svc_something->svcnum, - 'delete', $svc_something->username ); - ref($err_or_queue) ? '' : $err_or_queue; -} - -#a good idea to queue anything that could fail or take any time -sub myexport_queue { - my( $self, $svcnum, $method ) = (shift, shift, shift); - my $queue = new FS::queue { - 'svcnum' => $svcnum, - 'job' => "FS::part_export::myexport::myexport_$method", - }; - $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 -} - diff --git a/eg/table_template-svc.pm b/eg/table_template-svc.pm deleted file mode 100644 index 7f7ef4b68..000000000 --- a/eg/table_template-svc.pm +++ /dev/null @@ -1,161 +0,0 @@ -package FS::svc_table; - -use strict; -use vars qw(@ISA); -#use FS::Record qw( qsearch qsearchs ); -use FS::svc_Common; -use FS::cust_svc; - -@ISA = qw(FS::svc_Common); - -=head1 NAME - -FS::table_name - Object methods for table_name records - -=head1 SYNOPSIS - - use FS::table_name; - - $record = new FS::table_name \%hash; - $record = new FS::table_name { 'column' => 'value' }; - - $error = $record->insert; - - $error = $new_record->replace($old_record); - - $error = $record->delete; - - $error = $record->check; - - $error = $record->suspend; - - $error = $record->unsuspend; - - $error = $record->cancel; - -=head1 DESCRIPTION - -An FS::table_name object represents an example. FS::table_name inherits from -FS::svc_Common. The following fields are currently supported: - -=over 4 - -=item field - description - -=back - -=head1 METHODS - -=over 4 - -=item new HASHREF - -Creates a new example. To add the example to the database, see L<"insert">. - -Note that this stores the hash reference, not a distinct copy of the hash it -points to. You can ask the object for a copy with the I<hash> method. - -=cut - -sub table { 'table_name'; } - -=item insert - -Adds this record to the database. If there is an error, returns the error, -otherwise returns false. - -The additional fields pkgnum and svcpart (see L<FS::cust_svc>) should be -defined. An FS::cust_svc record will be created and inserted. - -=cut - -sub insert { - my $self = shift; - my $error; - - $error = $self->SUPER::insert; - return $error if $error; - - ''; -} - -=item delete - -Delete this record from the database. - -=cut - -sub delete { - my $self = shift; - my $error; - - $error = $self->SUPER::delete; - return $error if $error; - - ''; -} - - -=item replace OLD_RECORD - -Replaces the OLD_RECORD with this one in the database. If there is an error, -returns the error, otherwise returns false. - -=cut - -sub replace { - my ( $new, $old ) = ( shift, shift ); - my $error; - - $error = $new->SUPER::replace($old); - return $error if $error; - - ''; -} - -=item suspend - -Called by the suspend method of FS::cust_pkg (see L<FS::cust_pkg>). - -=item unsuspend - -Called by the unsuspend method of FS::cust_pkg (see L<FS::cust_pkg>). - -=item cancel - -Called by the cancel method of FS::cust_pkg (see L<FS::cust_pkg>). - -=item check - -Checks all fields to make sure this is a valid example. If there is -an error, returns the error, otherwise returns false. Called by the insert -and repalce methods. - -=cut - -sub check { - my $self = shift; - - my $x = $self->setfixed; - return $x unless ref($x); - my $part_svc = $x; - - - $self->SUPER::check; -} - -=back - -=head1 BUGS - -The author forgot to customize this manpage. - -=head1 SEE ALSO - -L<FS::svc_Common>, L<FS::Record>, L<FS::cust_svc>, L<FS::part_svc>, -L<FS::cust_pkg>, schema.html from the base documentation. - -=cut - -1; - diff --git a/eg/table_template.pm b/eg/table_template.pm deleted file mode 100644 index d609bd544..000000000 --- a/eg/table_template.pm +++ /dev/null @@ -1,112 +0,0 @@ -package FS::table_name; - -use strict; -use vars qw( @ISA ); -use FS::Record qw( qsearch qsearchs ); - -@ISA = qw(FS::Record); - -=head1 NAME - -FS::table_name - Object methods for table_name records - -=head1 SYNOPSIS - - use FS::table_name; - - $record = new FS::table_name \%hash; - $record = new FS::table_name { 'column' => 'value' }; - - $error = $record->insert; - - $error = $new_record->replace($old_record); - - $error = $record->delete; - - $error = $record->check; - -=head1 DESCRIPTION - -An FS::table_name object represents an example. FS::table_name inherits from -FS::Record. The following fields are currently supported: - -=over 4 - -=item field - description - -=back - -=head1 METHODS - -=over 4 - -=item new HASHREF - -Creates a new example. To add the example to the database, see L<"insert">. - -Note that this stores the hash reference, not a distinct copy of the hash it -points to. You can ask the object for a copy with the I<hash> method. - -=cut - -# the new method can be inherited from FS::Record, if a table method is defined - -sub table { 'table_name'; } - -=item insert - -Adds this record to the database. If there is an error, returns the error, -otherwise returns false. - -=cut - -# the insert method can be inherited from FS::Record - -=item delete - -Delete this record from the database. - -=cut - -# the delete method can be inherited from FS::Record - -=item replace OLD_RECORD - -Replaces the OLD_RECORD with this one in the database. If there is an error, -returns the error, otherwise returns false. - -=cut - -# the replace method can be inherited from FS::Record - -=item check - -Checks all fields to make sure this is a valid example. If there is -an error, returns the error, otherwise returns false. Called by the insert -and replace methods. - -=cut - -# the check method should currently be supplied - FS::Record contains some -# data checking routines - -sub check { - my $self = shift; - - ''; #no error -} - -=back - -=head1 BUGS - -The author forgot to customize this manpage. - -=head1 SEE ALSO - -L<FS::Record>, schema.html from the base documentation. - -=cut - -1; - |