summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
Diffstat (limited to 'FS')
-rw-r--r--FS/Changes5
-rw-r--r--FS/FS.pm237
-rw-r--r--FS/FS/CGI.pm360
-rw-r--r--FS/FS/ClientAPI.pm44
-rw-r--r--FS/FS/ClientAPI/MyAccount.pm459
-rw-r--r--FS/FS/ClientAPI/Signup.pm262
-rw-r--r--FS/FS/ClientAPI/passwd.pm53
-rw-r--r--FS/FS/Conf.pm1205
-rw-r--r--FS/FS/ConfItem.pm63
-rw-r--r--FS/FS/InitHandler.pm91
-rw-r--r--FS/FS/Misc.pm102
-rw-r--r--FS/FS/Msgcat.pm98
-rw-r--r--FS/FS/Record.pm1659
-rw-r--r--FS/FS/Report.pm46
-rw-r--r--FS/FS/Report/Table.pm27
-rw-r--r--FS/FS/Report/Table/Monthly.pm168
-rw-r--r--FS/FS/SearchCache.pm96
-rw-r--r--FS/FS/UI/Base.pm194
-rw-r--r--FS/FS/UI/CGI.pm239
-rw-r--r--FS/FS/UI/Gtk.pm224
-rw-r--r--FS/FS/UI/agent.pm62
-rw-r--r--FS/FS/UID.pm316
-rw-r--r--FS/FS/acct_snarf.pm128
-rwxr-xr-xFS/FS/addr_block.pm331
-rw-r--r--FS/FS/agent.pm183
-rw-r--r--FS/FS/agent_type.pm166
-rw-r--r--FS/FS/cust_bill.pm1411
-rw-r--r--FS/FS/cust_bill_event.pm180
-rw-r--r--FS/FS/cust_bill_pay.pm226
-rw-r--r--FS/FS/cust_bill_pkg.pm215
-rw-r--r--FS/FS/cust_bill_pkg_detail.pm124
-rw-r--r--FS/FS/cust_credit.pm318
-rw-r--r--FS/FS/cust_credit_bill.pm192
-rw-r--r--FS/FS/cust_credit_refund.pm205
-rw-r--r--FS/FS/cust_main.pm2856
-rw-r--r--FS/FS/cust_main_county.pm290
-rw-r--r--FS/FS/cust_main_invoice.pm177
-rw-r--r--FS/FS/cust_pay.pm418
-rw-r--r--FS/FS/cust_pay_batch.pm397
-rw-r--r--FS/FS/cust_pkg.pm926
-rw-r--r--FS/FS/cust_refund.pm283
-rw-r--r--FS/FS/cust_svc.pm616
-rw-r--r--FS/FS/cust_tax_exempt.pm132
-rw-r--r--FS/FS/domain_record.pm351
-rw-r--r--FS/FS/export_svc.pm124
-rw-r--r--FS/FS/msgcat.pm132
-rw-r--r--FS/FS/nas.pm154
-rw-r--r--FS/FS/part_bill_event.pm188
-rw-r--r--FS/FS/part_export.pm590
-rw-r--r--FS/FS/part_export/apache.pm43
-rw-r--r--FS/FS/part_export/bind.pm35
-rw-r--r--FS/FS/part_export/bind_slave.pm28
-rw-r--r--FS/FS/part_export/bsdshell.pm25
-rw-r--r--FS/FS/part_export/communigate_pro.pm178
-rw-r--r--FS/FS/part_export/communigate_pro_singledomain.pm37
-rw-r--r--FS/FS/part_export/cp.pm160
-rw-r--r--FS/FS/part_export/cyrus.pm120
-rw-r--r--FS/FS/part_export/domain_shellcommands.pm161
-rw-r--r--FS/FS/part_export/forward_shellcommands.pm159
-rw-r--r--FS/FS/part_export/http.pm134
-rw-r--r--FS/FS/part_export/infostreet.pm277
-rw-r--r--FS/FS/part_export/ldap.pm294
-rw-r--r--FS/FS/part_export/null.pm13
-rw-r--r--FS/FS/part_export/passwdfile.pm18
-rw-r--r--FS/FS/part_export/postfix.pm27
-rw-r--r--FS/FS/part_export/router.pm190
-rw-r--r--FS/FS/part_export/shellcommands.pm317
-rw-r--r--FS/FS/part_export/shellcommands_withdomain.pm104
-rw-r--r--FS/FS/part_export/sqlmail.pm220
-rw-r--r--FS/FS/part_export/sqlradius.pm337
-rw-r--r--FS/FS/part_export/sqlradius_withdomain.pm28
-rw-r--r--FS/FS/part_export/sysvshell.pm25
-rw-r--r--FS/FS/part_export/textradius.pm191
-rw-r--r--FS/FS/part_export/vpopmail.pm252
-rw-r--r--FS/FS/part_export/www_shellcommands.pm158
-rw-r--r--FS/FS/part_export_option.pm134
-rw-r--r--FS/FS/part_pkg.pm333
-rw-r--r--FS/FS/part_pop_local.pm117
-rw-r--r--FS/FS/part_referral.pm126
-rw-r--r--FS/FS/part_svc.pm324
-rw-r--r--FS/FS/part_svc_column.pm118
-rwxr-xr-xFS/FS/part_svc_router.pm32
-rwxr-xr-xFS/FS/part_virtual_field.pm303
-rw-r--r--FS/FS/pkg_svc.pm155
-rw-r--r--FS/FS/port.pm160
-rw-r--r--FS/FS/prepay_credit.pm127
-rw-r--r--FS/FS/queue.pm440
-rw-r--r--FS/FS/queue_arg.pm121
-rw-r--r--FS/FS/queue_depend.pm121
-rw-r--r--FS/FS/raddb.pm1599
-rw-r--r--FS/FS/radius_usergroup.pm131
-rwxr-xr-xFS/FS/router.pm144
-rw-r--r--FS/FS/session.pm269
-rw-r--r--FS/FS/svc_Common.pm515
-rw-r--r--FS/FS/svc_acct.pm1372
-rw-r--r--FS/FS/svc_acct_pop.pm210
-rwxr-xr-xFS/FS/svc_broadband.pm243
-rw-r--r--FS/FS/svc_domain.pm443
-rw-r--r--FS/FS/svc_external.pm180
-rw-r--r--FS/FS/svc_forward.pm306
-rw-r--r--FS/FS/svc_www.pm284
-rw-r--r--FS/FS/type_pkgs.pm126
-rw-r--r--FS/MANIFEST210
-rw-r--r--FS/MANIFEST.SKIP1
-rw-r--r--FS/Makefile.PL10
-rw-r--r--FS/README6
-rw-r--r--FS/bin/freeside-addoutsource24
-rw-r--r--FS/bin/freeside-addoutsourceuser15
-rw-r--r--FS/bin/freeside-adduser63
-rwxr-xr-xFS/bin/freeside-apply-credits21
-rwxr-xr-xFS/bin/freeside-bill128
-rwxr-xr-xFS/bin/freeside-cc-receipts-report270
-rwxr-xr-xFS/bin/freeside-count-active-customers17
-rwxr-xr-xFS/bin/freeside-credit-report224
-rwxr-xr-xFS/bin/freeside-daily141
-rw-r--r--FS/bin/freeside-deloutsource11
-rw-r--r--FS/bin/freeside-deloutsourceuser6
-rw-r--r--FS/bin/freeside-deluser64
-rwxr-xr-xFS/bin/freeside-email59
-rwxr-xr-xFS/bin/freeside-expiration-alerter226
-rw-r--r--FS/bin/freeside-queued267
-rw-r--r--FS/bin/freeside-radgroup76
-rw-r--r--FS/bin/freeside-reexport62
-rw-r--r--FS/bin/freeside-selfservice-server266
-rw-r--r--FS/bin/freeside-setinvoice42
-rwxr-xr-xFS/bin/freeside-setup1123
-rw-r--r--FS/bin/freeside-sqlradius-radacctd180
-rwxr-xr-xFS/bin/freeside-sqlradius-reset76
-rw-r--r--FS/bin/freeside-sqlradius-seconds58
-rwxr-xr-xFS/bin/freeside-tax-report292
-rw-r--r--FS/t/CGI.t5
-rw-r--r--FS/t/ClientAPI.t5
-rw-r--r--FS/t/Conf.t5
-rw-r--r--FS/t/ConfItem.t5
-rw-r--r--FS/t/InitHandler.t5
-rw-r--r--FS/t/Misc.t5
-rw-r--r--FS/t/Msgcat.t5
-rw-r--r--FS/t/Record.t5
-rw-r--r--FS/t/Report-Table-Monthly.t5
-rw-r--r--FS/t/Report-Table.t5
-rw-r--r--FS/t/Report.t5
-rw-r--r--FS/t/SearchCache.t5
-rw-r--r--FS/t/UID.t5
-rw-r--r--FS/t/acct_snarf.t5
-rw-r--r--FS/t/agent.t5
-rw-r--r--FS/t/agent_type.t5
-rw-r--r--FS/t/cust_bill.t5
-rw-r--r--FS/t/cust_bill_event.t5
-rw-r--r--FS/t/cust_bill_pay.t5
-rw-r--r--FS/t/cust_bill_pkg.t5
-rw-r--r--FS/t/cust_bill_pkg_detail.t5
-rw-r--r--FS/t/cust_credit.t5
-rw-r--r--FS/t/cust_credit_bill.t5
-rw-r--r--FS/t/cust_credit_refund.t5
-rw-r--r--FS/t/cust_main.t5
-rw-r--r--FS/t/cust_main_county.t5
-rw-r--r--FS/t/cust_main_invoice.t5
-rw-r--r--FS/t/cust_pay.t5
-rw-r--r--FS/t/cust_pay_batch.t5
-rw-r--r--FS/t/cust_pkg.t5
-rw-r--r--FS/t/cust_refund.t5
-rw-r--r--FS/t/cust_svc.t5
-rw-r--r--FS/t/cust_tax_exempt.pm5
-rw-r--r--FS/t/cust_tax_exempt.t5
-rw-r--r--FS/t/domain_record.t5
-rw-r--r--FS/t/export_svc.t5
-rw-r--r--FS/t/msgcat.t5
-rw-r--r--FS/t/nas.t5
-rw-r--r--FS/t/part_bill_event.t5
-rw-r--r--FS/t/part_export-apache.t5
-rw-r--r--FS/t/part_export-bind.t5
-rw-r--r--FS/t/part_export-bind_slave.t5
-rw-r--r--FS/t/part_export-bsdshell.t5
-rw-r--r--FS/t/part_export-communigate_pro_singledomain.t5
-rw-r--r--FS/t/part_export-cp.t5
-rw-r--r--FS/t/part_export-cyrus.t5
-rw-r--r--FS/t/part_export-domain_shellcommands.t5
-rw-r--r--FS/t/part_export-forward_shellcommands.t5
-rw-r--r--FS/t/part_export-http.t5
-rw-r--r--FS/t/part_export-infostreet.t5
-rw-r--r--FS/t/part_export-ldap.t5
-rw-r--r--FS/t/part_export-null.t5
-rw-r--r--FS/t/part_export-passwdfile.t5
-rw-r--r--FS/t/part_export-postfix.t5
-rw-r--r--FS/t/part_export-router.t5
-rw-r--r--FS/t/part_export-shellcommands.t5
-rw-r--r--FS/t/part_export-shellcommands_withdomain.t5
-rw-r--r--FS/t/part_export-sqlmail.t5
-rw-r--r--FS/t/part_export-sqlradius.t5
-rw-r--r--FS/t/part_export-sqlradius_withdomain.t5
-rw-r--r--FS/t/part_export-sysvshell.t5
-rw-r--r--FS/t/part_export-textradius.t5
-rw-r--r--FS/t/part_export-vpopmail.t5
-rw-r--r--FS/t/part_export-www_shellcommands.t5
-rw-r--r--FS/t/part_export.t5
-rw-r--r--FS/t/part_export_option.t5
-rw-r--r--FS/t/part_pkg.t5
-rw-r--r--FS/t/part_pop_local.t5
-rw-r--r--FS/t/part_referral.t5
-rw-r--r--FS/t/part_svc.t5
-rw-r--r--FS/t/part_svc_column.t5
-rw-r--r--FS/t/pkg_svc.t5
-rw-r--r--FS/t/port.t5
-rw-r--r--FS/t/prepay_credit.t5
-rw-r--r--FS/t/queue.t5
-rw-r--r--FS/t/queue_arg.t5
-rw-r--r--FS/t/queue_depend.t5
-rw-r--r--FS/t/raddb.t5
-rw-r--r--FS/t/radius_usergroup.t5
-rw-r--r--FS/t/session.t5
-rw-r--r--FS/t/svc_Common.t5
-rw-r--r--FS/t/svc_acct.t5
-rw-r--r--FS/t/svc_acct_pop.t5
-rw-r--r--FS/t/svc_broadband.t5
-rw-r--r--FS/t/svc_domain.t5
-rw-r--r--FS/t/svc_external.t5
-rw-r--r--FS/t/svc_forward.t5
-rw-r--r--FS/t/svc_www.t5
-rw-r--r--FS/t/type_pkgs.t5
219 files changed, 0 insertions, 33670 deletions
diff --git a/FS/Changes b/FS/Changes
deleted file mode 100644
index c94ef10..0000000
--- a/FS/Changes
+++ /dev/null
@@ -1,5 +0,0 @@
-Revision history for Perl extension FS.
-
-0.01 Wed Aug 4 00:13:45 1999
- - original version; created by h2xs 1.19
-
diff --git a/FS/FS.pm b/FS/FS.pm
deleted file mode 100644
index 36c3a17..0000000
--- a/FS/FS.pm
+++ /dev/null
@@ -1,237 +0,0 @@
-package FS;
-
-use strict;
-use vars qw($VERSION);
-
-$VERSION = '0.01';
-
-#find missing entries in this file with:
-# for a in `ls *pm | cut -d. -f1`; do grep 'L<FS::'$a'>' ../FS.pm >/dev/null || echo "missing $a" ; done
-
-1;
-__END__
-
-=head1 NAME
-
-FS - Freeside Perl modules
-
-=head1 SYNOPSIS
-
-Freeside perl modules and CLI utilities.
-
-=head2 Utility classes
-
-L<FS::Conf> - Freeside configuration values
-
-L<FS::ConfItem> - Freeside configuration option meta-data.
-
-L<FS::UID> - User class (not yet OO)
-
-L<FS::CGI> - Non OO-subroutines for the web interface.
-
-L<FS::Msgcat> - Message catalog
-
-L<FS::SearchCache> - Search cache
-
-L<FS::raddb> - RADIUS dictionary
-
-=head2 Database record classes
-
-L<FS::Record> - Database record base class
-
-L<FS::svc_acct_pop> - POP (Point of Presence, not Post
-Office Protocol) class
-
-L<FS::part_pop_local> - Local calling area class
-
-L<FS::part_referral> - Referral class
-
-L<FS::cust_main_county> - Locale (tax rate) class
-
-L<FS::cust_tax_exempt> - Tax exemption record class
-
-L<FS::svc_Common> - Service base class
-
-L<FS::svc_acct> - Account (shell, RADIUS, POP3) class
-
-L<FS::acct_snarf> - External mail account class
-
-L<FS::radius_usergroup> - RADIUS groups
-
-L<FS::svc_domain> - Domain class
-
-L<FS::domain_record> - DNS zone entries
-
-L<FS::svc_forward> - Mail forwarding class
-
-L<FS::svc_www> - Web virtual host class.
-
-L<FS::svc_broadband> - DSL, wireless and other broadband class.
-
-L<FS::svc_external> - Externally tracked service class.
-
-L<FS::part_svc> - Service definition class
-
-L<FS::part_svc_column> - Column constraint class
-
-L<FS::export_svc> - Class linking service definitions (see L<FS::part_svc>)
-with exports (see L<FS::part_export>)
-
-L<FS::part_export> - External provisioning export class
-
-L<FS::part_export_option> - Export option class
-
-L<FS::part_pkg> - Package (billing item) definition class
-
-L<FS::pkg_svc> - Class linking package (billing item)
-definitions (see L<FS::part_pkg>) with service definitions
-(see L<FS::part_svc>)
-
-L<FS::agent> - Agent (reseller) class
-
-L<FS::agent_type> - Agent type class
-
-L<FS::type_pkgs> - Class linking agent types (see
-L<FS::agent_type>) with package (billing item) definitions
-(see L<FS::part_pkg>)
-
-L<FS::cust_svc> - Service class
-
-L<FS::cust_pkg> - Package (billing item) class
-
-L<FS::cust_main> - Customer class
-
-L<FS::cust_main_invoice> - Invoice destination
-class
-
-L<FS::cust_bill> - Invoice class
-
-L<FS::cust_bill_pkg> - Invoice line item class
-
-L<FS::cust_bill_pkg_detail> - Invoice line item detail class
-
-L<FS::part_bill_event> - Invoice event definition class
-
-L<FS::cust_bill_event> - Completed invoice event class
-
-L<FS::cust_pay> - Payment class
-
-L<FS::cust_bill_pay> - Payment application class
-
-L<FS::cust_credit> - Credit class
-
-L<FS::cust_refund> - Refund class
-
-L<FS::cust_credit_refund> - Refund application class
-
-L<FS::cust_credit_bill> - Credit invoice application class
-
-L<FS::cust_pay_batch> - Credit card transaction queue class
-
-L<FS::prepay_credit> - Prepaid "calling card" credit class.
-
-L<FS::nas> - Network Access Server class
-
-L<FS::port> - NAS port class
-
-L<FS::session> - User login session class
-
-L<FS::queue> - Job queue
-
-L<FS::queue_arg> - Job arguments
-
-L<FS::queue_depend> - Job dependencies
-
-L<FS::msgcat> - Message catalogs
-
-=head1 Remote API modules
-
-L<FS::SignupClient>
-
-L<FS::SessionClient>
-
-L<FS::MailAdminServer>
-
-=head2 Command-line utilities
-
-L<freeside-adduser>
-
-L<freeside-queued>
-
-L<freeside-daily>
-
-L<freeside-expiration-alerter>
-
-L<freeside-email>
-
-L<freeside-cc-receipts-report>
-
-L<freeside-credit-report>
-
-L<freeside-receivables-report>
-
-L<freeside-tax-report>
-
-L<freeside-bill>
-
-L<freeside-overdue>
-
-=head2 User Interface classes (under (stalled) development; not yet usable)
-
-L<FS::UI::Base> - User-interface base class
-
-L<FS::UI::Gtk> - Gtk user-interface class
-
-L<FS::UI::CGI> - CGI (HTML) user-interface class
-
-L<FS::UI::agent> - agent table user-interface class
-
-=head2 Notes
-
-To quote perl(1), "If you're intending to read these straight through for the
-first time, the suggested order will tend to reduce the number of forward
-references."
-
-If you've never used OO modules before,
-http://www.perl.com/doc/FMTEYEWTK/easy_objects.html might help you out.
-
-=head1 DESCRIPTION
-
-Freeside is a billing and administration package for Internet Service
-Providers.
-
-The Freeside home page is at <http://www.sisd.com/freeside>.
-
-The main documentation is in httemplate/docs.
-
-=head1 SUPPORT
-
-A mailing list for users is available. Send a blank message to
-<ivan-freeside-subscribe@sisd.com> to subscribe.
-
-A mailing list for developers is available. It is intended to be lower volume
-and higher SNR than the users list. Send a blank message to
-<ivan-freeside-devel-subscribe@sisd.com> to subscribe.
-
-Commercial support is available; see
-<http://www.sisd.com/freeside/commercial.html>.
-
-=head1 AUTHOR
-
-Primarily Ivan Kohler <ivan@sisd.com>, with help from many kind folks.
-
-See the CREDITS file in the Freeside distribution for a (hopefully) complete
-list and the individal files for details.
-
-=head1 SEE ALSO
-
-perl(1), main Freeside documentation in htdocs/docs/
-
-=head1 BUGS
-
-Those modules which would be useful separately should be pulled out,
-renamed appropriately and uploaded to CPAN. So far: DBIx::DBSchema, Net::SSH
-and Net::SCP...
-
-=cut
-
diff --git a/FS/FS/CGI.pm b/FS/FS/CGI.pm
deleted file mode 100644
index a328629..0000000
--- a/FS/FS/CGI.pm
+++ /dev/null
@@ -1,360 +0,0 @@
-package FS::CGI;
-
-use strict;
-use vars qw(@EXPORT_OK @ISA);
-use Exporter;
-use CGI;
-use URI::URL;
-#use CGI::Carp qw(fatalsToBrowser);
-use FS::UID;
-
-@ISA = qw(Exporter);
-@EXPORT_OK = qw(header menubar idiot eidiot popurl table itable ntable
- small_custview myexit http_header);
-
-=head1 NAME
-
-FS::CGI - Subroutines for the web interface
-
-=head1 SYNOPSIS
-
- use FS::CGI qw(header menubar idiot eidiot popurl);
-
- print header( 'Title', '' );
- print header( 'Title', menubar('item', 'URL', ... ) );
-
- idiot "error message";
- eidiot "error message";
-
- $url = popurl; #returns current url
- $url = popurl(3); #three levels up
-
-=head1 DESCRIPTION
-
-Provides a few common subroutines for the web interface.
-
-=head1 SUBROUTINES
-
-=over 4
-
-=item header TITLE, MENUBAR
-
-Returns an HTML header.
-
-=cut
-
-sub header {
- use Carp;
- carp 'FS::CGI::header deprecated; include /elements/header.html instead';
-
- my($title,$menubar,$etc)=@_; #$etc is for things like onLoad= etc.
- $etc = '' unless defined $etc;
-
- my $x = <<END;
- <HTML>
- <HEAD>
- <TITLE>
- $title
- </TITLE>
- <META HTTP-Equiv="Cache-Control" Content="no-cache">
- <META HTTP-Equiv="Pragma" Content="no-cache">
- <META HTTP-Equiv="Expires" Content="0">
- </HEAD>
- <BODY BGCOLOR="#e8e8e8"$etc>
- <FONT SIZE=6>
- $title
- </FONT>
- <BR><BR>
-END
- $x .= $menubar. "<BR><BR>" if $menubar;
- $x;
-}
-
-=item http_header
-
-Sets an http header.
-
-=cut
-
-sub http_header {
- my ( $header, $value ) = @_;
- if (exists $ENV{MOD_PERL}) {
- if ( defined $main::Response
- && $main::Response->isa('Apache::ASP::Response') ) { #Apache::ASP
- if ( $header =~ /^Content-Type$/ ) {
- $main::Response->{ContentType} = $value;
- } else {
- $main::Response->AddHeader( $header => $value );
- }
- } elsif ( defined $HTML::Mason::Commands::r ) { #Mason
- ## is this the correct pacakge for $r ??? for 1.0x and 1.1x ?
- if ( $header =~ /^Content-Type$/ ) {
- $HTML::Mason::Commands::r->content_type($value);
- } else {
- $HTML::Mason::Commands::r->header_out( $header => $value );
- }
- } else {
- die "http_header called in unknown environment";
- }
- } else {
- die "http_header called not running under mod_perl";
- }
-
-}
-
-=item menubar ITEM, URL, ...
-
-Returns an HTML menubar.
-
-=cut
-
-sub menubar { #$menubar=menubar('Main Menu', '../', 'Item', 'url', ... );
- use Carp;
- carp 'FS::CGI::menubar deprecated; include /elements/menubar.html instead';
-
- my($item,$url,@html);
- while (@_) {
- ($item,$url)=splice(@_,0,2);
- push @html, qq!<A HREF="$url">$item</A>!;
- }
- join(' | ',@html);
-}
-
-=item idiot ERROR
-
-This is depriciated. Don't use it.
-
-Sends an HTML error message.
-
-=cut
-
-sub idiot {
- #warn "idiot depriciated";
- my($error)=@_;
-# my $cgi = &FS::UID::cgi();
-# if ( $cgi->isa('CGI::Base') ) {
-# no strict 'subs';
-# &CGI::Base::SendHeaders;
-# } else {
-# print $cgi->header( @FS::CGI::header );
-# }
- print <<END;
-<HTML>
- <HEAD>
- <TITLE>Error processing your request</TITLE>
- <META HTTP-Equiv="Cache-Control" Content="no-cache">
- <META HTTP-Equiv="Pragma" Content="no-cache">
- <META HTTP-Equiv="Expires" Content="0">
- </HEAD>
- <BODY>
- <CENTER>
- <H4>Error processing your request</H4>
- </CENTER>
- Your request could not be processed because of the following error:
- <P><B>$error</B>
- </BODY>
-</HTML>
-END
-
-}
-
-=item eidiot ERROR
-
-This is depriciated. Don't use it.
-
-Sends an HTML error message, then exits.
-
-=cut
-
-sub eidiot {
- warn "eidiot depriciated";
- $HTML::Mason::Commands::r->send_http_header
- if defined $HTML::Mason::Commands::r;
- idiot(@_);
- &myexit();
-}
-
-=item myexit
-
-You probably shouldn't use this; but if you must:
-
-If running under mod_perl, calles Apache::exit, otherwise, calls exit.
-
-=cut
-
-sub myexit {
- if (exists $ENV{MOD_PERL}) {
-
- if ( defined $main::Response
- && $main::Response->isa('Apache::ASP::Response') ) { #Apache::ASP
- $main::Response->End();
- require Apache;
- Apache::exit();
- } elsif ( defined $HTML::Mason::Commands::m ) { #Mason
- #$HTML::Mason::Commands::m->flush_buffer();
- $HTML::Mason::Commands::m->abort();
- die "shouldn't fall through to here (mason \$m->abort didn't)";
- } else {
- #??? well, it is $ENV{MOD_PERL}
- warn "running under unknown mod_perl environment; trying Apache::exit()";
- require Apache;
- Apache::exit();
- }
- } else {
- exit;
- }
-}
-
-=item popurl LEVEL
-
-Returns current URL with LEVEL levels of path removed from the end (default 0).
-
-=cut
-
-sub popurl {
- my($up)=@_;
- my $cgi = &FS::UID::cgi;
- my $url_string = $cgi->isa('Apache') ? $cgi->uri : $cgi->url;
- $url_string =~ s/\?.*//;
- my $url = new URI::URL ( $url_string );
- my(@path)=$url->path_components;
- splice @path, 0-$up;
- $url->path_components(@path);
- my $x = $url->as_string;
- $x .= '/' unless $x =~ /\/$/;
- $x;
-}
-
-=item table
-
-Returns HTML tag for beginning a table.
-
-=cut
-
-sub table {
- use Carp;
- carp 'FS::CGI::table deprecated; include /elements/table.html instead';
-
- my $col = shift;
- if ( $col ) {
- qq!<TABLE BGCOLOR="$col" BORDER=1 WIDTH="100%" CELLSPACING=0 CELLPADDING=2 BORDERCOLOR="#999999">!;
- } else {
- '<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=2 BORDERCOLOR="#999999">';
- }
-}
-
-=item itable
-
-Returns HTML tag for beginning an (invisible) table.
-
-=cut
-
-sub itable {
- my $col = shift;
- my $cellspacing = shift || 0;
- if ( $col ) {
- qq!<TABLE BGCOLOR="$col" BORDER=0 CELLSPACING=$cellspacing WIDTH="100%">!;
- } else {
- qq!<TABLE BORDER=0 CELLSPACING=$cellspacing WIDTH="100%">!;
- }
-}
-
-=item ntable
-
-This is getting silly.
-
-=cut
-
-sub ntable {
- my $col = shift;
- my $cellspacing = shift || 0;
- if ( $col ) {
- qq!<TABLE BGCOLOR="$col" BORDER=0 CELLSPACING=$cellspacing>!;
- } else {
- '<TABLE BORDER CELLSPACING=0 CELLPADDING=2 BORDERCOLOR="#999999">';
- }
-
-}
-
-=item small_custview CUSTNUM || CUST_MAIN_OBJECT, COUNTRYDEFAULT
-
-Sheesh. I should just switch to Mason.
-
-=cut
-
-sub small_custview {
- use FS::Record qw(qsearchs);
- use FS::cust_main;
-
- my $arg = shift;
- my $countrydefault = shift || 'US';
-
- my $cust_main = ref($arg) ? $arg
- : qsearchs('cust_main', { 'custnum' => $arg } )
- or die "unknown custnum $arg";
-
- my $html = 'Customer #<B>'. $cust_main->custnum. '</B>'.
- ntable('#e8e8e8'). '<TR><TD>'. ntable("#cccccc",2).
- '<TR><TD ALIGN="right" VALIGN="top">Billing<BR>Address</TD><TD BGCOLOR="#ffffff">'.
- $cust_main->getfield('last'). ', '. $cust_main->first. '<BR>';
-
- $html .= $cust_main->company. '<BR>' if $cust_main->company;
- $html .= $cust_main->address1. '<BR>';
- $html .= $cust_main->address2. '<BR>' if $cust_main->address2;
- $html .= $cust_main->city. ', '. $cust_main->state. ' '. $cust_main->zip. '<BR>';
- $html .= $cust_main->country. '<BR>'
- if $cust_main->country && $cust_main->country ne $countrydefault;
-
- $html .= '</TD></TR></TABLE></TD>';
-
- if ( defined $cust_main->dbdef_table->column('ship_last') ) {
-
- my $pre = $cust_main->ship_last ? 'ship_' : '';
-
- $html .= '<TD>'. ntable("#cccccc",2).
- '<TR><TD ALIGN="right" VALIGN="top">Service<BR>Address</TD><TD BGCOLOR="#ffffff">'.
- $cust_main->get("${pre}last"). ', '.
- $cust_main->get("${pre}first"). '<BR>';
- $html .= $cust_main->get("${pre}company"). '<BR>'
- if $cust_main->get("${pre}company");
- $html .= $cust_main->get("${pre}address1"). '<BR>';
- $html .= $cust_main->get("${pre}address2"). '<BR>'
- if $cust_main->get("${pre}address2");
- $html .= $cust_main->get("${pre}city"). ', '.
- $cust_main->get("${pre}state"). ' '.
- $cust_main->get("${pre}ship_zip"). '<BR>';
- $html .= $cust_main->get("${pre}country"). '<BR>'
- if $cust_main->get("${pre}country")
- && $cust_main->get("${pre}country") ne $countrydefault;
-
- $html .= '</TD></TR></TABLE></TD>';
- }
-
- $html .= '</TR></TABLE>';
-
- $html .= '<BR>Balance: <B>$'. $cust_main->balance. '</B><BR>';
-
- # last payment might be good here too?
-
- $html;
-}
-
-=back
-
-=head1 BUGS
-
-Not OO.
-
-Not complete.
-
-small_custview sooooo doesn't belong here. i should just switch to Mason.
-
-=head1 SEE ALSO
-
-L<CGI>, L<CGI::Base>
-
-=cut
-
-1;
-
-
diff --git a/FS/FS/ClientAPI.pm b/FS/FS/ClientAPI.pm
deleted file mode 100644
index 7cbbdbf..0000000
--- a/FS/FS/ClientAPI.pm
+++ /dev/null
@@ -1,44 +0,0 @@
-package FS::ClientAPI;
-
-use strict;
-use vars qw(%handler $domain);
-
-%handler = ();
-
-#find modules
-foreach my $INC ( @INC ) {
- foreach my $file ( glob("$INC/FS/ClientAPI/*.pm") ) {
- $file =~ /\/(\w+)\.pm$/ or do {
- warn "unrecognized ClientAPI file: $file";
- next
- };
- my $mod = $1;
- #warn "using FS::ClientAPI::$mod";
- eval "use FS::ClientAPI::$mod;";
- die "error using FS::ClientAPI::$mod: $@" if $@;
- }
-}
-
-#(sub for modules)
-sub register_handlers {
- my $self = shift;
- my %new_handlers = @_;
- foreach my $key ( keys %new_handlers ) {
- warn "WARNING: redefining sub $key" if exists $handler{$key};
- #warn "registering $key";
- $handler{$key} = $new_handlers{$key};
- }
-}
-
-#---
-
-sub dispatch {
- my ( $self, $name ) = ( shift, shift );
- my $sub = $handler{$name}
- or die "unknown FS::ClientAPI sub $name (known: ". join(" ", keys %handler );
- #or die "unknown FS::ClientAPI sub $name";
- &{$sub}(@_);
-}
-
-1;
-
diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm
deleted file mode 100644
index 44d81c9..0000000
--- a/FS/FS/ClientAPI/MyAccount.pm
+++ /dev/null
@@ -1,459 +0,0 @@
-package FS::ClientAPI::MyAccount;
-
-use strict;
-use vars qw($cache);
-use Digest::MD5 qw(md5_hex);
-use Date::Format;
-use Business::CreditCard;
-use Cache::SharedMemoryCache; #store in db?
-use FS::CGI qw(small_custview); #doh
-use FS::Conf;
-use FS::Record qw(qsearch qsearchs);
-use FS::Msgcat qw(gettext);
-use FS::svc_acct;
-use FS::svc_domain;
-use FS::cust_main;
-use FS::cust_bill;
-use FS::cust_main_county;
-use FS::cust_pkg;
-
-use FS::ClientAPI; #hmm
-FS::ClientAPI->register_handlers(
- 'MyAccount/login' => \&login,
- 'MyAccount/customer_info' => \&customer_info,
- 'MyAccount/edit_info' => \&edit_info,
- 'MyAccount/invoice' => \&invoice,
- 'MyAccount/cancel' => \&cancel,
- 'MyAccount/payment_info' => \&payment_info,
- 'MyAccount/process_payment' => \&process_payment,
- 'MyAccount/list_pkgs' => \&list_pkgs,
- 'MyAccount/order_pkg' => \&order_pkg,
- 'MyAccount/cancel_pkg' => \&cancel_pkg,
- 'MyAccount/charge' => \&charge,
-);
-
-use vars qw( @cust_main_editable_fields );
-@cust_main_editable_fields = qw(
- first last company address1 address2 city
- county state zip country daytime night fax
- ship_first ship_last ship_company ship_address1 ship_address2 ship_city
- ship_state ship_zip ship_country ship_daytime ship_night ship_fax
-);
-
-#store in db?
-my $cache = new Cache::SharedMemoryCache( {
- 'namespace' => 'FS::ClientAPI::MyAccount',
-} );
-
-#false laziness w/FS::ClientAPI::passwd::passwd
-sub login {
- my $p = shift;
-
- my $svc_domain = qsearchs('svc_domain', { 'domain' => $p->{'domain'} } )
- or return { error => 'Domain '. $p->{'domain'}. ' not found' };
-
- my $svc_acct = qsearchs( 'svc_acct', { 'username' => $p->{'username'},
- 'domsvc' => $svc_domain->svcnum, }
- );
- return { error => 'User not found.' } unless $svc_acct;
- return { error => 'Incorrect password.' }
- unless $svc_acct->check_password($p->{'password'});
-
- my $session = {
- 'svcnum' => $svc_acct->svcnum,
- };
-
- my $cust_pkg = $svc_acct->cust_svc->cust_pkg;
- if ( $cust_pkg ) {
- my $cust_main = $cust_pkg->cust_main;
- $session->{'custnum'} = $cust_main->custnum;
- }
-
- my $session_id;
- do {
- $session_id = md5_hex(md5_hex(time(). {}. rand(). $$))
- } until ( ! defined $cache->get($session_id) ); #just in case
-
- $cache->set( $session_id, $session, '1 hour' );
-
- return { 'error' => '',
- 'session_id' => $session_id,
- };
-}
-
-sub customer_info {
- my $p = shift;
- my $session = $cache->get($p->{'session_id'})
- or return { 'error' => "Can't resume session" }; #better error message
-
- my %return;
-
- my $custnum = $session->{'custnum'};
-
- if ( $custnum ) { #customer record
-
- my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } )
- or return { 'error' => "unknown custnum $custnum" };
-
- $return{balance} = $cust_main->balance;
-
- my @open = map {
- {
- invnum => $_->invnum,
- date => time2str("%b %o, %Y", $_->_date),
- owed => $_->owed,
- };
- } $cust_main->open_cust_bill;
- $return{open_invoices} = \@open;
-
- my $conf = new FS::Conf;
- $return{small_custview} =
- small_custview( $cust_main, $conf->config('defaultcountry') );
-
- $return{name} = $cust_main->first. ' '. $cust_main->get('last');
-
- for (@cust_main_editable_fields) {
- $return{$_} = $cust_main->get($_);
- }
-
- } else { #no customer record
-
- my $svc_acct = qsearchs('svc_acct', { 'svcnum' => $session->{'svcnum'} } )
- or die "unknown svcnum";
- $return{name} = $svc_acct->email;
-
- }
-
- return { 'error' => '',
- 'custnum' => $custnum,
- %return,
- };
-
-}
-
-sub edit_info {
- my $p = shift;
- my $session = $cache->get($p->{'session_id'})
- or return { 'error' => "Can't resume session" }; #better error message
-
- my $custnum = $session->{'custnum'}
- or return { 'error' => "no customer record" };
-
- my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } )
- or return { 'error' => "unknown custnum $custnum" };
-
- my $new = new FS::cust_main { $cust_main->hash };
- $new->set( $_ => $p->{$_} )
- foreach grep { exists $p->{$_} } @cust_main_editable_fields;
- my $error = $new->replace($cust_main);
- return { 'error' => $error } if $error;
- #$cust_main = $new;
-
- return { 'error' => '' };
-}
-
-sub payment_info {
- my $p = shift;
- my $session = $cache->get($p->{'session_id'})
- or return { 'error' => "Can't resume session" }; #better error message
-
- my %return;
-
- my $custnum = $session->{'custnum'};
-
- my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } )
- or return { 'error' => "unknown custnum $custnum" };
-
- $return{balance} = $cust_main->balance;
-
- $return{payname} = $cust_main->payname
- || ( $cust_main->first. ' '. $cust_main->get('last') );
-
- $return{$_} = $cust_main->get($_) for qw(address1 address2 city state zip);
-
- $return{payby} = $cust_main->payby;
-
- if ( $cust_main->payby =~ /^(CARD|DCRD)$/ ) {
- warn $return{card_type} = cardtype($cust_main->payinfo);
- $return{payinfo} = $cust_main->payinfo;
-
- @return{'month', 'year'} = $cust_main->paydate_monthyear;
-
- }
-
- #list all counties/states/countries
- $return{'cust_main_county'} =
- [ map { $_->hashref } qsearch('cust_main_county', {}) ],
-
- #shortcut for one-country folks
- my $conf = new FS::Conf;
- my %states = map { $_->state => 1 }
- qsearch('cust_main_county', {
- 'country' => $conf->config('defaultcountry') || 'US'
- } );
- $return{'states'} = [ sort { $a cmp $b } keys %states ];
-
- $return{card_types} = {
- 'VISA' => 'VISA card',
- 'MasterCard' => 'MasterCard',
- 'Discover' => 'Discover card',
- 'American Express' => 'American Express card',
- };
-
- my $_date = time;
- $return{paybatch} = "webui-MyAccount-$_date-$$-". rand() * 2**32;
-
- return { 'error' => '',
- %return,
- };
-
-};
-
-#some false laziness with httemplate/process/payment.cgi - look there for
-#ACH and CVV support stuff
-sub process_payment {
-
- my $p = shift;
-
- my $session = $cache->get($p->{'session_id'})
- or return { 'error' => "Can't resume session" }; #better error message
-
- my %return;
-
- my $custnum = $session->{'custnum'};
-
- my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } )
- or return { 'error' => "unknown custnum $custnum" };
-
- $p->{'payname'} =~ /^([\w \,\.\-\']+)$/
- or return { 'error' => gettext('illegal_name'). " payname: ". $p->{'payname'} };
- my $payname = $1;
-
- $p->{'paybatch'} =~ /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=]*)$/
- or return { 'error' => gettext('illegal_text'). " paybatch: ". $p->{'paybatch'} };
- my $paybatch = $1;
-
- my $payinfo;
- my $paycvv = '';
- #if ( $payby eq 'CHEK' ) {
- #
- # $p->{'payinfo1'} =~ /^(\d+)$/
- # or return { 'error' => "illegal account number ". $p->{'payinfo1'} };
- # my $payinfo1 = $1;
- # $p->{'payinfo2'} =~ /^(\d+)$/
- # or return { 'error' => "illegal ABA/routing number ". $p->{'payinfo2'} };
- # my $payinfo2 = $1;
- # $payinfo = $payinfo1. '@'. $payinfo2;
- #
- #} elsif ( $payby eq 'CARD' ) {
-
- $payinfo = $p->{'payinfo'};
- $payinfo =~ s/\D//g;
- $payinfo =~ /^(\d{13,16})$/
- or return { 'error' => gettext('invalid_card') }; # . ": ". $self->payinfo
- $payinfo = $1;
- validate($payinfo)
- or return { 'error' => gettext('invalid_card') }; # . ": ". $self->payinfo
- return { 'error' => gettext('unknown_card_type') }
- if cardtype($payinfo) eq "Unknown";
-
- if ( defined $cust_main->dbdef_table->column('paycvv') ) {
- if ( length($p->{'paycvv'} ) ) {
- if ( cardtype($payinfo) eq 'American Express card' ) {
- $p->{'paycvv'} =~ /^(\d{4})$/
- or return { 'error' => "CVV2 (CID) for American Express cards is four digits." };
- $paycvv = $1;
- } else {
- $p->{'paycvv'} =~ /^(\d{3})$/
- or return { 'error' => "CVV2 (CVC2/CID) is three digits." };
- $paycvv = $1;
- }
- }
- }
-
- #} else {
- # die "unknown payby $payby";
- #}
-
- my $error = $cust_main->realtime_bop( 'CC', $p->{'amount'},
- 'quiet' => 1,
- 'payinfo' => $payinfo,
- 'paydate' => $p->{'year'}. '-'. $p->{'month'}. '-01',
- 'payname' => $payname,
- 'paybatch' => $paybatch,
- 'paycvv' => $paycvv,
- map { $_ => $p->{$_} } qw( address1 address2 city state zip )
- );
- return { 'error' => $error } if $error;
-
- $cust_main->apply_payments;
-
- if ( $p->{'save'} ) {
- my $new = new FS::cust_main { $cust_main->hash };
- $new->set( $_ => $p->{$_} )
- foreach qw( payname address1 address2 city state zip payinfo );
- $new->set( 'paydate' => $p->{'year'}. '-'. $p->{'month'}. '-01' );
- $new->set( 'payby' => $p->{'auto'} ? 'CARD' : 'DCRD' );
- my $error = $new->replace($cust_main);
- return { 'error' => $error } if $error;
- $cust_main = $new;
- }
-
- return { 'error' => '' };
-
-}
-
-sub invoice {
- my $p = shift;
- my $session = $cache->get($p->{'session_id'})
- or return { 'error' => "Can't resume session" }; #better error message
-
- my $custnum = $session->{'custnum'};
-
- my $invnum = $p->{'invnum'};
-
- my $cust_bill = qsearchs('cust_bill', { 'invnum' => $invnum,
- 'custnum' => $custnum } )
- or return { 'error' => "Can't find invnum" };
-
- #my %return;
-
- return { 'error' => '',
- 'invnum' => $invnum,
- 'invoice_text' => join('', $cust_bill->print_text ),
- };
-
-}
-
-sub cancel {
- my $p = shift;
- my $session = $cache->get($p->{'session_id'})
- or return { 'error' => "Can't resume session" }; #better error message
-
- my $custnum = $session->{'custnum'};
-
- my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } )
- or return { 'error' => "unknown custnum $custnum" };
-
- my @errors = $cust_main->cancel( 'quiet'=>1 );
-
- my $error = scalar(@errors) ? join(' / ', @errors) : '';
-
- return { 'error' => $error };
-
-}
-
-sub list_pkgs {
- my $p = shift;
- my $session = $cache->get($p->{'session_id'})
- or return { 'error' => "Can't resume session" }; #better error message
-
- my $custnum = $session->{'custnum'};
-
- my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } )
- or return { 'error' => "unknown custnum $custnum" };
-
- return { 'cust_pkg' => [ map { $_->hashref } $cust_main->ncancelled_pkgs ] };
-
-}
-
-sub order_pkg {
- my $p = shift;
- my $session = $cache->get($p->{'session_id'})
- or return { 'error' => "Can't resume session" }; #better error message
-
- my $custnum = $session->{'custnum'};
-
- my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } )
- or return { 'error' => "unknown custnum $custnum" };
-
- #false laziness w/ClientAPI/Signup.pm
-
- my $cust_pkg = new FS::cust_pkg ( {
- 'custnum' => $custnum,
- 'pkgpart' => $p->{'pkgpart'},
- } );
- my $error = $cust_pkg->check;
- return { 'error' => $error } if $error;
-
- my $svc_acct = new FS::svc_acct ( {
- 'svcpart' => $p->{'svcpart'} || $cust_pkg->part_pkg->svcpart('svc_acct'),
- map { $_ => $p->{$_} }
- qw( username _password sec_phrase popnum ),
- } );
-
- my @acct_snarf;
- my $snarfnum = 1;
- while ( length($p->{"snarf_machine$snarfnum"}) ) {
- my $acct_snarf = new FS::acct_snarf ( {
- 'machine' => $p->{"snarf_machine$snarfnum"},
- 'protocol' => $p->{"snarf_protocol$snarfnum"},
- 'username' => $p->{"snarf_username$snarfnum"},
- '_password' => $p->{"snarf_password$snarfnum"},
- } );
- $snarfnum++;
- push @acct_snarf, $acct_snarf;
- }
- $svc_acct->child_objects( \@acct_snarf );
-
- my $y = $svc_acct->setdefault; # arguably should be in new method
- return { 'error' => $y } if $y && !ref($y);
-
- $error = $svc_acct->check;
- return { 'error' => $error } if $error;
-
- use Tie::RefHash;
- tie my %hash, 'Tie::RefHash';
- %hash = ( $cust_pkg => [ $svc_acct ] );
- #msgcat
- $error = $cust_main->order_pkgs( \%hash, '', 'noexport' => 1 );
- return { 'error' => $error } if $error;
-
- my $conf = new FS::Conf;
- if ( $conf->exists('signup_server-realtime') ) {
-
- my $old_balance = $cust_main->balance;
-
- my $bill_error = $cust_main->bill;
- $cust_main->apply_payments;
- $cust_main->apply_credits;
- $bill_error = $cust_main->collect;
-
- if ( $cust_main->balance > $old_balance ) {
- $cust_pkg->cancel('quiet'=>1);
- return { 'error' => '_decline' };
- } else {
- $cust_pkg->reexport;
- }
-
- } else {
- $cust_pkg->reexport;
- }
-
- return { error => '' };
-
-}
-
-sub cancel_pkg {
- my $p = shift;
- my $session = $cache->get($p->{'session_id'})
- or return { 'error' => "Can't resume session" }; #better error message
-
- my $custnum = $session->{'custnum'};
-
- my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } )
- or return { 'error' => "unknown custnum $custnum" };
-
- my $pkgnum = $session->{'pkgnum'};
-
- my $cust_pkg = qsearchs('cust_pkg', { 'custnum' => $custnum,
- 'pkgnum' => $pkgnum, } )
- or return { 'error' => "unknown pkgnum $pkgnum" };
-
- my $error = $cust_main->cancel( 'quiet'=>1 );
- return { 'error' => $error };
-
-}
-
-1;
-
diff --git a/FS/FS/ClientAPI/Signup.pm b/FS/FS/ClientAPI/Signup.pm
deleted file mode 100644
index 4655b09..0000000
--- a/FS/FS/ClientAPI/Signup.pm
+++ /dev/null
@@ -1,262 +0,0 @@
-package FS::ClientAPI::Signup;
-
-use strict;
-use Tie::RefHash;
-use FS::Conf;
-use FS::Record qw(qsearch qsearchs dbdef);
-use FS::Msgcat qw(gettext);
-use FS::agent;
-use FS::cust_main_county;
-use FS::part_pkg;
-use FS::svc_acct_pop;
-use FS::cust_main;
-use FS::cust_pkg;
-use FS::svc_acct;
-use FS::acct_snarf;
-use FS::queue;
-
-use FS::ClientAPI; #hmm
-FS::ClientAPI->register_handlers(
- 'Signup/signup_info' => \&signup_info,
- 'Signup/new_customer' => \&new_customer,
-);
-
-sub signup_info {
- #my $packet = shift;
-
- my $conf = new FS::Conf;
-
- use vars qw($signup_info); #cache for performance;
- $signup_info ||= {
-
- 'cust_main_county' =>
- [ map { $_->hashref } qsearch('cust_main_county', {}) ],
-
- 'agent' =>
- [
- map { $_->hashref }
- qsearch('agent', dbdef->table('agent')->column('disabled')
- ? { 'disabled' => '' }
- : {}
- )
- ],
-
- 'part_referral' =>
- [
- map { $_->hashref }
- qsearch('part_referral',
- dbdef->table('part_referral')->column('disabled')
- ? { 'disabled' => '' }
- : {}
- )
- ],
-
- 'agentnum2part_pkg' =>
- {
- map {
- my $href = $_->pkgpart_hashref;
- $_->agentnum =>
- [
- map { { 'payby' => [ $_->payby ], %{$_->hashref} } }
- grep { $_->svcpart('svc_acct') && $href->{ $_->pkgpart } }
- qsearch( 'part_pkg', { 'disabled' => '' } )
- ];
- } qsearch('agent', dbdef->table('agent')->column('disabled')
- ? { 'disabled' => '' }
- : {}
- )
- },
-
- 'svc_acct_pop' => [ map { $_->hashref } qsearch('svc_acct_pop',{} ) ],
-
- 'security_phrase' => $conf->exists('security_phrase'),
-
- 'payby' => [ $conf->config('signup_server-payby') ],
-
- 'cvv_enabled' => defined dbdef->table('cust_main')->column('paycvv'),
-
- 'msgcat' => { map { $_=>gettext($_) } qw(
- passwords_dont_match invalid_card unknown_card_type not_a
- ) },
-
- 'statedefault' => $conf->config('statedefault') || 'CA',
-
- 'countrydefault' => $conf->config('countrydefault') || 'US',
-
- 'refnum' => $conf->config('signup_server-default_refnum'),
-
- };
-
- if (
- $conf->config('signup_server-default_agentnum')
- && !exists $signup_info->{'part_pkg'} #cache for performance
- ) {
- my $agentnum = $conf->config('signup_server-default_agentnum');
- my $agent = qsearchs( 'agent', { 'agentnum' => $agentnum } )
- or die "fatal: signup_server-default_agentnum $agentnum not found\n";
- my $pkgpart_href = $agent->pkgpart_hashref;
-
- $signup_info->{'part_pkg'} = [
- #map { $_->hashref }
- map { { 'payby' => [ $_->payby ], %{$_->hashref} } }
- grep { $_->svcpart('svc_acct') && $pkgpart_href->{ $_->pkgpart } }
- qsearch( 'part_pkg', { 'disabled' => '' } )
- ];
- }
-
- $signup_info;
-
-}
-
-sub new_customer {
- my $packet = shift;
-
- my $conf = new FS::Conf;
-
- #things that aren't necessary in base class, but are for signup server
- #return "Passwords don't match"
- # if $hashref->{'_password'} ne $hashref->{'_password2'}
- return { 'error' => gettext('empty_password') }
- unless $packet->{'_password'};
- # a bit inefficient for large numbers of pops
- return { 'error' => gettext('no_access_number_selected') }
- unless $packet->{'popnum'} || !scalar(qsearch('svc_acct_pop',{} ));
-
- #shares some stuff with htdocs/edit/process/cust_main.cgi... take any
- # common that are still here and library them.
- my $cust_main = new FS::cust_main ( {
- #'custnum' => '',
- 'agentnum' => $packet->{agentnum}
- || $conf->config('signup_server-default_agentnum'),
- 'refnum' => $packet->{refnum}
- || $conf->config('signup_server-default_refnum'),
-
- map { $_ => $packet->{$_} } qw(
- last first ss company address1 address2 city county state zip country
- daytime night fax payby payinfo paycvv paydate payname referral_custnum
- comments
- ),
-
- } );
-
- return { 'error' => "Illegal payment type" }
- unless grep { $_ eq $packet->{'payby'} }
- $conf->config('signup_server-payby');
-
- $cust_main->payinfo($cust_main->daytime)
- if $cust_main->payby eq 'LECB' && ! $cust_main->payinfo;
-
- my @invoicing_list = split( /\s*\,\s*/, $packet->{'invoicing_list'} );
-
- $packet->{'pkgpart'} =~ /^(\d+)$/ or '' =~ /^()$/;
- my $pkgpart = $1;
- return { 'error' => 'Please select a package' } unless $pkgpart; #msgcat
-
- my $part_pkg =
- qsearchs( 'part_pkg', { 'pkgpart' => $pkgpart } )
- or return { 'error' => "WARNING: unknown pkgpart: $pkgpart" };
- my $svcpart = $part_pkg->svcpart('svc_acct');
-
- my $cust_pkg = new FS::cust_pkg ( {
- #later#'custnum' => $custnum,
- 'pkgpart' => $packet->{'pkgpart'},
- } );
- my $error = $cust_pkg->check;
- return { 'error' => $error } if $error;
-
- my $svc_acct = new FS::svc_acct ( {
- 'svcpart' => $svcpart,
- map { $_ => $packet->{$_} }
- qw( username _password sec_phrase popnum ),
- } );
-
- my @acct_snarf;
- my $snarfnum = 1;
- while ( exists($packet->{"snarf_machine$snarfnum"})
- && length($packet->{"snarf_machine$snarfnum"}) ) {
- my $acct_snarf = new FS::acct_snarf ( {
- 'machine' => $packet->{"snarf_machine$snarfnum"},
- 'protocol' => $packet->{"snarf_protocol$snarfnum"},
- 'username' => $packet->{"snarf_username$snarfnum"},
- '_password' => $packet->{"snarf_password$snarfnum"},
- } );
- $snarfnum++;
- push @acct_snarf, $acct_snarf;
- }
- $svc_acct->child_objects( \@acct_snarf );
-
- my $y = $svc_acct->setdefault; # arguably should be in new method
- return { 'error' => $y } if $y && !ref($y);
-
- $error = $svc_acct->check;
- return { 'error' => $error } if $error;
-
- #setup a job dependancy to delay provisioning
- my $placeholder = new FS::queue ( {
- 'job' => 'FS::ClientAPI::Signup::__placeholder',
- 'status' => 'locked',
- } );
- $error = $placeholder->insert;
- return { 'error' => $error } if $error;
-
- use Tie::RefHash;
- tie my %hash, 'Tie::RefHash';
- %hash = ( $cust_pkg => [ $svc_acct ] );
- #msgcat
- $error = $cust_main->insert(
- \%hash,
- \@invoicing_list,
- 'depend_jobnum' => $placeholder->jobnum,
- );
- if ( $error ) {
- my $perror = $placeholder->delete;
- $error .= " (Additionally, error removing placeholder: $perror)" if $perror;
- return { 'error' => $error };
- }
-
- if ( $conf->exists('signup_server-realtime') ) {
-
- #warn "[fs_signup_server] Billing customer...\n" if $Debug;
-
- my $bill_error = $cust_main->bill;
- #warn "[fs_signup_server] error billing new customer: $bill_error"
- # if $bill_error;
-
- $cust_main->apply_payments;
- $cust_main->apply_credits;
-
- $bill_error = $cust_main->collect;
- #warn "[fs_signup_server] error collecting from new customer: $bill_error"
- # if $bill_error;
-
- if ( $cust_main->balance > 0 ) {
-
- #this makes sense. credit is "un-doing" the invoice
- $cust_main->credit( $cust_main->balance, 'signup server decline' );
- $cust_main->apply_credits;
-
- #should check list for errors...
- #$cust_main->suspend;
- local $FS::svc_Common::noexport_hack = 1;
- $cust_main->cancel('quiet'=>1);
-
- my $perror = $placeholder->depended_delete;
- warn "error removing provisioning jobs after decline: $perror" if $perror;
- unless ( $perror ) {
- $perror = $placeholder->delete;
- warn "error removing placeholder after decline: $perror" if $perror;
- }
-
- return { 'error' => '_decline' };
- }
-
- }
-
- $error = $placeholder->delete;
- return { 'error' => $error } if $error;
-
- return { error => '' };
-
-}
-
-1;
diff --git a/FS/FS/ClientAPI/passwd.pm b/FS/FS/ClientAPI/passwd.pm
deleted file mode 100644
index cb839ec..0000000
--- a/FS/FS/ClientAPI/passwd.pm
+++ /dev/null
@@ -1,53 +0,0 @@
-package FS::ClientAPI::passwd;
-
-use strict;
-use FS::Record qw(qsearchs);
-use FS::svc_acct;
-use FS::svc_domain;
-
-use FS::ClientAPI; #hmm
-FS::ClientAPI->register_handlers(
- 'passwd/passwd' => \&passwd,
- 'passwd/chfn' => \&chfn,
- 'passwd/chsh' => \&chsh,
-);
-
-sub passwd {
- my $packet = shift;
-
- my $domain = $FS::ClientAPI::domain || $packet->{'domain'};
- my $svc_domain = qsearchs('svc_domain', { 'domain' => $domain } )
- or return { error => "Domain $domain not found" };
-
- my $old_password = $packet->{'old_password'};
- my $new_password = $packet->{'new_password'};
- my $new_gecos = $packet->{'new_gecos'};
- my $new_shell = $packet->{'new_shell'};
-
- #false laziness w/FS::ClientAPI::MyAccount::login
-
- my $svc_acct = qsearchs( 'svc_acct', { 'username' => $packet->{'username'},
- 'domsvc' => $svc_domain->svcnum, }
- );
- return { error => 'User not found.' } unless $svc_acct;
- return { error => 'Incorrect password.' }
- unless $svc_acct->check_password($old_password);
-
- my %hash = $svc_acct->hash;
- my $new_svc_acct = new FS::svc_acct ( \%hash );
- $new_svc_acct->setfield('_password', $new_password )
- if $new_password && $new_password ne $old_password;
- $new_svc_acct->setfield('finger',$new_gecos) if $new_gecos;
- $new_svc_acct->setfield('shell',$new_shell) if $new_shell;
- my $error = $new_svc_acct->replace($svc_acct);
-
- return { error => $error };
-
-}
-
-sub chfn {}
-
-sub chsh {}
-
-1;
-
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
deleted file mode 100644
index d8191c2..0000000
--- a/FS/FS/Conf.pm
+++ /dev/null
@@ -1,1205 +0,0 @@
-package FS::Conf;
-
-use vars qw($default_dir @config_items $DEBUG );
-use IO::File;
-use File::Basename;
-use FS::ConfItem;
-
-$DEBUG = 0;
-
-=head1 NAME
-
-FS::Conf - Freeside configuration values
-
-=head1 SYNOPSIS
-
- use FS::Conf;
-
- $conf = new FS::Conf "/config/directory";
-
- $FS::Conf::default_dir = "/config/directory";
- $conf = new FS::Conf;
-
- $dir = $conf->dir;
-
- $value = $conf->config('key');
- @list = $conf->config('key');
- $bool = $conf->exists('key');
-
- $conf->touch('key');
- $conf->set('key' => 'value');
- $conf->delete('key');
-
- @config_items = $conf->config_items;
-
-=head1 DESCRIPTION
-
-Read and write Freeside configuration values. Keys currently map to filenames,
-but this may change in the future.
-
-=head1 METHODS
-
-=over 4
-
-=item new [ DIRECTORY ]
-
-Create a new configuration object. A directory arguement is required if
-$FS::Conf::default_dir has not been set.
-
-=cut
-
-sub new {
- my($proto,$dir) = @_;
- my($class) = ref($proto) || $proto;
- my($self) = { 'dir' => $dir || $default_dir } ;
- bless ($self, $class);
-}
-
-=item dir
-
-Returns the directory.
-
-=cut
-
-sub dir {
- my($self) = @_;
- my $dir = $self->{dir};
- -e $dir or die "FATAL: $dir doesn't exist!";
- -d $dir or die "FATAL: $dir isn't a directory!";
- -r $dir or die "FATAL: Can't read $dir!";
- -x $dir or die "FATAL: $dir not searchable (executable)!";
- $dir =~ /^(.*)$/;
- $1;
-}
-
-=item config KEY
-
-Returns the configuration value or values (depending on context) for key.
-
-=cut
-
-sub config {
- my($self,$file)=@_;
- my($dir)=$self->dir;
- my $fh = new IO::File "<$dir/$file" or return;
- if ( wantarray ) {
- map {
- /^(.*)$/
- or die "Illegal line (array context) in $dir/$file:\n$_\n";
- $1;
- } <$fh>;
- } else {
- <$fh> =~ /^(.*)$/
- or die "Illegal line (scalar context) in $dir/$file:\n$_\n";
- $1;
- }
-}
-
-=item exists KEY
-
-Returns true if the specified key exists, even if the corresponding value
-is undefined.
-
-=cut
-
-sub exists {
- my($self,$file)=@_;
- my($dir) = $self->dir;
- -e "$dir/$file";
-}
-
-=item touch KEY
-
-Creates the specified configuration key if it does not exist.
-
-=cut
-
-sub touch {
- my($self, $file) = @_;
- my $dir = $self->dir;
- unless ( $self->exists($file) ) {
- warn "[FS::Conf] TOUCH $file\n" if $DEBUG;
- system('touch', "$dir/$file");
- }
-}
-
-=item set KEY VALUE
-
-Sets the specified configuration key to the given value.
-
-=cut
-
-sub set {
- my($self, $file, $value) = @_;
- my $dir = $self->dir;
- $value =~ /^(.*)$/s;
- $value = $1;
- unless ( join("\n", @{[ $self->config($file) ]}) eq $value ) {
- warn "[FS::Conf] SET $file\n" if $DEBUG;
-# warn "$dir" if is_tainted($dir);
-# warn "$dir" if is_tainted($file);
- chmod 0644, "$dir/$file";
- my $fh = new IO::File ">$dir/$file" or return;
- chmod 0644, "$dir/$file";
- print $fh "$value\n";
- }
-}
-#sub is_tainted {
-# return ! eval { join('',@_), kill 0; 1; };
-# }
-
-=item delete KEY
-
-Deletes the specified configuration key.
-
-=cut
-
-sub delete {
- my($self, $file) = @_;
- my $dir = $self->dir;
- if ( $self->exists($file) ) {
- warn "[FS::Conf] DELETE $file\n";
- unlink "$dir/$file";
- }
-}
-
-=item config_items
-
-Returns all of the possible configuration items as FS::ConfItem objects. See
-L<FS::ConfItem>.
-
-=cut
-
-sub config_items {
- my $self = shift;
- #quelle kludge
- @config_items,
- ( map {
- my $basename = basename($_);
- $basename =~ /^(.*)$/;
- $basename = $1;
- new FS::ConfItem {
- 'key' => $basename,
- 'section' => 'billing',
- 'description' => 'Alternate template file for invoices. See the <a href="../docs/billing.html">billing documentation</a> for details.',
- 'type' => 'textarea',
- }
- } glob($self->dir. '/invoice_template_*')
- ),
- ( map {
- my $basename = basename($_);
- $basename =~ /^(.*)$/;
- $basename = $1;
- new FS::ConfItem {
- 'key' => $basename,
- 'section' => 'billing',
- 'description' => 'Alternate LaTeX template for invoices. See the <a href="../docs/billing.html">billing documentation</a> for details.',
- 'type' => 'textarea',
- }
- } glob($self->dir. '/invoice_latex_*')
- );
-}
-
-=back
-
-=head1 BUGS
-
-If this was more than just crud that will never be useful outside Freeside I'd
-worry that config_items is freeside-specific and icky.
-
-=head1 SEE ALSO
-
-"Configuration" in the web interface (config/config.cgi).
-
-httemplate/docs/config.html
-
-=cut
-
-@config_items = map { new FS::ConfItem $_ } (
-
- {
- 'key' => 'address',
- 'section' => 'deprecated',
- 'description' => 'This configuration option is no longer used. See <a href="#invoice_template">invoice_template</a> instead.',
- 'type' => 'text',
- },
-
- {
- 'key' => 'alerter_template',
- 'section' => 'billing',
- 'description' => 'Template file for billing method expiration alerts. See the <a href="../docs/billing.html#invoice_template">billing documentation</a> for details.',
- 'type' => 'textarea',
- },
-
- {
- 'key' => 'apacheroot',
- 'section' => 'deprecated',
- 'description' => '<b>DEPRECATED</b>, add a <i>www_shellcommands</i> <a href="../browse/part_export.cgi">export</a> instead. The directory containing Apache virtual hosts',
- 'type' => 'text',
- },
-
- {
- 'key' => 'apacheip',
- 'section' => 'deprecated',
- 'description' => '<b>DEPRECATED</b>, add an <i>apache</i> <a href="../browse/part_export.cgi">export</a> instead. Used to be the current IP address to assign to new virtual hosts',
- 'type' => 'text',
- },
-
- {
- 'key' => 'apachemachine',
- 'section' => 'deprecated',
- 'description' => '<b>DEPRECATED</b>, add a <i>www_shellcommands</i> <a href="../browse/part_export.cgi">export</a> instead. A machine with the apacheroot directory and user home directories. The existance of this file enables setup of virtual host directories, and, in conjunction with the `home\' configuration file, symlinks into user home directories.',
- 'type' => 'text',
- },
-
- {
- 'key' => 'apachemachines',
- 'section' => 'deprecated',
- 'description' => '<b>DEPRECATED</b>, add an <i>apache</i> <a href="../browse/part_export.cgi">export</a> instead. Used to be Apache machines, one per line. This enables export of `/etc/apache/vhosts.conf\', which can be included in your Apache configuration via the <a href="http://www.apache.org/docs/mod/core.html#include">Include</a> directive.',
- 'type' => 'textarea',
- },
-
- {
- 'key' => 'bindprimary',
- 'section' => 'deprecated',
- 'description' => '<b>DEPRECATED</b>, add a <i>bind</i> <a href="../browse/part_export.cgi">export</a> instead. Your BIND primary nameserver. This enables export of /var/named/named.conf and zone files into /var/named',
- 'type' => 'text',
- },
-
- {
- 'key' => 'bindsecondaries',
- 'section' => 'deprecated',
- 'description' => '<b>DEPRECATED</b>, add a <i>bind_slave</i> <a href="../browse/part_export.cgi">export</a> instead. Your BIND secondary nameservers, one per line. This enables export of /var/named/named.conf',
- 'type' => 'textarea',
- },
-
- {
- 'key' => 'business-onlinepayment',
- 'section' => 'billing',
- 'description' => '<a href="http://search.cpan.org/search?mode=module&query=Business%3A%3AOnlinePayment">Business::OnlinePayment</a> support, at least three lines: processor, login, and password. An optional fourth line specifies the action or actions (multiple actions are separated with `,\': for example: `Authorization Only, Post Authorization\'). Optional additional lines are passed to Business::OnlinePayment as %processor_options.',
- 'type' => 'textarea',
- },
-
- {
- 'key' => 'business-onlinepayment-ach',
- 'section' => 'billing',
- 'description' => 'Alternate <a href="http://search.cpan.org/search?mode=module&query=Business%3A%3AOnlinePayment">Business::OnlinePayment</a> support for ACH transactions (defaults to regular <b>business-onlinepayment</b>). At least three lines: processor, login, and password. An optional fourth line specifies the action or actions (multiple actions are separated with `,\': for example: `Authorization Only, Post Authorization\'). Optional additional lines are passed to Business::OnlinePayment as %processor_options.',
- 'type' => 'textarea',
- },
-
- {
- 'key' => 'business-onlinepayment-description',
- 'section' => 'billing',
- 'description' => 'String passed as the description field to <a href="http://search.cpan.org/search?mode=module&query=Business%3A%3AOnlinePayment">Business::OnlinePayment</a>. Evaluated as a double-quoted perl string, with the following variables available: <code>$agent</code> (the agent name), and <code>$pkgs</code> (a comma-separated list of packages for which these charges apply)',
- 'type' => 'text',
- },
-
- {
- 'key' => 'bsdshellmachines',
- 'section' => 'deprecated',
- 'description' => '<b>DEPRECATED</b>, add a <i>bsdshell</i> <a href="../browse/part_export.cgi">export</a> instead. Your BSD flavored shell (and mail) machines, one per line. This enables export of `/etc/passwd\' and `/etc/master.passwd\'.',
- 'type' => 'textarea',
- },
-
- {
- 'key' => 'countrydefault',
- 'section' => 'UI',
- 'description' => 'Default two-letter country code (if not supplied, the default is `US\')',
- 'type' => 'text',
- },
-
- {
- 'key' => 'cyrus',
- 'section' => 'deprecated',
- 'description' => '<b>DEPRECATED</b>, add a <i>cyrus</i> <a href="../browse/part_export.cgi">export</a> instead. This option used to integrate with <a href="http://asg.web.cmu.edu/cyrus/imapd/">Cyrus IMAP Server</a>, three lines: IMAP server, admin username, and admin password. Cyrus::IMAP::Admin should be installed locally and the connection to the server secured.',
- 'type' => 'textarea',
- },
-
- {
- 'key' => 'cp_app',
- 'section' => 'deprecated',
- 'description' => '<b>DEPRECATED</b>, add a <i>cp</i> <a href="../browse/part_export.cgi">export</a> instead. This option used to integrate with <a href="http://www.cp.net/">Critial Path Account Provisioning Protocol</a>, four lines: "host:port", username, password, and workgroup (for new users).',
- 'type' => 'textarea',
- },
-
- {
- 'key' => 'deletecustomers',
- 'section' => 'UI',
- 'description' => 'Enable customer deletions. Be very careful! Deleting a customer will remove all traces that this customer ever existed! It should probably only be used when auditing a legacy database. Normally, you cancel all of a customers\' packages if they cancel service.',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'deletepayments',
- 'section' => 'UI',
- 'description' => 'Enable deletion of unclosed payments. Be very careful! Only delete payments that were data-entry errors, not adjustments. Optionally specify one or more comma-separated email addresses to be notified when a payment is deleted.',
- 'type' => [qw( checkbox text )],
- },
-
- {
- 'key' => 'deletecredits',
- 'section' => 'UI',
- 'description' => 'Enable deletion of unclosed credits. Be very careful! Only delete credits that were data-entry errors, not adjustments. Optionally specify one or more comma-separated email addresses to be notified when a credit is deleted.',
- 'type' => [qw( checkbox text )],
- },
-
- {
- 'key' => 'unapplypayments',
- 'section' => 'UI',
- 'description' => 'Enable "unapplication" of unclosed payments.',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'unapplycredits',
- 'section' => 'UI',
- 'description' => 'Enable "unapplication" of unclosed credits.',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'dirhash',
- 'section' => 'shell',
- 'description' => 'Optional numeric value to control directory hashing. If positive, hashes directories for the specified number of levels from the front of the username. If negative, hashes directories for the specified number of levels from the end of the username. Some examples: <ul><li>1: user -> <a href="#home">/home</a>/u/user<li>2: user -> <a href="#home">/home</a>/u/s/user<li>-1: user -> <a href="#home">/home</a>/r/user<li>-2: user -> <a href="#home">home</a>/r/e/user</ul>',
- 'type' => 'text',
- },
-
- {
- 'key' => 'disable_customer_referrals',
- 'section' => 'UI',
- 'description' => 'Disable new customer-to-customer referrals in the web interface',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'editreferrals',
- 'section' => 'UI',
- 'description' => 'Enable advertising source modification for existing customers',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'emailinvoiceonly',
- 'section' => 'billing',
- 'description' => 'Disables postal mail invoices',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'disablepostalinvoicedefault',
- 'section' => 'billing',
- 'description' => 'Disables postal mail invoices as the default option in the UI. Be careful not to setup customers which are not sent invoices. See <a href ="#emailinvoiceauto">emailinvoiceauto</a>.',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'emailinvoiceauto',
- 'section' => 'billing',
- 'description' => 'Automatically adds new accounts to the email invoice list',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'exclude_ip_addr',
- 'section' => '',
- 'description' => 'Exclude these from the list of available broadband service IP addresses. (One per line)',
- 'type' => 'textarea',
- },
-
- {
- 'key' => 'erpcdmachines',
- 'section' => 'deprecated',
- 'description' => '<b>DEPRECATED</b>, ERPCD is no longer supported. Used to be ERPCD authenticaion machines, one per line. This enables export of `/usr/annex/acp_passwd\' and `/usr/annex/acp_dialup\'',
- 'type' => 'textarea',
- },
-
- {
- 'key' => 'hidecancelledpackages',
- 'section' => 'UI',
- 'description' => 'Prevent cancelled packages from showing up in listings (though they will still be in the database)',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'hidecancelledcustomers',
- 'section' => 'UI',
- 'description' => 'Prevent customers with only cancelled packages from showing up in listings (though they will still be in the database)',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'home',
- 'section' => 'required',
- 'description' => 'For new users, prefixed to username to create a directory name. Should have a leading but not a trailing slash.',
- 'type' => 'text',
- },
-
- {
- 'key' => 'icradiusmachines',
- 'section' => 'deprecated',
- 'description' => '<b>DEPRECATED</b>, add an <i>sqlradius</i> <a href="../browse/part_export.cgi">export</a> instead. This option used to enable radcheck and radreply table population - by default in the Freeside database, or in the database specified by the <a href="http://rootwood.haze.st/aspside/config/config-view.cgi#icradius_secrets">icradius_secrets</a> config option (the radcheck and radreply tables needs to be created manually). You do not need to use MySQL for your Freeside database to export to an ICRADIUS/FreeRADIUS MySQL database with this option. <blockquote><b>ADDITIONAL DEPRECATED FUNCTIONALITY</b> (instead use <a href="http://www.mysql.com/documentation/mysql/bychapter/manual_MySQL_Database_Administration.html#Replication">MySQL replication</a> or point icradius_secrets to the external database) - your <a href="ftp://ftp.cheapnet.net/pub/icradius">ICRADIUS</a> machines or <a href="http://www.freeradius.org/">FreeRADIUS</a> (with MySQL authentication) machines, one per line. Machines listed in this file will have the radcheck table exported to them. Each line should contain four items, separted by whitespace: machine name, MySQL database name, MySQL username, and MySQL password. For example: <CODE>"radius.isp.tld&nbsp;radius_db&nbsp;radius_user&nbsp;passw0rd"</CODE></blockquote>',
- 'type' => [qw( checkbox textarea )],
- },
-
- {
- 'key' => 'icradius_mysqldest',
- 'section' => 'deprecated',
- 'description' => '<b>DEPRECATED</b>, add an <i>sqlradius</i> <a href="../browse/part_export.cgi">export</a> instead. Used to be the destination directory for the MySQL databases, on the ICRADIUS/FreeRADIUS machines. Defaults to "/usr/local/var/".',
- 'type' => 'text',
- },
-
- {
- 'key' => 'icradius_mysqlsource',
- 'section' => 'deprecated',
- 'description' => '<b>DEPRECATED</b>, add an <i>sqlradius</i> <a href="../browse/part_export.cgi">export</a> instead. Used to be the source directory for for the MySQL radcheck table files, on the Freeside machine. Defaults to "/usr/local/var/freeside".',
- 'type' => 'text',
- },
-
- {
- 'key' => 'icradius_secrets',
- 'section' => 'deprecated',
- 'description' => '<b>DEPRECATED</b>, add an <i>sqlradius</i> <a href="../browse/part_export.cgi">export</a> instead. This option used to specify a database for ICRADIUS/FreeRADIUS export. Three lines: DBI data source, username and password.',
- 'type' => 'textarea',
- },
-
- {
- 'key' => 'invoice_from',
- 'section' => 'required',
- 'description' => 'Return address on email invoices',
- 'type' => 'text',
- },
-
- {
- 'key' => 'invoice_template',
- 'section' => 'required',
- 'description' => 'Required template file for invoices. See the <a href="../docs/billing.html">billing documentation</a> for details.',
- 'type' => 'textarea',
- },
-
- {
- 'key' => 'invoice_latex',
- 'section' => 'billing',
- 'description' => 'Optional LaTeX template for typeset PostScript invoices.',
- 'type' => 'textarea',
- },
-
- {
- 'key' => 'invoice_latexnotes',
- 'section' => 'billing',
- 'description' => 'Notes section for LaTeX typeset PostScript invoices.',
- 'type' => 'textarea',
- },
-
- {
- 'key' => 'invoice_latexfooter',
- 'section' => 'billing',
- 'description' => 'Footer for LaTeX typeset PostScript invoices.',
- 'type' => 'textarea',
- },
-
- {
- 'key' => 'invoice_latexsmallfooter',
- 'section' => 'billing',
- 'description' => 'Optional small footer for multi-page LaTeX typeset PostScript invoices.',
- 'type' => 'textarea',
- },
-
- {
- 'key' => 'invoice_default_terms',
- 'section' => 'billing',
- 'description' => 'Optional default invoice term, used to calculate a due date printed on invoices.',
- 'type' => 'select',
- 'select_enum' => [ '', 'Payable upon receipt', 'Net 0', 'Net 10', 'Net 15', 'Net 30', 'Net 45', 'Net 60' ],
- },
-
- {
- 'key' => 'invoice_send_receipts',
- 'section' => 'billing',
- 'description' => 'Send receipts for payments and credits.',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'lpr',
- 'section' => 'required',
- 'description' => 'Print command for paper invoices, for example `lpr -h\'',
- 'type' => 'text',
- },
-
- {
- 'key' => 'maildisablecatchall',
- 'section' => 'deprecated',
- 'description' => '<b>DEPRECATED</b>, now the default. Turning this option on used to disable the requirement that each virtual domain have a catch-all mailbox.',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'money_char',
- 'section' => '',
- 'description' => 'Currency symbol - defaults to `$\'',
- 'type' => 'text',
- },
-
- {
- 'key' => 'mxmachines',
- 'section' => 'deprecated',
- 'description' => 'MX entries for new domains, weight and machine, one per line, with trailing `.\'',
- 'type' => 'textarea',
- },
-
- {
- 'key' => 'nsmachines',
- 'section' => 'deprecated',
- 'description' => 'NS nameservers for new domains, one per line, with trailing `.\'',
- 'type' => 'textarea',
- },
-
- {
- 'key' => 'defaultrecords',
- 'section' => 'BIND',
- 'description' => 'DNS entries to add automatically when creating a domain',
- 'type' => 'editlist',
- 'editlist_parts' => [ { type=>'text' },
- { type=>'immutable', value=>'IN' },
- { type=>'select',
- select_enum=>{ map { $_=>$_ } qw(A CNAME MX NS)} },
- { type=> 'text' }, ],
- },
-
- {
- 'key' => 'arecords',
- 'section' => 'deprecated',
- 'description' => 'A list of tab seperated CNAME records to add automatically when creating a domain',
- 'type' => 'textarea',
- },
-
- {
- 'key' => 'cnamerecords',
- 'section' => 'deprecated',
- 'description' => 'A list of tab seperated CNAME records to add automatically when creating a domain',
- 'type' => 'textarea',
- },
-
- {
- 'key' => 'nismachines',
- 'section' => 'deprecated',
- 'description' => '<b>DEPRECATED</b>. Your NIS master (not slave master) machines, one per line. This enables export of `/etc/global/passwd\' and `/etc/global/shadow\'.',
- 'type' => 'textarea',
- },
-
- {
- 'key' => 'passwordmin',
- 'section' => 'password',
- 'description' => 'Minimum password length (default 6)',
- 'type' => 'text',
- },
-
- {
- 'key' => 'passwordmax',
- 'section' => 'password',
- 'description' => 'Maximum password length (default 8) (don\'t set this over 12 if you need to import or export crypt() passwords)',
- 'type' => 'text',
- },
-
- {
- 'key' => 'qmailmachines',
- 'section' => 'deprecated',
- 'description' => '<b>DEPRECATED</b>, add <i>qmail</i> and <i>shellcommands</i> <a href="../browse/part_export.cgi">exports</a> instead. This option used to export `/var/qmail/control/virtualdomains\', `/var/qmail/control/recipientmap\', and `/var/qmail/control/rcpthosts\'. Setting this option (even if empty) also turns on user `.qmail-extension\' file maintenance in conjunction with the <b>shellmachine</b> option.',
- 'type' => [qw( checkbox textarea )],
- },
-
- {
- 'key' => 'radiusmachines',
- 'section' => 'deprecated',
- 'description' => '<b>DEPRECATED</b>, add an <i>sqlradius</i> <a href="../browse/part_export.cgi">export</a> instead. This option used to export to be: your RADIUS authentication machines, one per line. This enables export of `/etc/raddb/users\'.',
- 'type' => 'textarea',
- },
-
- {
- 'key' => 'referraldefault',
- 'section' => 'UI',
- 'description' => 'Default referral, specified by refnum',
- 'type' => 'text',
- },
-
-# {
-# 'key' => 'registries',
-# 'section' => 'required',
-# 'description' => 'Directory which contains domain registry information. Each registry is a directory.',
-# },
-
- {
- 'key' => 'report_template',
- 'section' => 'required',
- 'description' => 'Required template file for reports. See the <a href="../docs/billing.html">billing documentation</a> for details.',
- 'type' => 'textarea',
- },
-
-
- {
- 'key' => 'maxsearchrecordsperpage',
- 'section' => 'UI',
- 'description' => 'If set, number of search records to return per page.',
- 'type' => 'text',
- },
-
- {
- 'key' => 'sendmailconfigpath',
- 'section' => 'deprecated',
- 'description' => '<b>DEPRECATED</b>, add a <i>sendmail</i> <a href="../browse/part_export.cgi">export</a> instead. Used to be sendmail configuration file path. Defaults to `/etc\'. Many newer distributions use `/etc/mail\'.',
- 'type' => 'text',
- },
-
- {
- 'key' => 'sendmailmachines',
- 'section' => 'deprecated',
- 'description' => '<b>DEPRECATED</b>, add a <i>sendmail</i> <a href="../browse/part_export.cgi">export</a> instead. Used to be sendmail machines, one per line. This enables export of `/etc/virtusertable\' and `/etc/sendmail.cw\'.',
- 'type' => 'textarea',
- },
-
- {
- 'key' => 'sendmailrestart',
- 'section' => 'deprecated',
- 'description' => '<b>DEPRECATED</b>, add a <i>sendmail</i> <a href="../browse/part_export.cgi">export</a> instead. Used to define the command which is run on sendmail machines after files are copied.',
- 'type' => 'text',
- },
-
- {
- 'key' => 'session-start',
- 'section' => 'session',
- 'description' => 'If defined, the command which is executed on the Freeside machine when a session begins. The contents of the file are treated as a double-quoted perl string, with the following variables available: <code>$ip</code>, <code>$nasip</code> and <code>$nasfqdn</code>, which are the IP address of the starting session, and the IP address and fully-qualified domain name of the NAS this session is on.',
- 'type' => 'text',
- },
-
- {
- 'key' => 'session-stop',
- 'section' => 'session',
- 'description' => 'If defined, the command which is executed on the Freeside machine when a session ends. The contents of the file are treated as a double-quoted perl string, with the following variables available: <code>$ip</code>, <code>$nasip</code> and <code>$nasfqdn</code>, which are the IP address of the starting session, and the IP address and fully-qualified domain name of the NAS this session is on.',
- 'type' => 'text',
- },
-
- {
- 'key' => 'shellmachine',
- 'section' => 'deprecated',
- 'description' => '<b>DEPRECATED</b>, add a <i>shellcommands</i> <a href="../browse/part_export.cgi">export</a> instead. This option used to contain a single machine with user home directories mounted. This enables home directory creation, renaming and archiving/deletion. In conjunction with `qmailmachines\', it also enables `.qmail-extension\' file maintenance.',
- 'type' => 'text',
- },
-
- {
- 'key' => 'shellmachine-useradd',
- 'section' => 'deprecated',
- 'description' => '<b>DEPRECATED</b>, add a <i>shellcommands</i> <a href="../browse/part_export.cgi">export</a> instead. This option used to contain command(s) to run on shellmachine when an account is created. If the <b>shellmachine</b> option is set but this option is not, <code>useradd -d $dir -m -s $shell -u $uid $username</code> is the default. If this option is set but empty, <code>cp -pr /etc/skel $dir; chown -R $uid.$gid $dir</code> is the default instead. Otherwise the value is evaluated as a double-quoted perl string, with the following variables available: <code>$username</code>, <code>$uid</code>, <code>$gid</code>, <code>$dir</code>, and <code>$shell</code>.',
- 'type' => [qw( checkbox text )],
- },
-
- {
- 'key' => 'shellmachine-userdel',
- 'section' => 'deprecated',
- 'description' => '<b>DEPRECATED</b>, add a <i>shellcommands</i> <a href="../browse/part_export.cgi">export</a> instead. This option used to contain command(s) to run on shellmachine when an account is deleted. If the <b>shellmachine</b> option is set but this option is not, <code>userdel $username</code> is the default. If this option is set but empty, <code>rm -rf $dir</code> is the default instead. Otherwise the value is evaluated as a double-quoted perl string, with the following variables available: <code>$username</code> and <code>$dir</code>.',
- 'type' => [qw( checkbox text )],
- },
-
- {
- 'key' => 'shellmachine-usermod',
- 'section' => 'deprecated',
- 'description' => '<b>DEPRECATED</b>, add a <i>shellcommands</i> <a href="../browse/part_export.cgi">export</a> instead. This option used to contain command(s) to run on shellmachine when an account is modified. If the <b>shellmachine</b> option is set but this option is empty, <code>[ -d $old_dir ] &amp;&amp; mv $old_dir $new_dir || ( chmod u+t $old_dir; mkdir $new_dir; cd $old_dir; find . -depth -print | cpio -pdm $new_dir; chmod u-t $new_dir; chown -R $uid.$gid $new_dir; rm -rf $old_dir )</code> is the default. Otherwise the contents of the file are treated as a double-quoted perl string, with the following variables available: <code>$old_dir</code>, <code>$new_dir</code>, <code>$uid</code> and <code>$gid</code>.',
- #'type' => [qw( checkbox text )],
- 'type' => 'text',
- },
-
- {
- 'key' => 'shellmachines',
- 'section' => 'deprecated',
- 'description' => '<b>DEPRECATED</b>, add a <i>sysvshell</i> <a href="../browse/part_export.cgi">export</a> instead. Your Linux and System V flavored shell (and mail) machines, one per line. This enables export of `/etc/passwd\' and `/etc/shadow\' files.',
- 'type' => 'textarea',
- },
-
- {
- 'key' => 'shells',
- 'section' => 'required',
- 'description' => 'Legal shells (think /etc/shells). You probably want to `cut -d: -f7 /etc/passwd | sort | uniq\' initially so that importing doesn\'t fail with `Illegal shell\' errors, then remove any special entries afterwords. A blank line specifies that an empty shell is permitted.',
- 'type' => 'textarea',
- },
-
- {
- 'key' => 'showpasswords',
- 'section' => 'UI',
- 'description' => 'Display unencrypted user passwords in the web interface',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'signupurl',
- 'section' => 'UI',
- 'description' => 'if you are using customer-to-customer referrals, and you enter the URL of your <a href="../docs/signup.html">signup server CGI</a>, the customer view screen will display a customized link to the signup server with the appropriate customer as referral',
- 'type' => 'text',
- },
-
- {
- 'key' => 'smtpmachine',
- 'section' => 'required',
- 'description' => 'SMTP relay for Freeside\'s outgoing mail',
- 'type' => 'text',
- },
-
- {
- 'key' => 'soadefaultttl',
- 'section' => 'BIND',
- 'description' => 'SOA default TTL for new domains.',
- 'type' => 'text',
- },
-
- {
- 'key' => 'soaemail',
- 'section' => 'BIND',
- 'description' => 'SOA email for new domains, in BIND form (`.\' instead of `@\'), with trailing `.\'',
- 'type' => 'text',
- },
-
- {
- 'key' => 'soaexpire',
- 'section' => 'BIND',
- 'description' => 'SOA expire for new domains',
- 'type' => 'text',
- },
-
- {
- 'key' => 'soamachine',
- 'section' => 'BIND',
- 'description' => 'SOA machine for new domains, with trailing `.\'',
- 'type' => 'text',
- },
-
- {
- 'key' => 'soarefresh',
- 'section' => 'BIND',
- 'description' => 'SOA refresh for new domains',
- 'type' => 'text',
- },
-
- {
- 'key' => 'soaretry',
- 'section' => 'BIND',
- 'description' => 'SOA retry for new domains',
- 'type' => 'text',
- },
-
- {
- 'key' => 'statedefault',
- 'section' => 'UI',
- 'description' => 'Default state or province (if not supplied, the default is `CA\')',
- 'type' => 'text',
- },
-
- {
- 'key' => 'radiusprepend',
- 'section' => 'deprecated',
- 'description' => '<b>DEPRECATED</b>, real-time text radius now edits an existing file in place - just (turn off freeside-queued and) edit your RADIUS users file directly. The contents used to be be prepended to the top of the RADIUS users file (text exports only).',
- 'type' => 'textarea',
- },
-
- {
- 'key' => 'textradiusprepend',
- 'section' => 'deprecated',
- 'description' => '<b>DEPRECATED</b>, use RADIUS check attributes instead. The contents used to be prepended to the first line of a user\'s RADIUS entry in text exports.',
- 'type' => 'text',
- },
-
- {
- 'key' => 'unsuspendauto',
- 'section' => 'billing',
- 'description' => 'Enables the automatic unsuspension of suspended packages when a customer\'s balance due changes from positive to zero or negative as the result of a payment or credit',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'usernamemin',
- 'section' => 'username',
- 'description' => 'Minimum username length (default 2)',
- 'type' => 'text',
- },
-
- {
- 'key' => 'usernamemax',
- 'section' => 'username',
- 'description' => 'Maximum username length',
- 'type' => 'text',
- },
-
- {
- 'key' => 'username-ampersand',
- 'section' => 'username',
- 'description' => 'Allow the ampersand character (&amp;) in usernames. Be careful when using this option in conjunction with <a href="../browse/part_export.cgi">exports</a> which execute shell commands, as the ampersand will be interpreted by the shell if not quoted.',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'username-letter',
- 'section' => 'username',
- 'description' => 'Usernames must contain at least one letter',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'username-letterfirst',
- 'section' => 'username',
- 'description' => 'Usernames must start with a letter',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'username-noperiod',
- 'section' => 'username',
- 'description' => 'Disallow periods in usernames',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'username-nounderscore',
- 'section' => 'username',
- 'description' => 'Disallow underscores in usernames',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'username-nodash',
- 'section' => 'username',
- 'description' => 'Disallow dashes in usernames',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'username-uppercase',
- 'section' => 'username',
- 'description' => 'Allow uppercase characters in usernames',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'username_policy',
- 'section' => 'deprecated',
- 'description' => 'This file controls the mechanism for preventing duplicate usernames in passwd/radius files exported from svc_accts. This should be one of \'prepend domsvc\' \'append domsvc\' \'append domain\' or \'append @domain\'',
- 'type' => 'select',
- 'select_enum' => [ 'prepend domsvc', 'append domsvc', 'append domain', 'append @domain' ],
- #'type' => 'text',
- },
-
- {
- 'key' => 'vpopmailmachines',
- 'section' => 'deprecated',
- 'description' => '<b>DEPRECATED</b>, add a <i>vpopmail</i> <a href="../browse/part_export.cgi">export</a> instead. This option used to contain your vpopmail pop toasters, one per line. Each line is of the form "machinename vpopdir vpopuid vpopgid". For example: <code>poptoaster.domain.tld /home/vpopmail 508 508</code> Note: vpopuid and vpopgid are values taken from the vpopmail machine\'s /etc/passwd',
- 'type' => 'textarea',
- },
-
- {
- 'key' => 'vpopmailrestart',
- 'section' => 'deprecated',
- 'description' => '<b>DEPRECATED</b>, add a <i>vpopmail</i> <a href="../browse/part_export.cgi">export</a> instead. This option used to define the shell commands to run on vpopmail machines after files are copied. An example can be found in eg/vpopmailrestart of the source distribution.',
- 'type' => 'textarea',
- },
-
- {
- 'key' => 'safe-part_pkg',
- 'section' => 'UI',
- 'description' => 'Validates package definition setup and recur expressions against a preset list. Useful for webdemos, annoying to powerusers.',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'safe-part_bill_event',
- 'section' => 'UI',
- 'description' => 'Validates invoice event expressions against a preset list. Useful for webdemos, annoying to powerusers.',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'show_ss',
- 'section' => 'UI',
- 'description' => 'Turns on display/collection of SS# in the web interface.',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'agent_defaultpkg',
- 'section' => 'UI',
- 'description' => 'Setting this option will cause new packages to be available to all agent types by default.',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'legacy_link',
- 'section' => 'UI',
- 'description' => 'Display options in the web interface to link legacy pre-Freeside services.',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'legacy_link-steal',
- 'section' => 'UI',
- 'description' => 'Allow "stealing" an already-audited service from one customer (or package) to another using the link function.',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'queue_dangerous_controls',
- 'section' => 'UI',
- 'description' => 'Enable queue modification controls on account pages and for new jobs. Unless you are a developer working on new export code, you should probably leave this off to avoid causing provisioning problems.',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'security_phrase',
- 'section' => 'password',
- 'description' => 'Enable the tracking of a "security phrase" with each account. Not recommended, as it is vulnerable to social engineering.',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'locale',
- 'section' => 'UI',
- 'description' => 'Message locale',
- 'type' => 'select',
- 'select_enum' => [ qw(en_US) ],
- },
-
- {
- 'key' => 'selfservice_server-quiet',
- 'section' => 'deprecated',
- 'description' => '<b>DEPRECATED</b>, the self-service server no longer sends superfluous decline and cancel emails. Used to disable decline and cancel emails generated by transactions initiated by the selfservice server.',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'signup_server-quiet',
- 'section' => 'deprecated',
- 'description' => '<b>DEPRECATED</b>, the signup server is now part of the self-service server and no longer sends superfluous decline and cancel emails. Used to disable decline and cancel emails generated by transactions initiated by the signup server. Does not disable welcome emails.',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'signup_server-payby',
- 'section' => '',
- 'description' => 'Acceptable payment types for the signup server',
- 'type' => 'selectmultiple',
- 'select_enum' => [ qw(CARD DCRD CHEK DCHK LECB PREPAY BILL COMP) ],
- },
-
- {
- 'key' => 'signup_server-email',
- 'section' => 'deprecated',
- 'description' => '<b>DEPRECATED</b>, this feature is no longer available. See the ***fill me in*** report instead. Used to contain a comma-separated list of email addresses to receive notification of signups via the signup server.',
- 'type' => 'text',
- },
-
- {
- 'key' => 'signup_server-default_agentnum',
- 'section' => '',
- 'description' => 'Default agentnum for the signup server',
- 'type' => 'text',
- },
-
- {
- 'key' => 'signup_server-default_refnum',
- 'section' => '',
- 'description' => 'Default advertising source number for the signup server',
- 'type' => 'text',
- },
-
- {
- 'key' => 'show-msgcat-codes',
- 'section' => 'UI',
- 'description' => 'Show msgcat codes in error messages. Turn this option on before reporting errors to the mailing list.',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'signup_server-realtime',
- 'section' => '',
- 'description' => 'Run billing for signup server signups immediately, and suspend accounts which subsequently have a balance.',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'declinetemplate',
- 'section' => 'billing',
- 'description' => 'Template file for credit card decline emails.',
- 'type' => 'textarea',
- },
-
- {
- 'key' => 'emaildecline',
- 'section' => 'billing',
- 'description' => 'Enable emailing of credit card decline notices.',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'emaildecline-exclude',
- 'section' => 'billing',
- 'description' => 'List of error messages that should not trigger email decline notices, one per line.',
- 'type' => 'textarea',
- },
-
- {
- 'key' => 'cancelmessage',
- 'section' => 'billing',
- 'description' => 'Template file for cancellation emails.',
- 'type' => 'textarea',
- },
-
- {
- 'key' => 'cancelsubject',
- 'section' => 'billing',
- 'description' => 'Subject line for cancellation emails.',
- 'type' => 'text',
- },
-
- {
- 'key' => 'emailcancel',
- 'section' => 'billing',
- 'description' => 'Enable emailing of cancellation notices.',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'require_cardname',
- 'section' => 'billing',
- 'description' => 'Require an "Exact name on card" to be entered explicitly; don\'t default to using the first and last name.',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'enable_taxclasses',
- 'section' => 'billing',
- 'description' => 'Enable per-package tax classes',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'welcome_email',
- 'section' => '',
- 'description' => 'Template file for welcome email. Welcome emails are sent to the customer email invoice destination(s) each time a svc_acct record is created. See the <a href="http://search.cpan.org/doc/MJD/Text-Template-1.42/Template.pm">Text::Template</a> documentation for details on the template substitution language. The following variables are available: <code>$username</code>, <code>$password</code>, <code>$first</code>, <code>$last</code> and <code>$pkg</code>.',
- 'type' => 'textarea',
- },
-
- {
- 'key' => 'welcome_email-from',
- 'section' => '',
- 'description' => 'From: address header for welcome email',
- 'type' => 'text',
- },
-
- {
- 'key' => 'welcome_email-subject',
- 'section' => '',
- 'description' => 'Subject: header for welcome email',
- 'type' => 'text',
- },
-
- {
- 'key' => 'welcome_email-mimetype',
- 'section' => '',
- 'description' => 'MIME type for welcome email',
- 'type' => 'select',
- 'select_enum' => [ 'text/plain', 'text/html' ],
- },
-
- {
- 'key' => 'payby-default',
- 'section' => 'UI',
- 'description' => 'Default payment type. HIDE disables display of billing information and sets customers to BILL.',
- 'type' => 'select',
- 'select_enum' => [ '', qw(CARD DCRD CHEK DCHK LECB BILL COMP HIDE) ],
- },
-
- {
- 'key' => 'svc_acct-notes',
- 'section' => 'UI',
- 'description' => 'Extra HTML to be displayed on the Account View screen.',
- 'type' => 'textarea',
- },
-
- {
- 'key' => 'radius-password',
- 'section' => '',
- 'description' => 'RADIUS attribute for plain-text passwords.',
- 'type' => 'select',
- 'select_enum' => [ 'Password', 'User-Password' ],
- },
-
- {
- 'key' => 'radius-ip',
- 'section' => '',
- 'description' => 'RADIUS attribute for IP addresses.',
- 'type' => 'select',
- 'select_enum' => [ 'Framed-IP-Address', 'Framed-Address' ],
- },
-
- {
- 'key' => 'svc_acct-alldomains',
- 'section' => '',
- 'description' => 'Allow accounts to select any domain in the database. Normally accounts can only select from the domain set in the service definition and those purchased by the customer.',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'dump-scpdest',
- 'section' => '',
- 'description' => 'destination for scp database dumps: user@host:/path',
- 'type' => 'text',
- },
-
- {
- 'key' => 'users-allow_comp',
- 'section' => '',
- 'description' => 'Usernames (Freeside users, created with <a href="../docs/man/bin/freeside-adduser.html">freeside-adduser</a>) which can create complimentary customers, one per line. If no usernames are entered, all users can create complimentary accounts.',
- 'type' => 'textarea',
- },
-
- {
- 'key' => 'cvv-save',
- 'section' => 'billing',
- 'description' => 'Save CVV2 information after the initial transaction for the selected credit card types. Enabling this option may be in violation of your merchant agreement(s), so please check them carefully before enabling this option for any credit card types.',
- 'type' => 'selectmultiple',
- 'select_enum' => [ "VISA card",
- "MasterCard",
- "Discover card",
- "American Express card",
- "Diner's Club/Carte Blanche",
- "enRoute",
- "JCB",
- "BankCard",
- ],
- },
-
- {
- 'key' => 'allow_negative_charges',
- 'section' => 'billing',
- 'description' => 'Allow negative charges. Normally not used unless importing data from a legacy system that requires this.',
- 'type' => 'checkbox',
- },
- {
- 'key' => 'auto_unset_catchall',
- 'section' => '',
- 'description' => 'When canceling a svc_acct that is the email catchall for one or more svc_domains, automatically set their catchall fields to null. If this option is not set, the attempt will simply fail.',
- 'type' => 'checkbox',
- },
-
- {
- 'key' => 'system_usernames',
- 'section' => 'username',
- 'description' => 'A list of system usernames that cannot be edited or removed, one per line. Use a bare username to prohibit modification/deletion of the username in any domain, or username@domain to prohibit modification/deletetion of a specific username and domain.',
- 'type' => 'textarea',
- },
-
- {
- 'key' => 'cust_pkg-change_svcpart',
- 'section' => '',
- 'description' => "When changing packages, move services even if svcparts don't match between old and new pacakge definitions. Use with caution! No provision is made for export differences between the old and new service definitions. Probably only should be used when your exports for all service definitions of a given svcdb are identical.",
- 'type' => 'checkbox',
- },
-
-);
-
-1;
-
diff --git a/FS/FS/ConfItem.pm b/FS/FS/ConfItem.pm
deleted file mode 100644
index 83295b4..0000000
--- a/FS/FS/ConfItem.pm
+++ /dev/null
@@ -1,63 +0,0 @@
-package FS::ConfItem;
-
-=head1 NAME
-
-FS::ConfItem - Configutaion option meta-data.
-
-=head1 SYNOPSIS
-
- use FS::Conf;
- @config_items = $conf->config_items;
-
- foreach $item ( @config_items ) {
- $key = $item->key;
- $section = $item->section;
- $description = $item->description;
- }
-
-=head1 DESCRIPTION
-
-=head1 METHODS
-
-=over 4
-
-=item new
-
-=cut
-
-sub new {
- my $proto = shift;
- my $class = ref($proto) || $proto;
- my $self = @_ ? shift : {};
- bless ($self, $class);
-}
-
-=item key
-
-=item section
-
-=item description
-
-=cut
-
-sub AUTOLOAD {
- my $self = shift;
- my $field = $AUTOLOAD;
- $field =~ s/.*://;
- $self->{$field};
-}
-
-=back
-
-=head1 BUGS
-
-Terse docs.
-
-=head1 SEE ALSO
-
-L<FS::Conf>
-
-=cut
-
-1;
-
diff --git a/FS/FS/InitHandler.pm b/FS/FS/InitHandler.pm
deleted file mode 100644
index 5038cf3..0000000
--- a/FS/FS/InitHandler.pm
+++ /dev/null
@@ -1,91 +0,0 @@
-package FS::InitHandler;
-
-# this leaks memory under graceful restarts and i wouldn't use it on any
-# modern server. useful for very slow machines with memory to spare, just
-# always do a full restart
-
-use strict;
-use vars qw($DEBUG);
-use FS::UID qw(adminsuidsetup);
-use FS::Record;
-
-$DEBUG = 1;
-
-sub handler {
-
- use Date::Format;
- use Date::Parse;
- use Tie::IxHash;
- use HTML::Entities;
- use IO::Handle;
- use IO::File;
- use String::Approx;
- use HTML::Widgets::SelectLayers 0.02;
- #use FS::UID;
- #use FS::Record;
- use FS::Conf;
- use FS::CGI;
- use FS::Msgcat;
-
- use FS::agent;
- use FS::agent_type;
- use FS::domain_record;
- use FS::cust_bill;
- use FS::cust_bill_pay;
- use FS::cust_credit;
- use FS::cust_credit_bill;
- use FS::cust_main;
- use FS::cust_main_county;
- use FS::cust_pay;
- use FS::cust_pkg;
- use FS::cust_refund;
- use FS::cust_svc;
- use FS::nas;
- use FS::part_bill_event;
- use FS::part_pkg;
- use FS::part_referral;
- use FS::part_svc;
- use FS::pkg_svc;
- use FS::port;
- use FS::queue;
- use FS::raddb;
- use FS::session;
- use FS::svc_acct;
- use FS::svc_acct_pop;
- use FS::svc_domain;
- use FS::svc_forward;
- use FS::svc_www;
- use FS::type_pkgs;
- use FS::part_export;
- use FS::part_export_option;
- use FS::export_svc;
- use FS::msgcat;
-
- warn "[FS::InitHandler] handler called\n" if $DEBUG;
-
- #this is sure to be broken on freebsd
- $> = $FS::UID::freeside_uid;
-
- open(MAPSECRETS,"<$FS::UID::conf_dir/mapsecrets")
- or die "can't read $FS::UID::conf_dir/mapsecrets: $!";
-
- my %seen;
- while (<MAPSECRETS>) {
- next if /^\s*(#|$)/;
- /^([\w\-\.]+)\s(.*)$/
- or do { warn "strange line in mapsecrets: $_"; next; };
- my($user, $datasrc) = ($1, $2);
- next if $seen{$datasrc}++;
- warn "[FS::InitHandler] preloading $datasrc for $user\n" if $DEBUG;
- adminsuidsetup($user);
- }
-
- close MAPSECRETS;
-
- #lalala probably broken on freebsd
- ($<, $>) = ($>, $<);
- $< = 0;
-
-}
-
-1;
diff --git a/FS/FS/Misc.pm b/FS/FS/Misc.pm
deleted file mode 100644
index efad2df..0000000
--- a/FS/FS/Misc.pm
+++ /dev/null
@@ -1,102 +0,0 @@
-package FS::Misc;
-
-use strict;
-use vars qw ( @ISA @EXPORT_OK );
-use Exporter;
-
-@ISA = qw( Exporter );
-@EXPORT_OK = qw( send_email );
-
-=head1 NAME
-
-FS::Misc - Miscellaneous subroutines
-
-=head1 SYNOPSIS
-
- use FS::Misc qw(send_email);
-
- send_email();
-
-=head1 DESCRIPTION
-
-Miscellaneous subroutines. This module contains miscellaneous subroutines
-called from multiple other modules. These are not OO or necessarily related,
-but are collected here to elimiate code duplication.
-
-=head1 SUBROUTINES
-
-=over 4
-
-=item send_email OPTION => VALUE ...
-
-Options:
-
-I<from> - (required)
-
-I<to> - (required) comma-separated scalar or arrayref of recipients
-
-I<subject> - (required)
-
-I<content-type> - (optional) MIME type
-
-I<body> - (required) arrayref of body text lines
-
-=cut
-
-use vars qw( $conf );
-use Date::Format;
-use Mail::Header;
-use Mail::Internet 1.44;
-use FS::UID;
-
-FS::UID->install_callback( sub {
- $conf = new FS::Conf;
-} );
-
-sub send_email {
- my(%options) = @_;
-
- $ENV{MAILADDRESS} = $options{'from'};
- my $to = ref($options{to}) ? join(', ', @{ $options{to} } ) : $options{to};
- my @header = (
- 'From: '. $options{'from'},
- 'To: '. $to,
- 'Sender: '. $options{'from'},
- 'Reply-To: '. $options{'from'},
- 'Date: '. time2str("%a, %d %b %Y %X %z", time),
- 'Subject: '. $options{'subject'},
- );
- push @header, 'Content-Type: '. $options{'content-type'}
- if exists($options{'content-type'});
- my $header = new Mail::Header ( \@header );
-
- my $message = new Mail::Internet (
- 'Header' => $header,
- 'Body' => $options{'body'},
- );
-
- my $smtpmachine = $conf->config('smtpmachine');
- $!=0;
-
- my $rv = $message->smtpsend( 'Host' => $smtpmachine )
- or $message->smtpsend( Host => $smtpmachine, Debug => 1 );
-
- if ($rv) { #smtpsend returns a list of addresses, not true/false
- return '';
- } else {
- return "can't send email to $to via server $smtpmachine with SMTP: $!";
- }
-
-}
-
-=head1 BUGS
-
-This package exists.
-
-=head1 SEE ALSO
-
-L<FS::UID>, L<FS::CGI>, L<FS::Record>, the base documentation.
-
-=cut
-
-1;
diff --git a/FS/FS/Msgcat.pm b/FS/FS/Msgcat.pm
deleted file mode 100644
index 625743d..0000000
--- a/FS/FS/Msgcat.pm
+++ /dev/null
@@ -1,98 +0,0 @@
-package FS::Msgcat;
-
-use strict;
-use vars qw( @ISA @EXPORT_OK $conf $locale $debug );
-use Exporter;
-use FS::UID;
-#use FS::Record qw( qsearchs ); # wtf? won't import...
-use FS::Record;
-use FS::Conf;
-use FS::msgcat;
-
-@ISA = qw(Exporter);
-@EXPORT_OK = qw( gettext geterror );
-
-$FS::UID::callback{'Msgcat'} = sub {
- $conf = new FS::Conf;
- $locale = $conf->config('locale') || 'en_US';
- $debug = $conf->exists('show-msgcat-codes')
-};
-
-=head1 NAME
-
-FS::Msgcat - Message catalog functions
-
-=head1 SYNOPSIS
-
- use FS::Msgcat qw(gettext geterror);
-
- #simple interface for retreiving messages...
- $message = gettext('msgcode');
- #or errors (includes the error code)
- $message = geterror('msgcode');
-
-=head1 DESCRIPTION
-
-FS::Msgcat provides functions to use the message catalog. If you want to
-maintain the message catalog database, see L<FS::msgcat> instead.
-
-=head1 SUBROUTINES
-
-=over 4
-
-=item gettext MSGCODE
-
-Returns the full message for the supplied message code.
-
-=cut
-
-sub gettext {
- $debug ? geterror(@_) : _gettext(@_);
-}
-
-sub _gettext {
- my $msgcode = shift;
- my $msgcat = FS::Record::qsearchs('msgcat', {
- 'msgcode' => $msgcode,
- 'locale' => $locale
- } );
- if ( $msgcat ) {
- $msgcat->msg;
- } else {
- warn "WARNING: message for msgcode $msgcode in locale $locale not found";
- $msgcode;
- }
-
-}
-
-=item geterror MSGCODE
-
-Returns the full message for the supplied message code, including the message
-code.
-
-=cut
-
-sub geterror {
- my $msgcode = shift;
- my $msg = _gettext($msgcode);
- if ( $msg eq $msgcode ) {
- "Error code $msgcode (message for locale $locale not found)";
- } else {
- "$msg (error code $msgcode)";
- }
-}
-
-=back
-
-=head1 BUGS
-
-i18n/l10n, eek
-
-=head1 SEE ALSO
-
-L<FS::msgcat>, L<FS::Record>, schema.html from the base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm
deleted file mode 100644
index 801b89d..0000000
--- a/FS/FS/Record.pm
+++ /dev/null
@@ -1,1659 +0,0 @@
-package FS::Record;
-
-use strict;
-use vars qw( $dbdef_file $dbdef $setup_hack $AUTOLOAD @ISA @EXPORT_OK $DEBUG
- $me %dbdef_cache %virtual_fields_cache );
-use subs qw(reload_dbdef);
-use Exporter;
-use Carp qw(carp cluck croak confess);
-use File::CounterFile;
-use Locale::Country;
-use DBI qw(:sql_types);
-use DBIx::DBSchema 0.23;
-use FS::UID qw(dbh getotaker datasrc driver_name);
-use FS::SearchCache;
-use FS::Msgcat qw(gettext);
-
-use FS::part_virtual_field;
-
-use Tie::IxHash;
-
-@ISA = qw(Exporter);
-@EXPORT_OK = qw(dbh fields hfields qsearch qsearchs dbdef jsearch);
-
-$DEBUG = 0;
-$me = '[FS::Record]';
-
-#ask FS::UID to run this stuff for us later
-$FS::UID::callback{'FS::Record'} = sub {
- $File::CounterFile::DEFAULT_DIR = "/usr/local/etc/freeside/counters.". datasrc;
- $dbdef_file = "/usr/local/etc/freeside/dbdef.". datasrc;
- &reload_dbdef unless $setup_hack; #$setup_hack needed now?
-};
-
-=head1 NAME
-
-FS::Record - Database record objects
-
-=head1 SYNOPSIS
-
- use FS::Record;
- use FS::Record qw(dbh fields qsearch qsearchs dbdef);
-
- $record = new FS::Record 'table', \%hash;
- $record = new FS::Record 'table', { 'column' => 'value', ... };
-
- $record = qsearchs FS::Record 'table', \%hash;
- $record = qsearchs FS::Record 'table', { 'column' => 'value', ... };
- @records = qsearch FS::Record 'table', \%hash;
- @records = qsearch FS::Record 'table', { 'column' => 'value', ... };
-
- $table = $record->table;
- $dbdef_table = $record->dbdef_table;
-
- $value = $record->get('column');
- $value = $record->getfield('column');
- $value = $record->column;
-
- $record->set( 'column' => 'value' );
- $record->setfield( 'column' => 'value' );
- $record->column('value');
-
- %hash = $record->hash;
-
- $hashref = $record->hashref;
-
- $error = $record->insert;
-
- $error = $record->delete;
-
- $error = $new_record->replace($old_record);
-
- # external use deprecated - handled by the database (at least for Pg, mysql)
- $value = $record->unique('column');
-
- $error = $record->ut_float('column');
- $error = $record->ut_number('column');
- $error = $record->ut_numbern('column');
- $error = $record->ut_money('column');
- $error = $record->ut_text('column');
- $error = $record->ut_textn('column');
- $error = $record->ut_alpha('column');
- $error = $record->ut_alphan('column');
- $error = $record->ut_phonen('column');
- $error = $record->ut_anything('column');
- $error = $record->ut_name('column');
-
- $dbdef = reload_dbdef;
- $dbdef = reload_dbdef "/non/standard/filename";
- $dbdef = dbdef;
-
- $quoted_value = _quote($value,'table','field');
-
- #deprecated
- $fields = hfields('table');
- if ( $fields->{Field} ) { # etc.
-
- @fields = fields 'table'; #as a subroutine
- @fields = $record->fields; #as a method call
-
-
-=head1 DESCRIPTION
-
-(Mostly) object-oriented interface to database records. Records are currently
-implemented on top of DBI. FS::Record is intended as a base class for
-table-specific classes to inherit from, i.e. FS::cust_main.
-
-=head1 CONSTRUCTORS
-
-=over 4
-
-=item new [ TABLE, ] HASHREF
-
-Creates a new record. It doesn't store it in the database, though. See
-L<"insert"> for that.
-
-Note that the object stores this 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.
-
-TABLE can only be omitted when a dervived class overrides the table method.
-
-=cut
-
-sub new {
- my $proto = shift;
- my $class = ref($proto) || $proto;
- my $self = {};
- bless ($self, $class);
-
- unless ( defined ( $self->table ) ) {
- $self->{'Table'} = shift;
- carp "warning: FS::Record::new called with table name ". $self->{'Table'};
- }
-
- my $hashref = $self->{'Hash'} = shift;
-
- foreach my $field ( grep !defined($hashref->{$_}), $self->fields ) {
- $hashref->{$field}='';
- }
-
- $self->_cache($hashref, shift) if $self->can('_cache') && @_;
-
- $self;
-}
-
-sub new_or_cached {
- my $proto = shift;
- my $class = ref($proto) || $proto;
- my $self = {};
- bless ($self, $class);
-
- $self->{'Table'} = shift unless defined ( $self->table );
-
- my $hashref = $self->{'Hash'} = shift;
- my $cache = shift;
- if ( defined( $cache->cache->{$hashref->{$cache->key}} ) ) {
- my $obj = $cache->cache->{$hashref->{$cache->key}};
- $obj->_cache($hashref, $cache) if $obj->can('_cache');
- $obj;
- } else {
- $cache->cache->{$hashref->{$cache->key}} = $self->new($hashref, $cache);
- }
-
-}
-
-sub create {
- my $proto = shift;
- my $class = ref($proto) || $proto;
- my $self = {};
- bless ($self, $class);
- if ( defined $self->table ) {
- cluck "create constructor is deprecated, use new!";
- $self->new(@_);
- } else {
- croak "FS::Record::create called (not from a subclass)!";
- }
-}
-
-=item qsearch TABLE, HASHREF, SELECT, EXTRA_SQL, CACHE_OBJ
-
-Searches the database for all records matching (at least) the key/value pairs
-in HASHREF. Returns all the records found as `FS::TABLE' objects if that
-module is loaded (i.e. via `use FS::cust_main;'), otherwise returns FS::Record
-objects.
-
-###oops, argh, FS::Record::new only lets us create database fields.
-#Normal behaviour if SELECT is not specified is `*', as in
-#C<SELECT * FROM table WHERE ...>. However, there is an experimental new
-#feature where you can specify SELECT - remember, the objects returned,
-#although blessed into the appropriate `FS::TABLE' package, will only have the
-#fields you specify. This might have unwanted results if you then go calling
-#regular FS::TABLE methods
-#on it.
-
-=cut
-
-sub qsearch {
- my($stable, $record, $select, $extra_sql, $cache ) = @_;
- #$stable =~ /^([\w\_]+)$/ or die "Illegal table: $table";
- #for jsearch
- $stable =~ /^([\w\s\(\)\.\,\=]+)$/ or die "Illegal table: $stable";
- $stable = $1;
- $select ||= '*';
- my $dbh = dbh;
-
- my $table = $cache ? $cache->table : $stable;
- my $pkey = $dbdef->table($table)->primary_key;
-
- my @real_fields = grep exists($record->{$_}), real_fields($table);
- my @virtual_fields = grep exists($record->{$_}), "FS::$table"->virtual_fields;
-
- my $statement = "SELECT $select FROM $stable";
- if ( @real_fields or @virtual_fields ) {
- $statement .= ' WHERE '. join(' AND ',
- ( map {
-
- my $op = '=';
- my $column = $_;
- if ( ref($record->{$_}) ) {
- $op = $record->{$_}{'op'} if $record->{$_}{'op'};
- #$op = 'LIKE' if $op =~ /^ILIKE$/i && driver_name ne 'Pg';
- if ( uc($op) eq 'ILIKE' ) {
- $op = 'LIKE';
- $record->{$_}{'value'} = lc($record->{$_}{'value'});
- $column = "LOWER($_)";
- }
- $record->{$_} = $record->{$_}{'value'}
- }
-
- if ( ! defined( $record->{$_} ) || $record->{$_} eq '' ) {
- if ( $op eq '=' ) {
- if ( driver_name eq 'Pg' ) {
- my $type = $dbdef->table($table)->column($column)->type;
- if ( $type =~ /(int|serial)/i ) {
- qq-( $column IS NULL )-;
- } else {
- qq-( $column IS NULL OR $column = '' )-;
- }
- } else {
- qq-( $column IS NULL OR $column = "" )-;
- }
- } elsif ( $op eq '!=' ) {
- if ( driver_name eq 'Pg' ) {
- my $type = $dbdef->table($table)->column($column)->type;
- if ( $type =~ /(int|serial)/i ) {
- qq-( $column IS NOT NULL )-;
- } else {
- qq-( $column IS NOT NULL AND $column != '' )-;
- }
- } else {
- qq-( $column IS NOT NULL AND $column != "" )-;
- }
- } else {
- if ( driver_name eq 'Pg' ) {
- qq-( $column $op '' )-;
- } else {
- qq-( $column $op "" )-;
- }
- }
- } else {
- "$column $op ?";
- }
- } @real_fields ),
- ( map {
- my $op = '=';
- my $column = $_;
- if ( ref($record->{$_}) ) {
- $op = $record->{$_}{'op'} if $record->{$_}{'op'};
- if ( uc($op) eq 'ILIKE' ) {
- $op = 'LIKE';
- $record->{$_}{'value'} = lc($record->{$_}{'value'});
- $column = "LOWER($_)";
- }
- $record->{$_} = $record->{$_}{'value'};
- }
-
- # ... EXISTS ( SELECT name, value FROM part_virtual_field
- # JOIN virtual_field
- # ON part_virtual_field.vfieldpart = virtual_field.vfieldpart
- # WHERE recnum = svc_acct.svcnum
- # AND (name, value) = ('egad', 'brain') )
-
- my $value = $record->{$_};
-
- my $subq;
-
- $subq = ($value ? 'EXISTS ' : 'NOT EXISTS ') .
- "( SELECT part_virtual_field.name, virtual_field.value ".
- "FROM part_virtual_field JOIN virtual_field ".
- "ON part_virtual_field.vfieldpart = virtual_field.vfieldpart ".
- "WHERE virtual_field.recnum = ${table}.${pkey} ".
- "AND part_virtual_field.name = '${column}'".
- ($value ?
- " AND virtual_field.value ${op} '${value}'"
- : "") . ")";
- $subq;
-
- } @virtual_fields ) );
-
- }
-
- $statement .= " $extra_sql" if defined($extra_sql);
-
- warn "[debug]$me $statement\n" if $DEBUG > 1;
- my $sth = $dbh->prepare($statement)
- or croak "$dbh->errstr doing $statement";
-
- my $bind = 1;
-
- foreach my $field (
- grep defined( $record->{$_} ) && $record->{$_} ne '', @real_fields
- ) {
- if ( $record->{$field} =~ /^\d+(\.\d+)?$/
- && $dbdef->table($table)->column($field)->type =~ /(int|serial)/i
- ) {
- $sth->bind_param($bind++, $record->{$field}, { TYPE => SQL_INTEGER } );
- } else {
- $sth->bind_param($bind++, $record->{$field}, { TYPE => SQL_VARCHAR } );
- }
- }
-
-# $sth->execute( map $record->{$_},
-# grep defined( $record->{$_} ) && $record->{$_} ne '', @fields
-# ) or croak "Error executing \"$statement\": ". $sth->errstr;
-
- $sth->execute or croak "Error executing \"$statement\": ". $sth->errstr;
-
- my %result;
- tie %result, "Tie::IxHash";
- @virtual_fields = "FS::$table"->virtual_fields;
-
- my @stuff = @{ $sth->fetchall_arrayref( {} ) };
- if($pkey) {
- %result = map { $_->{$pkey}, $_ } @stuff;
- } else {
- @result{@stuff} = @stuff;
- }
-
- $sth->finish;
- if ( keys(%result) and @virtual_fields ) {
- $statement =
- "SELECT virtual_field.recnum, part_virtual_field.name, ".
- "virtual_field.value ".
- "FROM part_virtual_field JOIN virtual_field USING (vfieldpart) ".
- "WHERE part_virtual_field.dbtable = '$table' AND ".
- "virtual_field.recnum IN (".
- join(',', keys(%result)). ") AND part_virtual_field.name IN ('".
- join(q!', '!, @virtual_fields) . "')";
- warn "[debug]$me $statement\n" if $DEBUG > 1;
- $sth = $dbh->prepare($statement) or croak "$dbh->errstr doing $statement";
- $sth->execute or croak "Error executing \"$statement\": ". $sth->errstr;
-
- foreach (@{ $sth->fetchall_arrayref({}) }) {
- my $recnum = $_->{recnum};
- my $name = $_->{name};
- my $value = $_->{value};
- if (exists($result{$recnum})) {
- $result{$recnum}->{$name} = $value;
- }
- }
- }
-
- if ( eval 'scalar(@FS::'. $table. '::ISA);' ) {
- if ( eval 'FS::'. $table. '->can(\'new\')' eq \&new ) {
- #derivied class didn't override new method, so this optimization is safe
- if ( $cache ) {
- map {
- new_or_cached( "FS::$table", { %{$_} }, $cache )
- } values(%result);
- } else {
- map {
- new( "FS::$table", { %{$_} } )
- } values(%result);
- }
- } else {
- warn "untested code (class FS::$table uses custom new method)";
- map {
- eval 'FS::'. $table. '->new( { %{$_} } )';
- } values(%result);
- }
- } else {
- cluck "warning: FS::$table not loaded; returning FS::Record objects";
- map {
- FS::Record->new( $table, { %{$_} } );
- } values(%result);
- }
-
-}
-
-=item jsearch TABLE, HASHREF, SELECT, EXTRA_SQL, PRIMARY_TABLE, PRIMARY_KEY
-
-Experimental JOINed search method. Using this method, you can execute a
-single SELECT spanning multiple tables, and cache the results for subsequent
-method calls. Interface will almost definately change in an incompatible
-fashion.
-
-Arguments:
-
-=cut
-
-sub jsearch {
- my($table, $record, $select, $extra_sql, $ptable, $pkey ) = @_;
- my $cache = FS::SearchCache->new( $ptable, $pkey );
- my %saw;
- ( $cache,
- grep { !$saw{$_->getfield($pkey)}++ }
- qsearch($table, $record, $select, $extra_sql, $cache )
- );
-}
-
-=item qsearchs TABLE, HASHREF
-
-Same as qsearch, except that if more than one record matches, it B<carp>s but
-returns the first. If this happens, you either made a logic error in asking
-for a single item, or your data is corrupted.
-
-=cut
-
-sub qsearchs { # $result_record = &FS::Record:qsearchs('table',\%hash);
- my $table = $_[0];
- my(@result) = qsearch(@_);
- carp "warning: Multiple records in scalar search ($table)"
- if scalar(@result) > 1;
- #should warn more vehemently if the search was on a primary key?
- scalar(@result) ? ($result[0]) : ();
-}
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item table
-
-Returns the table name.
-
-=cut
-
-sub table {
-# cluck "warning: FS::Record::table deprecated; supply one in subclass!";
- my $self = shift;
- $self -> {'Table'};
-}
-
-=item dbdef_table
-
-Returns the DBIx::DBSchema::Table object for the table.
-
-=cut
-
-sub dbdef_table {
- my($self)=@_;
- my($table)=$self->table;
- $dbdef->table($table);
-}
-
-=item get, getfield COLUMN
-
-Returns the value of the column/field/key COLUMN.
-
-=cut
-
-sub get {
- my($self,$field) = @_;
- # to avoid "Use of unitialized value" errors
- if ( defined ( $self->{Hash}->{$field} ) ) {
- $self->{Hash}->{$field};
- } else {
- '';
- }
-}
-sub getfield {
- my $self = shift;
- $self->get(@_);
-}
-
-=item set, setfield COLUMN, VALUE
-
-Sets the value of the column/field/key COLUMN to VALUE. Returns VALUE.
-
-=cut
-
-sub set {
- my($self,$field,$value) = @_;
- $self->{'Hash'}->{$field} = $value;
-}
-sub setfield {
- my $self = shift;
- $self->set(@_);
-}
-
-=item AUTLOADED METHODS
-
-$record->column is a synonym for $record->get('column');
-
-$record->column('value') is a synonym for $record->set('column','value');
-
-=cut
-
-# readable/safe
-sub AUTOLOAD {
- my($self,$value)=@_;
- my($field)=$AUTOLOAD;
- $field =~ s/.*://;
- if ( defined($value) ) {
- confess "errant AUTOLOAD $field for $self (arg $value)"
- unless ref($self) && $self->can('setfield');
- $self->setfield($field,$value);
- } else {
- confess "errant AUTOLOAD $field for $self (no args)"
- unless ref($self) && $self->can('getfield');
- $self->getfield($field);
- }
-}
-
-# efficient
-#sub AUTOLOAD {
-# my $field = $AUTOLOAD;
-# $field =~ s/.*://;
-# if ( defined($_[1]) ) {
-# $_[0]->setfield($field, $_[1]);
-# } else {
-# $_[0]->getfield($field);
-# }
-#}
-
-=item hash
-
-Returns a list of the column/value pairs, usually for assigning to a new hash.
-
-To make a distinct duplicate of an FS::Record object, you can do:
-
- $new = new FS::Record ( $old->table, { $old->hash } );
-
-=cut
-
-sub hash {
- my($self) = @_;
- %{ $self->{'Hash'} };
-}
-
-=item hashref
-
-Returns a reference to the column/value hash.
-
-=cut
-
-sub hashref {
- my($self) = @_;
- $self->{'Hash'};
-}
-
-=item insert
-
-Inserts this record to the database. If there is an error, returns the error,
-otherwise returns false.
-
-=cut
-
-sub insert {
- my $self = shift;
-
- my $error = $self->check;
- return $error if $error;
-
- #single-field unique keys are given a value if false
- #(like MySQL's AUTO_INCREMENT or Pg SERIAL)
- foreach ( $self->dbdef_table->unique->singles ) {
- $self->unique($_) unless $self->getfield($_);
- }
-
- #and also the primary key, if the database isn't going to
- my $primary_key = $self->dbdef_table->primary_key;
- my $db_seq = 0;
- if ( $primary_key ) {
- my $col = $self->dbdef_table->column($primary_key);
-
- $db_seq =
- uc($col->type) eq 'SERIAL'
- || ( driver_name eq 'Pg'
- && defined($col->default)
- && $col->default =~ /^nextval\(/i
- )
- || ( driver_name eq 'mysql'
- && defined($col->local)
- && $col->local =~ /AUTO_INCREMENT/i
- );
- $self->unique($primary_key) unless $self->getfield($primary_key) || $db_seq;
- }
-
- my $table = $self->table;
- #false laziness w/delete
- my @real_fields =
- grep defined($self->getfield($_)) && $self->getfield($_) ne "",
- real_fields($table)
- ;
- my @values = map { _quote( $self->getfield($_), $table, $_) } @real_fields;
- #eslaf
-
- my $statement = "INSERT INTO $table ( ".
- join( ', ', @real_fields ).
- ") VALUES (".
- join( ', ', @values ).
- ")"
- ;
- warn "[debug]$me $statement\n" if $DEBUG > 1;
- my $sth = dbh->prepare($statement) or return dbh->errstr;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- $sth->execute or return $sth->errstr;
-
- my $insertid = '';
- if ( $db_seq ) { # get inserted id from the database, if applicable
- warn "[debug]$me retreiving sequence from database\n" if $DEBUG;
- if ( driver_name eq 'Pg' ) {
-
- my $oid = $sth->{'pg_oid_status'};
- my $i_sql = "SELECT $primary_key FROM $table WHERE oid = ?";
- my $i_sth = dbh->prepare($i_sql) or do {
- dbh->rollback if $FS::UID::AutoCommit;
- return dbh->errstr;
- };
- $i_sth->execute($oid) or do {
- dbh->rollback if $FS::UID::AutoCommit;
- return $i_sth->errstr;
- };
- $insertid = $i_sth->fetchrow_arrayref->[0];
-
- } elsif ( driver_name eq 'mysql' ) {
-
- $insertid = dbh->{'mysql_insertid'};
- # work around mysql_insertid being null some of the time, ala RT :/
- unless ( $insertid ) {
- warn "WARNING: DBD::mysql didn't return mysql_insertid; ".
- "using SELECT LAST_INSERT_ID();";
- my $i_sql = "SELECT LAST_INSERT_ID()";
- my $i_sth = dbh->prepare($i_sql) or do {
- dbh->rollback if $FS::UID::AutoCommit;
- return dbh->errstr;
- };
- $i_sth->execute or do {
- dbh->rollback if $FS::UID::AutoCommit;
- return $i_sth->errstr;
- };
- $insertid = $i_sth->fetchrow_arrayref->[0];
- }
-
- } else {
- dbh->rollback if $FS::UID::AutoCommit;
- return "don't know how to retreive inserted ids from ". driver_name.
- ", try using counterfiles (maybe run dbdef-create?)";
- }
- $self->setfield($primary_key, $insertid);
- }
-
- my @virtual_fields =
- grep defined($self->getfield($_)) && $self->getfield($_) ne "",
- $self->virtual_fields;
- if (@virtual_fields) {
- my %v_values = map { $_, $self->getfield($_) } @virtual_fields;
-
- my $vfieldpart = $self->vfieldpart_hashref;
-
- my $v_statement = "INSERT INTO virtual_field(recnum, vfieldpart, value) ".
- "VALUES (?, ?, ?)";
-
- my $v_sth = dbh->prepare($v_statement) or do {
- dbh->rollback if $FS::UID::AutoCommit;
- return dbh->errstr;
- };
-
- foreach (keys(%v_values)) {
- $v_sth->execute($self->getfield($primary_key),
- $vfieldpart->{$_},
- $v_values{$_})
- or do {
- dbh->rollback if $FS::UID::AutoCommit;
- return $v_sth->errstr;
- };
- }
- }
-
-
- my $h_sth;
- if ( defined $dbdef->table('h_'. $table) ) {
- my $h_statement = $self->_h_statement('insert');
- warn "[debug]$me $h_statement\n" if $DEBUG > 2;
- $h_sth = dbh->prepare($h_statement) or do {
- dbh->rollback if $FS::UID::AutoCommit;
- return dbh->errstr;
- };
- } else {
- $h_sth = '';
- }
- $h_sth->execute or return $h_sth->errstr if $h_sth;
-
- dbh->commit or croak dbh->errstr if $FS::UID::AutoCommit;
-
- '';
-}
-
-=item add
-
-Depriciated (use insert instead).
-
-=cut
-
-sub add {
- cluck "warning: FS::Record::add deprecated!";
- insert @_; #call method in this scope
-}
-
-=item delete
-
-Delete this record from the database. If there is an error, returns the error,
-otherwise returns false.
-
-=cut
-
-sub delete {
- my $self = shift;
-
- my $statement = "DELETE FROM ". $self->table. " WHERE ". join(' AND ',
- map {
- $self->getfield($_) eq ''
- #? "( $_ IS NULL OR $_ = \"\" )"
- ? ( driver_name eq 'Pg'
- ? "$_ IS NULL"
- : "( $_ IS NULL OR $_ = \"\" )"
- )
- : "$_ = ". _quote($self->getfield($_),$self->table,$_)
- } ( $self->dbdef_table->primary_key )
- ? ( $self->dbdef_table->primary_key)
- : real_fields($self->table)
- );
- warn "[debug]$me $statement\n" if $DEBUG > 1;
- my $sth = dbh->prepare($statement) or return dbh->errstr;
-
- my $h_sth;
- if ( defined $dbdef->table('h_'. $self->table) ) {
- my $h_statement = $self->_h_statement('delete');
- warn "[debug]$me $h_statement\n" if $DEBUG > 2;
- $h_sth = dbh->prepare($h_statement) or return dbh->errstr;
- } else {
- $h_sth = '';
- }
-
- my $primary_key = $self->dbdef_table->primary_key;
- my $v_sth;
- my @del_vfields;
- my $vfp = $self->vfieldpart_hashref;
- foreach($self->virtual_fields) {
- next if $self->getfield($_) eq '';
- unless(@del_vfields) {
- my $st = "DELETE FROM virtual_field WHERE recnum = ? AND vfieldpart = ?";
- $v_sth = dbh->prepare($st) or return dbh->errstr;
- }
- push @del_vfields, $_;
- }
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $rc = $sth->execute or return $sth->errstr;
- #not portable #return "Record not found, statement:\n$statement" if $rc eq "0E0";
- $h_sth->execute or return $h_sth->errstr if $h_sth;
- $v_sth->execute($self->getfield($primary_key), $vfp->{$_})
- or return $v_sth->errstr
- foreach (@del_vfields);
-
- dbh->commit or croak dbh->errstr if $FS::UID::AutoCommit;
-
- #no need to needlessly destoy the data either (causes problems actually)
- #undef $self; #no need to keep object!
-
- '';
-}
-
-=item del
-
-Depriciated (use delete instead).
-
-=cut
-
-sub del {
- cluck "warning: FS::Record::del deprecated!";
- &delete(@_); #call method in this scope
-}
-
-=item replace OLD_RECORD
-
-Replace 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 = shift;
-
- my $old;
- if ( @_ ) {
- $old = shift;
- } else {
- warn "[debug]$me replace called with no arguments; autoloading old record\n"
- if $DEBUG;
- my $primary_key = $new->dbdef_table->primary_key;
- if ( $primary_key ) {
- $old = qsearchs($new->table, { $primary_key => $new->$primary_key() } )
- or croak "can't find ". $new->table. ".$primary_key ".
- $new->$primary_key();
- } else {
- croak $new->table. " has no primary key; pass old record as argument";
- }
- }
-
- warn "[debug]$me $new ->replace $old\n" if $DEBUG;
-
- return "Records not in same table!" unless $new->table eq $old->table;
-
- my $primary_key = $old->dbdef_table->primary_key;
- return "Can't change $primary_key"
- if $primary_key
- && ( $old->getfield($primary_key) ne $new->getfield($primary_key) );
-
- my $error = $new->check;
- return $error if $error;
-
- #my @diff = grep $new->getfield($_) ne $old->getfield($_), $old->fields;
- my %diff = map { ($new->getfield($_) ne $old->getfield($_))
- ? ($_, $new->getfield($_)) : () } $old->fields;
-
- unless ( keys(%diff) ) {
- carp "[warning]$me $new -> replace $old: records identical";
- return '';
- }
-
- my $statement = "UPDATE ". $old->table. " SET ". join(', ',
- map {
- "$_ = ". _quote($new->getfield($_),$old->table,$_)
- } real_fields($old->table)
- ). ' WHERE '.
- join(' AND ',
- map {
- $old->getfield($_) eq ''
- #? "( $_ IS NULL OR $_ = \"\" )"
- ? ( driver_name eq 'Pg'
- ? "( $_ IS NULL OR $_ = '' )"
- : "( $_ IS NULL OR $_ = \"\" )"
- )
- : "$_ = ". _quote($old->getfield($_),$old->table,$_)
- } ( $primary_key ? ( $primary_key ) : real_fields($old->table) )
- )
- ;
- warn "[debug]$me $statement\n" if $DEBUG > 1;
- my $sth = dbh->prepare($statement) or return dbh->errstr;
-
- my $h_old_sth;
- if ( defined $dbdef->table('h_'. $old->table) ) {
- my $h_old_statement = $old->_h_statement('replace_old');
- warn "[debug]$me $h_old_statement\n" if $DEBUG > 2;
- $h_old_sth = dbh->prepare($h_old_statement) or return dbh->errstr;
- } else {
- $h_old_sth = '';
- }
-
- my $h_new_sth;
- if ( defined $dbdef->table('h_'. $new->table) ) {
- my $h_new_statement = $new->_h_statement('replace_new');
- warn "[debug]$me $h_new_statement\n" if $DEBUG > 2;
- $h_new_sth = dbh->prepare($h_new_statement) or return dbh->errstr;
- } else {
- $h_new_sth = '';
- }
-
- # For virtual fields we have three cases with different SQL
- # statements: add, replace, delete
- my $v_add_sth;
- my $v_rep_sth;
- my $v_del_sth;
- my (@add_vfields, @rep_vfields, @del_vfields);
- my $vfp = $old->vfieldpart_hashref;
- foreach(grep { exists($diff{$_}) } $new->virtual_fields) {
- if($diff{$_} eq '') {
- # Delete
- unless(@del_vfields) {
- my $st = "DELETE FROM virtual_field WHERE recnum = ? ".
- "AND vfieldpart = ?";
- warn "[debug]$me $st\n" if $DEBUG > 2;
- $v_del_sth = dbh->prepare($st) or return dbh->errstr;
- }
- push @del_vfields, $_;
- } elsif($old->getfield($_) eq '') {
- # Add
- unless(@add_vfields) {
- my $st = "INSERT INTO virtual_field (value, recnum, vfieldpart) ".
- "VALUES (?, ?, ?)";
- warn "[debug]$me $st\n" if $DEBUG > 2;
- $v_add_sth = dbh->prepare($st) or return dbh->errstr;
- }
- push @add_vfields, $_;
- } else {
- # Replace
- unless(@rep_vfields) {
- my $st = "UPDATE virtual_field SET value = ? ".
- "WHERE recnum = ? AND vfieldpart = ?";
- warn "[debug]$me $st\n" if $DEBUG > 2;
- $v_rep_sth = dbh->prepare($st) or return dbh->errstr;
- }
- push @rep_vfields, $_;
- }
- }
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $rc = $sth->execute or return $sth->errstr;
- #not portable #return "Record not found (or records identical)." if $rc eq "0E0";
- $h_old_sth->execute or return $h_old_sth->errstr if $h_old_sth;
- $h_new_sth->execute or return $h_new_sth->errstr if $h_new_sth;
-
- $v_del_sth->execute($old->getfield($primary_key),
- $vfp->{$_})
- or return $v_del_sth->errstr
- foreach(@del_vfields);
-
- $v_add_sth->execute($new->getfield($_),
- $old->getfield($primary_key),
- $vfp->{$_})
- or return $v_add_sth->errstr
- foreach(@add_vfields);
-
- $v_rep_sth->execute($new->getfield($_),
- $old->getfield($primary_key),
- $vfp->{$_})
- or return $v_rep_sth->errstr
- foreach(@rep_vfields);
-
- dbh->commit or croak dbh->errstr if $FS::UID::AutoCommit;
-
- '';
-
-}
-
-=item rep
-
-Depriciated (use replace instead).
-
-=cut
-
-sub rep {
- cluck "warning: FS::Record::rep deprecated!";
- replace @_; #call method in this scope
-}
-
-=item check
-
-Checks virtual fields (using check_blocks). Subclasses should still provide
-a check method to validate real fields, foreign keys, etc., and call this
-method via $self->SUPER::check.
-
-(FIXME: Should this method try to make sure that it I<is> being called from
-a subclass's check method, to keep the current semantics as far as possible?)
-
-=cut
-
-sub check {
- #confess "FS::Record::check not implemented; supply one in subclass!";
- my $self = shift;
-
- foreach my $field ($self->virtual_fields) {
- for ($self->getfield($field)) {
- # See notes on check_block in FS::part_virtual_field.
- eval $self->pvf($field)->check_block;
- return $@ if $@;
- $self->setfield($field, $_);
- }
- }
- '';
-}
-
-sub _h_statement {
- my( $self, $action ) = @_;
-
- my @fields =
- grep defined($self->getfield($_)) && $self->getfield($_) ne "",
- real_fields($self->table);
- ;
- my @values = map { _quote( $self->getfield($_), $self->table, $_) } @fields;
-
- "INSERT INTO h_". $self->table. " ( ".
- join(', ', qw(history_date history_user history_action), @fields ).
- ") VALUES (".
- join(', ', time, dbh->quote(getotaker()), dbh->quote($action), @values).
- ")"
- ;
-}
-
-=item unique COLUMN
-
-B<Warning>: External use is B<deprecated>.
-
-Replaces COLUMN in record with a unique number, using counters in the
-filesystem. Used by the B<insert> method on single-field unique columns
-(see L<DBIx::DBSchema::Table>) and also as a fallback for primary keys
-that aren't SERIAL (Pg) or AUTO_INCREMENT (mysql).
-
-Returns the new value.
-
-=cut
-
-sub unique {
- my($self,$field) = @_;
- my($table)=$self->table;
-
- croak "Unique called on field $field, but it is ",
- $self->getfield($field),
- ", not null!"
- if $self->getfield($field);
-
- #warn "table $table is tainted" if is_tainted($table);
- #warn "field $field is tainted" if is_tainted($field);
-
- my($counter) = new File::CounterFile "$table.$field",0;
-# hack for web demo
-# getotaker() =~ /^([\w\-]{1,16})$/ or die "Illegal CGI REMOTE_USER!";
-# my($user)=$1;
-# my($counter) = new File::CounterFile "$user/$table.$field",0;
-# endhack
-
- my $index = $counter->inc;
- $index = $counter->inc while qsearchs($table, { $field=>$index } );
-
- $index =~ /^(\d*)$/;
- $index=$1;
-
- $self->setfield($field,$index);
-
-}
-
-=item ut_float COLUMN
-
-Check/untaint floating point numeric data: 1.1, 1, 1.1e10, 1e10. May not be
-null. If there is an error, returns the error, otherwise returns false.
-
-=cut
-
-sub ut_float {
- my($self,$field)=@_ ;
- ($self->getfield($field) =~ /^(\d+\.\d+)$/ ||
- $self->getfield($field) =~ /^(\d+)$/ ||
- $self->getfield($field) =~ /^(\d+\.\d+e\d+)$/ ||
- $self->getfield($field) =~ /^(\d+e\d+)$/)
- or return "Illegal or empty (float) $field: ". $self->getfield($field);
- $self->setfield($field,$1);
- '';
-}
-
-=item ut_snumber COLUMN
-
-Check/untaint signed numeric data (whole numbers). May not be null. If there
-is an error, returns the error, otherwise returns false.
-
-=cut
-
-sub ut_snumber {
- my($self, $field) = @_;
- $self->getfield($field) =~ /^(-?)\s*(\d+)$/
- or return "Illegal or empty (numeric) $field: ". $self->getfield($field);
- $self->setfield($field, "$1$2");
- '';
-}
-
-=item ut_number COLUMN
-
-Check/untaint simple numeric data (whole numbers). May not be null. If there
-is an error, returns the error, otherwise returns false.
-
-=cut
-
-sub ut_number {
- my($self,$field)=@_;
- $self->getfield($field) =~ /^(\d+)$/
- or return "Illegal or empty (numeric) $field: ". $self->getfield($field);
- $self->setfield($field,$1);
- '';
-}
-
-=item ut_numbern COLUMN
-
-Check/untaint simple numeric data (whole numbers). May be null. If there is
-an error, returns the error, otherwise returns false.
-
-=cut
-
-sub ut_numbern {
- my($self,$field)=@_;
- $self->getfield($field) =~ /^(\d*)$/
- or return "Illegal (numeric) $field: ". $self->getfield($field);
- $self->setfield($field,$1);
- '';
-}
-
-=item ut_money COLUMN
-
-Check/untaint monetary numbers. May be negative. Set to 0 if null. If there
-is an error, returns the error, otherwise returns false.
-
-=cut
-
-sub ut_money {
- my($self,$field)=@_;
- $self->setfield($field, 0) if $self->getfield($field) eq '';
- $self->getfield($field) =~ /^(\-)? ?(\d*)(\.\d{2})?$/
- or return "Illegal (money) $field: ". $self->getfield($field);
- #$self->setfield($field, "$1$2$3" || 0);
- $self->setfield($field, ( ($1||''). ($2||''). ($3||'') ) || 0);
- '';
-}
-
-=item ut_text COLUMN
-
-Check/untaint text. Alphanumerics, spaces, and the following punctuation
-symbols are currently permitted: ! @ # $ % & ( ) - + ; : ' " , . ? / =
-May not be null. If there is an error, returns the error, otherwise returns
-false.
-
-=cut
-
-sub ut_text {
- my($self,$field)=@_;
- #warn "msgcat ". \&msgcat. "\n";
- #warn "notexist ". \&notexist. "\n";
- #warn "AUTOLOAD ". \&AUTOLOAD. "\n";
- $self->getfield($field) =~ /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=]+)$/
- or return gettext('illegal_or_empty_text'). " $field: ".
- $self->getfield($field);
- $self->setfield($field,$1);
- '';
-}
-
-=item ut_textn COLUMN
-
-Check/untaint text. Alphanumerics, spaces, and the following punctuation
-symbols are currently permitted: ! @ # $ % & ( ) - + ; : ' " , . ? /
-May be null. If there is an error, returns the error, otherwise returns false.
-
-=cut
-
-sub ut_textn {
- my($self,$field)=@_;
- $self->getfield($field) =~ /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=]*)$/
- or return gettext('illegal_text'). " $field: ". $self->getfield($field);
- $self->setfield($field,$1);
- '';
-}
-
-=item ut_alpha COLUMN
-
-Check/untaint alphanumeric strings (no spaces). May not be null. If there is
-an error, returns the error, otherwise returns false.
-
-=cut
-
-sub ut_alpha {
- my($self,$field)=@_;
- $self->getfield($field) =~ /^(\w+)$/
- or return "Illegal or empty (alphanumeric) $field: ".
- $self->getfield($field);
- $self->setfield($field,$1);
- '';
-}
-
-=item ut_alpha COLUMN
-
-Check/untaint alphanumeric strings (no spaces). May be null. If there is an
-error, returns the error, otherwise returns false.
-
-=cut
-
-sub ut_alphan {
- my($self,$field)=@_;
- $self->getfield($field) =~ /^(\w*)$/
- or return "Illegal (alphanumeric) $field: ". $self->getfield($field);
- $self->setfield($field,$1);
- '';
-}
-
-=item ut_phonen COLUMN [ COUNTRY ]
-
-Check/untaint phone numbers. May be null. If there is an error, returns
-the error, otherwise returns false.
-
-Takes an optional two-letter ISO country code; without it or with unsupported
-countries, ut_phonen simply calls ut_alphan.
-
-=cut
-
-sub ut_phonen {
- my( $self, $field, $country ) = @_;
- return $self->ut_alphan($field) unless defined $country;
- my $phonen = $self->getfield($field);
- if ( $phonen eq '' ) {
- $self->setfield($field,'');
- } elsif ( $country eq 'US' || $country eq 'CA' ) {
- $phonen =~ s/\D//g;
- $phonen =~ /^(\d{3})(\d{3})(\d{4})(\d*)$/
- or return gettext('illegal_phone'). " $field: ". $self->getfield($field);
- $phonen = "$1-$2-$3";
- $phonen .= " x$4" if $4;
- $self->setfield($field,$phonen);
- } else {
- warn "warning: don't know how to check phone numbers for country $country";
- return $self->ut_textn($field);
- }
- '';
-}
-
-=item ut_ip COLUMN
-
-Check/untaint ip addresses. IPv4 only for now.
-
-=cut
-
-sub ut_ip {
- my( $self, $field ) = @_;
- $self->getfield($field) =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/
- or return "Illegal (IP address) $field: ". $self->getfield($field);
- for ( $1, $2, $3, $4 ) { return "Illegal (IP address) $field" if $_ > 255; }
- $self->setfield($field, "$1.$2.$3.$4");
- '';
-}
-
-=item ut_ipn COLUMN
-
-Check/untaint ip addresses. IPv4 only for now. May be null.
-
-=cut
-
-sub ut_ipn {
- my( $self, $field ) = @_;
- if ( $self->getfield($field) =~ /^()$/ ) {
- $self->setfield($field,'');
- '';
- } else {
- $self->ut_ip($field);
- }
-}
-
-=item ut_domain COLUMN
-
-Check/untaint host and domain names.
-
-=cut
-
-sub ut_domain {
- my( $self, $field ) = @_;
- #$self->getfield($field) =~/^(\w+\.)*\w+$/
- $self->getfield($field) =~/^(([\w\-]+\.)*\w+)$/
- or return "Illegal (domain) $field: ". $self->getfield($field);
- $self->setfield($field,$1);
- '';
-}
-
-=item ut_name COLUMN
-
-Check/untaint proper names; allows alphanumerics, spaces and the following
-punctuation: , . - '
-
-May not be null.
-
-=cut
-
-sub ut_name {
- my( $self, $field ) = @_;
- $self->getfield($field) =~ /^([\w \,\.\-\']+)$/
- or return gettext('illegal_name'). " $field: ". $self->getfield($field);
- $self->setfield($field,$1);
- '';
-}
-
-=item ut_zip COLUMN
-
-Check/untaint zip codes.
-
-=cut
-
-sub ut_zip {
- my( $self, $field, $country ) = @_;
- if ( $country eq 'US' ) {
- $self->getfield($field) =~ /\s*(\d{5}(\-\d{4})?)\s*$/
- or return gettext('illegal_zip'). " $field for country $country: ".
- $self->getfield($field);
- $self->setfield($field,$1);
- } else {
- $self->getfield($field) =~ /^\s*(\w[\w\-\s]{2,8}\w)\s*$/
- or return gettext('illegal_zip'). " $field: ". $self->getfield($field);
- $self->setfield($field,$1);
- }
- '';
-}
-
-=item ut_country COLUMN
-
-Check/untaint country codes. Country names are changed to codes, if possible -
-see L<Locale::Country>.
-
-=cut
-
-sub ut_country {
- my( $self, $field ) = @_;
- unless ( $self->getfield($field) =~ /^(\w\w)$/ ) {
- if ( $self->getfield($field) =~ /^([\w \,\.\(\)\']+)$/
- && country2code($1) ) {
- $self->setfield($field,uc(country2code($1)));
- }
- }
- $self->getfield($field) =~ /^(\w\w)$/
- or return "Illegal (country) $field: ". $self->getfield($field);
- $self->setfield($field,uc($1));
- '';
-}
-
-=item ut_anything COLUMN
-
-Untaints arbitrary data. Be careful.
-
-=cut
-
-sub ut_anything {
- my( $self, $field ) = @_;
- $self->getfield($field) =~ /^(.*)$/s
- or return "Illegal $field: ". $self->getfield($field);
- $self->setfield($field,$1);
- '';
-}
-
-=item ut_enum COLUMN CHOICES_ARRAYREF
-
-Check/untaint a column, supplying all possible choices, like the "enum" type.
-
-=cut
-
-sub ut_enum {
- my( $self, $field, $choices ) = @_;
- foreach my $choice ( @$choices ) {
- if ( $self->getfield($field) eq $choice ) {
- $self->setfield($choice);
- return '';
- }
- }
- return "Illegal (enum) field $field: ". $self->getfield($field);
-}
-
-=item ut_foreign_key COLUMN FOREIGN_TABLE FOREIGN_COLUMN
-
-Check/untaint a foreign column key. Call a regular ut_ method (like ut_number)
-on the column first.
-
-=cut
-
-sub ut_foreign_key {
- my( $self, $field, $table, $foreign ) = @_;
- qsearchs($table, { $foreign => $self->getfield($field) })
- or return "Can't find $field ". $self->getfield($field).
- " in $table.$foreign";
- '';
-}
-
-=item ut_foreign_keyn COLUMN FOREIGN_TABLE FOREIGN_COLUMN
-
-Like ut_foreign_key, except the null value is also allowed.
-
-=cut
-
-sub ut_foreign_keyn {
- my( $self, $field, $table, $foreign ) = @_;
- $self->getfield($field)
- ? $self->ut_foreign_key($field, $table, $foreign)
- : '';
-}
-
-
-=item virtual_fields [ TABLE ]
-
-Returns a list of virtual fields defined for the table. This should not
-be exported, and should only be called as an instance or class method.
-
-=cut
-
-sub virtual_fields {
- my $self = shift;
- my $table;
- $table = $self->table or confess "virtual_fields called on non-table";
-
- confess "Unknown table $table" unless $dbdef->table($table);
-
- return () unless $self->dbdef->table('part_virtual_field');
-
- unless ( $virtual_fields_cache{$table} ) {
- my $query = 'SELECT name from part_virtual_field ' .
- "WHERE dbtable = '$table'";
- my $dbh = dbh;
- my $result = $dbh->selectcol_arrayref($query);
- confess $dbh->errstr if $dbh->err;
- $virtual_fields_cache{$table} = $result;
- }
-
- @{$virtual_fields_cache{$table}};
-
-}
-
-
-=item fields [ TABLE ]
-
-This is a wrapper for real_fields and virtual_fields. Code that called
-fields before should probably continue to call fields.
-
-=cut
-
-sub fields {
- my $something = shift;
- my $table;
- if($something->isa('FS::Record')) {
- $table = $something->table;
- } else {
- $table = $something;
- $something = "FS::$table";
- }
- return (real_fields($table), $something->virtual_fields());
-}
-
-=back
-
-=item pvf FIELD_NAME
-
-Returns the FS::part_virtual_field object corresponding to a field in the
-record (specified by FIELD_NAME).
-
-=cut
-
-sub pvf {
- my ($self, $name) = (shift, shift);
-
- if(grep /^$name$/, $self->virtual_fields) {
- return qsearchs('part_virtual_field', { dbtable => $self->table,
- name => $name } );
- }
- ''
-}
-
-=head1 SUBROUTINES
-
-=over 4
-
-=item real_fields [ TABLE ]
-
-Returns a list of the real columns in the specified table. Called only by
-fields() and other subroutines elsewhere in FS::Record.
-
-=cut
-
-sub real_fields {
- my $table = shift;
-
- my($table_obj) = $dbdef->table($table);
- confess "Unknown table $table" unless $table_obj;
- $table_obj->columns;
-}
-
-=item reload_dbdef([FILENAME])
-
-Load a database definition (see L<DBIx::DBSchema>), optionally from a
-non-default filename. This command is executed at startup unless
-I<$FS::Record::setup_hack> is true. Returns a DBIx::DBSchema object.
-
-=cut
-
-sub reload_dbdef {
- my $file = shift || $dbdef_file;
-
- unless ( exists $dbdef_cache{$file} ) {
- warn "[debug]$me loading dbdef for $file\n" if $DEBUG;
- $dbdef_cache{$file} = DBIx::DBSchema->load( $file )
- or die "can't load database schema from $file";
- } else {
- warn "[debug]$me re-using cached dbdef for $file\n" if $DEBUG;
- }
- $dbdef = $dbdef_cache{$file};
-}
-
-=item dbdef
-
-Returns the current database definition. See L<DBIx::DBSchema>.
-
-=cut
-
-sub dbdef { $dbdef; }
-
-=item _quote VALUE, TABLE, COLUMN
-
-This is an internal function used to construct SQL statements. It returns
-VALUE DBI-quoted (see L<DBI/"quote">) unless VALUE is a number and the column
-type (see L<DBIx::DBSchema::Column>) does not end in `char' or `binary'.
-
-=cut
-
-sub _quote {
- my($value, $table, $column) = @_;
- my $column_obj = $dbdef->table($table)->column($column);
- my $column_type = $column_obj->type;
-
- if ( $value eq '' && $column_type =~ /^int/ ) {
- if ( $column_obj->null ) {
- 'NULL';
- } else {
- cluck "WARNING: Attempting to set non-null integer $table.$column null; ".
- "using 0 instead";
- 0;
- }
- } elsif ( $value =~ /^\d+(\.\d+)?$/ &&
- ! $column_type =~ /(char|binary|text)$/i ) {
- $value;
- } else {
- dbh->quote($value);
- }
-}
-
-=item vfieldpart_hashref TABLE
-
-Returns a hashref of virtual field names and vfieldparts applicable to the given
-TABLE.
-
-=cut
-
-sub vfieldpart_hashref {
- my $self = shift;
- my $table = $self->table;
-
- return {} unless $self->dbdef->table('part_virtual_field');
-
- my $dbh = dbh;
- my $statement = "SELECT vfieldpart, name FROM part_virtual_field WHERE ".
- "dbtable = '$table'";
- my $sth = $dbh->prepare($statement);
- $sth->execute or croak "Execution of '$statement' failed: ".$dbh->errstr;
- return { map { $_->{name}, $_->{vfieldpart} }
- @{$sth->fetchall_arrayref({})} };
-
-}
-
-
-=item hfields TABLE
-
-This is deprecated. Don't use it.
-
-It returns a hash-type list with the fields of this record's table set true.
-
-=cut
-
-sub hfields {
- carp "warning: hfields is deprecated";
- my($table)=@_;
- my(%hash);
- foreach (fields($table)) {
- $hash{$_}=1;
- }
- \%hash;
-}
-
-sub _dump {
- my($self)=@_;
- join("\n", map {
- "$_: ". $self->getfield($_). "|"
- } (fields($self->table)) );
-}
-
-sub DESTROY { return; }
-
-#sub DESTROY {
-# my $self = shift;
-# #use Carp qw(cluck);
-# #cluck "DESTROYING $self";
-# warn "DESTROYING $self";
-#}
-
-#sub is_tainted {
-# return ! eval { join('',@_), kill 0; 1; };
-# }
-
-=back
-
-=head1 BUGS
-
-This module should probably be renamed, since much of the functionality is
-of general use. It is not completely unlike Adapter::DBI (see below).
-
-Exported qsearch and qsearchs should be deprecated in favor of method calls
-(against an FS::Record object like the old search and searchs that qsearch
-and qsearchs were on top of.)
-
-The whole fields / hfields mess should be removed.
-
-The various WHERE clauses should be subroutined.
-
-table string should be deprecated in favor of DBIx::DBSchema::Table.
-
-No doubt we could benefit from a Tied hash. Documenting how exists / defined
-true maps to the database (and WHERE clauses) would also help.
-
-The ut_ methods should ask the dbdef for a default length.
-
-ut_sqltype (like ut_varchar) should all be defined
-
-A fallback check method should be provided which uses the dbdef.
-
-The ut_money method assumes money has two decimal digits.
-
-The Pg money kludge in the new method only strips `$'.
-
-The ut_phonen method only checks US-style phone numbers.
-
-The _quote function should probably use ut_float instead of a regex.
-
-All the subroutines probably should be methods, here or elsewhere.
-
-Probably should borrow/use some dbdef methods where appropriate (like sub
-fields)
-
-As of 1.14, DBI fetchall_hashref( {} ) doesn't set fetchrow_hashref NAME_lc,
-or allow it to be set. Working around it is ugly any way around - DBI should
-be fixed. (only affects RDBMS which return uppercase column names)
-
-ut_zip should take an optional country like ut_phone.
-
-=head1 SEE ALSO
-
-L<DBIx::DBSchema>, L<FS::UID>, L<DBI>
-
-Adapter::DBI from Ch. 11 of Advanced Perl Programming by Sriram Srinivasan.
-
-=cut
-
-1;
-
diff --git a/FS/FS/Report.pm b/FS/FS/Report.pm
deleted file mode 100644
index 181fea2..0000000
--- a/FS/FS/Report.pm
+++ /dev/null
@@ -1,46 +0,0 @@
-package FS::Report;
-
-use strict;
-
-=head1 NAME
-
-FS::Report - Report data objects
-
-=head1 SYNOPSIS
-
- #see the more speicific report objects, currently only FS::Report::Table
-
-=head1 DESCRIPTION
-
-See the more specific report objects, currently only FS::Report::Table
-
-=head1 METHODS
-
-=over 4
-
-=item new [ OPTION => VALUE ... ]
-
-Constructor. Takes a list of options and their values.
-
-=cut
-
-sub new {
- my $proto = shift;
- my $class = ref($proto) || $proto;
- my $self = @_ ? ( ref($_[0]) ? shift : { @_ } ) : {};
- bless( $self, $class );
-}
-
-=back
-
-=head1 BUGS
-
-Documentation.
-
-=head1 SEE ALSO
-
-L<FS::Report::Table>, reports in the web interface.
-
-=cut
-
-1;
diff --git a/FS/FS/Report/Table.pm b/FS/FS/Report/Table.pm
deleted file mode 100644
index 9f636fa..0000000
--- a/FS/FS/Report/Table.pm
+++ /dev/null
@@ -1,27 +0,0 @@
-package FS::Report::Table;
-
-use strict;
-use vars qw( @ISA );
-use FS::Report;
-
-@ISA = qw( FS::Report );
-
-=head1 NAME
-
-FS::Report::Table - Tables of report data
-
-=head1 SYNOPSIS
-
-See the more specific report objects, currently only FS::Report::Table::Monthly
-
-=head1 BUGS
-
-Documentation.
-
-=head1 SEE ALSO
-
-L<FS::Report::Table::Monthly>, reports in the web interface.
-
-=cut
-
-1;
diff --git a/FS/FS/Report/Table/Monthly.pm b/FS/FS/Report/Table/Monthly.pm
deleted file mode 100644
index 3bbf01f..0000000
--- a/FS/FS/Report/Table/Monthly.pm
+++ /dev/null
@@ -1,168 +0,0 @@
-package FS::Report::Table::Monthly;
-
-use strict;
-use vars qw( @ISA $expenses_kludge );
-use Time::Local;
-use FS::UID qw( dbh );
-use FS::Report::Table;
-
-@ISA = qw( FS::Report::Table );
-
-$expenses_kludge = 0;
-
-=head1 NAME
-
-FS::Report::Table::Monthly - Tables of report data, indexed monthly
-
-=head1 SYNOPSIS
-
- use FS::Report::Table::Monthly;
-
- my $report = new FS::Report::Table (
- 'items' => [ 'invoiced', 'netsales', 'credits', 'receipts', ],
- 'start_month' => 4,
- 'start_year' => 2000,
- 'end_month' => 4,
- 'end_year' => 2020,
- );
-
- my $data = $report->data;
-
-=head1 METHODS
-
-=over 4
-
-=item data
-
-Returns a hashref of data (!! describe)
-
-=cut
-
-sub data {
- my $self = shift;
-
- my $smonth = $self->{'start_month'};
- my $syear = $self->{'start_year'};
- my $emonth = $self->{'end_month'};
- my $eyear = $self->{'end_year'};
-
- my %data;
-
- while ( $syear < $eyear || ( $syear == $eyear && $smonth < $emonth+1 ) ) {
-
- push @{$data{label}}, "$smonth/$syear";
-
- my $speriod = timelocal(0,0,0,1,$smonth-1,$syear);
- if ( ++$smonth == 13 ) { $syear++; $smonth=1; }
- my $eperiod = timelocal(0,0,0,1,$smonth-1,$syear);
-
- foreach my $item ( @{$self->{'items'}} ) {
- push @{$data{$item}}, $self->$item($speriod, $eperiod);
- }
-
- }
-
- \%data;
-
-}
-
-sub invoiced { #invoiced
- my( $self, $speriod, $eperiod ) = ( shift, shift, shift );
- $self->scalar_sql("
- SELECT SUM(charged) FROM cust_bill
- WHERE ". $self->in_time_period($speriod, $eperiod)
- );
-}
-
-sub netsales { #net sales
- my( $self, $speriod, $eperiod ) = ( shift, shift, shift );
-
- my $credited = $self->scalar_sql("
- SELECT SUM(cust_credit_bill.amount)
- FROM cust_credit_bill, cust_bill
- WHERE cust_bill.invnum = cust_credit_bill.invnum
- AND ". $self->in_time_period($speriod, $eperiod, 'cust_bill')
- );
-
- #horrible local kludge
- my $expenses = !$expenses_kludge ? 0 : $self->scalar_sql("
- SELECT SUM(cust_bill_pkg.setup)
- FROM cust_bill_pkg, cust_bill, cust_pkg, part_pkg
- WHERE cust_bill.invnum = cust_bill_pkg.invnum
- AND ". $self->in_time_period($speriod, $eperiod, 'cust_bill'). "
- AND cust_pkg.pkgnum = cust_bill_pkg.pkgnum
- AND cust_pkg.pkgpart = part_pkg.pkgpart
- AND LOWER(part_pkg.pkg) LIKE 'expense _%'
- ");
-
- $self->invoiced($speriod,$eperiod)-$credited-$expenses;
-}
-
-#deferred revenue
-
-sub receipts { #cashflow
- my( $self, $speriod, $eperiod ) = ( shift, shift, shift );
-
- #cashflow
- my $paid = $self->scalar_sql("
- SELECT SUM(paid) FROM cust_pay
- WHERE ". $self->in_time_period($speriod, $eperiod)
- );
-
- my $refunded = $self->scalar_sql("
- SELECT SUM(refund) FROM cust_refund
- WHERE ". $self->in_time_period($speriod, $eperiod)
- );
-
- #horrible local kludge that doesn't even really work right
- my $expenses = !$expenses_kludge ? 0 : $self->scalar_sql("
- SELECT SUM(cust_bill_pay.amount)
- FROM cust_bill_pay, cust_bill
- WHERE cust_bill_pay.invnum = cust_bill.invnum
- AND ". $self->in_time_period($speriod, $eperiod, 'cust_bill_pay'). "
- AND 0 < ( SELECT COUNT(*) from cust_bill_pkg, cust_pkg, part_pkg
- WHERE cust_bill.invnum = cust_bill_pkg.invnum
- AND cust_pkg.pkgnum = cust_bill_pkg.pkgnum
- AND cust_pkg.pkgpart = part_pkg.pkgpart
- AND LOWER(part_pkg.pkg) LIKE 'expense _%'
- )
- ");
- # my $expenses_sql2 = "SELECT SUM(cust_bill_pay.amount) FROM cust_bill_pay, cust_bill_pkg, cust_bill, cust_pkg, part_pkg WHERE cust_bill_pay.invnum = cust_bill.invnum AND cust_bill.invnum = cust_bill_pkg.invnum AND cust_bill_pay._date >= $speriod AND cust_bill_pay._date < $eperiod AND cust_pkg.pkgnum = cust_bill_pkg.pkgnum AND cust_pkg.pkgpart = part_pkg.pkgpart AND LOWER(part_pkg.pkg) LIKE 'expense _%'";
-
- $paid-$refunded-$expenses;
-}
-
-sub credits {
- my( $self, $speriod, $eperiod ) = ( shift, shift, shift );
- $self->scalar_sql("
- SELECT SUM(amount) FROM cust_credit
- WHERE ". $self->in_time_period($speriod, $eperiod)
- );
-}
-
-sub in_time_period {
- my( $self, $speriod, $eperiod ) = ( shift, shift, shift );
- my $table = @_ ? shift().'.' : '';
- "${table}_date >= $speriod AND ${table}_date < $eperiod";
-}
-
-sub scalar_sql {
- my( $self, $sql ) = ( shift, shift );
- my $sth = dbh->prepare($sql) or die dbh->errstr;
- $sth->execute
- or die "Unexpected error executing statement $sql: ". $sth->errstr;
- $sth->fetchrow_arrayref->[0] || 0;
-}
-
-=back
-
-=head1 BUGS
-
-Documentation.
-
-=head1 SEE ALSO
-
-=cut
-
-1;
-
diff --git a/FS/FS/SearchCache.pm b/FS/FS/SearchCache.pm
deleted file mode 100644
index 4218acf..0000000
--- a/FS/FS/SearchCache.pm
+++ /dev/null
@@ -1,96 +0,0 @@
-package FS::SearchCache;
-
-use strict;
-use vars qw($DEBUG);
-#use Carp qw(carp cluck croak confess);
-
-$DEBUG = 0;
-
-=head1 NAME
-
-FS::SearchCache - cache
-
-=head1 SYNOPSIS
-
-=head1 DESCRIPTION
-
-=head1 METHODS
-
-=over 4
-
-=item new
-
-=cut
-
-sub new {
- my $proto = shift;
- my $class = ref($proto) || $proto;
- my( $table, $key ) = @_;
- warn "table $table\n" if $DEBUG > 1;
- warn "key $key\n" if $DEBUG > 1;
- my $self = { 'table' => $table,
- 'key' => $key,
- 'cache' => {},
- 'subcache' => {},
- };
- bless ($self, $class);
-
- $self;
-}
-
-=item table
-
-=cut
-
-sub table { my $self = shift; $self->{table}; }
-
-=item key
-
-=cut
-
-sub key { my $self = shift; $self->{key}; }
-
-=item cache
-
-=cut
-
-sub cache { my $self = shift; $self->{cache}; }
-
-=item subcache
-
-=cut
-
-sub subcache {
- my $self = shift;
- my $col = shift;
- my $table = shift;
- my $keyval = shift;
- if ( exists $self->{subcache}->{$col}->{$keyval} ) {
- warn "returning existing subcache for $keyval ($col)".
- "$self->{subcache}->{$col}->{$keyval}\n" if $DEBUG;
- return $self->{subcache}->{$col}->{$keyval};
- } else {
- #my $tablekey = @_ ? shift : $col;
- my $tablekey = $col;
- my $subcache = ref($self)->new( $table, $tablekey );
- $self->{subcache}->{$col}->{$keyval} = $subcache;
- warn "creating new subcache $table $tablekey: $subcache\n" if $DEBUG;
- $subcache;
- }
-}
-
-=back
-
-=head1 BUGS
-
-Dismal documentation.
-
-=head1 SEE ALSO
-
-L<FS::Record>, L<FS::cust_main>
-
-=cut
-
-1;
-
-
diff --git a/FS/FS/UI/Base.pm b/FS/FS/UI/Base.pm
deleted file mode 100644
index bbeb9e1..0000000
--- a/FS/FS/UI/Base.pm
+++ /dev/null
@@ -1,194 +0,0 @@
-package FS::UI::Base;
-
-use strict;
-use vars qw ( @ISA );
-use FS::Record qw( fields qsearch );
-
-@ISA = ( $FS::UI::Base::_lock );
-
-=head1 NAME
-
-FS::UI::Base - Base class for all user-interface objects
-
-=head1 SYNOPSIS
-
- use FS::UI::SomeInterface;
- use FS::UI::some_table;
-
- $interface = new FS::UI::some_table;
-
- $error = $interface->browse;
- $error = $interface->search;
- $error = $interface->view;
- $error = $interface->edit;
- $error = $interface->process;
-
-=head1 DESCRIPTION
-
-An FS::UI::Base object represents a user interface object. FS::UI::Base
-is intended as a base class for table-specfic classes to inherit from, i.e.
-FS::UI::cust_main. The simplest case, which will provide a default UI for your
-new table, is as follows:
-
- package FS::UI::table_name;
- use vars qw ( @ISA );
- use FS::UI::Base;
- @ISA = qw( FS::UI::Base );
- sub db_table { 'table_name'; }
-
-Currently available interfaces are:
- FS::UI::Gtk, an X-Windows UI implemented using the Gtk+ toolkit
- FS::UI::CGI, a web interface implemented using CGI.pm, etc.
-
-=head1 METHODS
-
-=over 4
-
-=item new
-
-=cut
-
-=item browse
-
-=cut
-
-sub browse {
- my $self = shift;
-
- my @fields = $self->list_fields;
-
- #begin browse-specific stuff
-
- $self->title( "Browse ". $self->db_names ) unless $self->title;
- my @records = qsearch ( $self->db_table, {} );
-
- #end browse-specific stuff
-
- $self->addwidget ( new FS::UI::_Text ( $self->db_description ) );
-
- my @header = $self->list_header;
- my @headerspan = $self->list_headerspan;
- my %callback = $self->db_callback;
-
- my $columns;
-
- my $table = new FS::UI::_Tableborder (
- 'rows' => 1 + scalar(@records),
- 'columns' => $columns || scalar(@fields),
- );
-
- my $c = 0;
- foreach my $header ( @header ) {
- my $headerspan = shift(@headerspan) || 1;
- $table->attach(
- 0, $c, new FS::UI::_Text ( $header ), 1, $headerspan
- );
- $c += $headerspan;
- }
-
- my $r = 1;
-
- foreach my $record ( @records ) {
- $c = 0;
- foreach my $field ( @fields ) {
- my $value = $record->getfield($field);
- my $widget;
- if ( $callback{$field} ) {
- $widget = &{ $callback{$field} }( $value, $record );
- } else {
- $widget = new FS::UI::_Text ( $value );
- }
- $table->attach( $r, $c++, $widget, 1, 1 );
- }
- $r++;
- }
-
- $self->addwidget( $table );
-
- $self->activate;
-
-}
-
-=item title
-
-=cut
-
-sub title {
- my $self = shift;
- my $value = shift;
- if ( defined($value) ) {
- $self->{'title'} = $value;
- } else {
- $self->{'title'};
- }
-}
-
-=item addwidget
-
-=cut
-
-sub addwidget {
- my $self = shift;
- my $widget = shift;
- push @{ $self->{'Widgets'} }, $widget;
-}
-
-#fallback methods
-
-sub db_description {}
-
-sub db_name {}
-
-sub db_names {
- my $self = shift;
- $self->db_name. 's';
-}
-
-sub list_fields {
- my $self = shift;
- fields( $self->db_table );
-}
-
-sub list_header {
- my $self = shift;
- $self->list_fields
-}
-
-sub list_headerspan {
- my $self = shift;
- map 1, $self->list_header;
-}
-
-sub db_callback {}
-
-=back
-
-=head1 VERSION
-
-$Id: Base.pm,v 1.1 1999-08-04 09:03:53 ivan Exp $
-
-=head1 BUGS
-
-This documentation is incomplete.
-
-There should be some sort of per-(freeside)-user preferences and the ability
-for specific FS::UI:: modules to put their own values there as well.
-
-=head1 SEE ALSO
-
-L<FS::UI::Gtk>, L<FS::UI::CGI>
-
-=head1 HISTORY
-
-$Log: Base.pm,v $
-Revision 1.1 1999-08-04 09:03:53 ivan
-initial checkin of module files for proper perl installation
-
-Revision 1.1 1999/01/20 09:30:36 ivan
-skeletal cross-UI UI code.
-
-
-=cut
-
-1;
-
diff --git a/FS/FS/UI/CGI.pm b/FS/FS/UI/CGI.pm
deleted file mode 100644
index ae87d13..0000000
--- a/FS/FS/UI/CGI.pm
+++ /dev/null
@@ -1,239 +0,0 @@
-package FS::UI::CGI;
-
-use strict;
-use CGI;
-#use CGI::Switch; #when FS::UID user and preference callback stuff is fixed
-use CGI::Carp qw(fatalsToBrowser);
-use HTML::Table;
-use FS::UID qw(adminsuidsetup);
-#use FS::Record qw( qsearch fields );
-
-die "Can't initialize CGI interface; $FS::UI::Base::_lock used"
- if $FS::UI::Base::_lock;
-$FS::UI::Base::_lock = "FS::UI::CGI";
-
-=head1 NAME
-
-FS::UI::CGI - Base class for CGI user-interface objects
-
-=head1 SYNOPSIS
-
- use FS::UI::CGI;
- use FS::UI::some_table;
-
- $interface = new FS::UI::some_table;
-
- $error = $interface->browse;
- $error = $interface->search;
- $error = $interface->view;
- $error = $interface->edit;
- $error = $interface->process;
-
-=head1 DESCRIPTION
-
-An FS::UI::CGI object represents a CGI interface object.
-
-=head1 METHODS
-
-=over 4
-
-=item new
-
-=cut
-
-sub new {
- my $proto = shift;
- my $class = ref($proto) || $proto;
- my $self = { @_ };
-
- $self->{'_cgi'} = new CGI;
- $self->{'_user'} = $self->{'_cgi'}->remote_user;
- $self->{'_dbh'} = FS::UID::adminsuidsetup $self->{'_user'};
-
- bless ( $self, $class);
-}
-
-sub activate {
- my $self = shift;
- print $self->_header,
- join ( "<BR>", map $_->sprint, @{ $self->{'Widgets'} } ),
- $self->_footer,
- ;
-}
-
-=item _header
-
-=cut
-
-sub _header {
- my $self = shift;
- my $cgi = $self->{'_cgi'};
-
- $cgi->header( '-expires' => 'now' ), '<HTML>',
- '<HEAD><TITLE>', $self->title, '</TITLE></HEAD>',
- '<BODY BGCOLOR="#ffffff">',
- '<FONT COLOR="#ff0000" SIZE=7>', $self->title, '</FONT><BR><BR>',
- ;
-}
-
-=item _footer
-
-=cut
-
-sub _footer {
- "</BODY></HTML>";
-}
-
-=item interface
-
-Returns the string `CGI'. Useful for the author of a table-specific UI class
-to conditionally specify certain behaviour.
-
-=cut
-
-sub interface { 'CGI'; }
-
-=back
-
-=cut
-
-package FS::UI::_Widget;
-
-use vars qw( $AUTOLOAD );
-
-sub new {
- my $proto = shift;
- my $class = ref($proto) || $proto;
- my $self = { @_ };
- bless ( $self, $class );
-}
-
-sub AUTOLOAD {
- my $self = shift;
- my $value = shift;
- my($field)=$AUTOLOAD;
- $field =~ s/.*://;
- if ( defined($value) ) {
- $self->{$field} = $value;
- } else {
- $self->{$field};
- }
-}
-
-package FS::UI::_Text;
-
-use vars qw ( @ISA );
-
-@ISA = qw ( FS::UI::_Widget);
-
-sub new {
- my $proto = shift;
- my $class = ref($proto) || $proto;
- my $self = {};
- $self->{'_text'} = shift;
- bless ( $self, $class );
-}
-
-sub sprint {
- my $self = shift;
- $self->{'_text'};
-}
-
-package FS::UI::_Link;
-
-use vars qw ( @ISA $BASE_URL );
-
-@ISA = qw ( FS::UI::_Widget);
-$BASE_URL = "http://rootwood.sisd.com/freeside";
-
-sub sprint {
- my $self = shift;
- my $table = $self->{'table'};
- my $method = $self->{'method'};
-
- # i will be cleaned up when we're done moving from the old webinterface!
- my @arg = @{$self->{'arg'}};
- my $yuck = join( "&", @arg);
- qq(<A HREF="$BASE_URL/$method/$table.cgi?$yuck">). $self->{'text'}. "<\A>";
-}
-
-package FS::UI::_Table;
-
-use vars qw ( @ISA );
-
-@ISA = qw ( FS::UI::_Widget);
-
-sub new {
- my $proto = shift;
- my $class = ref($proto) || $proto;
- my $self = $class eq $proto ? { @_ } : $proto;
- bless ( $self, $class );
- $self->{'_table'} = new HTML::Table ( $self->rows, $self->columns );
- $self;
-}
-
-sub attach {
- my $self = shift;
- my ( $row, $column, $widget, $rowspan, $colspan ) = @_;
- $self->{"_table"}->setCell( $row+1, $column+1, $widget->sprint );
- $self->{"_table"}->setCellRowSpan( $row+1, $column+1, $rowspan ) if $rowspan;
- $self->{"_table"}->setCellColSpan( $row+1, $column+1, $colspan ) if $colspan;
-}
-
-sub sprint {
- my $self = shift;
- $self->{'_table'}->getTable;
-}
-
-package FS::UI::_Tableborder;
-
-use vars qw ( @ISA );
-
-@ISA = qw ( FS::UI::_Table );
-
-sub new {
- my $proto = shift;
- my $class = ref($proto) || $proto;
- my $self = $class eq $proto ? { @_ } : $proto;
- bless ( $self, $class );
- $self->SUPER::new(@_);
- $self->{'_table'}->setBorder;
- $self;
-}
-
-=head1 VERSION
-
-$Id: CGI.pm,v 1.1 1999-08-04 09:03:53 ivan Exp $
-
-=head1 BUGS
-
-This documentation is incomplete.
-
-In _Tableborder, headers should be links that sort on their fields.
-
-_Link uses a constant $BASE_URL
-
-_Link passes the arguments as a manually-constructed GET string instead
-of POSTing, for compatability while the web interface is upgraded. Once
-this is done it should pass arguements properly (i.e. as a POST, 8-bit clean)
-
-Still some small bits of widget code same as FS::UI::Gtk.
-
-=head1 SEE ALSO
-
-L<FS::UI::Base>
-
-=head1 HISTORY
-
-$Log: CGI.pm,v $
-Revision 1.1 1999-08-04 09:03:53 ivan
-initial checkin of module files for proper perl installation
-
-Revision 1.1 1999/01/20 09:30:36 ivan
-skeletal cross-UI UI code.
-
-
-=cut
-
-1;
-
diff --git a/FS/FS/UI/Gtk.pm b/FS/FS/UI/Gtk.pm
deleted file mode 100644
index 507a293..0000000
--- a/FS/FS/UI/Gtk.pm
+++ /dev/null
@@ -1,224 +0,0 @@
-package FS::UI::Gtk;
-
-use strict;
-use Gtk;
-use FS::UID qw(adminsuidsetup);
-
-die "Can't initialize Gtk interface; $FS::UI::Base::_lock used"
- if $FS::UI::Base::_lock;
-$FS::UI::Base::_lock = "FS::UI::Gtk";
-
-=head1 NAME
-
-FS::UI::Gtk - Base class for Gtk user-interface objects
-
-=head1 SYNOPSIS
-
- use FS::UI::Gtk;
- use FS::UI::some_table;
-
- $interface = new FS::UI::some_table;
-
- $error = $interface->browse;
- $error = $interface->search;
- $error = $interface->view;
- $error = $interface->edit;
- $error = $interface->process;
-
-=head1 DESCRIPTION
-
-An FS::UI::Gtk object represents a Gtk user interface object.
-
-=head1 METHODS
-
-=over 4
-
-=item new
-
-=cut
-
-sub new {
- my $proto = shift;
- my $class = ref($proto) || $proto;
- my $self = { @_ };
-
- bless ( $self, $class );
-
- $self->{'_user'} = 'ivan'; #Pop up login window?
- $self->{'_dbh'} = FS::UID::adminsuidsetup $self->{'_user'};
-
-
-
- $self;
-}
-
-sub activate {
- my $self = shift;
-
- my $vbox = new Gtk::VBox ( 0, 4 );
-
- foreach my $widget ( @{ $self->{'Widgets'} } ) {
- $widget->_gtk->show;
- $vbox->pack_start ( $widget->_gtk, 1, 1, 4 );
- }
- $vbox->show;
-
- my $window = new Gtk::Window "toplevel";
- $self->{'_gtk'} = $window;
- $window->set_title( $self->title );
- $window->add ( $vbox );
- $window->show;
- main Gtk;
-}
-
-=item interface
-
-Returns the string `Gtk'. Useful for the author of a table-specific UI class
-to conditionally specify certain behaviour.
-
-=cut
-
-sub interface { 'Gtk'; }
-
-=back
-
-=cut
-
-package FS::UI::_Widget;
-
-use vars qw( $AUTOLOAD );
-
-sub new {
- my $proto = shift;
- my $class = ref($proto) || $proto;
- my $self = { @_ };
- bless ( $self, $class );
-}
-
-sub _gtk {
- my $self = shift;
- $self->{'_gtk'};
-}
-
-sub AUTOLOAD {
- my $self = shift;
- my $value = shift;
- my($field)=$AUTOLOAD;
- $field =~ s/.*://;
- if ( defined($value) ) {
- $self->{$field} = $value;
- } else {
- $self->{$field};
- }
-}
-
-package FS::UI::_Text;
-
-use vars qw ( @ISA );
-
-@ISA = qw ( FS::UI::_Widget );
-
-sub new {
- my $proto = shift;
- my $class = ref($proto) || $proto;
- my $self = {};
- $self->{'_gtk'} = new Gtk::Label ( shift );
- bless ( $self, $class );
-}
-
-package FS::UI::_Link;
-
-use vars qw ( @ISA );
-
-@ISA = qw ( FS::UI::_Widget );
-
-sub new {
- my $proto = shift;
- my $class = ref($proto) || $proto;
- my $self = { @_ };
- $self->{'_gtk'} = new_with_label Gtk::Button ( $self->{'text'} );
- $self->{'_gtk'}->signal_connect( 'clicked', sub {
- print "STUB: (Gtk) FS::UI::_Link";
- }, "hi", "there" );
- bless ( $self, $class );
-}
-
-
-package FS::UI::_Table;
-
-use vars qw ( @ISA );
-
-@ISA = qw ( FS::UI::_Widget );
-
-sub new {
- my $proto = shift;
- my $class = ref($proto) || $proto;
- my $self = { @_ };
- bless ( $self, $class );
-
- $self->{'_gtk'} = new Gtk::Table (
- $self->rows,
- $self->columns,
- 0, #homogeneous
- );
-
- $self;
-}
-
-sub attach {
- my $self = shift;
- my ( $row, $column, $widget, $rowspan, $colspan ) = @_;
- $rowspan ||= 1;
- $colspan ||= 1;
- $self->_gtk->attach_defaults(
- $widget->_gtk,
- $column,
- $column + $colspan,
- $row,
- $row + $rowspan,
- );
- $widget->_gtk->show;
-}
-
-package FS::UI::_Tableborder;
-
-use vars qw ( @ISA );
-
-@ISA = qw ( FS::UI::_Table );
-
-=head1 VERSION
-
-$Id: Gtk.pm,v 1.1 1999-08-04 09:03:53 ivan Exp $
-
-=head1 BUGS
-
-This documentation is incomplete.
-
-_Tableborder is just a _Table now. _Tableborders should scroll (but not the
-headers) and need and need more decoration. (data in white section ala gtksql
-and sliding field widths) headers should be buttons that callback to sort on
-their fields.
-
-There should be a persistant, per-(freeside)-user store for window positions
-and sizes and sort fields etc (see L<FS::UI::CGI/BUGS>.
-
-Still some small bits of widget code same as FS::UI::CGI.
-
-=head1 SEE ALSO
-
-L<FS::UI::Base>
-
-=head1 HISTORY
-
-$Log: Gtk.pm,v $
-Revision 1.1 1999-08-04 09:03:53 ivan
-initial checkin of module files for proper perl installation
-
-Revision 1.1 1999/01/20 09:30:36 ivan
-skeletal cross-UI UI code.
-
-
-=cut
-
-1;
-
diff --git a/FS/FS/UI/agent.pm b/FS/FS/UI/agent.pm
deleted file mode 100644
index ce9744a..0000000
--- a/FS/FS/UI/agent.pm
+++ /dev/null
@@ -1,62 +0,0 @@
-package FS::UI::agent;
-
-use strict;
-use vars qw ( @ISA );
-use FS::UI::Base;
-use FS::Record qw( qsearchs );
-use FS::agent;
-use FS::agent_type;
-
-@ISA = qw ( FS::UI::Base );
-
-sub db_table { 'agent' };
-
-sub db_name { 'Agent' };
-
-sub db_description { <<END;
-Agents are resellers of your service. Agents may be limited to a subset of your
-full offerings (via their type).
-END
-}
-
-sub list_fields {
- 'agentnum',
- 'typenum',
-# 'freq',
-# 'prog',
-; }
-
-sub list_header {
- 'Agent',
- 'Type',
-# 'Freq (n/a)',
-# 'Prog (n/a)',
-; }
-
-sub db_callback {
- 'agentnum' =>
- sub {
- my ( $agentnum, $record ) = @_;
- my $agent = $record->agent;
- new FS::UI::_Link (
- 'table' => 'agent',
- 'method' => 'edit',
- 'arg' => [ $agentnum ],
- 'text' => "$agentnum: $agent",
- );
- },
- 'typenum' =>
- sub {
- my $typenum = shift;
- my $agent_type = qsearchs( 'agent_type', { 'typenum' => $typenum } );
- my $atype = $agent_type->atype;
- new FS::UI::_Link (
- 'table' => 'agent_type',
- 'method' => 'edit',
- 'arg' => [ $typenum ],
- 'text' => "$typenum: $atype"
- );
- },
-}
-
-1;
diff --git a/FS/FS/UID.pm b/FS/FS/UID.pm
deleted file mode 100644
index 8271f89..0000000
--- a/FS/FS/UID.pm
+++ /dev/null
@@ -1,316 +0,0 @@
-package FS::UID;
-
-use strict;
-use vars qw(
- @ISA @EXPORT_OK $cgi $dbh $freeside_uid $user
- $conf_dir $secrets $datasrc $db_user $db_pass %callback @callback
- $driver_name $AutoCommit
-);
-use subs qw(
- getsecrets cgisetotaker
-);
-use Exporter;
-use Carp qw(carp croak cluck);
-use DBI;
-use FS::Conf;
-
-@ISA = qw(Exporter);
-@EXPORT_OK = qw(checkeuid checkruid cgisuidsetup adminsuidsetup forksuidsetup
- getotaker dbh datasrc getsecrets driver_name );
-
-$freeside_uid = scalar(getpwnam('freeside'));
-
-$conf_dir = "/usr/local/etc/freeside/";
-
-$AutoCommit = 1; #ours, not DBI
-
-=head1 NAME
-
-FS::UID - Subroutines for database login and assorted other stuff
-
-=head1 SYNOPSIS
-
- use FS::UID qw(adminsuidsetup cgisuidsetup dbh datasrc getotaker
- checkeuid checkruid);
-
- adminsuidsetup $user;
-
- $cgi = new CGI;
- $dbh = cgisuidsetup($cgi);
-
- $dbh = dbh;
-
- $datasrc = datasrc;
-
- $driver_name = driver_name;
-
-=head1 DESCRIPTION
-
-Provides a hodgepodge of subroutines.
-
-=head1 SUBROUTINES
-
-=over 4
-
-=item adminsuidsetup USER
-
-Sets the user to USER (see config.html from the base documentation).
-Cleans the environment.
-Make sure the script is running as freeside, or setuid freeside.
-Opens a connection to the database.
-Swaps real and effective UIDs.
-Runs any defined callbacks (see below).
-Returns the DBI database handle (usually you don't need this).
-
-=cut
-
-sub adminsuidsetup {
- $dbh->disconnect if $dbh;
- &forksuidsetup(@_);
-}
-
-sub forksuidsetup {
- $user = shift;
- croak "fatal: adminsuidsetup called without arguements" unless $user;
-
- $user =~ /^([\w\-\.]+)$/ or croak "fatal: illegal user $user";
- $user = $1;
-
- $ENV{'PATH'} ='/usr/local/bin:/usr/bin:/usr/ucb:/bin';
- $ENV{'SHELL'} = '/bin/sh';
- $ENV{'IFS'} = " \t\n";
- $ENV{'CDPATH'} = '';
- $ENV{'ENV'} = '';
- $ENV{'BASH_ENV'} = '';
-
- croak "Not running uid freeside!" unless checkeuid();
- getsecrets;
- $dbh = DBI->connect($datasrc,$db_user,$db_pass, {
- 'AutoCommit' => 0,
- 'ChopBlanks' => 1,
- } ) or die "DBI->connect error: $DBI::errstr\n";
-
- foreach ( keys %callback ) {
- &{$callback{$_}};
- # breaks multi-database installs # delete $callback{$_}; #run once
- }
-
- &{$_} foreach @callback;
-
- $dbh;
-}
-
-=item install_callback
-
-A package can install a callback to be run in adminsuidsetup by passing
-a coderef to the FS::UID->install_callback class method. If adminsuidsetup has
-run already, the callback will also be run immediately.
-
- $coderef = sub { warn "Hi, I'm returning your call!" };
- FS::UID->install_callback($coderef);
-
- install_callback FS::UID sub {
- warn "Hi, I'm returning your call!"
- };
-
-=cut
-
-sub install_callback {
- my $class = shift;
- my $callback = shift;
- push @callback, $callback;
- &{$callback} if $dbh;
-}
-
-=item cgisuidsetup CGI_object
-
-Takes a single argument, which is a CGI (see L<CGI>) or Apache (see L<Apache>)
-object (CGI::Base is depriciated). Runs cgisetotaker and then adminsuidsetup.
-
-=cut
-
-sub cgisuidsetup {
- $cgi=shift;
- if ( $cgi->isa('CGI::Base') ) {
- carp "Use of CGI::Base is depriciated";
- } elsif ( $cgi->isa('Apache') ) {
-
- } elsif ( ! $cgi->isa('CGI') ) {
- croak "fatal: unrecognized object $cgi";
- }
- cgisetotaker;
- adminsuidsetup($user);
-}
-
-=item cgi
-
-Returns the CGI (see L<CGI>) object.
-
-=cut
-
-sub cgi {
- carp "warning: \$FS::UID::cgi isa Apache" if $cgi->isa('Apache');
- $cgi;
-}
-
-=item dbh
-
-Returns the DBI database handle.
-
-=cut
-
-sub dbh {
- $dbh;
-}
-
-=item datasrc
-
-Returns the DBI data source.
-
-=cut
-
-sub datasrc {
- $datasrc;
-}
-
-=item driver_name
-
-Returns just the driver name portion of the DBI data source.
-
-=cut
-
-sub driver_name {
- return $driver_name if defined $driver_name;
- $driver_name = ( split(':', $datasrc) )[1];
-}
-
-sub suidsetup {
- croak "suidsetup depriciated";
-}
-
-=item getotaker
-
-Returns the current Freeside user.
-
-=cut
-
-sub getotaker {
- $user;
-}
-
-=item cgisetotaker
-
-Sets and returns the CGI REMOTE_USER. $cgi should be defined as a CGI.pm
-object (see L<CGI>) or an Apache object (see L<Apache>). Support for CGI::Base
-and derived classes is depriciated.
-
-=cut
-
-sub cgisetotaker {
- if ( $cgi && $cgi->isa('CGI::Base') && defined $cgi->var('REMOTE_USER')) {
- carp "Use of CGI::Base is depriciated";
- $user = lc ( $cgi->var('REMOTE_USER') );
- } elsif ( $cgi && $cgi->isa('CGI') && defined $cgi->remote_user ) {
- $user = lc ( $cgi->remote_user );
- } elsif ( $cgi && $cgi->isa('Apache') ) {
- $user = lc ( $cgi->connection->user );
- } else {
- die "fatal: Can't get REMOTE_USER! for cgi $cgi - you need to setup ".
- "Apache user authentication as documented in httemplate/docs/install.html";
- }
- $user;
-}
-
-=item checkeuid
-
-Returns true if effective UID is that of the freeside user.
-
-=cut
-
-sub checkeuid {
- ( $> == $freeside_uid );
-}
-
-=item checkruid
-
-Returns true if the real UID is that of the freeside user.
-
-=cut
-
-sub checkruid {
- ( $< == $freeside_uid );
-}
-
-=item getsecrets [ USER ]
-
-Sets the user to USER, if supplied.
-Sets and returns the DBI datasource, username and password for this user from
-the `/usr/local/etc/freeside/mapsecrets' file.
-
-=cut
-
-sub getsecrets {
- my($setuser) = shift;
- $user = $setuser if $setuser;
- die "No user!" unless $user;
- my($conf) = new FS::Conf $conf_dir;
- my($line) = grep /^\s*$user\s/, $conf->config('mapsecrets');
- die "User $user not found in mapsecrets!" unless $line;
- $line =~ /^\s*$user\s+(.*)$/;
- $secrets = $1;
- die "Illegal mapsecrets line for user?!" unless $secrets;
- ($datasrc, $db_user, $db_pass) = $conf->config($secrets)
- or die "Can't get secrets: $!";
- $FS::Conf::default_dir = $conf_dir. "/conf.$datasrc";
- undef $driver_name;
- ($datasrc, $db_user, $db_pass);
-}
-
-=back
-
-=head1 CALLBACKS
-
-Warning: this interface is (still) likely to change in future releases.
-
-New (experimental) callback interface:
-
-A package can install a callback to be run in adminsuidsetup by passing
-a coderef to the FS::UID->install_callback class method. If adminsuidsetup has
-run already, the callback will also be run immediately.
-
- $coderef = sub { warn "Hi, I'm returning your call!" };
- FS::UID->install_callback($coderef);
-
- install_callback FS::UID sub {
- warn "Hi, I'm returning your call!"
- };
-
-Old (deprecated) callback interface:
-
-A package can install a callback to be run in adminsuidsetup by putting a
-coderef into the hash %FS::UID::callback :
-
- $coderef = sub { warn "Hi, I'm returning your call!" };
- $FS::UID::callback{'Package::Name'} = $coderef;
-
-=head1 BUGS
-
-Too many package-global variables.
-
-Not OO.
-
-No capabilities yet. When mod_perl and Authen::DBI are implemented,
-cgisuidsetup will go away as well.
-
-Goes through contortions to support non-OO syntax with multiple datasrc's.
-
-Callbacks are (still) inelegant.
-
-=head1 SEE ALSO
-
-L<FS::Record>, L<CGI>, L<DBI>, config.html from the base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/acct_snarf.pm b/FS/FS/acct_snarf.pm
deleted file mode 100644
index b4e88bf..0000000
--- a/FS/FS/acct_snarf.pm
+++ /dev/null
@@ -1,128 +0,0 @@
-package FS::acct_snarf;
-
-use strict;
-use vars qw( @ISA );
-use FS::Record;
-
-@ISA = qw( FS::Record );
-
-=head1 NAME
-
-FS::acct_snarf - Object methods for acct_snarf records
-
-=head1 SYNOPSIS
-
- use FS::acct_snarf;
-
- $record = new FS::acct_snarf \%hash;
- $record = new FS::acct_snarf { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
-=head1 DESCRIPTION
-
-An FS::svc_acct object represents an external mail account, typically for
-download of mail. FS::acct_snarf inherits from FS::Record. The following
-fields are currently supported:
-
-=over 4
-
-=item snarfnum - primary key
-
-=item svcnum - Account (see L<FS::svc_acct>)
-
-=item machine - external machine to download mail from
-
-=item protocol - protocol (pop3, imap, etc.)
-
-=item username - external login username
-
-=item _password - external login password
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new record. To add the record 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 { 'acct_snarf'; }
-
-=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 external mail account. If
-there is an error, returns the error, otherwise returns false. Called by the
-insert and replace methods.
-
-=cut
-
-sub check {
- my $self = shift;
- my $error =
- $self->ut_numbern('snarfnum')
- || $self->ut_number('svcnum')
- || $self->ut_foreign_key('svcnum', 'svc_acct', 'svcnum')
- || $self->ut_domain('machine')
- || $self->ut_alphan('protocol')
- || $self->ut_textn('username')
- ;
- return $error if $error;
-
- $self->_password =~ /^[^\t\n]*$/ or return "illegal password";
- $self->_password($1);
-
- ''; #no error
-}
-
-=back
-
-=head1 BUGS
-
-=head1 SEE ALSO
-
-L<FS::Record>, schema.html from the base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/addr_block.pm b/FS/FS/addr_block.pm
deleted file mode 100755
index 1fb6060..0000000
--- a/FS/FS/addr_block.pm
+++ /dev/null
@@ -1,331 +0,0 @@
-package FS::addr_block;
-
-use strict;
-use vars qw( @ISA );
-use FS::Record qw( qsearchs qsearch dbh );
-use FS::router;
-use FS::svc_broadband;
-use FS::Conf;
-use NetAddr::IP;
-
-@ISA = qw( FS::Record );
-
-=head1 NAME
-
-FS::addr_block - Object methods for addr_block records
-
-=head1 SYNOPSIS
-
- use FS::addr_block;
-
- $record = new FS::addr_block \%hash;
- $record = new FS::addr_block { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
-=head1 DESCRIPTION
-
-An FS::addr_block record describes an address block assigned for broadband
-access. FS::addr_block inherits from FS::Record. The following fields are
-currently supported:
-
-=over 4
-
-=item blocknum - primary key, used in FS::svc_broadband to associate
-services to the block.
-
-=item routernum - the router (see FS::router) to which this
-block is assigned.
-
-=item ip_gateway - the gateway address used by customers within this block.
-
-=item ip_netmask - the netmask of the block, expressed as an integer.
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Create a new record. To add the record to the database, see "insert".
-
-=cut
-
-sub table { 'addr_block'; }
-
-=item insert
-
-Adds this record to the database. If there is an error, returns the error,
-otherwise returns false.
-
-=item delete
-
-Deletes this record from the database. If there is an error, returns the
-error, otherwise returns false.
-
-sub delete {
- my $self = shift;
- return 'Block must be deallocated before deletion'
- if $self->router;
-
- $self->SUPER::delete;
-}
-
-=item replace OLD_RECORD
-
-Replaces OLD_RECORD with this one in the database. If there is an error,
-returns the error, otherwise returns false.
-
-=item check
-
-Checks all fields to make sure this is a valid record. If there is an error,
-returns the error, otherwise returns false. Called by the insert and replace
-methods.
-
-=cut
-
-sub check {
- my $self = shift;
-
- my $error =
- $self->ut_number('routernum')
- || $self->ut_ip('ip_gateway')
- || $self->ut_number('ip_netmask')
- ;
- return $error if $error;
-
-
- # A routernum of 0 indicates an unassigned block and is allowed
- return "Unknown routernum"
- if ($self->routernum and not $self->router);
-
- my $self_addr = $self->NetAddr;
- return "Cannot parse address: ". $self->ip_gateway . '/' . $self->ip_netmask
- unless $self_addr;
-
- if (not $self->blocknum) {
- my @block = grep {
- my $block_addr = $_->NetAddr;
- if($block_addr->contains($self_addr)
- or $self_addr->contains($block_addr)) { $_; };
- } qsearch( 'addr_block', {});
- foreach(@block) {
- return "Block intersects existing block ".$_->ip_gateway."/".$_->ip_netmask;
- }
- }
-
- $self->SUPER::check;
-}
-
-
-=item router
-
-Returns the FS::router object corresponding to this object. If the
-block is unassigned, returns undef.
-
-=cut
-
-sub router {
- my $self = shift;
- return qsearchs('router', { routernum => $self->routernum });
-}
-
-=item svc_broadband
-
-Returns a list of FS::svc_broadband objects associated
-with this object.
-
-=cut
-
-sub svc_broadband {
- my $self = shift;
- return qsearch('svc_broadband', { blocknum => $self->blocknum });
-}
-
-=item NetAddr
-
-Returns a NetAddr::IP object for this block's address and netmask.
-
-=cut
-
-sub NetAddr {
- my $self = shift;
-
- return new NetAddr::IP ($self->ip_gateway, $self->ip_netmask);
-}
-
-=item next_free_addr
-
-Returns a NetAddr::IP object corresponding to the first unassigned address
-in the block (other than the network, broadcast, or gateway address). If
-there are no free addresses, returns false.
-
-=cut
-
-sub next_free_addr {
- my $self = shift;
-
- my $conf = new FS::Conf;
- my @excludeaddr = $conf->config('exclude_ip_addr');
-
-my @used =
-( (map { $_->NetAddr->addr }
- ($self,
- qsearch('svc_broadband', { blocknum => $self->blocknum }))
- ), @excludeaddr
-);
-
- my @free = $self->NetAddr->hostenum;
- while (my $ip = shift @free) {
- if (not grep {$_ eq $ip->addr;} @used) { return $ip; };
- }
-
- '';
-
-}
-
-=item allocate
-
-Allocates this address block to a router. Takes an FS::router object
-as an argument.
-
-At present it's not possible to reallocate a block to a different router
-except by deallocating it first, which requires that none of its addresses
-be assigned. This is probably as it should be.
-
-=cut
-
-sub allocate {
- my ($self, $router) = @_;
-
- return 'Block is already allocated'
- if($self->router);
-
- return 'Block must be allocated to a router'
- unless(ref $router eq 'FS::router');
-
- my @svc = $self->svc_broadband;
- if (@svc) {
- return 'Block has assigned addresses: '. join ', ', map {$_->ip_addr} @svc;
- }
-
- my $new = new FS::addr_block {$self->hash};
- $new->routernum($router->routernum);
- return $new->replace($self);
-
-}
-
-=item deallocate
-
-Deallocates the block (i.e. sets the routernum to 0). If any addresses in the
-block are assigned to services, it fails.
-
-=cut
-
-sub deallocate {
- my $self = shift;
-
- my @svc = $self->svc_broadband;
- if (@svc) {
- return 'Block has assigned addresses: '. join ', ', map {$_->ip_addr} @svc;
- }
-
- my $new = new FS::addr_block {$self->hash};
- $new->routernum(0);
- return $new->replace($self);
-}
-
-=item split_block
-
-Splits this address block into two equal blocks, occupying the same space as
-the original block. The first of the two will also have the same blocknum.
-The gateway address of each block will be set to the first usable address, i.e.
-(network address)+1. Since this method is designed for use on unallocated
-blocks, this is probably the correct behavior.
-
-(At present, splitting allocated blocks is disallowed. Anyone who wants to
-implement this is reminded that each split costs three addresses, and any
-customers who were using these addresses will have to be moved; depending on
-how full the block was before being split, they might have to be moved to a
-different block. Anyone who I<still> wants to implement it is asked to tie it
-to a configuration switch so that site admins can disallow it.)
-
-=cut
-
-sub split_block {
-
- # We should consider using Attribute::Handlers/Aspect/Hook::LexWrap/
- # something to atomicize functions, so that we can say
- #
- # sub split_block : atomic {
- #
- # instead of repeating all this AutoCommit verbage in every
- # sub that does more than one database operation.
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- my $self = shift;
- my $error;
-
- if ($self->router) {
- return 'Block is already allocated';
- }
-
- #TODO: Smallest allowed block should be a config option.
- if ($self->NetAddr->masklen() ge 30) {
- return 'Cannot split blocks with a mask length >= 30';
- }
-
- my (@new, @ip);
- $ip[0] = $self->NetAddr;
- @ip = map {$_->first()} $ip[0]->split($self->ip_netmask + 1);
-
- foreach (0,1) {
- $new[$_] = new FS::addr_block {$self->hash};
- $new[$_]->ip_gateway($ip[$_]->addr);
- $new[$_]->ip_netmask($ip[$_]->masklen);
- }
-
- $new[1]->blocknum('');
-
- $error = $new[0]->replace($self);
- if ($error) {
- $dbh->rollback;
- return $error;
- }
-
- $error = $new[1]->insert;
- if ($error) {
- $dbh->rollback;
- return $error;
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
- return '';
-}
-
-=item merge
-
-To be implemented.
-
-=back
-
-=head1 BUGS
-
-Minimum block size should be a config option. It's hardcoded at /30 right
-now because that's the smallest block that makes any sense at all.
-
-=cut
-
-1;
-
diff --git a/FS/FS/agent.pm b/FS/FS/agent.pm
deleted file mode 100644
index 2f70d65..0000000
--- a/FS/FS/agent.pm
+++ /dev/null
@@ -1,183 +0,0 @@
-package FS::agent;
-
-use strict;
-use vars qw( @ISA );
-use FS::Record qw( qsearch qsearchs );
-use FS::cust_main;
-use FS::agent_type;
-
-@ISA = qw( FS::Record );
-
-=head1 NAME
-
-FS::agent - Object methods for agent records
-
-=head1 SYNOPSIS
-
- use FS::agent;
-
- $record = new FS::agent \%hash;
- $record = new FS::agent { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
- $agent_type = $record->agent_type;
-
- $hashref = $record->pkgpart_hashref;
- #may purchase $pkgpart if $hashref->{$pkgpart};
-
-=head1 DESCRIPTION
-
-An FS::agent object represents an agent. Every customer has an agent. Agents
-can be used to track things like resellers or salespeople. FS::agent inherits
-from FS::Record. The following fields are currently supported:
-
-=over 4
-
-=item agentnum - primary key (assigned automatically for new agents)
-
-=item agent - Text name of this agent
-
-=item typenum - Agent type. See L<FS::agent_type>
-
-=item prog - For future use.
-
-=item freq - For future use.
-
-=item disabled - Disabled flag, empty or 'Y'
-
-=item username - Username for the Agent interface
-
-=item _password - Password for the Agent interface
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new agent. To add the agent to the database, see L<"insert">.
-
-=cut
-
-sub table { 'agent'; }
-
-=item insert
-
-Adds this agent to the database. If there is an error, returns the error,
-otherwise returns false.
-
-=item delete
-
-Deletes this agent from the database. Only agents with no customers can be
-deleted. If there is an error, returns the error, otherwise returns false.
-
-=cut
-
-sub delete {
- my $self = shift;
-
- return "Can't delete an agent with customers!"
- if qsearch( 'cust_main', { 'agentnum' => $self->agentnum } );
-
- $self->SUPER::delete;
-}
-
-=item replace OLD_RECORD
-
-Replaces OLD_RECORD with this one in the database. If there is an error,
-returns the error, otherwise returns false.
-
-=item check
-
-Checks all fields to make sure this is a valid agent. If there is an error,
-returns the error, otherwise returns false. Called by the insert and replace
-methods.
-
-=cut
-
-sub check {
- my $self = shift;
-
- my $error =
- $self->ut_numbern('agentnum')
- || $self->ut_text('agent')
- || $self->ut_number('typenum')
- || $self->ut_numbern('freq')
- || $self->ut_textn('prog')
- ;
- return $error if $error;
-
- if ( $self->dbdef_table->column('disabled') ) {
- $error = $self->ut_enum('disabled', [ '', 'Y' ] );
- return $error if $error;
- }
-
- if ( $self->dbdef_table->column('username') ) {
- $error = $self->ut_alphan('username');
- return $error if $error;
- if ( length($self->username) ) {
- my $conflict = qsearchs('agent', { 'username' => $self->username } );
- return 'duplicate agent username (with '. $conflict->agent. ')'
- if $conflict;
- $error = $self->ut_text('password'); # ut_text... arbitrary choice
- } else {
- $self->_password('');
- }
- }
-
- return "Unknown typenum!"
- unless $self->agent_type;
-
- $self->SUPER::check;
-}
-
-=item agent_type
-
-Returns the FS::agent_type object (see L<FS::agent_type>) for this agent.
-
-=cut
-
-sub agent_type {
- my $self = shift;
- qsearchs( 'agent_type', { 'typenum' => $self->typenum } );
-}
-
-=item pkgpart_hashref
-
-Returns a hash reference. The keys of the hash are pkgparts. The value is
-true if this agent may purchase the specified package definition. See
-L<FS::part_pkg>.
-
-=cut
-
-sub pkgpart_hashref {
- my $self = shift;
- $self->agent_type->pkgpart_hashref;
-}
-
-=back
-
-=head1 VERSION
-
-$Id: agent.pm,v 1.6 2003-09-30 15:01:46 ivan Exp $
-
-=head1 BUGS
-
-=head1 SEE ALSO
-
-L<FS::Record>, L<FS::agent_type>, L<FS::cust_main>, L<FS::part_pkg>,
-schema.html from the base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/agent_type.pm b/FS/FS/agent_type.pm
deleted file mode 100644
index 5ba5ef2..0000000
--- a/FS/FS/agent_type.pm
+++ /dev/null
@@ -1,166 +0,0 @@
-package FS::agent_type;
-
-use strict;
-use vars qw( @ISA );
-use FS::Record qw( qsearch );
-use FS::agent;
-use FS::type_pkgs;
-
-@ISA = qw( FS::Record );
-
-=head1 NAME
-
-FS::agent_type - Object methods for agent_type records
-
-=head1 SYNOPSIS
-
- use FS::agent_type;
-
- $record = new FS::agent_type \%hash;
- $record = new FS::agent_type { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
- $hashref = $record->pkgpart_hashref;
- #may purchase $pkgpart if $hashref->{$pkgpart};
-
- @type_pkgs = $record->type_pkgs;
-
- @pkgparts = $record->pkgpart;
-
-=head1 DESCRIPTION
-
-An FS::agent_type object represents an agent type. Every agent (see
-L<FS::agent>) has an agent type. Agent types define which packages (see
-L<FS::part_pkg>) may be purchased by customers (see L<FS::cust_main>), via
-FS::type_pkgs records (see L<FS::type_pkgs>). FS::agent_type inherits from
-FS::Record. The following fields are currently supported:
-
-=over 4
-
-=item typenum - primary key (assigned automatically for new agent types)
-
-=item atype - Text name of this agent type
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new agent type. To add the agent type to the database, see
-L<"insert">.
-
-=cut
-
-sub table { 'agent_type'; }
-
-=item insert
-
-Adds this agent type to the database. If there is an error, returns the error,
-otherwise returns false.
-
-=item delete
-
-Deletes this agent type from the database. Only agent types with no agents
-can be deleted. If there is an error, returns the error, otherwise returns
-false.
-
-=cut
-
-sub delete {
- my $self = shift;
-
- return "Can't delete an agent_type with agents!"
- if qsearch( 'agent', { 'typenum' => $self->typenum } );
-
- $self->SUPER::delete;
-}
-
-=item replace OLD_RECORD
-
-Replaces OLD_RECORD with this one in the database. If there is an error,
-returns the error, otherwise returns false.
-
-=item check
-
-Checks all fields to make sure this is a valid agent type. If there is an
-error, returns the error, otherwise returns false. Called by the insert and
-replace methods.
-
-=cut
-
-sub check {
- my $self = shift;
-
- $self->ut_numbern('typenum')
- or $self->ut_text('atype')
- or $self->SUPER::check;
-
-}
-
-=item pkgpart_hashref
-
-Returns a hash reference. The keys of the hash are pkgparts. The value is
-true iff this agent may purchase the specified package definition. See
-L<FS::part_pkg>.
-
-=cut
-
-sub pkgpart_hashref {
- my $self = shift;
- my %pkgpart;
- #$pkgpart{$_}++ foreach $self->pkgpart;
- # not compatible w/5.004_04 (fixed in 5.004_05)
- foreach ( $self->pkgpart ) { $pkgpart{$_}++; }
- \%pkgpart;
-}
-
-=item type_pkgs
-
-Returns all FS::type_pkgs objects (see L<FS::type_pkgs>) for this agent type.
-
-=cut
-
-sub type_pkgs {
- my $self = shift;
- qsearch('type_pkgs', { 'typenum' => $self->typenum } );
-}
-
-=item pkgpart
-
-Returns the pkgpart of all package definitions (see L<FS::part_pkg>) for this
-agent type.
-
-=cut
-
-sub pkgpart {
- my $self = shift;
- map $_->pkgpart, $self->type_pkgs;
-}
-
-=back
-
-=head1 VERSION
-
-$Id: agent_type.pm,v 1.2 2003-08-05 00:20:40 khoff Exp $
-
-=head1 BUGS
-
-=head1 SEE ALSO
-
-L<FS::Record>, L<FS::agent>, L<FS::type_pkgs>, L<FS::cust_main>,
-L<FS::part_pkg>, schema.html from the base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm
deleted file mode 100644
index a3e7662..0000000
--- a/FS/FS/cust_bill.pm
+++ /dev/null
@@ -1,1411 +0,0 @@
-package FS::cust_bill;
-
-use strict;
-use vars qw( @ISA $conf $money_char );
-use vars qw( $invoice_lines @buf ); #yuck
-use Date::Format;
-use Text::Template;
-use FS::UID qw( datasrc );
-use FS::Record qw( qsearch qsearchs );
-use FS::Misc qw( send_email );
-use FS::cust_main;
-use FS::cust_bill_pkg;
-use FS::cust_credit;
-use FS::cust_pay;
-use FS::cust_pkg;
-use FS::cust_credit_bill;
-use FS::cust_pay_batch;
-use FS::cust_bill_event;
-
-@ISA = qw( FS::Record );
-
-#ask FS::UID to run this stuff for us later
-FS::UID->install_callback( sub {
- $conf = new FS::Conf;
- $money_char = $conf->config('money_char') || '$';
-} );
-
-=head1 NAME
-
-FS::cust_bill - Object methods for cust_bill records
-
-=head1 SYNOPSIS
-
- use FS::cust_bill;
-
- $record = new FS::cust_bill \%hash;
- $record = new FS::cust_bill { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
- ( $total_previous_balance, @previous_cust_bill ) = $record->previous;
-
- @cust_bill_pkg_objects = $cust_bill->cust_bill_pkg;
-
- ( $total_previous_credits, @previous_cust_credit ) = $record->cust_credit;
-
- @cust_pay_objects = $cust_bill->cust_pay;
-
- $tax_amount = $record->tax;
-
- @lines = $cust_bill->print_text;
- @lines = $cust_bill->print_text $time;
-
-=head1 DESCRIPTION
-
-An FS::cust_bill object represents an invoice; a declaration that a customer
-owes you money. The specific charges are itemized as B<cust_bill_pkg> records
-(see L<FS::cust_bill_pkg>). FS::cust_bill inherits from FS::Record. The
-following fields are currently supported:
-
-=over 4
-
-=item invnum - primary key (assigned automatically for new invoices)
-
-=item custnum - customer (see L<FS::cust_main>)
-
-=item _date - specified as a UNIX timestamp; see L<perlfunc/"time">. Also see
-L<Time::Local> and L<Date::Parse> for conversion functions.
-
-=item charged - amount of this invoice
-
-=item printed - deprecated
-
-=item closed - books closed flag, empty or `Y'
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new invoice. To add the invoice to the database, see L<"insert">.
-Invoices are normally created by calling the bill method of a customer object
-(see L<FS::cust_main>).
-
-=cut
-
-sub table { 'cust_bill'; }
-
-=item insert
-
-Adds this invoice to the database ("Posts" the invoice). If there is an error,
-returns the error, otherwise returns false.
-
-=item delete
-
-Currently unimplemented. I don't remove invoices because there would then be
-no record you ever posted this invoice (which is bad, no?)
-
-=cut
-
-sub delete {
- my $self = shift;
- return "Can't delete closed invoice" if $self->closed =~ /^Y/i;
- $self->SUPER::delete(@_);
-}
-
-=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.
-
-Only printed may be changed. printed is normally updated by calling the
-collect method of a customer object (see L<FS::cust_main>).
-
-=cut
-
-sub replace {
- my( $new, $old ) = ( shift, shift );
- return "Can't change custnum!" unless $old->custnum == $new->custnum;
- #return "Can't change _date!" unless $old->_date eq $new->_date;
- return "Can't change _date!" unless $old->_date == $new->_date;
- return "Can't change charged!" unless $old->charged == $new->charged;
-
- $new->SUPER::replace($old);
-}
-
-=item check
-
-Checks all fields to make sure this is a valid invoice. If there is an error,
-returns the error, otherwise returns false. Called by the insert and replace
-methods.
-
-=cut
-
-sub check {
- my $self = shift;
-
- my $error =
- $self->ut_numbern('invnum')
- || $self->ut_number('custnum')
- || $self->ut_numbern('_date')
- || $self->ut_money('charged')
- || $self->ut_numbern('printed')
- || $self->ut_enum('closed', [ '', 'Y' ])
- ;
- return $error if $error;
-
- return "Unknown customer"
- unless qsearchs( 'cust_main', { 'custnum' => $self->custnum } );
-
- $self->_date(time) unless $self->_date;
-
- $self->printed(0) if $self->printed eq '';
-
- $self->SUPER::check;
-}
-
-=item previous
-
-Returns a list consisting of the total previous balance for this customer,
-followed by the previous outstanding invoices (as FS::cust_bill objects also).
-
-=cut
-
-sub previous {
- my $self = shift;
- my $total = 0;
- my @cust_bill = sort { $a->_date <=> $b->_date }
- grep { $_->owed != 0 && $_->_date < $self->_date }
- qsearch( 'cust_bill', { 'custnum' => $self->custnum } )
- ;
- foreach ( @cust_bill ) { $total += $_->owed; }
- $total, @cust_bill;
-}
-
-=item cust_bill_pkg
-
-Returns the line items (see L<FS::cust_bill_pkg>) for this invoice.
-
-=cut
-
-sub cust_bill_pkg {
- my $self = shift;
- qsearch( 'cust_bill_pkg', { 'invnum' => $self->invnum } );
-}
-
-=item cust_bill_event
-
-Returns the completed invoice events (see L<FS::cust_bill_event>) for this
-invoice.
-
-=cut
-
-sub cust_bill_event {
- my $self = shift;
- qsearch( 'cust_bill_event', { 'invnum' => $self->invnum } );
-}
-
-
-=item cust_main
-
-Returns the customer (see L<FS::cust_main>) for this invoice.
-
-=cut
-
-sub cust_main {
- my $self = shift;
- qsearchs( 'cust_main', { 'custnum' => $self->custnum } );
-}
-
-=item cust_credit
-
-Depreciated. See the cust_credited method.
-
- #Returns a list consisting of the total previous credited (see
- #L<FS::cust_credit>) and unapplied for this customer, followed by the previous
- #outstanding credits (FS::cust_credit objects).
-
-=cut
-
-sub cust_credit {
- use Carp;
- croak "FS::cust_bill->cust_credit depreciated; see ".
- "FS::cust_bill->cust_credit_bill";
- #my $self = shift;
- #my $total = 0;
- #my @cust_credit = sort { $a->_date <=> $b->_date }
- # grep { $_->credited != 0 && $_->_date < $self->_date }
- # qsearch('cust_credit', { 'custnum' => $self->custnum } )
- #;
- #foreach (@cust_credit) { $total += $_->credited; }
- #$total, @cust_credit;
-}
-
-=item cust_pay
-
-Depreciated. See the cust_bill_pay method.
-
-#Returns all payments (see L<FS::cust_pay>) for this invoice.
-
-=cut
-
-sub cust_pay {
- use Carp;
- croak "FS::cust_bill->cust_pay depreciated; see FS::cust_bill->cust_bill_pay";
- #my $self = shift;
- #sort { $a->_date <=> $b->_date }
- # qsearch( 'cust_pay', { 'invnum' => $self->invnum } )
- #;
-}
-
-=item cust_bill_pay
-
-Returns all payment applications (see L<FS::cust_bill_pay>) for this invoice.
-
-=cut
-
-sub cust_bill_pay {
- my $self = shift;
- sort { $a->_date <=> $b->_date }
- qsearch( 'cust_bill_pay', { 'invnum' => $self->invnum } );
-}
-
-=item cust_credited
-
-Returns all applied credits (see L<FS::cust_credit_bill>) for this invoice.
-
-=cut
-
-sub cust_credited {
- my $self = shift;
- sort { $a->_date <=> $b->_date }
- qsearch( 'cust_credit_bill', { 'invnum' => $self->invnum } )
- ;
-}
-
-=item tax
-
-Returns the tax amount (see L<FS::cust_bill_pkg>) for this invoice.
-
-=cut
-
-sub tax {
- my $self = shift;
- my $total = 0;
- my @taxlines = qsearch( 'cust_bill_pkg', { 'invnum' => $self->invnum ,
- 'pkgnum' => 0 } );
- foreach (@taxlines) { $total += $_->setup; }
- $total;
-}
-
-=item owed
-
-Returns the amount owed (still outstanding) on this invoice, which is charged
-minus all payment applications (see L<FS::cust_bill_pay>) and credit
-applications (see L<FS::cust_credit_bill>).
-
-=cut
-
-sub owed {
- my $self = shift;
- my $balance = $self->charged;
- $balance -= $_->amount foreach ( $self->cust_bill_pay );
- $balance -= $_->amount foreach ( $self->cust_credited );
- $balance = sprintf( "%.2f", $balance);
- $balance =~ s/^\-0\.00$/0.00/; #yay ieee fp
- $balance;
-}
-
-=item send
-
-Sends this invoice to the destinations configured for this customer: send
-emails or print. See L<FS::cust_main_invoice>.
-
-=cut
-
-sub send {
- my($self,$template) = @_;
- my @print_text = $self->print_text('', $template);
- my @invoicing_list = $self->cust_main->invoicing_list;
-
- if ( grep { $_ ne 'POST' } @invoicing_list or !@invoicing_list ) { #email
-
- #better to notify this person than silence
- @invoicing_list = ($conf->config('invoice_from')) unless @invoicing_list;
-
- my $error = send_email(
- 'from' => $conf->config('invoice_from'),
- 'to' => [ grep { $_ ne 'POST' } @invoicing_list ],
- 'subject' => 'Invoice',
- 'body' => \@print_text,
- );
- return "can't send invoice: $error" if $error;
-
- }
-
- if ( $conf->config('invoice_latex') ) {
- @print_text = $self->print_ps('', $template);
- }
-
- if ( grep { $_ eq 'POST' } @invoicing_list ) { #postal
- my $lpr = $conf->config('lpr');
- open(LPR, "|$lpr")
- or return "Can't open pipe to $lpr: $!";
- print LPR @print_text;
- close LPR
- or return $! ? "Error closing $lpr: $!"
- : "Exit status $? from $lpr";
- }
-
- '';
-
-}
-
-=item send_csv OPTIONS
-
-Sends invoice as a CSV data-file to a remote host with the specified protocol.
-
-Options are:
-
-protocol - currently only "ftp"
-server
-username
-password
-dir
-
-The file will be named "N-YYYYMMDDHHMMSS.csv" where N is the invoice number
-and YYMMDDHHMMSS is a timestamp.
-
-The fields of the CSV file is as follows:
-
-record_type, invnum, custnum, _date, charged, first, last, company, address1, address2, city, state, zip, country, pkg, setup, recur, sdate, edate
-
-=over 4
-
-=item record type - B<record_type> is either C<cust_bill> or C<cust_bill_pkg>
-
-If B<record_type> is C<cust_bill>, this is a primary invoice record. The
-last five fields (B<pkg> through B<edate>) are irrelevant, and all other
-fields are filled in.
-
-If B<record_type> is C<cust_bill_pkg>, this is a line item record. Only the
-first two fields (B<record_type> and B<invnum>) and the last five fields
-(B<pkg> through B<edate>) are filled in.
-
-=item invnum - invoice number
-
-=item custnum - customer number
-
-=item _date - invoice date
-
-=item charged - total invoice amount
-
-=item first - customer first name
-
-=item last - customer first name
-
-=item company - company name
-
-=item address1 - address line 1
-
-=item address2 - address line 1
-
-=item city
-
-=item state
-
-=item zip
-
-=item country
-
-=item pkg - line item description
-
-=item setup - line item setup fee (one or both of B<setup> and B<recur> will be defined)
-
-=item recur - line item recurring fee (one or both of B<setup> and B<recur> will be defined)
-
-=item sdate - start date for recurring fee
-
-=item edate - end date for recurring fee
-
-=back
-
-=cut
-
-sub send_csv {
- my($self, %opt) = @_;
-
- #part one: create file
-
- my $spooldir = "/usr/local/etc/freeside/export.". datasrc. "/cust_bill";
- mkdir $spooldir, 0700 unless -d $spooldir;
-
- my $file = $spooldir. '/'. $self->invnum. time2str('-%Y%m%d%H%M%S.csv', time);
-
- open(CSV, ">$file") or die "can't open $file: $!";
-
- eval "use Text::CSV_XS";
- die $@ if $@;
-
- my $csv = Text::CSV_XS->new({'always_quote'=>1});
-
- my $cust_main = $self->cust_main;
-
- $csv->combine(
- 'cust_bill',
- $self->invnum,
- $self->custnum,
- time2str("%x", $self->_date),
- sprintf("%.2f", $self->charged),
- ( map { $cust_main->getfield($_) }
- qw( first last company address1 address2 city state zip country ) ),
- map { '' } (1..5),
- ) or die "can't create csv";
- print CSV $csv->string. "\n";
-
- #new charges (false laziness w/print_text)
- foreach my $cust_bill_pkg ( $self->cust_bill_pkg ) {
-
- my($pkg, $setup, $recur, $sdate, $edate);
- if ( $cust_bill_pkg->pkgnum ) {
-
- ($pkg, $setup, $recur, $sdate, $edate) = (
- $cust_bill_pkg->cust_pkg->part_pkg->pkg,
- ( $cust_bill_pkg->setup != 0
- ? sprintf("%.2f", $cust_bill_pkg->setup )
- : '' ),
- ( $cust_bill_pkg->recur != 0
- ? sprintf("%.2f", $cust_bill_pkg->recur )
- : '' ),
- time2str("%x", $cust_bill_pkg->sdate),
- time2str("%x", $cust_bill_pkg->edate),
- );
-
- } else { #pkgnum tax
- next unless $cust_bill_pkg->setup != 0;
- my $itemdesc = defined $cust_bill_pkg->dbdef_table->column('itemdesc')
- ? ( $cust_bill_pkg->itemdesc || 'Tax' )
- : 'Tax';
- ($pkg, $setup, $recur, $sdate, $edate) =
- ( $itemdesc, sprintf("%10.2f",$cust_bill_pkg->setup), '', '', '' );
- }
-
- $csv->combine(
- 'cust_bill_pkg',
- $self->invnum,
- ( map { '' } (1..11) ),
- ($pkg, $setup, $recur, $sdate, $edate)
- ) or die "can't create csv";
- print CSV $csv->string. "\n";
-
- }
-
- close CSV or die "can't close CSV: $!";
-
- #part two: upload it
-
- my $net;
- if ( $opt{protocol} eq 'ftp' ) {
- eval "use Net::FTP;";
- die $@ if $@;
- $net = Net::FTP->new($opt{server}) or die @$;
- } else {
- die "unknown protocol: $opt{protocol}";
- }
-
- $net->login( $opt{username}, $opt{password} )
- or die "can't FTP to $opt{username}\@$opt{server}: login error: $@";
-
- $net->binary or die "can't set binary mode";
-
- $net->cwd($opt{dir}) or die "can't cwd to $opt{dir}";
-
- $net->put($file) or die "can't put $file: $!";
-
- $net->quit;
-
- unlink $file;
-
-}
-
-=item comp
-
-Pays this invoice with a compliemntary payment. If there is an error,
-returns the error, otherwise returns false.
-
-=cut
-
-sub comp {
- my $self = shift;
- my $cust_pay = new FS::cust_pay ( {
- 'invnum' => $self->invnum,
- 'paid' => $self->owed,
- '_date' => '',
- 'payby' => 'COMP',
- 'payinfo' => $self->cust_main->payinfo,
- 'paybatch' => '',
- } );
- $cust_pay->insert;
-}
-
-=item realtime_card
-
-Attempts to pay this invoice with a credit card payment via a
-Business::OnlinePayment realtime gateway. See
-http://search.cpan.org/search?mode=module&query=Business%3A%3AOnlinePayment
-for supported processors.
-
-=cut
-
-sub realtime_card {
- my $self = shift;
- $self->realtime_bop( 'CC', @_ );
-}
-
-=item realtime_ach
-
-Attempts to pay this invoice with an electronic check (ACH) payment via a
-Business::OnlinePayment realtime gateway. See
-http://search.cpan.org/search?mode=module&query=Business%3A%3AOnlinePayment
-for supported processors.
-
-=cut
-
-sub realtime_ach {
- my $self = shift;
- $self->realtime_bop( 'ECHECK', @_ );
-}
-
-=item realtime_lec
-
-Attempts to pay this invoice with phone bill (LEC) payment via a
-Business::OnlinePayment realtime gateway. See
-http://search.cpan.org/search?mode=module&query=Business%3A%3AOnlinePayment
-for supported processors.
-
-=cut
-
-sub realtime_lec {
- my $self = shift;
- $self->realtime_bop( 'LEC', @_ );
-}
-
-sub realtime_bop {
- my( $self, $method ) = @_;
-
- my $cust_main = $self->cust_main;
- my $balance = $cust_main->balance;
- my $amount = ( $balance < $self->owed ) ? $balance : $self->owed;
- $amount = sprintf("%.2f", $amount);
- return "not run (balance $balance)" unless $amount > 0;
-
- my $description = 'Internet Services';
- if ( $conf->exists('business-onlinepayment-description') ) {
- my $dtempl = $conf->config('business-onlinepayment-description');
-
- my $agent_obj = $cust_main->agent
- or die "can't retreive agent for $cust_main (agentnum ".
- $cust_main->agentnum. ")";
- my $agent = $agent_obj->agent;
- my $pkgs = join(', ',
- map { $_->cust_pkg->part_pkg->pkg }
- grep { $_->pkgnum } $self->cust_bill_pkg
- );
- $description = eval qq("$dtempl");
- }
-
- $cust_main->realtime_bop($method, $amount,
- 'description' => $description,
- 'invnum' => $self->invnum,
- );
-
-}
-
-=item batch_card
-
-Adds a payment for this invoice to the pending credit card batch (see
-L<FS::cust_pay_batch>).
-
-=cut
-
-sub batch_card {
- my $self = shift;
- my $cust_main = $self->cust_main;
-
- my $cust_pay_batch = new FS::cust_pay_batch ( {
- 'invnum' => $self->getfield('invnum'),
- 'custnum' => $cust_main->getfield('custnum'),
- 'last' => $cust_main->getfield('last'),
- 'first' => $cust_main->getfield('first'),
- 'address1' => $cust_main->getfield('address1'),
- 'address2' => $cust_main->getfield('address2'),
- 'city' => $cust_main->getfield('city'),
- 'state' => $cust_main->getfield('state'),
- 'zip' => $cust_main->getfield('zip'),
- 'country' => $cust_main->getfield('country'),
- 'cardnum' => $cust_main->getfield('payinfo'),
- 'exp' => $cust_main->getfield('paydate'),
- 'payname' => $cust_main->getfield('payname'),
- 'amount' => $self->owed,
- } );
- my $error = $cust_pay_batch->insert;
- die $error if $error;
-
- '';
-}
-
-=item print_text [ TIME [ , TEMPLATE ] ]
-
-Returns an text invoice, as a list of lines.
-
-TIME an optional value used to control the printing of overdue messages. The
-default is now. It isn't the date of the invoice; that's the `_date' field.
-It is specified as a UNIX timestamp; see L<perlfunc/"time">. Also see
-L<Time::Local> and L<Date::Parse> for conversion functions.
-
-=cut
-
-sub print_text {
-
- my( $self, $today, $template ) = @_;
- $today ||= time;
-# my $invnum = $self->invnum;
- my $cust_main = qsearchs('cust_main', { 'custnum', $self->custnum } );
- $cust_main->payname( $cust_main->first. ' '. $cust_main->getfield('last') )
- unless $cust_main->payname && $cust_main->payby ne 'CHEK';
-
- my( $pr_total, @pr_cust_bill ) = $self->previous; #previous balance
-# my( $cr_total, @cr_cust_credit ) = $self->cust_credit; #credits
- #my $balance_due = $self->owed + $pr_total - $cr_total;
- my $balance_due = $self->owed + $pr_total;
-
- #my @collect = ();
- #my($description,$amount);
- @buf = ();
-
- #previous balance
- foreach ( @pr_cust_bill ) {
- push @buf, [
- "Previous Balance, Invoice #". $_->invnum.
- " (". time2str("%x",$_->_date). ")",
- $money_char. sprintf("%10.2f",$_->owed)
- ];
- }
- if (@pr_cust_bill) {
- push @buf,['','-----------'];
- push @buf,[ 'Total Previous Balance',
- $money_char. sprintf("%10.2f",$pr_total ) ];
- push @buf,['',''];
- }
-
- #new charges
- foreach my $cust_bill_pkg (
- ( grep { $_->pkgnum } $self->cust_bill_pkg ), #packages first
- ( grep { ! $_->pkgnum } $self->cust_bill_pkg ), #then taxes
- ) {
-
- if ( $cust_bill_pkg->pkgnum ) {
-
- my $cust_pkg = qsearchs('cust_pkg', { pkgnum =>$cust_bill_pkg->pkgnum } );
- my $part_pkg = qsearchs('part_pkg', { pkgpart=>$cust_pkg->pkgpart } );
- my $pkg = $part_pkg->pkg;
-
- if ( $cust_bill_pkg->setup != 0 ) {
- my $description = $pkg;
- $description .= ' Setup' if $cust_bill_pkg->recur != 0;
- push @buf, [ $description,
- $money_char. sprintf("%10.2f", $cust_bill_pkg->setup) ];
- push @buf,
- map { [ " ". $_->[0]. ": ". $_->[1], '' ] } $cust_pkg->labels;
- }
-
- if ( $cust_bill_pkg->recur != 0 ) {
- push @buf, [
- "$pkg (" . time2str("%x", $cust_bill_pkg->sdate) . " - " .
- time2str("%x", $cust_bill_pkg->edate) . ")",
- $money_char. sprintf("%10.2f", $cust_bill_pkg->recur)
- ];
- push @buf,
- map { [ " ". $_->[0]. ": ". $_->[1], '' ] } $cust_pkg->labels;
- }
-
- push @buf, map { [ " $_", '' ] } $cust_bill_pkg->details;
-
- } else { #pkgnum tax or one-shot line item
- my $itemdesc = defined $cust_bill_pkg->dbdef_table->column('itemdesc')
- ? ( $cust_bill_pkg->itemdesc || 'Tax' )
- : 'Tax';
- if ( $cust_bill_pkg->setup != 0 ) {
- push @buf, [ $itemdesc,
- $money_char. sprintf("%10.2f", $cust_bill_pkg->setup) ];
- }
- if ( $cust_bill_pkg->recur != 0 ) {
- push @buf, [ "$itemdesc (". time2str("%x", $cust_bill_pkg->sdate). " - "
- . time2str("%x", $cust_bill_pkg->edate). ")",
- $money_char. sprintf("%10.2f", $cust_bill_pkg->recur)
- ];
- }
- }
- }
-
- push @buf,['','-----------'];
- push @buf,['Total New Charges',
- $money_char. sprintf("%10.2f",$self->charged) ];
- push @buf,['',''];
-
- push @buf,['','-----------'];
- push @buf,['Total Charges',
- $money_char. sprintf("%10.2f",$self->charged + $pr_total) ];
- push @buf,['',''];
-
- #credits
- foreach ( $self->cust_credited ) {
-
- #something more elaborate if $_->amount ne $_->cust_credit->credited ?
-
- my $reason = substr($_->cust_credit->reason,0,32);
- $reason .= '...' if length($reason) < length($_->cust_credit->reason);
- $reason = " ($reason) " if $reason;
- push @buf,[
- "Credit #". $_->crednum. " (". time2str("%x",$_->cust_credit->_date) .")".
- $reason,
- $money_char. sprintf("%10.2f",$_->amount)
- ];
- }
- #foreach ( @cr_cust_credit ) {
- # push @buf,[
- # "Credit #". $_->crednum. " (" . time2str("%x",$_->_date) .")",
- # $money_char. sprintf("%10.2f",$_->credited)
- # ];
- #}
-
- #get & print payments
- foreach ( $self->cust_bill_pay ) {
-
- #something more elaborate if $_->amount ne ->cust_pay->paid ?
-
- push @buf,[
- "Payment received ". time2str("%x",$_->cust_pay->_date ),
- $money_char. sprintf("%10.2f",$_->amount )
- ];
- }
-
- #balance due
- my $balance_due_msg = $self->balance_due_msg;
-
- push @buf,['','-----------'];
- push @buf,[$balance_due_msg, $money_char.
- sprintf("%10.2f", $balance_due ) ];
-
- #create the template
- my $templatefile = 'invoice_template';
- $templatefile .= "_$template" if $template;
- my @invoice_template = $conf->config($templatefile)
- or die "cannot load config file $templatefile";
- $invoice_lines = 0;
- my $wasfunc = 0;
- foreach ( grep /invoice_lines\(\d*\)/, @invoice_template ) { #kludgy
- /invoice_lines\((\d*)\)/;
- $invoice_lines += $1 || scalar(@buf);
- $wasfunc=1;
- }
- die "no invoice_lines() functions in template?" unless $wasfunc;
- my $invoice_template = new Text::Template (
- TYPE => 'ARRAY',
- SOURCE => [ map "$_\n", @invoice_template ],
- ) or die "can't create new Text::Template object: $Text::Template::ERROR";
- $invoice_template->compile()
- or die "can't compile template: $Text::Template::ERROR";
-
- #setup template variables
- package FS::cust_bill::_template; #!
- use vars qw( $invnum $date $page $total_pages @address $overdue @buf $agent );
-
- $invnum = $self->invnum;
- $date = $self->_date;
- $page = 1;
- $agent = $self->cust_main->agent->agent;
-
- if ( $FS::cust_bill::invoice_lines ) {
- $total_pages =
- int( scalar(@FS::cust_bill::buf) / $FS::cust_bill::invoice_lines );
- $total_pages++
- if scalar(@FS::cust_bill::buf) % $FS::cust_bill::invoice_lines;
- } else {
- $total_pages = 1;
- }
-
- #format address (variable for the template)
- my $l = 0;
- @address = ( '', '', '', '', '', '' );
- package FS::cust_bill; #!
- $FS::cust_bill::_template::address[$l++] =
- $cust_main->payname.
- ( ( $cust_main->payby eq 'BILL' ) && $cust_main->payinfo
- ? " (P.O. #". $cust_main->payinfo. ")"
- : ''
- )
- ;
- $FS::cust_bill::_template::address[$l++] = $cust_main->company
- if $cust_main->company;
- $FS::cust_bill::_template::address[$l++] = $cust_main->address1;
- $FS::cust_bill::_template::address[$l++] = $cust_main->address2
- if $cust_main->address2;
- $FS::cust_bill::_template::address[$l++] =
- $cust_main->city. ", ". $cust_main->state. " ". $cust_main->zip;
- $FS::cust_bill::_template::address[$l++] = $cust_main->country
- unless $cust_main->country eq 'US';
-
- # #overdue? (variable for the template)
- # $FS::cust_bill::_template::overdue = (
- # $balance_due > 0
- # && $today > $self->_date
- ## && $self->printed > 1
- # && $self->printed > 0
- # );
-
- #and subroutine for the template
- sub FS::cust_bill::_template::invoice_lines {
- my $lines = shift || scalar(@buf);
- map {
- scalar(@buf) ? shift @buf : [ '', '' ];
- }
- ( 1 .. $lines );
- }
-
- #and fill it in
- $FS::cust_bill::_template::page = 1;
- my $lines;
- my @collect;
- while (@buf) {
- push @collect, split("\n",
- $invoice_template->fill_in( PACKAGE => 'FS::cust_bill::_template' )
- );
- $FS::cust_bill::_template::page++;
- }
-
- map "$_\n", @collect;
-
-}
-
-=item print_latex [ TIME [ , TEMPLATE ] ]
-
-Internal method - returns a filename of a filled-in LaTeX template for this
-invoice (Note: add ".tex" to get the actual filename).
-
-See print_ps and print_pdf for methods that return PostScript and PDF output.
-
-TIME an optional value used to control the printing of overdue messages. The
-default is now. It isn't the date of the invoice; that's the `_date' field.
-It is specified as a UNIX timestamp; see L<perlfunc/"time">. Also see
-L<Time::Local> and L<Date::Parse> for conversion functions.
-
-=cut
-
-#still some false laziness w/print_text
-sub print_latex {
-
- my( $self, $today, $template ) = @_;
- $today ||= time;
-
-# my $invnum = $self->invnum;
- my $cust_main = $self->cust_main;
- $cust_main->payname( $cust_main->first. ' '. $cust_main->getfield('last') )
- unless $cust_main->payname && $cust_main->payby ne 'CHEK';
-
- my( $pr_total, @pr_cust_bill ) = $self->previous; #previous balance
-# my( $cr_total, @cr_cust_credit ) = $self->cust_credit; #credits
- #my $balance_due = $self->owed + $pr_total - $cr_total;
- my $balance_due = $self->owed + $pr_total;
-
- #my @collect = ();
- #my($description,$amount);
- @buf = ();
-
- #create the template
- my $templatefile = 'invoice_latex';
- $templatefile .= "_$template" if $template;
- my @invoice_template = $conf->config($templatefile)
- or die "cannot load config file $templatefile";
-
- my %invoice_data = (
- 'invnum' => $self->invnum,
- 'date' => time2str('%b %o, %Y', $self->_date),
- 'agent' => _latex_escape($cust_main->agent->agent),
- 'payname' => _latex_escape($cust_main->payname),
- 'company' => _latex_escape($cust_main->company),
- 'address1' => _latex_escape($cust_main->address1),
- 'address2' => _latex_escape($cust_main->address2),
- 'city' => _latex_escape($cust_main->city),
- 'state' => _latex_escape($cust_main->state),
- 'zip' => _latex_escape($cust_main->zip),
- 'country' => _latex_escape($cust_main->country),
- 'footer' => join("\n", $conf->config('invoice_latexfooter') ),
- 'smallfooter' => join("\n", $conf->config('invoice_latexsmallfooter') ),
- 'quantity' => 1,
- 'terms' => $conf->config('invoice_default_terms') || 'Payable upon receipt',
- #'notes' => join("\n", $conf->config('invoice_latexnotes') ),
- );
-
- my $countrydefault = $conf->config('countrydefault') || 'US';
- $invoice_data{'country'} = '' if $invoice_data{'country'} eq $countrydefault;
-
- #do variable substitutions in notes
- $invoice_data{'notes'} =
- join("\n",
- map { my $b=$_; $b =~ s/\$(\w+)/$invoice_data{$1}/eg; $b }
- $conf->config('invoice_latexnotes')
- );
-
- $invoice_data{'footer'} =~ s/\n+$//;
- $invoice_data{'smallfooter'} =~ s/\n+$//;
- $invoice_data{'notes'} =~ s/\n+$//;
-
- $invoice_data{'po_line'} =
- ( $cust_main->payby eq 'BILL' && $cust_main->payinfo )
- ? _latex_escape("Purchase Order #". $cust_main->payinfo)
- : '~';
-
- my @line_item = ();
- my @total_item = ();
- my @filled_in = ();
- while ( @invoice_template ) {
- my $line = shift @invoice_template;
-
- if ( $line =~ /^%%Detail\s*$/ ) {
-
- while ( ( my $line_item_line = shift @invoice_template )
- !~ /^%%EndDetail\s*$/ ) {
- push @line_item, $line_item_line;
- }
- foreach my $line_item ( $self->_items ) {
- #foreach my $line_item ( $self->_items_pkg ) {
- $invoice_data{'ref'} = $line_item->{'pkgnum'};
- $invoice_data{'description'} = _latex_escape($line_item->{'description'});
- if ( exists $line_item->{'ext_description'} ) {
- $invoice_data{'description'} .=
- "\\tabularnewline\n~~".
- join("\\tabularnewline\n~~", map { _latex_escape($_) } @{$line_item->{'ext_description'}} );
- }
- $invoice_data{'amount'} = $line_item->{'amount'};
- $invoice_data{'product_code'} = $line_item->{'pkgpart'} || 'N/A';
- push @filled_in,
- map { my $b=$_; $b =~ s/\$(\w+)/$invoice_data{$1}/eg; $b } @line_item;
- }
-
- } elsif ( $line =~ /^%%TotalDetails\s*$/ ) {
-
- while ( ( my $total_item_line = shift @invoice_template )
- !~ /^%%EndTotalDetails\s*$/ ) {
- push @total_item, $total_item_line;
- }
-
- my @total_fill = ();
-
- my $taxtotal = 0;
- foreach my $tax ( $self->_items_tax ) {
- $invoice_data{'total_item'} = _latex_escape($tax->{'description'});
- $taxtotal += ( $invoice_data{'total_amount'} = $tax->{'amount'} );
- push @total_fill,
- map { my $b=$_; $b =~ s/\$(\w+)/$invoice_data{$1}/eg; $b }
- @total_item;
- }
-
- if ( $taxtotal ) {
- $invoice_data{'total_item'} = 'Sub-total';
- $invoice_data{'total_amount'} =
- '\dollar '. sprintf('%.2f', $self->charged - $taxtotal );
- unshift @total_fill,
- map { my $b=$_; $b =~ s/\$(\w+)/$invoice_data{$1}/eg; $b }
- @total_item;
- }
-
- $invoice_data{'total_item'} = '\textbf{Total}';
- $invoice_data{'total_amount'} =
- '\textbf{\dollar '. sprintf('%.2f', $self->charged + $pr_total ). '}';
- push @total_fill,
- map { my $b=$_; $b =~ s/\$(\w+)/$invoice_data{$1}/eg; $b }
- @total_item;
-
- #foreach my $thing ( sort { $a->_date <=> $b->_date } $self->_items_credits, $self->_items_payments
-
- # credits
- foreach my $credit ( $self->_items_credits ) {
- $invoice_data{'total_item'} = _latex_escape($credit->{'description'});
- #$credittotal
- $invoice_data{'total_amount'} = '-\dollar '. $credit->{'amount'};
- push @total_fill,
- map { my $b=$_; $b =~ s/\$(\w+)/$invoice_data{$1}/eg; $b }
- @total_item;
- }
-
- # payments
- foreach my $payment ( $self->_items_payments ) {
- $invoice_data{'total_item'} = _latex_escape($payment->{'description'});
- #$paymenttotal
- $invoice_data{'total_amount'} = '-\dollar '. $payment->{'amount'};
- push @total_fill,
- map { my $b=$_; $b =~ s/\$(\w+)/$invoice_data{$1}/eg; $b }
- @total_item;
- }
-
- $invoice_data{'total_item'} = '\textbf{'. $self->balance_due_msg. '}';
- $invoice_data{'total_amount'} =
- '\textbf{\dollar '. sprintf('%.2f', $self->owed + $pr_total ). '}';
- push @total_fill,
- map { my $b=$_; $b =~ s/\$(\w+)/$invoice_data{$1}/eg; $b }
- @total_item;
-
- push @filled_in, @total_fill;
-
- } else {
- #$line =~ s/\$(\w+)/$invoice_data{$1}/eg;
- $line =~ s/\$(\w+)/exists($invoice_data{$1}) ? $invoice_data{$1} : nounder($1)/eg;
- push @filled_in, $line;
- }
-
- }
-
- sub nounder {
- my $var = $1;
- $var =~ s/_/\-/g;
- $var;
- }
-
- my $dir = '/tmp'; #! /usr/local/etc/freeside/invoices.datasrc/
- my $unique = int(rand(2**31)); #UGH... use File::Temp or something
-
- chdir($dir);
- my $file = $self->invnum. ".$unique";
-
- open(TEX,">$file.tex") or die "can't open $file.tex: $!\n";
- print TEX join("\n", @filled_in ), "\n";
- close TEX;
-
- return $file;
-
-}
-
-=item print_ps [ TIME [ , TEMPLATE ] ]
-
-Returns an postscript invoice, as a scalar.
-
-TIME an optional value used to control the printing of overdue messages. The
-default is now. It isn't the date of the invoice; that's the `_date' field.
-It is specified as a UNIX timestamp; see L<perlfunc/"time">. Also see
-L<Time::Local> and L<Date::Parse> for conversion functions.
-
-=cut
-
-sub print_ps {
- my $self = shift;
-
- my $file = $self->print_latex(@_);
-
- #error checking!!
- system('pslatex', "$file.tex");
- system('pslatex', "$file.tex");
- system('dvips', '-q', '-t', 'letter', "$file.dvi", '-o', "$file.ps" );
-
- open(POSTSCRIPT, "<$file.ps")
- or die "can't open $file.ps (probable error in LaTeX template): $!\n";
-
- unlink("$file.dvi", "$file.log", "$file.aux", "$file.ps", "$file.tex");
-
- my $ps = '';
- while (<POSTSCRIPT>) {
- $ps .= $_;
- }
-
- close POSTSCRIPT;
-
- return $ps;
-
-}
-
-=item print_pdf [ TIME [ , TEMPLATE ] ]
-
-Returns an PDF invoice, as a scalar.
-
-TIME an optional value used to control the printing of overdue messages. The
-default is now. It isn't the date of the invoice; that's the `_date' field.
-It is specified as a UNIX timestamp; see L<perlfunc/"time">. Also see
-L<Time::Local> and L<Date::Parse> for conversion functions.
-
-=cut
-
-sub print_pdf {
- my $self = shift;
-
- my $file = $self->print_latex(@_);
-
- #system('pdflatex', "$file.tex");
- #system('pdflatex', "$file.tex");
- #! LaTeX Error: Unknown graphics extension: .eps.
-
- #error checking!!
- system('pslatex', "$file.tex");
- system('pslatex', "$file.tex");
-
- #system('dvipdf', "$file.dvi", "$file.pdf" );
- system("dvips -q -t letter -f $file.dvi | gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=$file.pdf -c save pop -");
-
- open(PDF, "<$file.pdf")
- or die "can't open $file.pdf (probably error in LaTeX tempalte: $!\n";
-
- unlink("$file.dvi", "$file.log", "$file.aux", "$file.pdf", "$file.tex");
-
- my $pdf = '';
- while (<PDF>) {
- $pdf .= $_;
- }
-
- close PDF;
-
- return $pdf;
-
-}
-
-# quick subroutine for print_latex
-#
-# There are ten characters that LaTeX treats as special characters, which
-# means that they do not simply typeset themselves:
-# # $ % & ~ _ ^ \ { }
-#
-# TeX ignores blanks following an escaped character; if you want a blank (as
-# in "10% of ..."), you have to "escape" the blank as well ("10\%\ of ...").
-
-sub _latex_escape {
- my $value = shift;
- $value =~ s/([#\$%&~_\^{}])( )?/"\\$1". ( length($2) ? "\\$2" : '' )/ge;
- $value;
-}
-
-#utility methods for print_*
-
-sub balance_due_msg {
- my $self = shift;
- my $msg = 'Balance Due';
- return $msg unless $conf->exists('invoice_default_terms');
- if ( $conf->config('invoice_default_terms') =~ /^\s*Net\s*(\d+)\s*$/ ) {
- $msg .= ' - Please pay by '. time2str("%x", $self->_date + ($1*86400) );
- } elsif ( $conf->config('invoice_default_terms') ) {
- $msg .= ' - '. $conf->config('invoice_default_terms');
- }
- $msg;
-}
-
-sub _items {
- my $self = shift;
- my @display = scalar(@_)
- ? @_
- : qw( _items_previous _items_pkg );
- #: qw( _items_pkg );
- #: qw( _items_previous _items_pkg _items_tax _items_credits _items_payments );
- my @b = ();
- foreach my $display ( @display ) {
- push @b, $self->$display(@_);
- }
- @b;
-}
-
-sub _items_previous {
- my $self = shift;
- my $cust_main = $self->cust_main;
- my( $pr_total, @pr_cust_bill ) = $self->previous; #previous balance
- my @b = ();
- foreach ( @pr_cust_bill ) {
- push @b, {
- 'description' => 'Previous Balance, Invoice #'. $_->invnum.
- ' ('. time2str('%x',$_->_date). ')',
- #'pkgpart' => 'N/A',
- 'pkgnum' => 'N/A',
- 'amount' => sprintf("%10.2f", $_->owed),
- };
- }
- @b;
-
- #{
- # 'description' => 'Previous Balance',
- # #'pkgpart' => 'N/A',
- # 'pkgnum' => 'N/A',
- # 'amount' => sprintf("%10.2f", $pr_total ),
- # 'ext_description' => [ map {
- # "Invoice ". $_->invnum.
- # " (". time2str("%x",$_->_date). ") ".
- # sprintf("%10.2f", $_->owed)
- # } @pr_cust_bill ],
-
- #};
-}
-
-sub _items_pkg {
- my $self = shift;
- my @cust_bill_pkg = grep { $_->pkgnum } $self->cust_bill_pkg;
- $self->_items_cust_bill_pkg(\@cust_bill_pkg, @_);
-}
-
-sub _items_tax {
- my $self = shift;
- my @cust_bill_pkg = grep { ! $_->pkgnum } $self->cust_bill_pkg;
- $self->_items_cust_bill_pkg(\@cust_bill_pkg, @_);
-}
-
-sub _items_cust_bill_pkg {
- my $self = shift;
- my $cust_bill_pkg = shift;
-
- my @b = ();
- foreach my $cust_bill_pkg ( @$cust_bill_pkg ) {
-
- if ( $cust_bill_pkg->pkgnum ) {
-
- my $cust_pkg = qsearchs('cust_pkg', { pkgnum =>$cust_bill_pkg->pkgnum } );
- my $part_pkg = qsearchs('part_pkg', { pkgpart=>$cust_pkg->pkgpart } );
- my $pkg = $part_pkg->pkg;
-
- my %labels;
- #tie %labels, 'Tie::IxHash';
- push @{ $labels{$_->[0]} }, $_->[1] foreach $cust_pkg->labels;
- my @ext_description;
- foreach my $label ( keys %labels ) {
- my @values = @{ $labels{$label} };
- my $num = scalar(@values);
- if ( $num > 5 ) {
- push @ext_description, "$label ($num)";
- } else {
- push @ext_description, map { "$label: $_" } @values;
- }
- }
-
- if ( $cust_bill_pkg->setup != 0 ) {
- my $description = $pkg;
- $description .= ' Setup' if $cust_bill_pkg->recur != 0;
- my @d = @ext_description;
- push @d, $cust_bill_pkg->details if $cust_bill_pkg->recur == 0;
- push @b, {
- 'description' => $description,
- #'pkgpart' => $part_pkg->pkgpart,
- 'pkgnum' => $cust_pkg->pkgnum,
- 'amount' => sprintf("%10.2f", $cust_bill_pkg->setup),
- 'ext_description' => \@d,
- };
- }
-
- if ( $cust_bill_pkg->recur != 0 ) {
- push @b, {
- 'description' => "$pkg (" .
- time2str('%x', $cust_bill_pkg->sdate). ' - '.
- time2str('%x', $cust_bill_pkg->edate). ')',
- #'pkgpart' => $part_pkg->pkgpart,
- 'pkgnum' => $cust_pkg->pkgnum,
- 'amount' => sprintf("%10.2f", $cust_bill_pkg->recur),
- 'ext_description' => [ @ext_description,
- $cust_bill_pkg->details,
- ],
- };
- }
-
- } else { #pkgnum tax or one-shot line item (??)
-
- my $itemdesc = defined $cust_bill_pkg->dbdef_table->column('itemdesc')
- ? ( $cust_bill_pkg->itemdesc || 'Tax' )
- : 'Tax';
- if ( $cust_bill_pkg->setup != 0 ) {
- push @b, {
- 'description' => $itemdesc,
- 'amount' => sprintf("%10.2f", $cust_bill_pkg->setup),
- };
- }
- if ( $cust_bill_pkg->recur != 0 ) {
- push @b, {
- 'description' => "$itemdesc (".
- time2str("%x", $cust_bill_pkg->sdate). ' - '.
- time2str("%x", $cust_bill_pkg->edate). ')',
- 'amount' => sprintf("%10.2f", $cust_bill_pkg->recur),
- };
- }
-
- }
-
- }
-
- @b;
-
-}
-
-sub _items_credits {
- my $self = shift;
-
- my @b;
- #credits
- foreach ( $self->cust_credited ) {
-
- #something more elaborate if $_->amount ne $_->cust_credit->credited ?
-
- my $reason = $_->cust_credit->reason;
- #my $reason = substr($_->cust_credit->reason,0,32);
- #$reason .= '...' if length($reason) < length($_->cust_credit->reason);
- $reason = " ($reason) " if $reason;
- push @b, {
- #'description' => 'Credit ref\#'. $_->crednum.
- # " (". time2str("%x",$_->cust_credit->_date) .")".
- # $reason,
- 'description' => 'Credit applied'.
- time2str("%x",$_->cust_credit->_date). $reason,
- 'amount' => sprintf("%10.2f",$_->amount),
- };
- }
- #foreach ( @cr_cust_credit ) {
- # push @buf,[
- # "Credit #". $_->crednum. " (" . time2str("%x",$_->_date) .")",
- # $money_char. sprintf("%10.2f",$_->credited)
- # ];
- #}
-
- @b;
-
-}
-
-sub _items_payments {
- my $self = shift;
-
- my @b;
- #get & print payments
- foreach ( $self->cust_bill_pay ) {
-
- #something more elaborate if $_->amount ne ->cust_pay->paid ?
-
- push @b, {
- 'description' => "Payment received ".
- time2str("%x",$_->cust_pay->_date ),
- 'amount' => sprintf("%10.2f", $_->amount )
- };
- }
-
- @b;
-
-}
-
-=back
-
-=head1 BUGS
-
-The delete method.
-
-print_text formatting (and some logic :/) is in source, but needs to be
-slurped in from a file. Also number of lines ($=).
-
-missing print_ps for a nice postscript copy (maybe HylaFAX-cover-page-style
-or something similar so the look can be completely customized?)
-
-=head1 SEE ALSO
-
-L<FS::Record>, L<FS::cust_main>, L<FS::cust_bill_pay>, L<FS::cust_pay>,
-L<FS::cust_bill_pkg>, L<FS::cust_bill_credit>, schema.html from the base
-documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/cust_bill_event.pm b/FS/FS/cust_bill_event.pm
deleted file mode 100644
index ddd6762..0000000
--- a/FS/FS/cust_bill_event.pm
+++ /dev/null
@@ -1,180 +0,0 @@
-package FS::cust_bill_event;
-
-use strict;
-use vars qw( @ISA );
-use FS::Record qw( qsearch qsearchs );
-use FS::cust_bill;
-use FS::part_bill_event;
-
-@ISA = qw(FS::Record);
-
-=head1 NAME
-
-FS::cust_bill_event - Object methods for cust_bill_event records
-
-=head1 SYNOPSIS
-
- use FS::cust_bill_event;
-
- $record = new FS::cust_bill_event \%hash;
- $record = new FS::cust_bill_event { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
-=head1 DESCRIPTION
-
-An FS::cust_bill_event object represents an complete invoice event.
-FS::cust_bill_event inherits from FS::Record. The following fields are
-currently supported:
-
-=over 4
-
-=item eventnum - primary key
-
-=item invnum - invoice (see L<FS::cust_bill>)
-
-=item eventpart - event definition (see L<FS::part_bill_event>)
-
-=item _date - specified as a UNIX timestamp; see L<perlfunc/"time">. Also see
-L<Time::Local> and L<Date::Parse> for conversion functions.
-
-=item status - event status: B<done> or B<failed>
-
-=item statustext - additional status detail (i.e. error message)
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new completed invoice event. To add the compelted invoice event 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 { 'cust_bill_event'; }
-
-=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 completed invoice event. 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;
-
- my $error = $self->ut_numbern('eventnum')
- || $self->ut_number('invnum')
- || $self->ut_number('eventpart')
- || $self->ut_number('_date')
- || $self->ut_enum('status', [qw( done failed )])
- || $self->ut_textn('statustext')
- ;
-
- return "Unknown invnum ". $self->invnum
- unless qsearchs( 'cust_bill' ,{ 'invnum' => $self->invnum } );
-
- return "Unknown eventpart ". $self->eventpart
- unless qsearchs( 'part_bill_event' ,{ 'eventpart' => $self->eventpart } );
-
- $self->SUPER::check;
-}
-
-=item part_bill_event
-
-Returns the invoice event definition (see L<FS::part_bill_event>) for this
-completed invoice event.
-
-=cut
-
-sub part_bill_event {
- my $self = shift;
- qsearchs( 'part_bill_event', { 'eventpart' => $self->eventpart } );
-}
-
-=item cust_bill
-
-Returns the invoice (see L<FS::cust_bill>) for this completed invoice event.
-
-=cut
-
-sub cust_bill {
- my $self = shift;
- qsearchs( 'cust_bill', { 'invnum' => $self->invnum } );
-}
-
-=item retry
-
-Changes the status of this event from B<done> to B<failed>, allowing it to be
-retried.
-
-=cut
-
-sub retry {
- my $self = shift;
- return '' unless $self->status eq 'done';
- my $old = ref($self)->new( { $self->hash } );
- $self->status('failed');
- $self->replace($old);
-}
-
-=back
-
-=head1 BUGS
-
-Far too early in the morning.
-
-=head1 SEE ALSO
-
-L<FS::part_bill_event>, L<FS::cust_bill>, L<FS::Record>, schema.html from the
-base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/cust_bill_pay.pm b/FS/FS/cust_bill_pay.pm
deleted file mode 100644
index c8b5525..0000000
--- a/FS/FS/cust_bill_pay.pm
+++ /dev/null
@@ -1,226 +0,0 @@
-package FS::cust_bill_pay;
-
-use strict;
-use vars qw( @ISA $conf );
-use FS::Record qw( qsearch qsearchs dbh );
-use FS::cust_bill;
-use FS::cust_pay;
-
-@ISA = qw( FS::Record );
-
-#ask FS::UID to run this stuff for us later
-FS::UID->install_callback( sub {
- $conf = new FS::Conf;
-} );
-
-=head1 NAME
-
-FS::cust_bill_pay - Object methods for cust_bill_pay records
-
-=head1 SYNOPSIS
-
- use FS::cust_bill_pay;
-
- $record = new FS::cust_bill_pay \%hash;
- $record = new FS::cust_bill_pay { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
-=head1 DESCRIPTION
-
-An FS::cust_bill_pay object represents the application of a payment to a
-specific invoice. FS::cust_bill_pay inherits from FS::Record. The following
-fields are currently supported:
-
-=over 4
-
-=item billpaynum - primary key (assigned automatically)
-
-=item invnum - Invoice (see L<FS::cust_bill>)
-
-=item paynum - Payment (see L<FS::cust_pay>)
-
-=item amount - Amount of the payment to apply to the specific invoice.
-
-=item _date - specified as a UNIX timestamp; see L<perlfunc/"time">. Also see
-L<Time::Local> and L<Date::Parse> for conversion functions.
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new record. To add the record to the database, see L<"insert">.
-
-=cut
-
-sub table { 'cust_bill_pay'; }
-
-=item insert
-
-Adds this record to the database. If there is an error, returns the error,
-otherwise returns false.
-
-=cut
-
-sub insert {
- my $self = shift;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- my $error = $self->check;
- return $error if $error;
-
- $error = $self->SUPER::insert;
-
- my $cust_pay = qsearchs('cust_pay', { 'paynum' => $self->paynum } ) or do {
- $dbh->rollback if $oldAutoCommit;
- return "unknown cust_pay.paynum: ". $self->paynum;
- };
-
- my $pay_total = 0;
- $pay_total += $_ foreach map { $_->amount }
- qsearch('cust_bill_pay', { 'paynum' => $self->paynum } );
-
- if ( sprintf("%.2f", $pay_total) > sprintf("%.2f", $cust_pay->paid) ) {
- $dbh->rollback if $oldAutoCommit;
- return "total cust_bill_pay.amount $pay_total for paynum ". $self->paynum.
- " greater than cust_pay.paid ". $cust_pay->paid;
- }
-
- my $cust_bill = $self->cust_bill;
- unless ( $cust_bill ) {
- $dbh->rollback if $oldAutoCommit;
- return "unknown cust_bill.invnum: ". $self->invnum;
- };
-
- my $bill_total = 0;
- $bill_total += $_ foreach map { $_->amount }
- qsearch('cust_bill_pay', { 'invnum' => $self->invnum } );
- $bill_total += $_ foreach map { $_->amount }
- qsearch('cust_credit_bill', { 'invnum' => $self->invnum } );
- if ( sprintf("%.2f", $bill_total) > sprintf("%.2f", $cust_bill->charged) ) {
- $dbh->rollback if $oldAutoCommit;
- return "total cust_bill_pay.amount and cust_credit_bill.amount $bill_total".
- " for invnum ". $self->invnum.
- " greater than cust_bill.charged ". $cust_bill->charged;
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
-
- if ( $conf->exists('invoice_send_receipts') ) {
- my $send_error = $cust_bill->send;
- warn "Error sending receipt: $send_error\n" if $send_error;
- }
-
- '';
-}
-
-=item delete
-
-Deletes this payment application, unless the closed flag for the parent payment
-(see L<FS::cust_pay>) is set.
-
-=cut
-
-sub delete {
- my $self = shift;
- return "Can't delete application for closed payment"
- if $self->cust_pay->closed =~ /^Y/i;
- $self->SUPER::delete(@_);
-}
-
-=item replace OLD_RECORD
-
-Currently unimplemented (accounting reasons).
-
-=cut
-
-sub replace {
- return "Can't (yet?) modify cust_bill_pay records!";
-}
-
-=item check
-
-Checks all fields to make sure this is a valid payment. If there is an error,
-returns the error, otherwise returns false. Called by the insert method.
-
-=cut
-
-sub check {
- my $self = shift;
-
- my $error =
- $self->ut_numbern('billpaynum')
- || $self->ut_number('invnum')
- || $self->ut_number('paynum')
- || $self->ut_money('amount')
- || $self->ut_numbern('_date')
- ;
- return $error if $error;
-
- return "amount must be > 0" if $self->amount <= 0;
-
- $self->_date(time) unless $self->_date;
-
- $self->SUPER::check;
-}
-
-=item cust_pay
-
-Returns the payment (see L<FS::cust_pay>)
-
-=cut
-
-sub cust_pay {
- my $self = shift;
- qsearchs( 'cust_pay', { 'paynum' => $self->paynum } );
-}
-
-=item cust_bill
-
-Returns the invoice (see L<FS::cust_bill>)
-
-=cut
-
-sub cust_bill {
- my $self = shift;
- qsearchs( 'cust_bill', { 'invnum' => $self->invnum } );
-}
-
-=back
-
-=head1 BUGS
-
-Delete and replace methods.
-
-the checks for over-applied payments could be better done like the ones in
-cust_bill_credit
-
-=head1 SEE ALSO
-
-L<FS::cust_pay>, L<FS::cust_bill>, L<FS::Record>, schema.html from the
-base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/cust_bill_pkg.pm b/FS/FS/cust_bill_pkg.pm
deleted file mode 100644
index 6800707..0000000
--- a/FS/FS/cust_bill_pkg.pm
+++ /dev/null
@@ -1,215 +0,0 @@
-package FS::cust_bill_pkg;
-
-use strict;
-use vars qw( @ISA );
-use FS::Record qw( qsearch qsearchs dbdef dbh );
-use FS::cust_pkg;
-use FS::cust_bill;
-use FS::cust_bill_pkg_detail;
-
-@ISA = qw( FS::Record );
-
-=head1 NAME
-
-FS::cust_bill_pkg - Object methods for cust_bill_pkg records
-
-=head1 SYNOPSIS
-
- use FS::cust_bill_pkg;
-
- $record = new FS::cust_bill_pkg \%hash;
- $record = new FS::cust_bill_pkg { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
-=head1 DESCRIPTION
-
-An FS::cust_bill_pkg object represents an invoice line item.
-FS::cust_bill_pkg inherits from FS::Record. The following fields are currently
-supported:
-
-=over 4
-
-=item invnum - invoice (see L<FS::cust_bill>)
-
-=item pkgnum - package (see L<FS::cust_pkg>) or 0 for the special virtual sales tax package
-
-=item setup - setup fee
-
-=item recur - recurring fee
-
-=item sdate - starting date of recurring fee
-
-=item edate - ending date of recurring fee
-
-=item itemdesc - Line item description (currentlty used only when pkgnum is 0)
-
-=back
-
-sdate and edate are specified as UNIX timestamps; see L<perlfunc/"time">. Also
-see L<Time::Local> and L<Date::Parse> for conversion functions.
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new line item. To add the line item to the database, see
-L<"insert">. Line items are normally created by calling the bill method of a
-customer object (see L<FS::cust_main>).
-
-=cut
-
-sub table { 'cust_bill_pkg'; }
-
-=item insert
-
-Adds this line item to the database. If there is an error, returns the error,
-otherwise returns false.
-
-=cut
-
-sub insert {
- my $self = shift;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- my $error = $self->SUPER::insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- unless ( defined dbdef->table('cust_bill_pkg_detail') && $self->get('details') ) {
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
- return '';
- }
-
- foreach my $detail ( @{$self->get('details')} ) {
- my $cust_bill_pkg_detail = new FS::cust_bill_pkg_detail {
- 'pkgnum' => $self->pkgnum,
- 'invnum' => $self->invnum,
- 'detail' => $detail,
- };
- $error = $cust_bill_pkg_detail->insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
- '';
-
-}
-
-=item delete
-
-Currently unimplemented. I don't remove line items because there would then be
-no record the items ever existed (which is bad, no?)
-
-=cut
-
-sub delete {
- return "Can't delete cust_bill_pkg records!";
-}
-
-=item replace OLD_RECORD
-
-Currently unimplemented. This would be even more of an accounting nightmare
-than deleteing the items. Just don't do it.
-
-=cut
-
-sub replace {
- return "Can't modify cust_bill_pkg records!";
-}
-
-=item check
-
-Checks all fields to make sure this is a valid line item. If there is an
-error, returns the error, otherwise returns false. Called by the insert
-method.
-
-=cut
-
-sub check {
- my $self = shift;
-
- my $error =
- $self->ut_number('pkgnum')
- || $self->ut_number('invnum')
- || $self->ut_money('setup')
- || $self->ut_money('recur')
- || $self->ut_numbern('sdate')
- || $self->ut_numbern('edate')
- || $self->ut_textn('itemdesc')
- ;
- return $error if $error;
-
- if ( $self->pkgnum != 0 ) { #allow unchecked pkgnum 0 for tax! (add to part_pkg?)
- return "Unknown pkgnum ". $self->pkgnum
- unless qsearchs( 'cust_pkg', { 'pkgnum' => $self->pkgnum } );
- }
-
- return "Unknown invnum"
- unless qsearchs( 'cust_bill' ,{ 'invnum' => $self->invnum } );
-
- $self->SUPER::check;
-}
-
-=item cust_pkg
-
-Returns the package (see L<FS::cust_pkg>) for this invoice line item.
-
-=cut
-
-sub cust_pkg {
- my $self = shift;
- qsearchs( 'cust_pkg', { 'pkgnum' => $self->pkgnum } );
-}
-
-=item details
-
-Returns an array of detail information for the invoice line item.
-
-=cut
-
-sub details {
- my $self = shift;
- return () unless defined dbdef->table('cust_bill_pkg_detail');
- map { $_->detail }
- qsearch ( 'cust_bill_pkg_detail', { 'pkgnum' => $self->pkgnum,
- 'invnum' => $self->invnum, } );
- #qsearch ( 'cust_bill_pkg_detail', { 'lineitemnum' => $self->lineitemnum });
-}
-
-=back
-
-=head1 BUGS
-
-=head1 SEE ALSO
-
-L<FS::Record>, L<FS::cust_bill>, L<FS::cust_pkg>, L<FS::cust_main>, schema.html
-from the base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/cust_bill_pkg_detail.pm b/FS/FS/cust_bill_pkg_detail.pm
deleted file mode 100644
index 261aa80..0000000
--- a/FS/FS/cust_bill_pkg_detail.pm
+++ /dev/null
@@ -1,124 +0,0 @@
-package FS::cust_bill_pkg_detail;
-
-use strict;
-use vars qw( @ISA );
-use FS::Record qw( qsearch qsearchs );
-
-@ISA = qw(FS::Record);
-
-=head1 NAME
-
-FS::cust_bill_pkg_detail - Object methods for cust_bill_pkg_detail records
-
-=head1 SYNOPSIS
-
- use FS::cust_bill_pkg_detail;
-
- $record = new FS::cust_bill_pkg_detail \%hash;
- $record = new FS::cust_bill_pkg_detail { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
-=head1 DESCRIPTION
-
-An FS::cust_bill_pkg_detail object represents additional detail information for
-an invoice line item (see L<FS::cust_bill_pkg>). FS::cust_bill_pkg_detail
-inherits from FS::Record. The following fields are currently supported:
-
-=over 4
-
-=item detailnum - primary key
-
-=item pkgnum -
-
-=item invnum -
-
-=item detail - detail description
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new line item detail. To add the line item detail 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 { 'cust_bill_pkg_detail'; }
-
-=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 line item detail. 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;
-
- $self->ut_numbern('detailnum')
- || $self->ut_foreign_key('pkgnum', 'cust_pkg', 'pkgnum')
- || $self->ut_foreign_key('invnum', 'cust_pkg', 'invnum')
- || $self->ut_text('detail')
- || $self->SUPER::check
- ;
-
-}
-
-=back
-
-=head1 BUGS
-
-=head1 SEE ALSO
-
-L<FS::cust_bill_pkg>, L<FS::Record>, schema.html from the base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/cust_credit.pm b/FS/FS/cust_credit.pm
deleted file mode 100644
index 19a5453..0000000
--- a/FS/FS/cust_credit.pm
+++ /dev/null
@@ -1,318 +0,0 @@
-package FS::cust_credit;
-
-use strict;
-use vars qw( @ISA $conf $unsuspendauto );
-use Date::Format;
-use FS::UID qw( dbh getotaker );
-use FS::Record qw( qsearch qsearchs );
-use FS::Misc qw(send_email);
-use FS::cust_main;
-use FS::cust_refund;
-use FS::cust_credit_bill;
-
-@ISA = qw( FS::Record );
-
-#ask FS::UID to run this stuff for us later
-$FS::UID::callback{'FS::cust_credit'} = sub {
-
- $conf = new FS::Conf;
- $unsuspendauto = $conf->exists('unsuspendauto');
-
-};
-
-=head1 NAME
-
-FS::cust_credit - Object methods for cust_credit records
-
-=head1 SYNOPSIS
-
- use FS::cust_credit;
-
- $record = new FS::cust_credit \%hash;
- $record = new FS::cust_credit { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
-=head1 DESCRIPTION
-
-An FS::cust_credit object represents a credit; the equivalent of a negative
-B<cust_bill> record (see L<FS::cust_bill>). FS::cust_credit inherits from
-FS::Record. The following fields are currently supported:
-
-=over 4
-
-=item crednum - primary key (assigned automatically for new credits)
-
-=item custnum - customer (see L<FS::cust_main>)
-
-=item amount - amount of the credit
-
-=item _date - specified as a UNIX timestamp; see L<perlfunc/"time">. Also see
-L<Time::Local> and L<Date::Parse> for conversion functions.
-
-=item otaker - order taker (assigned automatically, see L<FS::UID>)
-
-=item reason - text
-
-=item closed - books closed flag, empty or `Y'
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new credit. To add the credit to the database, see L<"insert">.
-
-=cut
-
-sub table { 'cust_credit'; }
-
-=item insert
-
-Adds this credit to the database ("Posts" the credit). If there is an error,
-returns the error, otherwise returns false.
-
-=cut
-
-sub insert {
- my $self = shift;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- my $cust_main = qsearchs( 'cust_main', { 'custnum' => $self->custnum } );
- my $old_balance = $cust_main->balance;
-
- my $error = $self->SUPER::insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "error inserting $self: $error";
- }
-
- #false laziness w/ cust_credit::insert
- if ( $unsuspendauto && $old_balance && $cust_main->balance <= 0 ) {
- my @errors = $cust_main->unsuspend;
- #return
- # side-fx with nested transactions? upstack rolls back?
- warn "WARNING:Errors unsuspending customer ". $cust_main->custnum. ": ".
- join(' / ', @errors)
- if @errors;
- }
- #eslaf
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
-
- '';
-
-}
-
-=item delete
-
-Currently unimplemented.
-
-=cut
-
-sub delete {
- my $self = shift;
- return "Can't delete closed credit" if $self->closed =~ /^Y/i;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- foreach my $cust_credit_bill ( $self->cust_credit_bill ) {
- my $error = $cust_credit_bill->delete;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
-
- my $error = $self->SUPER::delete(@_);
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- if ( $conf->config('deletecredits') ne '' ) {
-
- my $cust_main = qsearchs('cust_main',{ 'custnum' => $self->custnum });
-
- my $error = send_email(
- 'from' => $conf->config('invoice_from'), #??? well as good as any
- 'to' => $conf->config('deletecredits'),
- 'subject' => 'FREESIDE NOTIFICATION: Credit deleted',
- 'body' => [
- "This is an automatic message from your Freeside installation\n",
- "informing you that the following credit has been deleted:\n",
- "\n",
- 'crednum: '. $self->crednum. "\n",
- 'custnum: '. $self->custnum.
- " (". $cust_main->last. ", ". $cust_main->first. ")\n",
- 'amount: $'. sprintf("%.2f", $self->amount). "\n",
- 'date: '. time2str("%a %b %e %T %Y", $self->_date). "\n",
- 'reason: '. $self->reason. "\n",
- ],
- );
-
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "can't send credit deletion notification: $error";
- }
-
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
-
- '';
-
-}
-
-=item replace OLD_RECORD
-
-Credits may not be modified; there would then be no record the credit was ever
-posted.
-
-=cut
-
-sub replace {
- #return "Can't modify credit!"
- my $self = shift;
- return "Can't modify closed credit" if $self->closed =~ /^Y/i;
- $self->SUPER::replace(@_);
-}
-
-=item check
-
-Checks all fields to make sure this is a valid credit. If there is an error,
-returns the error, otherwise returns false. Called by the insert and replace
-methods.
-
-=cut
-
-sub check {
- my $self = shift;
-
- my $error =
- $self->ut_numbern('crednum')
- || $self->ut_number('custnum')
- || $self->ut_numbern('_date')
- || $self->ut_money('amount')
- || $self->ut_textn('reason')
- || $self->ut_enum('closed', [ '', 'Y' ])
- ;
- return $error if $error;
-
- return "amount must be > 0 " if $self->amount <= 0;
-
- return "Unknown customer"
- unless qsearchs( 'cust_main', { 'custnum' => $self->custnum } );
-
- $self->_date(time) unless $self->_date;
-
- $self->otaker(getotaker);
-
- $self->SUPER::check;
-}
-
-=item cust_refund
-
-Depreciated. See the cust_credit_refund method.
-
-#Returns all refunds (see L<FS::cust_refund>) for this credit.
-
-=cut
-
-sub cust_refund {
- use Carp;
- croak "FS::cust_credit->cust_pay depreciated; see ".
- "FS::cust_credit->cust_credit_refund";
- #my $self = shift;
- #sort { $a->_date <=> $b->_date }
- # qsearch( 'cust_refund', { 'crednum' => $self->crednum } )
- #;
-}
-
-=item cust_credit_refund
-
-Returns all refund applications (see L<FS::cust_credit_refund>) for this credit.
-
-=cut
-
-sub cust_credit_refund {
- my $self = shift;
- sort { $a->_date <=> $b->_date }
- qsearch( 'cust_credit_refund', { 'crednum' => $self->crednum } )
- ;
-}
-
-=item cust_credit_bill
-
-Returns all application to invoices (see L<FS::cust_credit_bill>) for this
-credit.
-
-=cut
-
-sub cust_credit_bill {
- my $self = shift;
- sort { $a->_date <=> $b->_date }
- qsearch( 'cust_credit_bill', { 'crednum' => $self->crednum } )
- ;
-}
-
-=item credited
-
-Returns the amount of this credit that is still outstanding; which is
-amount minus all refund applications (see L<FS::cust_credit_refund>) and
-applications to invoices (see L<FS::cust_credit_bill>).
-
-=cut
-
-sub credited {
- my $self = shift;
- my $amount = $self->amount;
- $amount -= $_->amount foreach ( $self->cust_credit_refund );
- $amount -= $_->amount foreach ( $self->cust_credit_bill );
- sprintf( "%.2f", $amount );
-}
-
-=back
-
-=head1 BUGS
-
-The delete method. The replace method.
-
-=head1 SEE ALSO
-
-L<FS::Record>, L<FS::cust_credit_refund>, L<FS::cust_refund>,
-L<FS::cust_credit_bill> L<FS::cust_bill>, schema.html from the base
-documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/cust_credit_bill.pm b/FS/FS/cust_credit_bill.pm
deleted file mode 100644
index bd76c2e..0000000
--- a/FS/FS/cust_credit_bill.pm
+++ /dev/null
@@ -1,192 +0,0 @@
-package FS::cust_credit_bill;
-
-use strict;
-use vars qw( @ISA $conf );
-use FS::UID qw( getotaker );
-use FS::Record qw( qsearch qsearchs );
-use FS::cust_main;
-#use FS::cust_refund;
-use FS::cust_credit;
-use FS::cust_bill;
-
-@ISA = qw( FS::Record );
-
-#ask FS::UID to run this stuff for us later
-FS::UID->install_callback( sub {
- $conf = new FS::Conf;
-} );
-
-=head1 NAME
-
-FS::cust_credit_bill - Object methods for cust_credit_bill records
-
-=head1 SYNOPSIS
-
- use FS::cust_credit_bill;
-
- $record = new FS::cust_credit_bill \%hash;
- $record = new FS::cust_credit_bill { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
-=head1 DESCRIPTION
-
-An FS::cust_credit_bill object represents application of a credit (see
-L<FS::cust_credit>) to an invoice (see L<FS::cust_bill>). FS::cust_credit
-inherits from FS::Record. The following fields are currently supported:
-
-=over 4
-
-=item creditbillnum - primary key
-
-=item crednum - credit being applied
-
-=item invnum - invoice to which credit is applied (see L<FS::cust_bill>)
-
-=item amount - amount of the credit applied
-
-=item _date - specified as a UNIX timestamp; see L<perlfunc/"time">. Also see
-L<Time::Local> and L<Date::Parse> for conversion functions.
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new cust_credit_bill. To add the cust_credit_bill to the database,
-see L<"insert">.
-
-=cut
-
-sub table { 'cust_credit_bill'; }
-
-=item insert
-
-Adds this cust_credit_bill to the database ("Posts" all or part of a credit).
-If there is an error, returns the error, otherwise returns false.
-
-=cut
-
-sub insert {
- my $self = shift;
- my $error = $self->SUPER::insert(@_);
- return $error if $error;
-
- if ( $conf->exists('invoice_send_receipts') ) {
- my $send_error = $self->cust_bill->send;
- warn "Error sending receipt: $send_error\n" if $send_error;
- }
-
- '';
-}
-
-=item delete
-
-Currently unimplemented.
-
-=cut
-
-sub delete {
- my $self = shift;
- return "Can't delete application for closed credit"
- if $self->cust_credit->closed =~ /^Y/i;
- $self->SUPER::delete(@_);
-}
-
-=item replace OLD_RECORD
-
-Application of credits may not be modified.
-
-=cut
-
-sub replace {
- return "Can't modify application of credit!"
-}
-
-=item check
-
-Checks all fields to make sure this is a valid credit application. If there
-is an error, returns the error, otherwise returns false. Called by the insert
-and replace methods.
-
-=cut
-
-sub check {
- my $self = shift;
-
- my $error =
- $self->ut_numbern('creditbillnum')
- || $self->ut_number('crednum')
- || $self->ut_number('invnum')
- || $self->ut_numbern('_date')
- || $self->ut_money('amount')
- ;
- return $error if $error;
-
- return "amount must be > 0" if $self->amount <= 0;
-
- return "Unknown credit"
- unless my $cust_credit =
- qsearchs( 'cust_credit', { 'crednum' => $self->crednum } );
-
- return "Unknown invoice"
- unless my $cust_bill =
- qsearchs( 'cust_bill', { 'invnum' => $self->invnum } );
-
- $self->_date(time) unless $self->_date;
-
- return "Cannot apply more than remaining value of credit"
- unless $self->amount <= $cust_credit->credited;
-
- return "Cannot apply more than remaining value of invoice"
- unless $self->amount <= $cust_bill->owed;
-
- $self->SUPER::check;
-}
-
-=item sub cust_credit
-
-Returns the credit (see L<FS::cust_credit>)
-
-=cut
-
-sub cust_credit {
- my $self = shift;
- qsearchs( 'cust_credit', { 'crednum' => $self->crednum } );
-}
-
-=item cust_bill
-
-Returns the invoice (see L<FS::cust_bill>)
-
-=cut
-
-sub cust_bill {
- my $self = shift;
- qsearchs( 'cust_bill', { 'invnum' => $self->invnum } );
-}
-
-=back
-
-=head1 BUGS
-
-The delete method.
-
-=head1 SEE ALSO
-
-L<FS::Record>, L<FS::cust_refund>, L<FS::cust_bill>, L<FS::cust_credit>,
-schema.html from the base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/cust_credit_refund.pm b/FS/FS/cust_credit_refund.pm
deleted file mode 100644
index d0deae2..0000000
--- a/FS/FS/cust_credit_refund.pm
+++ /dev/null
@@ -1,205 +0,0 @@
-package FS::cust_credit_refund;
-
-use strict;
-use vars qw( @ISA );
-use FS::Record qw( qsearch qsearchs dbh );
-#use FS::UID qw(getotaker);
-use FS::cust_credit;
-use FS::cust_refund;
-
-@ISA = qw( FS::Record );
-
-=head1 NAME
-
-FS::cust_credit_refund - Object methods for cust_bill_pay records
-
-=head1 SYNOPSIS
-
- use FS::cust_credit_refund;
-
- $record = new FS::cust_credit_refund \%hash;
- $record = new FS::cust_credit_refund { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
-=head1 DESCRIPTION
-
-An FS::cust_credit_refund represents the application of a refund to a specific
-credit. FS::cust_credit_refund inherits from FS::Record. The following fields
-are currently supported:
-
-=over 4
-
-=item creditrefundnum - primary key (assigned automatically)
-
-=item crednum - Credit (see L<FS::cust_credit>)
-
-=item refundnum - Refund (see L<FS::cust_refund>)
-
-=item amount - Amount of the refund to apply to the specific credit.
-
-=item _date - specified as a UNIX timestamp; see L<perlfunc/"time">. Also see
-L<Time::Local> and L<Date::Parse> for conversion functions.
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new record. To add the record to the database, see L<"insert">.
-
-=cut
-
-sub table { 'cust_credit_refund'; }
-
-=item insert
-
-Adds this record to the database. If there is an error, returns the error,
-otherwise returns false.
-
-=cut
-
-sub insert {
- my $self = shift;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- my $error = $self->check;
- return $error if $error;
-
- $error = $self->SUPER::insert;
-
- my $cust_refund =
- qsearchs('cust_refund', { 'refundnum' => $self->refundnum } )
- or do {
- $dbh->rollback if $oldAutoCommit;
- return "unknown cust_refund.refundnum: ". $self->refundnum
- };
-
- my $refund_total = 0;
- $refund_total += $_ foreach map { $_->amount }
- qsearch('cust_credit_refund', { 'refundnum' => $self->refundnum } );
-
- if ( $refund_total > $cust_refund->refund ) {
- $dbh->rollback if $oldAutoCommit;
- return "total cust_credit_refund.amount $refund_total for refundnum ".
- $self->refundnum.
- " greater than cust_refund.refund ". $cust_refund->refund;
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
-
- '';
-}
-
-=item delete
-
-Currently unimplemented (accounting reasons).
-
-=cut
-
-sub delete {
- return "Can't (yet?) delete cust_credit_refund records!";
-}
-
-=item replace OLD_RECORD
-
-Currently unimplemented (accounting reasons).
-
-=cut
-
-sub replace {
- return "Can't (yet?) modify cust_credit_refund records!";
-}
-
-=item check
-
-Checks all fields to make sure this is a valid payment. If there is an error,
-returns the error, otherwise returns false. Called by the insert method.
-
-=cut
-
-sub check {
- my $self = shift;
-
- my $error =
- $self->ut_numbern('creditrefundnum')
- || $self->ut_number('crednum')
- || $self->ut_number('refundnum')
- || $self->ut_money('amount')
- || $self->ut_numbern('_date')
- ;
- return $error if $error;
-
- return "amount must be > 0" if $self->amount <= 0;
-
- $self->_date(time) unless $self->_date;
-
- return "unknown cust_credit.crednum: ". $self->crednum
- unless qsearchs( 'cust_credit', { 'crednum' => $self->crednum } );
-
- $self->SUPER::check;
-}
-
-=item cust_refund
-
-Returns the refund (see L<FS::cust_refund>)
-
-=cut
-
-sub cust_refund {
- my $self = shift;
- qsearchs( 'cust_refund', { 'refundnum' => $self->refundnum } );
-}
-
-=item cust_credit
-
-Returns the credit (see L<FS::cust_credit>)
-
-=cut
-
-sub cust_credit {
- my $self = shift;
- qsearchs( 'cust_credit', { 'crednum' => $self->crednum } );
-}
-
-=back
-
-=head1 VERSION
-
-$Id: cust_credit_refund.pm,v 1.10 2003-08-05 00:20:41 khoff Exp $
-
-=head1 BUGS
-
-Delete and replace methods.
-
-the checks for over-applied refunds could be better done like the ones in
-cust_bill_credit
-
-=head1 SEE ALSO
-
-L<FS::cust_credit>, L<FS::cust_refund>, L<FS::Record>, schema.html from the
-base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
deleted file mode 100644
index 74015de..0000000
--- a/FS/FS/cust_main.pm
+++ /dev/null
@@ -1,2856 +0,0 @@
-package FS::cust_main;
-
-use strict;
-use vars qw( @ISA $conf $DEBUG $import );
-use vars qw( $realtime_bop_decline_quiet ); #ugh
-use Safe;
-use Carp;
-BEGIN {
- eval "use Time::Local;";
- die "Time::Local minimum version 1.05 required with Perl versions before 5.6"
- if $] < 5.006 && !defined($Time::Local::VERSION);
- eval "use Time::Local qw(timelocal timelocal_nocheck);";
-}
-use Date::Format;
-#use Date::Manip;
-use Business::CreditCard;
-use FS::UID qw( getotaker dbh );
-use FS::Record qw( qsearchs qsearch dbdef );
-use FS::Misc qw( send_email );
-use FS::cust_pkg;
-use FS::cust_bill;
-use FS::cust_bill_pkg;
-use FS::cust_pay;
-use FS::cust_credit;
-use FS::cust_refund;
-use FS::part_referral;
-use FS::cust_main_county;
-use FS::agent;
-use FS::cust_main_invoice;
-use FS::cust_credit_bill;
-use FS::cust_bill_pay;
-use FS::prepay_credit;
-use FS::queue;
-use FS::part_pkg;
-use FS::part_bill_event;
-use FS::cust_bill_event;
-use FS::cust_tax_exempt;
-use FS::type_pkgs;
-use FS::Msgcat qw(gettext);
-
-@ISA = qw( FS::Record );
-
-$realtime_bop_decline_quiet = 0;
-
-$DEBUG = 0;
-#$DEBUG = 1;
-
-$import = 0;
-
-#ask FS::UID to run this stuff for us later
-#$FS::UID::callback{'FS::cust_main'} = sub {
-install_callback FS::UID sub {
- $conf = new FS::Conf;
- #yes, need it for stuff below (prolly should be cached)
-};
-
-sub _cache {
- my $self = shift;
- my ( $hashref, $cache ) = @_;
- if ( exists $hashref->{'pkgnum'} ) {
-# #@{ $self->{'_pkgnum'} } = ();
- my $subcache = $cache->subcache( 'pkgnum', 'cust_pkg', $hashref->{custnum});
- $self->{'_pkgnum'} = $subcache;
- #push @{ $self->{'_pkgnum'} },
- FS::cust_pkg->new_or_cached($hashref, $subcache) if $hashref->{pkgnum};
- }
-}
-
-=head1 NAME
-
-FS::cust_main - Object methods for cust_main records
-
-=head1 SYNOPSIS
-
- use FS::cust_main;
-
- $record = new FS::cust_main \%hash;
- $record = new FS::cust_main { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
- @cust_pkg = $record->all_pkgs;
-
- @cust_pkg = $record->ncancelled_pkgs;
-
- @cust_pkg = $record->suspended_pkgs;
-
- $error = $record->bill;
- $error = $record->bill %options;
- $error = $record->bill 'time' => $time;
-
- $error = $record->collect;
- $error = $record->collect %options;
- $error = $record->collect 'invoice_time' => $time,
- 'batch_card' => 'yes',
- 'report_badcard' => 'yes',
- ;
-
-=head1 DESCRIPTION
-
-An FS::cust_main object represents a customer. FS::cust_main inherits from
-FS::Record. The following fields are currently supported:
-
-=over 4
-
-=item custnum - primary key (assigned automatically for new customers)
-
-=item agentnum - agent (see L<FS::agent>)
-
-=item refnum - Advertising source (see L<FS::part_referral>)
-
-=item first - name
-
-=item last - name
-
-=item ss - social security number (optional)
-
-=item company - (optional)
-
-=item address1
-
-=item address2 - (optional)
-
-=item city
-
-=item county - (optional, 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 daytime - phone (optional)
-
-=item night - phone (optional)
-
-=item fax - phone (optional)
-
-=item ship_first - name
-
-=item ship_last - name
-
-=item ship_company - (optional)
-
-=item ship_address1
-
-=item ship_address2 - (optional)
-
-=item ship_city
-
-=item ship_county - (optional, 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_daytime - phone (optional)
-
-=item ship_night - phone (optional)
-
-=item ship_fax - phone (optional)
-
-=item payby - I<CARD> (credit card - automatic), I<DCRD> (credit card - on-demand), I<CHEK> (electronic check - automatic), I<DCHK> (electronic check - on-demand), I<LECB> (Phone bill billing), I<BILL> (billing), I<COMP> (free), or I<PREPAY> (special billing type: applies a credit - see L<FS::prepay_credit> and sets billing type to I<BILL>)
-
-=item payinfo - card number, P.O., comp issuer (4-8 lowercase alphanumerics; think username) or prepayment identifier (see L<FS::prepay_credit>)
-
-=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 payname - name on card or billing name
-
-=item tax - tax exempt, empty or `Y'
-
-=item otaker - order taker (assigned automatically, see L<FS::UID>)
-
-=item comments - comments (optional)
-
-=item referral_custnum - referring customer number
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new customer. To add the customer 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 { 'cust_main'; }
-
-=item insert [ CUST_PKG_HASHREF [ , INVOICING_LIST_ARYREF ] [ , OPTION => VALUE ... ] ]
-
-Adds this customer to the database. If there is an error, returns the error,
-otherwise returns false.
-
-CUST_PKG_HASHREF: If you pass a Tie::RefHash data structure to the insert
-method containing FS::cust_pkg and FS::svc_I<tablename> objects, all records
-are inserted atomicly, or the transaction is rolled back. Passing an empty
-hash reference is equivalent to not supplying this parameter. There should be
-a better explanation of this, but until then, here's an example:
-
- use Tie::RefHash;
- tie %hash, 'Tie::RefHash'; #this part is important
- %hash = (
- $cust_pkg => [ $svc_acct ],
- ...
- );
- $cust_main->insert( \%hash );
-
-INVOICING_LIST_ARYREF: If you pass an arrarref to the insert method, it will
-be set as the invoicing list (see L<"invoicing_list">). Errors return as
-expected and rollback the entire transaction; it is not necessary to call
-check_invoicing_list first. The invoicing_list is set after the records in the
-CUST_PKG_HASHREF above are inserted, so it is now possible to set an
-invoicing_list destination to the newly-created svc_acct. Here's an example:
-
- $cust_main->insert( {}, [ $email, 'POST' ] );
-
-Currently available options are: I<depend_jobnum> and I<noexport>.
-
-If I<depend_jobnum> is set, all provisioning jobs will have a dependancy
-on the supplied jobnum (they will not run until the specific job completes).
-This can be used to defer provisioning until some action completes (such
-as running the customer's credit card sucessfully).
-
-The I<noexport> option is deprecated. If I<noexport> is set true, no
-provisioning jobs (exports) are scheduled. (You can schedule them later with
-the B<reexport> method.)
-
-=cut
-
-sub insert {
- my $self = shift;
- my $cust_pkgs = @_ ? shift : {};
- my $invoicing_list = @_ ? shift : '';
- my %options = @_;
- warn "FS::cust_main::insert called with options ".
- join(', ', map { "$_: $options{$_}" } keys %options ). "\n"
- if $DEBUG;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- my $amount = 0;
- my $seconds = 0;
- if ( $self->payby eq 'PREPAY' ) {
- $self->payby('BILL');
- my $prepay_credit = qsearchs(
- 'prepay_credit',
- { 'identifier' => $self->payinfo },
- '',
- 'FOR UPDATE'
- );
- warn "WARNING: can't find pre-found prepay_credit: ". $self->payinfo
- unless $prepay_credit;
- $amount = $prepay_credit->amount;
- $seconds = $prepay_credit->seconds;
- my $error = $prepay_credit->delete;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "removing prepay_credit (transaction rolled back): $error";
- }
- }
-
- my $error = $self->SUPER::insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- #return "inserting cust_main record (transaction rolled back): $error";
- return $error;
- }
-
- # invoicing list
- if ( $invoicing_list ) {
- $error = $self->check_invoicing_list( $invoicing_list );
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "checking invoicing_list (transaction rolled back): $error";
- }
- $self->invoicing_list( $invoicing_list );
- }
-
- # packages
- $error = $self->order_pkgs($cust_pkgs, \$seconds, %options);
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- if ( $seconds ) {
- $dbh->rollback if $oldAutoCommit;
- return "No svc_acct record to apply pre-paid time";
- }
-
- if ( $amount ) {
- my $cust_credit = new FS::cust_credit {
- 'custnum' => $self->custnum,
- 'amount' => $amount,
- };
- $error = $cust_credit->insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "inserting credit (transaction rolled back): $error";
- }
- }
-
- $error = $self->queue_fuzzyfiles_update;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "updating fuzzy search cache: $error";
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
- '';
-
-}
-
-=item order_pkgs HASHREF, [ SECONDSREF, [ , OPTION => VALUE ... ] ]
-
-Like the insert method on an existing record, this method orders a package
-and included services atomicaly. Pass a Tie::RefHash data structure to this
-method containing FS::cust_pkg and FS::svc_I<tablename> objects. There should
-be a better explanation of this, but until then, here's an example:
-
- use Tie::RefHash;
- tie %hash, 'Tie::RefHash'; #this part is important
- %hash = (
- $cust_pkg => [ $svc_acct ],
- ...
- );
- $cust_main->order_pkgs( \%hash, \'0', 'noexport'=>1 );
-
-Currently available options are: I<depend_jobnum> and I<noexport>.
-
-If I<depend_jobnum> is set, all provisioning jobs will have a dependancy
-on the supplied jobnum (they will not run until the specific job completes).
-This can be used to defer provisioning until some action completes (such
-as running the customer's credit card sucessfully).
-
-The I<noexport> option is deprecated. If I<noexport> is set true, no
-provisioning jobs (exports) are scheduled. (You can schedule them later with
-the B<reexport> method for each cust_pkg object. Using the B<reexport> method
-on the cust_main object is not recommended, as existing services will also be
-reexported.)
-
-=cut
-
-sub order_pkgs {
- my $self = shift;
- my $cust_pkgs = shift;
- my $seconds = shift;
- my %options = @_;
- my %svc_options = ();
- $svc_options{'depend_jobnum'} = $options{'depend_jobnum'}
- if exists $options{'depend_jobnum'};
- warn "FS::cust_main::order_pkgs called with options ".
- join(', ', map { "$_: $options{$_}" } keys %options ). "\n"
- if $DEBUG;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- local $FS::svc_Common::noexport_hack = 1 if $options{'noexport'};
-
- foreach my $cust_pkg ( keys %$cust_pkgs ) {
- $cust_pkg->custnum( $self->custnum );
- my $error = $cust_pkg->insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "inserting cust_pkg (transaction rolled back): $error";
- }
- foreach my $svc_something ( @{$cust_pkgs->{$cust_pkg}} ) {
- $svc_something->pkgnum( $cust_pkg->pkgnum );
- if ( $seconds && $$seconds && $svc_something->isa('FS::svc_acct') ) {
- $svc_something->seconds( $svc_something->seconds + $$seconds );
- $$seconds = 0;
- }
- $error = $svc_something->insert(%svc_options);
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- #return "inserting svc_ (transaction rolled back): $error";
- return $error;
- }
- }
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
- ''; #no error
-}
-
-=item reexport
-
-This method is deprecated. See the I<depend_jobnum> option to the insert and
-order_pkgs methods for a better way to defer provisioning.
-
-Re-schedules all exports by calling the B<reexport> method of all associated
-packages (see L<FS::cust_pkg>). If there is an error, returns the error;
-otherwise returns false.
-
-=cut
-
-sub reexport {
- my $self = shift;
-
- carp "warning: FS::cust_main::reexport is deprectated; ".
- "use the depend_jobnum option to insert or order_pkgs to delay export";
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- foreach my $cust_pkg ( $self->ncancelled_pkgs ) {
- my $error = $cust_pkg->reexport;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
- '';
-
-}
-
-=item delete NEW_CUSTNUM
-
-This deletes the customer. If there is an error, returns the error, otherwise
-returns false.
-
-This will completely remove all traces of the customer record. This is not
-what you want when a customer cancels service; for that, cancel all of the
-customer's packages (see L</cancel>).
-
-If the customer has any uncancelled packages, you need to pass a new (valid)
-customer number for those packages to be transferred to. Cancelled packages
-will be deleted. Did I mention that this is NOT what you want when a customer
-cancels service and that you really should be looking see L<FS::cust_pkg/cancel>?
-
-You can't delete a customer with invoices (see L<FS::cust_bill>),
-or credits (see L<FS::cust_credit>), payments (see L<FS::cust_pay>) or
-refunds (see L<FS::cust_refund>).
-
-=cut
-
-sub delete {
- my $self = shift;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- if ( $self->cust_bill ) {
- $dbh->rollback if $oldAutoCommit;
- return "Can't delete a customer with invoices";
- }
- if ( $self->cust_credit ) {
- $dbh->rollback if $oldAutoCommit;
- return "Can't delete a customer with credits";
- }
- if ( $self->cust_pay ) {
- $dbh->rollback if $oldAutoCommit;
- return "Can't delete a customer with payments";
- }
- if ( $self->cust_refund ) {
- $dbh->rollback if $oldAutoCommit;
- return "Can't delete a customer with refunds";
- }
-
- my @cust_pkg = $self->ncancelled_pkgs;
- if ( @cust_pkg ) {
- my $new_custnum = shift;
- unless ( qsearchs( 'cust_main', { 'custnum' => $new_custnum } ) ) {
- $dbh->rollback if $oldAutoCommit;
- return "Invalid new customer number: $new_custnum";
- }
- foreach my $cust_pkg ( @cust_pkg ) {
- my %hash = $cust_pkg->hash;
- $hash{'custnum'} = $new_custnum;
- my $new_cust_pkg = new FS::cust_pkg ( \%hash );
- my $error = $new_cust_pkg->replace($cust_pkg);
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
- }
- my @cancelled_cust_pkg = $self->all_pkgs;
- foreach my $cust_pkg ( @cancelled_cust_pkg ) {
- my $error = $cust_pkg->delete;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
-
- foreach my $cust_main_invoice ( #(email invoice destinations, not invoices)
- qsearch( 'cust_main_invoice', { 'custnum' => $self->custnum } )
- ) {
- my $error = $cust_main_invoice->delete;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
-
- my $error = $self->SUPER::delete;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
- '';
-
-}
-
-=item replace OLD_RECORD [ INVOICING_LIST_ARYREF ]
-
-Replaces the OLD_RECORD with this one in the database. If there is an error,
-returns the error, otherwise returns false.
-
-INVOICING_LIST_ARYREF: If you pass an arrarref to the insert method, it will
-be set as the invoicing list (see L<"invoicing_list">). Errors return as
-expected and rollback the entire transaction; it is not necessary to call
-check_invoicing_list first. Here's an example:
-
- $new_cust_main->replace( $old_cust_main, [ $email, 'POST' ] );
-
-=cut
-
-sub replace {
- my $self = shift;
- my $old = shift;
- my @param = @_;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- if ( $self->payby eq 'COMP' && $self->payby ne $old->payby
- && $conf->config('users-allow_comp') ) {
- return "You are not permitted to create complimentary accounts."
- unless grep { $_ eq getotaker } $conf->config('users-allow_comp');
- }
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- my $error = $self->SUPER::replace($old);
-
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- if ( @param ) { # INVOICING_LIST_ARYREF
- my $invoicing_list = shift @param;
- $error = $self->check_invoicing_list( $invoicing_list );
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- $self->invoicing_list( $invoicing_list );
- }
-
- if ( $self->payby =~ /^(CARD|CHEK|LECB)$/ &&
- grep { $self->get($_) ne $old->get($_) } qw(payinfo paydate payname) ) {
- # card/check/lec info has changed, want to retry realtime_ invoice events
- my $error = $self->retry_realtime;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
-
- $error = $self->queue_fuzzyfiles_update;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "updating fuzzy search cache: $error";
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
- '';
-
-}
-
-=item queue_fuzzyfiles_update
-
-Used by insert & replace to update the fuzzy search cache
-
-=cut
-
-sub queue_fuzzyfiles_update {
- my $self = shift;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- my $queue = new FS::queue { 'job' => 'FS::cust_main::append_fuzzyfiles' };
- my $error = $queue->insert($self->getfield('last'), $self->company);
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "queueing job (transaction rolled back): $error";
- }
-
- if ( defined $self->dbdef_table->column('ship_last') && $self->ship_last ) {
- $queue = new FS::queue { 'job' => 'FS::cust_main::append_fuzzyfiles' };
- $error = $queue->insert($self->getfield('ship_last'), $self->ship_company);
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "queueing job (transaction rolled back): $error";
- }
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
- '';
-
-}
-
-=item check
-
-Checks all fields to make sure this is a valid customer record. If there is
-an error, returns the error, otherwise returns false. Called by the insert
-and repalce methods.
-
-=cut
-
-sub check {
- my $self = shift;
-
- #warn "BEFORE: \n". $self->_dump;
-
- my $error =
- $self->ut_numbern('custnum')
- || $self->ut_number('agentnum')
- || $self->ut_number('refnum')
- || $self->ut_name('last')
- || $self->ut_name('first')
- || $self->ut_textn('company')
- || $self->ut_text('address1')
- || $self->ut_textn('address2')
- || $self->ut_text('city')
- || $self->ut_textn('county')
- || $self->ut_textn('state')
- || $self->ut_country('country')
- || $self->ut_anything('comments')
- || $self->ut_numbern('referral_custnum')
- ;
- #barf. need message catalogs. i18n. etc.
- $error .= "Please select an advertising source."
- if $error =~ /^Illegal or empty \(numeric\) refnum: /;
- return $error if $error;
-
- return "Unknown agent"
- unless qsearchs( 'agent', { 'agentnum' => $self->agentnum } );
-
- return "Unknown refnum"
- unless qsearchs( 'part_referral', { 'refnum' => $self->refnum } );
-
- return "Unknown referring custnum ". $self->referral_custnum
- unless ! $self->referral_custnum
- || qsearchs( 'cust_main', { 'custnum' => $self->referral_custnum } );
-
- if ( $self->ss eq '' ) {
- $self->ss('');
- } else {
- my $ss = $self->ss;
- $ss =~ s/\D//g;
- $ss =~ /^(\d{3})(\d{2})(\d{4})$/
- or return "Illegal social security number: ". $self->ss;
- $self->ss("$1-$2-$3");
- }
-
-
-# bad idea to disable, causes billing to fail because of no tax rates later
-# unless ( $import ) {
- unless ( qsearch('cust_main_county', {
- 'country' => $self->country,
- 'state' => '',
- } ) ) {
- return "Unknown state/county/country: ".
- $self->state. "/". $self->county. "/". $self->country
- unless qsearch('cust_main_county',{
- 'state' => $self->state,
- 'county' => $self->county,
- 'country' => $self->country,
- } );
- }
-# }
-
- $error =
- $self->ut_phonen('daytime', $self->country)
- || $self->ut_phonen('night', $self->country)
- || $self->ut_phonen('fax', $self->country)
- || $self->ut_zip('zip', $self->country)
- ;
- return $error if $error;
-
- my @addfields = qw(
- last first company address1 address2 city county state zip
- country daytime night fax
- );
-
- if ( defined $self->dbdef_table->column('ship_last') ) {
- if ( scalar ( grep { $self->getfield($_) ne $self->getfield("ship_$_") }
- @addfields )
- && scalar ( grep { $self->getfield("ship_$_") ne '' } @addfields )
- )
- {
- my $error =
- $self->ut_name('ship_last')
- || $self->ut_name('ship_first')
- || $self->ut_textn('ship_company')
- || $self->ut_text('ship_address1')
- || $self->ut_textn('ship_address2')
- || $self->ut_text('ship_city')
- || $self->ut_textn('ship_county')
- || $self->ut_textn('ship_state')
- || $self->ut_country('ship_country')
- ;
- return $error if $error;
-
- #false laziness with above
- unless ( qsearchs('cust_main_county', {
- 'country' => $self->ship_country,
- 'state' => '',
- } ) ) {
- return "Unknown ship_state/ship_county/ship_country: ".
- $self->ship_state. "/". $self->ship_county. "/". $self->ship_country
- unless qsearchs('cust_main_county',{
- 'state' => $self->ship_state,
- 'county' => $self->ship_county,
- 'country' => $self->ship_country,
- } );
- }
- #eofalse
-
- $error =
- $self->ut_phonen('ship_daytime', $self->ship_country)
- || $self->ut_phonen('ship_night', $self->ship_country)
- || $self->ut_phonen('ship_fax', $self->ship_country)
- || $self->ut_zip('ship_zip', $self->ship_country)
- ;
- return $error if $error;
-
- } else { # ship_ info eq billing info, so don't store dup info in database
- $self->setfield("ship_$_", '')
- foreach qw( last first company address1 address2 city county state zip
- country daytime night fax );
- }
- }
-
- $self->payby =~ /^(CARD|DCRD|CHEK|DCHK|LECB|BILL|COMP|PREPAY)$/
- or return "Illegal payby: ". $self->payby;
- $self->payby($1);
-
- if ( $self->payby eq 'CARD' || $self->payby eq 'DCRD' ) {
-
- my $payinfo = $self->payinfo;
- $payinfo =~ s/\D//g;
- $payinfo =~ /^(\d{13,16})$/
- or return gettext('invalid_card'); # . ": ". $self->payinfo;
- $payinfo = $1;
- $self->payinfo($payinfo);
- validate($payinfo)
- or return gettext('invalid_card'); # . ": ". $self->payinfo;
- return gettext('unknown_card_type')
- if cardtype($self->payinfo) eq "Unknown";
- if ( defined $self->dbdef_table->column('paycvv') ) {
- if ( length($self->paycvv) ) {
- if ( cardtype($self->payinfo) eq 'American Express card' ) {
- $self->paycvv =~ /^(\d{4})$/
- or return "CVV2 (CID) for American Express cards is four digits.";
- $self->paycvv($1);
- } else {
- $self->paycvv =~ /^(\d{3})$/
- or return "CVV2 (CVC2/CID) is three digits.";
- $self->paycvv($1);
- }
- } else {
- $self->paycvv('');
- }
- }
-
- } elsif ( $self->payby eq 'CHEK' || $self->payby eq 'DCHK' ) {
-
- my $payinfo = $self->payinfo;
- $payinfo =~ s/[^\d\@]//g;
- $payinfo =~ /^(\d+)\@(\d{9})$/ or return 'invalid echeck account@aba';
- $payinfo = "$1\@$2";
- $self->payinfo($payinfo);
- $self->paycvv('') if $self->dbdef_table->column('paycvv');
-
- } elsif ( $self->payby eq 'LECB' ) {
-
- my $payinfo = $self->payinfo;
- $payinfo =~ s/\D//g;
- $payinfo =~ /^1?(\d{10})$/ or return 'invalid btn billing telephone number';
- $payinfo = $1;
- $self->payinfo($payinfo);
- $self->paycvv('') if $self->dbdef_table->column('paycvv');
-
- } elsif ( $self->payby eq 'BILL' ) {
-
- $error = $self->ut_textn('payinfo');
- return "Illegal P.O. number: ". $self->payinfo if $error;
- $self->paycvv('') if $self->dbdef_table->column('paycvv');
-
- } elsif ( $self->payby eq 'COMP' ) {
-
- if ( !$self->custnum && $conf->config('users-allow_comp') ) {
- return "You are not permitted to create complimentary accounts."
- unless grep { $_ eq getotaker } $conf->config('users-allow_comp');
- }
-
- $error = $self->ut_textn('payinfo');
- return "Illegal comp account issuer: ". $self->payinfo if $error;
- $self->paycvv('') if $self->dbdef_table->column('paycvv');
-
- } elsif ( $self->payby eq 'PREPAY' ) {
-
- my $payinfo = $self->payinfo;
- $payinfo =~ s/\W//g; #anything else would just confuse things
- $self->payinfo($payinfo);
- $error = $self->ut_alpha('payinfo');
- return "Illegal prepayment identifier: ". $self->payinfo if $error;
- return "Unknown prepayment identifier"
- unless qsearchs('prepay_credit', { 'identifier' => $self->payinfo } );
- $self->paycvv('') if $self->dbdef_table->column('paycvv');
-
- }
-
- if ( $self->paydate eq '' || $self->paydate eq '-' ) {
- return "Expriation date required"
- unless $self->payby =~ /^(BILL|PREPAY|CHEK|LECB)$/;
- $self->paydate('');
- } else {
- my( $m, $y );
- if ( $self->paydate =~ /^(\d{1,2})[\/\-](\d{2}(\d{2})?)$/ ) {
- ( $m, $y ) = ( $1, length($2) == 4 ? $2 : "20$2" );
- } elsif ( $self->paydate =~ /^(20)?(\d{2})[\/\-](\d{2})[\/\-]\d+$/ ) {
- ( $m, $y ) = ( $3, "20$2" );
- } else {
- return "Illegal expiration date: ". $self->paydate;
- }
- $self->paydate("$y-$m-01");
- my($nowm,$nowy)=(localtime(time))[4,5]; $nowm++; $nowy+=1900;
- return gettext('expired_card')
- if !$import && ( $y<$nowy || ( $y==$nowy && $1<$nowm ) );
- }
-
- if ( $self->payname eq '' && $self->payby !~ /^(CHEK|DCHK)$/ &&
- ( ! $conf->exists('require_cardname')
- || $self->payby !~ /^(CARD|DCRD)$/ )
- ) {
- $self->payname( $self->first. " ". $self->getfield('last') );
- } else {
- $self->payname =~ /^([\w \,\.\-\']+)$/
- or return gettext('illegal_name'). " payname: ". $self->payname;
- $self->payname($1);
- }
-
- $self->tax =~ /^(Y?)$/ or return "Illegal tax: ". $self->tax;
- $self->tax($1);
-
- $self->otaker(getotaker) unless $self->otaker;
-
- #warn "AFTER: \n". $self->_dump;
-
- $self->SUPER::check;
-}
-
-=item all_pkgs
-
-Returns all packages (see L<FS::cust_pkg>) for this customer.
-
-=cut
-
-sub all_pkgs {
- my $self = shift;
- if ( $self->{'_pkgnum'} ) {
- values %{ $self->{'_pkgnum'}->cache };
- } else {
- qsearch( 'cust_pkg', { 'custnum' => $self->custnum });
- }
-}
-
-=item ncancelled_pkgs
-
-Returns all non-cancelled packages (see L<FS::cust_pkg>) for this customer.
-
-=cut
-
-sub ncancelled_pkgs {
- my $self = shift;
- if ( $self->{'_pkgnum'} ) {
- grep { ! $_->getfield('cancel') } values %{ $self->{'_pkgnum'}->cache };
- } else {
- @{ [ # force list context
- qsearch( 'cust_pkg', {
- 'custnum' => $self->custnum,
- 'cancel' => '',
- }),
- qsearch( 'cust_pkg', {
- 'custnum' => $self->custnum,
- 'cancel' => 0,
- }),
- ] };
- }
-}
-
-=item suspended_pkgs
-
-Returns all suspended packages (see L<FS::cust_pkg>) for this customer.
-
-=cut
-
-sub suspended_pkgs {
- my $self = shift;
- grep { $_->susp } $self->ncancelled_pkgs;
-}
-
-=item unflagged_suspended_pkgs
-
-Returns all unflagged suspended packages (see L<FS::cust_pkg>) for this
-customer (thouse packages without the `manual_flag' set).
-
-=cut
-
-sub unflagged_suspended_pkgs {
- my $self = shift;
- return $self->suspended_pkgs
- unless dbdef->table('cust_pkg')->column('manual_flag');
- grep { ! $_->manual_flag } $self->suspended_pkgs;
-}
-
-=item unsuspended_pkgs
-
-Returns all unsuspended (and uncancelled) packages (see L<FS::cust_pkg>) for
-this customer.
-
-=cut
-
-sub unsuspended_pkgs {
- my $self = shift;
- grep { ! $_->susp } $self->ncancelled_pkgs;
-}
-
-=item unsuspend
-
-Unsuspends all unflagged suspended packages (see L</unflagged_suspended_pkgs>
-and L<FS::cust_pkg>) for this customer. Always returns a list: an empty list
-on success or a list of errors.
-
-=cut
-
-sub unsuspend {
- my $self = shift;
- grep { $_->unsuspend } $self->suspended_pkgs;
-}
-
-=item suspend
-
-Suspends all unsuspended packages (see L<FS::cust_pkg>) for this customer.
-Always returns a list: an empty list on success or a list of errors.
-
-=cut
-
-sub suspend {
- my $self = shift;
- grep { $_->suspend } $self->unsuspended_pkgs;
-}
-
-=item cancel [ OPTION => VALUE ... ]
-
-Cancels all uncancelled packages (see L<FS::cust_pkg>) for this customer.
-
-Available options are: I<quiet>
-
-I<quiet> can be set true to supress email cancellation notices.
-
-Always returns a list: an empty list on success or a list of errors.
-
-=cut
-
-sub cancel {
- my $self = shift;
- grep { $_ } map { $_->cancel(@_) } $self->ncancelled_pkgs;
-}
-
-=item agent
-
-Returns the agent (see L<FS::agent>) for this customer.
-
-=cut
-
-sub agent {
- my $self = shift;
- qsearchs( 'agent', { 'agentnum' => $self->agentnum } );
-}
-
-=item bill OPTIONS
-
-Generates invoices (see L<FS::cust_bill>) for this customer. Usually used in
-conjunction with the collect method.
-
-Options are passed as name-value pairs.
-
-Currently available options are:
-
-resetup - if set true, re-charges setup fees.
-
-time - bills the customer as if it were that time. Specified as a UNIX
-timestamp; see L<perlfunc/"time">). Also see L<Time::Local> and
-L<Date::Parse> for conversion functions. For example:
-
- use Date::Parse;
- ...
- $cust_main->bill( 'time' => str2time('April 20th, 2001') );
-
-
-If there is an error, returns the error, otherwise returns false.
-
-=cut
-
-sub bill {
- my( $self, %options ) = @_;
- my $time = $options{'time'} || time;
-
- my $error;
-
- #put below somehow?
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- $self->select_for_update; #mutex
-
- # find the packages which are due for billing, find out how much they are
- # & generate invoice database.
-
- my( $total_setup, $total_recur ) = ( 0, 0 );
- #my( $taxable_setup, $taxable_recur ) = ( 0, 0 );
- my @cust_bill_pkg = ();
- #my $tax = 0;##
- #my $taxable_charged = 0;##
- #my $charged = 0;##
-
- my %tax;
-
- foreach my $cust_pkg (
- qsearch('cust_pkg', { 'custnum' => $self->custnum } )
- ) {
-
- #NO!! next if $cust_pkg->cancel;
- next if $cust_pkg->getfield('cancel');
-
- #? to avoid use of uninitialized value errors... ?
- $cust_pkg->setfield('bill', '')
- unless defined($cust_pkg->bill);
-
- my $part_pkg = $cust_pkg->part_pkg;
-
- #so we don't modify cust_pkg record unnecessarily
- my $cust_pkg_mod_flag = 0;
- my %hash = $cust_pkg->hash;
- my $old_cust_pkg = new FS::cust_pkg \%hash;
-
- my @details = ();
-
- # bill setup
- my $setup = 0;
- if ( !$cust_pkg->setup || $options{'resetup'} ) {
- my $setup_prog = $part_pkg->getfield('setup');
- $setup_prog =~ /^(.*)$/ or do {
- $dbh->rollback if $oldAutoCommit;
- return "Illegal setup for pkgpart ". $part_pkg->pkgpart.
- ": $setup_prog";
- };
- $setup_prog = $1;
- $setup_prog = '0' if $setup_prog =~ /^\s*$/;
-
- #my $cpt = new Safe;
- ##$cpt->permit(); #what is necessary?
- #$cpt->share(qw( $cust_pkg )); #can $cpt now use $cust_pkg methods?
- #$setup = $cpt->reval($setup_prog);
- $setup = eval $setup_prog;
- unless ( defined($setup) ) {
- $dbh->rollback if $oldAutoCommit;
- return "Error eval-ing part_pkg->setup pkgpart ". $part_pkg->pkgpart.
- "(expression $setup_prog): $@";
- }
- $cust_pkg->setfield('setup', $time) unless $cust_pkg->setup;
- $cust_pkg_mod_flag=1;
- }
-
- #bill recurring fee
- my $recur = 0;
- my $sdate;
- if ( $part_pkg->getfield('freq') ne '0' &&
- ! $cust_pkg->getfield('susp') &&
- ( $cust_pkg->getfield('bill') || 0 ) <= $time
- ) {
- my $recur_prog = $part_pkg->getfield('recur');
- $recur_prog =~ /^(.*)$/ or do {
- $dbh->rollback if $oldAutoCommit;
- return "Illegal recur for pkgpart ". $part_pkg->pkgpart.
- ": $recur_prog";
- };
- $recur_prog = $1;
- $recur_prog = '0' if $recur_prog =~ /^\s*$/;
-
- # shared with $recur_prog
- $sdate = $cust_pkg->bill || $cust_pkg->setup || $time;
-
- #my $cpt = new Safe;
- ##$cpt->permit(); #what is necessary?
- #$cpt->share(qw( $cust_pkg )); #can $cpt now use $cust_pkg methods?
- #$recur = $cpt->reval($recur_prog);
- $recur = eval $recur_prog;
- unless ( defined($recur) ) {
- $dbh->rollback if $oldAutoCommit;
- return "Error eval-ing part_pkg->recur pkgpart ". $part_pkg->pkgpart.
- "(expression $recur_prog): $@";
- }
- #change this bit to use Date::Manip? CAREFUL with timezones (see
- # mailing list archive)
- my ($sec,$min,$hour,$mday,$mon,$year) =
- (localtime($sdate) )[0,1,2,3,4,5];
-
- #pro-rating magic - if $recur_prog fiddles $sdate, want to use that
- # only for figuring next bill date, nothing else, so, reset $sdate again
- # here
- $sdate = $cust_pkg->bill || $cust_pkg->setup || $time;
- $cust_pkg->last_bill($sdate)
- if $cust_pkg->dbdef_table->column('last_bill');
-
- if ( $part_pkg->freq =~ /^\d+$/ ) {
- $mon += $part_pkg->freq;
- until ( $mon < 12 ) { $mon -= 12; $year++; }
- } elsif ( $part_pkg->freq =~ /^(\d+)w$/ ) {
- my $weeks = $1;
- $mday += $weeks * 7;
- } elsif ( $part_pkg->freq =~ /^(\d+)d$/ ) {
- my $days = $1;
- $mday += $days;
- } else {
- $dbh->rollback if $oldAutoCommit;
- return "unparsable frequency: ". $part_pkg->freq;
- }
- $cust_pkg->setfield('bill',
- timelocal_nocheck($sec,$min,$hour,$mday,$mon,$year));
- $cust_pkg_mod_flag = 1;
- }
-
- warn "\$setup is undefined" unless defined($setup);
- warn "\$recur is undefined" unless defined($recur);
- warn "\$cust_pkg->bill is undefined" unless defined($cust_pkg->bill);
-
- if ( $cust_pkg_mod_flag ) {
- $error=$cust_pkg->replace($old_cust_pkg);
- if ( $error ) { #just in case
- $dbh->rollback if $oldAutoCommit;
- return "Error modifying pkgnum ". $cust_pkg->pkgnum. ": $error";
- }
- $setup = sprintf( "%.2f", $setup );
- $recur = sprintf( "%.2f", $recur );
- if ( $setup < 0 && ! $conf->exists('allow_negative_charges') ) {
- $dbh->rollback if $oldAutoCommit;
- return "negative setup $setup for pkgnum ". $cust_pkg->pkgnum;
- }
- if ( $recur < 0 && ! $conf->exists('allow_negative_charges') ) {
- $dbh->rollback if $oldAutoCommit;
- return "negative recur $recur for pkgnum ". $cust_pkg->pkgnum;
- }
- if ( $setup != 0 || $recur != 0 ) {
- my $cust_bill_pkg = new FS::cust_bill_pkg ({
- 'pkgnum' => $cust_pkg->pkgnum,
- 'setup' => $setup,
- 'recur' => $recur,
- 'sdate' => $sdate,
- 'edate' => $cust_pkg->bill,
- 'details' => \@details,
- });
- push @cust_bill_pkg, $cust_bill_pkg;
- $total_setup += $setup;
- $total_recur += $recur;
-
- unless ( $self->tax =~ /Y/i || $self->payby eq 'COMP' ) {
-
- my @taxes = qsearch( 'cust_main_county', {
- 'state' => $self->state,
- 'county' => $self->county,
- 'country' => $self->country,
- 'taxclass' => $part_pkg->taxclass,
- } );
- unless ( @taxes ) {
- @taxes = qsearch( 'cust_main_county', {
- 'state' => $self->state,
- 'county' => $self->county,
- 'country' => $self->country,
- 'taxclass' => '',
- } );
- }
-
- #one more try at a whole-country tax rate
- unless ( @taxes ) {
- @taxes = qsearch( 'cust_main_county', {
- 'state' => '',
- 'county' => '',
- 'country' => $self->country,
- 'taxclass' => '',
- } );
- }
-
- # maybe eliminate this entirely, along with all the 0% records
- unless ( @taxes ) {
- $dbh->rollback if $oldAutoCommit;
- return
- "fatal: can't find tax rate for state/county/country/taxclass ".
- join('/', ( map $self->$_(), qw(state county country) ),
- $part_pkg->taxclass ). "\n";
- }
-
- foreach my $tax ( @taxes ) {
-
- my $taxable_charged = 0;
- $taxable_charged += $setup
- unless $part_pkg->setuptax =~ /^Y$/i
- || $tax->setuptax =~ /^Y$/i;
- $taxable_charged += $recur
- unless $part_pkg->recurtax =~ /^Y$/i
- || $tax->recurtax =~ /^Y$/i;
- next unless $taxable_charged;
-
- if ( $tax->exempt_amount > 0 ) {
- my ($mon,$year) = (localtime($sdate) )[4,5];
- $mon++;
- my $freq = $part_pkg->freq || 1;
- if ( $freq !~ /(\d+)$/ ) {
- $dbh->rollback if $oldAutoCommit;
- return "daily/weekly package definitions not (yet?)".
- " compatible with monthly tax exemptions";
- }
- my $taxable_per_month = sprintf("%.2f", $taxable_charged / $freq );
- foreach my $which_month ( 1 .. $freq ) {
- my %hash = (
- 'custnum' => $self->custnum,
- 'taxnum' => $tax->taxnum,
- 'year' => 1900+$year,
- 'month' => $mon++,
- );
- #until ( $mon < 12 ) { $mon -= 12; $year++; }
- until ( $mon < 13 ) { $mon -= 12; $year++; }
- my $cust_tax_exempt =
- qsearchs('cust_tax_exempt', \%hash)
- || new FS::cust_tax_exempt( { %hash, 'amount' => 0 } );
- my $remaining_exemption = sprintf("%.2f",
- $tax->exempt_amount - $cust_tax_exempt->amount );
- if ( $remaining_exemption > 0 ) {
- my $addl = $remaining_exemption > $taxable_per_month
- ? $taxable_per_month
- : $remaining_exemption;
- $taxable_charged -= $addl;
- my $new_cust_tax_exempt = new FS::cust_tax_exempt ( {
- $cust_tax_exempt->hash,
- 'amount' =>
- sprintf("%.2f", $cust_tax_exempt->amount + $addl),
- } );
- $error = $new_cust_tax_exempt->exemptnum
- ? $new_cust_tax_exempt->replace($cust_tax_exempt)
- : $new_cust_tax_exempt->insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "fatal: can't update cust_tax_exempt: $error";
- }
-
- } # if $remaining_exemption > 0
-
- } #foreach $which_month
-
- } #if $tax->exempt_amount
-
- $taxable_charged = sprintf( "%.2f", $taxable_charged);
-
- #$tax += $taxable_charged * $cust_main_county->tax / 100
- $tax{ $tax->taxname || 'Tax' } +=
- $taxable_charged * $tax->tax / 100
-
- } #foreach my $tax ( @taxes )
-
- } #unless $self->tax =~ /Y/i || $self->payby eq 'COMP'
-
- } #if $setup != 0 || $recur != 0
-
- } #if $cust_pkg_mod_flag
-
- } #foreach my $cust_pkg
-
- my $charged = sprintf( "%.2f", $total_setup + $total_recur );
-# my $taxable_charged = sprintf( "%.2f", $taxable_setup + $taxable_recur );
-
- unless ( @cust_bill_pkg ) { #don't create invoices with no line items
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
- return '';
- }
-
-# unless ( $self->tax =~ /Y/i
-# || $self->payby eq 'COMP'
-# || $taxable_charged == 0 ) {
-# my $cust_main_county = qsearchs('cust_main_county',{
-# 'state' => $self->state,
-# 'county' => $self->county,
-# 'country' => $self->country,
-# } ) or die "fatal: can't find tax rate for state/county/country ".
-# $self->state. "/". $self->county. "/". $self->country. "\n";
-# my $tax = sprintf( "%.2f",
-# $taxable_charged * ( $cust_main_county->getfield('tax') / 100 )
-# );
-
- if ( dbdef->table('cust_bill_pkg')->column('itemdesc') ) { #1.5 schema
-
- foreach my $taxname ( grep { $tax{$_} > 0 } keys %tax ) {
- my $tax = sprintf("%.2f", $tax{$taxname} );
- $charged = sprintf( "%.2f", $charged+$tax );
-
- my $cust_bill_pkg = new FS::cust_bill_pkg ({
- 'pkgnum' => 0,
- 'setup' => $tax,
- 'recur' => 0,
- 'sdate' => '',
- 'edate' => '',
- 'itemdesc' => $taxname,
- });
- push @cust_bill_pkg, $cust_bill_pkg;
- }
-
- } else { #1.4 schema
-
- my $tax = 0;
- foreach ( values %tax ) { $tax += $_ };
- $tax = sprintf("%.2f", $tax);
- if ( $tax > 0 ) {
- $charged = sprintf( "%.2f", $charged+$tax );
-
- my $cust_bill_pkg = new FS::cust_bill_pkg ({
- 'pkgnum' => 0,
- 'setup' => $tax,
- 'recur' => 0,
- 'sdate' => '',
- 'edate' => '',
- });
- push @cust_bill_pkg, $cust_bill_pkg;
- }
-
- }
-
- my $cust_bill = new FS::cust_bill ( {
- 'custnum' => $self->custnum,
- '_date' => $time,
- 'charged' => $charged,
- } );
- $error = $cust_bill->insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "can't create invoice for customer #". $self->custnum. ": $error";
- }
-
- my $invnum = $cust_bill->invnum;
- my $cust_bill_pkg;
- foreach $cust_bill_pkg ( @cust_bill_pkg ) {
- #warn $invnum;
- $cust_bill_pkg->invnum($invnum);
- $error = $cust_bill_pkg->insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "can't create invoice line item for customer #". $self->custnum.
- ": $error";
- }
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
- ''; #no error
-}
-
-=item collect OPTIONS
-
-(Attempt to) collect money for this customer's outstanding invoices (see
-L<FS::cust_bill>). Usually used after the bill method.
-
-Depending on the value of `payby', this may print or email an invoice (I<BILL>,
-I<DCRD>, or I<DCHK>), charge a credit card (I<CARD>), charge via electronic
-check/ACH (I<CHEK>), or just add any necessary (pseudo-)payment (I<COMP>).
-
-Most actions are now triggered by invoice events; see L<FS::part_bill_event>
-and the invoice events web interface.
-
-If there is an error, returns the error, otherwise returns false.
-
-Options are passed as name-value pairs.
-
-Currently available options are:
-
-invoice_time - Use this time when deciding when to print invoices and
-late notices on those invoices. The default is now. It is specified as a UNIX timestamp; see L<perlfunc/"time">). Also see L<Time::Local> and L<Date::Parse>
-for conversion functions.
-
-retry - Retry card/echeck/LEC transactions even when not scheduled by invoice
-events.
-
-retry_card - Deprecated alias for 'retry'
-
-batch_card - This option is deprecated. See the invoice events web interface
-to control whether cards are batched or run against a realtime gateway.
-
-report_badcard - This option is deprecated.
-
-force_print - This option is deprecated; see the invoice events web interface.
-
-quiet - set true to surpress email card/ACH decline notices.
-
-=cut
-
-sub collect {
- my( $self, %options ) = @_;
- my $invoice_time = $options{'invoice_time'} || time;
-
- #put below somehow?
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- $self->select_for_update; #mutex
-
- my $balance = $self->balance;
- warn "collect customer". $self->custnum. ": balance $balance" if $DEBUG;
- unless ( $balance > 0 ) { #redundant?????
- $dbh->rollback if $oldAutoCommit; #hmm
- return '';
- }
-
- if ( exists($options{'retry_card'}) ) {
- carp 'retry_card option passed to collect is deprecated; use retry';
- $options{'retry'} ||= $options{'retry_card'};
- }
- if ( exists($options{'retry'}) && $options{'retry'} ) {
- my $error = $self->retry_realtime;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
-
- foreach my $cust_bill ( $self->open_cust_bill ) {
-
- # don't try to charge for the same invoice if it's already in a batch
- #next if qsearchs( 'cust_pay_batch', { 'invnum' => $cust_bill->invnum } );
-
- last if $self->balance <= 0;
-
- warn "invnum ". $cust_bill->invnum. " (owed ". $cust_bill->owed. ")"
- if $DEBUG;
-
- foreach my $part_bill_event (
- sort { $a->seconds <=> $b->seconds
- || $a->weight <=> $b->weight
- || $a->eventpart <=> $b->eventpart }
- grep { $_->seconds <= ( $invoice_time - $cust_bill->_date )
- && ! qsearchs( 'cust_bill_event', {
- 'invnum' => $cust_bill->invnum,
- 'eventpart' => $_->eventpart,
- 'status' => 'done',
- } )
- }
- qsearch('part_bill_event', { 'payby' => $self->payby,
- 'disabled' => '', } )
- ) {
-
- last if $cust_bill->owed <= 0 # don't run subsequent events if owed<=0
- || $self->balance <= 0; # or if balance<=0
-
- warn "calling invoice event (". $part_bill_event->eventcode. ")\n"
- if $DEBUG;
- my $cust_main = $self; #for callback
-
- my $error;
- {
- local $realtime_bop_decline_quiet = 1 if $options{'quiet'};
- $error = eval $part_bill_event->eventcode;
- }
-
- my $status = '';
- my $statustext = '';
- if ( $@ ) {
- $status = 'failed';
- $statustext = $@;
- } elsif ( $error ) {
- $status = 'done';
- $statustext = $error;
- } else {
- $status = 'done'
- }
-
- #add cust_bill_event
- my $cust_bill_event = new FS::cust_bill_event {
- 'invnum' => $cust_bill->invnum,
- 'eventpart' => $part_bill_event->eventpart,
- #'_date' => $invoice_time,
- '_date' => time,
- 'status' => $status,
- 'statustext' => $statustext,
- };
- $error = $cust_bill_event->insert;
- if ( $error ) {
- #$dbh->rollback if $oldAutoCommit;
- #return "error: $error";
-
- # gah, even with transactions.
- $dbh->commit if $oldAutoCommit; #well.
- my $e = 'WARNING: Event run but database not updated - '.
- 'error inserting cust_bill_event, invnum #'. $cust_bill->invnum.
- ', eventpart '. $part_bill_event->eventpart.
- ": $error";
- warn $e;
- return $e;
- }
-
-
- }
-
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
- '';
-
-}
-
-=item retry_realtime
-
-Schedules realtime credit card / electronic check / LEC billing events for
-for retry. Useful if card information has changed or manual retry is desired.
-The 'collect' method must be called to actually retry the transaction.
-
-Implementation details: For each of this customer's open invoices, changes
-the status of the first "done" (with statustext error) realtime processing
-event to "failed".
-
-=cut
-
-sub retry_realtime {
- my $self = shift;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- foreach my $cust_bill (
- grep { $_->cust_bill_event }
- $self->open_cust_bill
- ) {
- my @cust_bill_event =
- sort { $a->part_bill_event->seconds <=> $b->part_bill_event->seconds }
- grep {
- #$_->part_bill_event->plan eq 'realtime-card'
- $_->part_bill_event->eventcode =~
- /\$cust_bill\->realtime_(card|ach|lec)/
- && $_->status eq 'done'
- && $_->statustext
- }
- $cust_bill->cust_bill_event;
- next unless @cust_bill_event;
- my $error = $cust_bill_event[0]->retry;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "error scheduling invoice event for retry: $error";
- }
-
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
- '';
-
-}
-
-=item realtime_bop METHOD AMOUNT [ OPTION => VALUE ... ]
-
-Runs a realtime credit card, ACH (electronic check) or phone bill transaction
-via a Business::OnlinePayment realtime gateway. See
-L<http://420.am/business-onlinepayment> for supported gateways.
-
-Available methods are: I<CC>, I<ECHECK> and I<LEC>
-
-Available options are: I<description>, I<invnum>, I<quiet>
-
-The additional options I<payname>, I<address1>, I<address2>, I<city>, I<state>,
-I<zip>, I<payinfo> and I<paydate> are also available. Any of these options,
-if set, will override the value from the customer record.
-
-I<description> is a free-text field passed to the gateway. It defaults to
-"Internet services".
-
-If an I<invnum> is specified, this payment (if sucessful) is applied to the
-specified invoice. If you don't specify an I<invnum> you might want to
-call the B<apply_payments> method.
-
-I<quiet> can be set true to surpress email decline notices.
-
-(moved from cust_bill) (probably should get realtime_{card,ach,lec} here too)
-
-=cut
-
-sub realtime_bop {
- my( $self, $method, $amount, %options ) = @_;
- if ( $DEBUG ) {
- warn "$self $method $amount\n";
- warn " $_ => $options{$_}\n" foreach keys %options;
- }
-
- $options{'description'} ||= 'Internet services';
-
- #pre-requisites
- die "Real-time processing not enabled\n"
- unless $conf->exists('business-onlinepayment');
- eval "use Business::OnlinePayment";
- die $@ if $@;
-
- #overrides
- $self->set( $_ => $options{$_} )
- foreach grep { exists($options{$_}) }
- qw( payname address1 address2 city state zip payinfo paydate paycvv);
-
- #load up config
- my $bop_config = 'business-onlinepayment';
- $bop_config .= '-ach'
- if $method eq 'ECHECK' && $conf->exists($bop_config. '-ach');
- my ( $processor, $login, $password, $action, @bop_options ) =
- $conf->config($bop_config);
- $action ||= 'normal authorization';
- pop @bop_options if scalar(@bop_options) % 2 && $bop_options[-1] =~ /^\s*$/;
- die "No real-time processor is enabled - ".
- "did you set the business-onlinepayment configuration value?\n"
- unless $processor;
-
- #massage data
-
- my $address = $self->address1;
- $address .= ", ". $self->address2 if $self->address2;
-
- my($payname, $payfirst, $paylast);
- if ( $self->payname && $method ne 'ECHECK' ) {
- $payname = $self->payname;
- $payname =~ /^\s*([\w \,\.\-\']*)?\s+([\w\,\.\-\']+)\s*$/
- or return "Illegal payname $payname";
- ($payfirst, $paylast) = ($1, $2);
- } else {
- $payfirst = $self->getfield('first');
- $paylast = $self->getfield('last');
- $payname = "$payfirst $paylast";
- }
-
- my @invoicing_list = grep { $_ ne 'POST' } $self->invoicing_list;
- if ( $conf->exists('emailinvoiceauto')
- || ( $conf->exists('emailinvoiceonly') && ! @invoicing_list ) ) {
- push @invoicing_list, $self->all_emails;
- }
- my $email = $invoicing_list[0];
-
- my %content;
- if ( $method eq 'CC' ) {
-
- $content{card_number} = $self->payinfo;
- $self->paydate =~ /^\d{2}(\d{2})[\/\-](\d+)[\/\-]\d+$/;
- $content{expiration} = "$2/$1";
-
- $content{cvv2} = $self->paycvv
- if defined $self->dbdef_table->column('paycvv')
- && length($self->paycvv);
-
- $content{recurring_billing} = 'YES'
- if qsearch('cust_pay', { 'custnum' => $self->custnum,
- 'payby' => 'CARD',
- 'payinfo' => $self->payinfo, } );
-
- } elsif ( $method eq 'ECHECK' ) {
- my($account_number,$routing_code) = $self->payinfo;
- ( $content{account_number}, $content{routing_code} ) =
- split('@', $self->payinfo);
- $content{bank_name} = $self->payname;
- $content{account_type} = 'CHECKING';
- $content{account_name} = $payname;
- $content{customer_org} = $self->company ? 'B' : 'I';
- $content{customer_ssn} = $self->ss;
- } elsif ( $method eq 'LEC' ) {
- $content{phone} = $self->payinfo;
- }
-
- #transaction(s)
-
- my( $action1, $action2 ) = split(/\s*\,\s*/, $action );
-
- my $transaction =
- new Business::OnlinePayment( $processor, @bop_options );
- $transaction->content(
- 'type' => $method,
- 'login' => $login,
- 'password' => $password,
- 'action' => $action1,
- 'description' => $options{'description'},
- 'amount' => $amount,
- 'invoice_number' => $options{'invnum'},
- 'customer_id' => $self->custnum,
- 'last_name' => $paylast,
- 'first_name' => $payfirst,
- 'name' => $payname,
- 'address' => $address,
- 'city' => $self->city,
- 'state' => $self->state,
- 'zip' => $self->zip,
- 'country' => $self->country,
- 'referer' => 'http://cleanwhisker.420.am/',
- 'email' => $email,
- 'phone' => $self->daytime || $self->night,
- %content, #after
- );
- $transaction->submit();
-
- if ( $transaction->is_success() && $action2 ) {
- my $auth = $transaction->authorization;
- my $ordernum = $transaction->can('order_number')
- ? $transaction->order_number
- : '';
-
- my $capture =
- new Business::OnlinePayment( $processor, @bop_options );
-
- my %capture = (
- %content,
- type => $method,
- action => $action2,
- login => $login,
- password => $password,
- order_number => $ordernum,
- amount => $amount,
- authorization => $auth,
- description => $options{'description'},
- );
-
- foreach my $field (qw( authorization_source_code returned_ACI transaction_identifier validation_code
- transaction_sequence_num local_transaction_date
- local_transaction_time AVS_result_code )) {
- $capture{$field} = $transaction->$field() if $transaction->can($field);
- }
-
- $capture->content( %capture );
-
- $capture->submit();
-
- unless ( $capture->is_success ) {
- my $e = "Authorization sucessful but capture failed, custnum #".
- $self->custnum. ': '. $capture->result_code.
- ": ". $capture->error_message;
- warn $e;
- return $e;
- }
-
- }
-
- #remove paycvv after initial transaction
- #false laziness w/misc/process/payment.cgi - check both to make sure working
- # correctly
- if ( defined $self->dbdef_table->column('paycvv')
- && length($self->paycvv)
- && ! grep { $_ eq cardtype($self->payinfo) } $conf->config('cvv-save')
- && ! length($options{'paycvv'})
- ) {
- my $new = new FS::cust_main { $self->hash };
- $new->paycvv('');
- my $error = $new->replace($self);
- if ( $error ) {
- warn "error removing cvv: $error\n";
- }
- }
-
- #result handling
- if ( $transaction->is_success() ) {
-
- my %method2payby = (
- 'CC' => 'CARD',
- 'ECHECK' => 'CHEK',
- 'LEC' => 'LECB',
- );
-
- my $cust_pay = new FS::cust_pay ( {
- 'custnum' => $self->custnum,
- 'invnum' => $options{'invnum'},
- 'paid' => $amount,
- '_date' => '',
- 'payby' => $method2payby{$method},
- 'payinfo' => $self->payinfo,
- 'paybatch' => "$processor:". $transaction->authorization,
- } );
- my $error = $cust_pay->insert;
- if ( $error ) {
- $cust_pay->invnum(''); #try again with no specific invnum
- my $error2 = $cust_pay->insert;
- if ( $error2 ) {
- # gah, even with transactions.
- my $e = 'WARNING: Card/ACH debited but database not updated - '.
- "error inserting payment ($processor): $error2".
- " (previously tried insert with invnum #$options{'invnum'}" .
- ": $error )";
- warn $e;
- return $e;
- }
- }
- return ''; #no error
-
- } else {
-
- my $perror = "$processor error: ". $transaction->error_message;
-
- if ( !$options{'quiet'} && !$realtime_bop_decline_quiet
- && $conf->exists('emaildecline')
- && grep { $_ ne 'POST' } $self->invoicing_list
- && ! grep { $transaction->error_message =~ /$_/ }
- $conf->config('emaildecline-exclude')
- ) {
- my @templ = $conf->config('declinetemplate');
- my $template = new Text::Template (
- TYPE => 'ARRAY',
- SOURCE => [ map "$_\n", @templ ],
- ) or return "($perror) can't create template: $Text::Template::ERROR";
- $template->compile()
- or return "($perror) can't compile template: $Text::Template::ERROR";
-
- my $templ_hash = { error => $transaction->error_message };
-
- my $error = send_email(
- 'from' => $conf->config('invoice_from'),
- 'to' => [ grep { $_ ne 'POST' } $self->invoicing_list ],
- 'subject' => 'Your payment could not be processed',
- 'body' => [ $template->fill_in(HASH => $templ_hash) ],
- );
-
- $perror .= " (also received error sending decline notification: $error)"
- if $error;
-
- }
-
- return $perror;
- }
-
-}
-
-=item total_owed
-
-Returns the total owed for this customer on all invoices
-(see L<FS::cust_bill/owed>).
-
-=cut
-
-sub total_owed {
- my $self = shift;
- $self->total_owed_date(2145859200); #12/31/2037
-}
-
-=item total_owed_date TIME
-
-Returns the total owed for this customer on all invoices with date earlier than
-TIME. TIME is specified as a UNIX timestamp; see L<perlfunc/"time">). Also
-see L<Time::Local> and L<Date::Parse> for conversion functions.
-
-=cut
-
-sub total_owed_date {
- my $self = shift;
- my $time = shift;
- my $total_bill = 0;
- foreach my $cust_bill (
- grep { $_->_date <= $time }
- qsearch('cust_bill', { 'custnum' => $self->custnum, } )
- ) {
- $total_bill += $cust_bill->owed;
- }
- sprintf( "%.2f", $total_bill );
-}
-
-=item apply_credits
-
-Applies (see L<FS::cust_credit_bill>) unapplied credits (see L<FS::cust_credit>)
-to outstanding invoice balances in chronological order and returns the value
-of any remaining unapplied credits available for refund
-(see L<FS::cust_refund>).
-
-=cut
-
-sub apply_credits {
- my $self = shift;
-
- return 0 unless $self->total_credited;
-
- my @credits = sort { $b->_date <=> $a->_date} (grep { $_->credited > 0 }
- qsearch('cust_credit', { 'custnum' => $self->custnum } ) );
-
- my @invoices = sort { $a->_date <=> $b->_date} (grep { $_->owed > 0 }
- qsearch('cust_bill', { 'custnum' => $self->custnum } ) );
-
- my $credit;
-
- foreach my $cust_bill ( @invoices ) {
- my $amount;
-
- if ( !defined($credit) || $credit->credited == 0) {
- $credit = pop @credits or last;
- }
-
- if ($cust_bill->owed >= $credit->credited) {
- $amount=$credit->credited;
- }else{
- $amount=$cust_bill->owed;
- }
-
- my $cust_credit_bill = new FS::cust_credit_bill ( {
- 'crednum' => $credit->crednum,
- 'invnum' => $cust_bill->invnum,
- 'amount' => $amount,
- } );
- my $error = $cust_credit_bill->insert;
- die $error if $error;
-
- redo if ($cust_bill->owed > 0);
-
- }
-
- return $self->total_credited;
-}
-
-=item apply_payments
-
-Applies (see L<FS::cust_bill_pay>) unapplied payments (see L<FS::cust_pay>)
-to outstanding invoice balances in chronological order.
-
- #and returns the value of any remaining unapplied payments.
-
-=cut
-
-sub apply_payments {
- my $self = shift;
-
- #return 0 unless
-
- my @payments = sort { $b->_date <=> $a->_date } ( grep { $_->unapplied > 0 }
- qsearch('cust_pay', { 'custnum' => $self->custnum } ) );
-
- my @invoices = sort { $a->_date <=> $b->_date} (grep { $_->owed > 0 }
- qsearch('cust_bill', { 'custnum' => $self->custnum } ) );
-
- my $payment;
-
- foreach my $cust_bill ( @invoices ) {
- my $amount;
-
- if ( !defined($payment) || $payment->unapplied == 0 ) {
- $payment = pop @payments or last;
- }
-
- if ( $cust_bill->owed >= $payment->unapplied ) {
- $amount = $payment->unapplied;
- } else {
- $amount = $cust_bill->owed;
- }
-
- my $cust_bill_pay = new FS::cust_bill_pay ( {
- 'paynum' => $payment->paynum,
- 'invnum' => $cust_bill->invnum,
- 'amount' => $amount,
- } );
- my $error = $cust_bill_pay->insert;
- die $error if $error;
-
- redo if ( $cust_bill->owed > 0);
-
- }
-
- return $self->total_unapplied_payments;
-}
-
-=item total_credited
-
-Returns the total outstanding credit (see L<FS::cust_credit>) for this
-customer. See L<FS::cust_credit/credited>.
-
-=cut
-
-sub total_credited {
- my $self = shift;
- my $total_credit = 0;
- foreach my $cust_credit ( qsearch('cust_credit', {
- 'custnum' => $self->custnum,
- } ) ) {
- $total_credit += $cust_credit->credited;
- }
- sprintf( "%.2f", $total_credit );
-}
-
-=item total_unapplied_payments
-
-Returns the total unapplied payments (see L<FS::cust_pay>) for this customer.
-See L<FS::cust_pay/unapplied>.
-
-=cut
-
-sub total_unapplied_payments {
- my $self = shift;
- my $total_unapplied = 0;
- foreach my $cust_pay ( qsearch('cust_pay', {
- 'custnum' => $self->custnum,
- } ) ) {
- $total_unapplied += $cust_pay->unapplied;
- }
- sprintf( "%.2f", $total_unapplied );
-}
-
-=item balance
-
-Returns the balance for this customer (total_owed minus total_credited
-minus total_unapplied_payments).
-
-=cut
-
-sub balance {
- my $self = shift;
- sprintf( "%.2f",
- $self->total_owed - $self->total_credited - $self->total_unapplied_payments
- );
-}
-
-=item balance_date TIME
-
-Returns the balance for this customer, only considering invoices with date
-earlier than TIME (total_owed_date minus total_credited minus
-total_unapplied_payments). TIME is specified as a UNIX timestamp; see
-L<perlfunc/"time">). Also see L<Time::Local> and L<Date::Parse> for conversion
-functions.
-
-=cut
-
-sub balance_date {
- my $self = shift;
- my $time = shift;
- sprintf( "%.2f",
- $self->total_owed_date($time)
- - $self->total_credited
- - $self->total_unapplied_payments
- );
-}
-
-=item paydate_monthyear
-
-Returns a two-element list consisting of the month and year of this customer's
-paydate (credit card expiration date for CARD customers)
-
-=cut
-
-sub paydate_monthyear {
- my $self = shift;
- if ( $self->paydate =~ /^(\d{4})-(\d{2})-\d{2}$/ ) { #Pg date format
- ( $2, $1 );
- } elsif ( $self->paydate =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
- ( $1, $3 );
- } else {
- ('', '');
- }
-}
-
-=item invoicing_list [ ARRAYREF ]
-
-If an arguement is given, sets these email addresses as invoice recipients
-(see L<FS::cust_main_invoice>). Errors are not fatal and are not reported
-(except as warnings), so use check_invoicing_list first.
-
-Returns a list of email addresses (with svcnum entries expanded).
-
-Note: You can clear the invoicing list by passing an empty ARRAYREF. You can
-check it without disturbing anything by passing nothing.
-
-This interface may change in the future.
-
-=cut
-
-sub invoicing_list {
- my( $self, $arrayref ) = @_;
- if ( $arrayref ) {
- my @cust_main_invoice;
- if ( $self->custnum ) {
- @cust_main_invoice =
- qsearch( 'cust_main_invoice', { 'custnum' => $self->custnum } );
- } else {
- @cust_main_invoice = ();
- }
- foreach my $cust_main_invoice ( @cust_main_invoice ) {
- #warn $cust_main_invoice->destnum;
- unless ( grep { $cust_main_invoice->address eq $_ } @{$arrayref} ) {
- #warn $cust_main_invoice->destnum;
- my $error = $cust_main_invoice->delete;
- warn $error if $error;
- }
- }
- if ( $self->custnum ) {
- @cust_main_invoice =
- qsearch( 'cust_main_invoice', { 'custnum' => $self->custnum } );
- } else {
- @cust_main_invoice = ();
- }
- my %seen = map { $_->address => 1 } @cust_main_invoice;
- foreach my $address ( @{$arrayref} ) {
- next if exists $seen{$address} && $seen{$address};
- $seen{$address} = 1;
- my $cust_main_invoice = new FS::cust_main_invoice ( {
- 'custnum' => $self->custnum,
- 'dest' => $address,
- } );
- my $error = $cust_main_invoice->insert;
- warn $error if $error;
- }
- }
- if ( $self->custnum ) {
- map { $_->address }
- qsearch( 'cust_main_invoice', { 'custnum' => $self->custnum } );
- } else {
- ();
- }
-}
-
-=item check_invoicing_list ARRAYREF
-
-Checks these arguements as valid input for the invoicing_list method. If there
-is an error, returns the error, otherwise returns false.
-
-=cut
-
-sub check_invoicing_list {
- my( $self, $arrayref ) = @_;
- foreach my $address ( @{$arrayref} ) {
- my $cust_main_invoice = new FS::cust_main_invoice ( {
- 'custnum' => $self->custnum,
- 'dest' => $address,
- } );
- my $error = $self->custnum
- ? $cust_main_invoice->check
- : $cust_main_invoice->checkdest
- ;
- return $error if $error;
- }
- '';
-}
-
-=item set_default_invoicing_list
-
-Sets the invoicing list to all accounts associated with this customer,
-overwriting any previous invoicing list.
-
-=cut
-
-sub set_default_invoicing_list {
- my $self = shift;
- $self->invoicing_list($self->all_emails);
-}
-
-=item all_emails
-
-Returns the email addresses of all accounts provisioned for this customer.
-
-=cut
-
-sub all_emails {
- my $self = shift;
- my %list;
- foreach my $cust_pkg ( $self->all_pkgs ) {
- my @cust_svc = qsearch('cust_svc', { 'pkgnum' => $cust_pkg->pkgnum } );
- my @svc_acct =
- map { qsearchs('svc_acct', { 'svcnum' => $_->svcnum } ) }
- grep { qsearchs('svc_acct', { 'svcnum' => $_->svcnum } ) }
- @cust_svc;
- $list{$_}=1 foreach map { $_->email } @svc_acct;
- }
- keys %list;
-}
-
-=item invoicing_list_addpost
-
-Adds postal invoicing to this customer. If this customer is already configured
-to receive postal invoices, does nothing.
-
-=cut
-
-sub invoicing_list_addpost {
- my $self = shift;
- return if grep { $_ eq 'POST' } $self->invoicing_list;
- my @invoicing_list = $self->invoicing_list;
- push @invoicing_list, 'POST';
- $self->invoicing_list(\@invoicing_list);
-}
-
-=item referral_cust_main [ DEPTH [ EXCLUDE_HASHREF ] ]
-
-Returns an array of customers referred by this customer (referral_custnum set
-to this custnum). If DEPTH is given, recurses up to the given depth, returning
-customers referred by customers referred by this customer and so on, inclusive.
-The default behavior is DEPTH 1 (no recursion).
-
-=cut
-
-sub referral_cust_main {
- my $self = shift;
- my $depth = @_ ? shift : 1;
- my $exclude = @_ ? shift : {};
-
- my @cust_main =
- map { $exclude->{$_->custnum}++; $_; }
- grep { ! $exclude->{ $_->custnum } }
- qsearch( 'cust_main', { 'referral_custnum' => $self->custnum } );
-
- if ( $depth > 1 ) {
- push @cust_main,
- map { $_->referral_cust_main($depth-1, $exclude) }
- @cust_main;
- }
-
- @cust_main;
-}
-
-=item referral_cust_main_ncancelled
-
-Same as referral_cust_main, except only returns customers with uncancelled
-packages.
-
-=cut
-
-sub referral_cust_main_ncancelled {
- my $self = shift;
- grep { scalar($_->ncancelled_pkgs) } $self->referral_cust_main;
-}
-
-=item referral_cust_pkg [ DEPTH ]
-
-Like referral_cust_main, except returns a flat list of all unsuspended (and
-uncancelled) packages for each customer. The number of items in this list may
-be useful for comission calculations (perhaps after a C<grep { my $pkgpart = $_->pkgpart; grep { $_ == $pkgpart } @commission_worthy_pkgparts> } $cust_main-> ).
-
-=cut
-
-sub referral_cust_pkg {
- my $self = shift;
- my $depth = @_ ? shift : 1;
-
- map { $_->unsuspended_pkgs }
- grep { $_->unsuspended_pkgs }
- $self->referral_cust_main($depth);
-}
-
-=item credit AMOUNT, REASON
-
-Applies a credit to this customer. If there is an error, returns the error,
-otherwise returns false.
-
-=cut
-
-sub credit {
- my( $self, $amount, $reason ) = @_;
- my $cust_credit = new FS::cust_credit {
- 'custnum' => $self->custnum,
- 'amount' => $amount,
- 'reason' => $reason,
- };
- $cust_credit->insert;
-}
-
-=item charge AMOUNT [ PKG [ COMMENT [ TAXCLASS ] ] ]
-
-Creates a one-time charge for this customer. If there is an error, returns
-the error, otherwise returns false.
-
-=cut
-
-sub charge {
- my ( $self, $amount ) = ( shift, shift );
- my $pkg = @_ ? shift : 'One-time charge';
- my $comment = @_ ? shift : '$'. sprintf("%.2f",$amount);
- my $taxclass = @_ ? shift : '';
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- my $part_pkg = new FS::part_pkg ( {
- 'pkg' => $pkg,
- 'comment' => $comment,
- 'setup' => $amount,
- 'freq' => 0,
- 'recur' => '0',
- 'disabled' => 'Y',
- 'taxclass' => $taxclass,
- } );
-
- my $error = $part_pkg->insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- my $pkgpart = $part_pkg->pkgpart;
- my %type_pkgs = ( 'typenum' => $self->agent->typenum, 'pkgpart' => $pkgpart );
- unless ( qsearchs('type_pkgs', \%type_pkgs ) ) {
- my $type_pkgs = new FS::type_pkgs \%type_pkgs;
- $error = $type_pkgs->insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
-
- my $cust_pkg = new FS::cust_pkg ( {
- 'custnum' => $self->custnum,
- 'pkgpart' => $pkgpart,
- } );
-
- $error = $cust_pkg->insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
- '';
-
-}
-
-=item cust_bill
-
-Returns all the invoices (see L<FS::cust_bill>) for this customer.
-
-=cut
-
-sub cust_bill {
- my $self = shift;
- sort { $a->_date <=> $b->_date }
- qsearch('cust_bill', { 'custnum' => $self->custnum, } )
-}
-
-=item open_cust_bill
-
-Returns all the open (owed > 0) invoices (see L<FS::cust_bill>) for this
-customer.
-
-=cut
-
-sub open_cust_bill {
- my $self = shift;
- grep { $_->owed > 0 } $self->cust_bill;
-}
-
-=item cust_credit
-
-Returns all the credits (see L<FS::cust_credit>) for this customer.
-
-=cut
-
-sub cust_credit {
- my $self = shift;
- sort { $a->_date <=> $b->_date }
- qsearch( 'cust_credit', { 'custnum' => $self->custnum } )
-}
-
-=item cust_pay
-
-Returns all the payments (see L<FS::cust_pay>) for this customer.
-
-=cut
-
-sub cust_pay {
- my $self = shift;
- sort { $a->_date <=> $b->_date }
- qsearch( 'cust_pay', { 'custnum' => $self->custnum } )
-}
-
-=item cust_refund
-
-Returns all the refunds (see L<FS::cust_refund>) for this customer.
-
-=cut
-
-sub cust_refund {
- my $self = shift;
- sort { $a->_date <=> $b->_date }
- qsearch( 'cust_refund', { 'custnum' => $self->custnum } )
-}
-
-=item select_for_update
-
-Selects this record with the SQL "FOR UPDATE" command. This can be useful as
-a mutex.
-
-=cut
-
-sub select_for_update {
- my $self = shift;
- qsearch('cust_main', { 'custnum' => $self->custnum }, '*', 'FOR UPDATE' );
-}
-
-=back
-
-=head1 SUBROUTINES
-
-=over 4
-
-=item check_and_rebuild_fuzzyfiles
-
-=cut
-
-sub check_and_rebuild_fuzzyfiles {
- my $dir = $FS::UID::conf_dir. "cache.". $FS::UID::datasrc;
- -e "$dir/cust_main.last" && -e "$dir/cust_main.company"
- or &rebuild_fuzzyfiles;
-}
-
-=item rebuild_fuzzyfiles
-
-=cut
-
-sub rebuild_fuzzyfiles {
-
- use Fcntl qw(:flock);
-
- my $dir = $FS::UID::conf_dir. "cache.". $FS::UID::datasrc;
-
- #last
-
- open(LASTLOCK,">>$dir/cust_main.last")
- or die "can't open $dir/cust_main.last: $!";
- flock(LASTLOCK,LOCK_EX)
- or die "can't lock $dir/cust_main.last: $!";
-
- my @all_last = map $_->getfield('last'), qsearch('cust_main', {});
- push @all_last,
- grep $_, map $_->getfield('ship_last'), qsearch('cust_main',{})
- if defined dbdef->table('cust_main')->column('ship_last');
-
- open (LASTCACHE,">$dir/cust_main.last.tmp")
- or die "can't open $dir/cust_main.last.tmp: $!";
- print LASTCACHE join("\n", @all_last), "\n";
- close LASTCACHE or die "can't close $dir/cust_main.last.tmp: $!";
-
- rename "$dir/cust_main.last.tmp", "$dir/cust_main.last";
- close LASTLOCK;
-
- #company
-
- open(COMPANYLOCK,">>$dir/cust_main.company")
- or die "can't open $dir/cust_main.company: $!";
- flock(COMPANYLOCK,LOCK_EX)
- or die "can't lock $dir/cust_main.company: $!";
-
- my @all_company = grep $_ ne '', map $_->company, qsearch('cust_main',{});
- push @all_company,
- grep $_ ne '', map $_->ship_company, qsearch('cust_main', {})
- if defined dbdef->table('cust_main')->column('ship_last');
-
- open (COMPANYCACHE,">$dir/cust_main.company.tmp")
- or die "can't open $dir/cust_main.company.tmp: $!";
- print COMPANYCACHE join("\n", @all_company), "\n";
- close COMPANYCACHE or die "can't close $dir/cust_main.company.tmp: $!";
-
- rename "$dir/cust_main.company.tmp", "$dir/cust_main.company";
- close COMPANYLOCK;
-
-}
-
-=item all_last
-
-=cut
-
-sub all_last {
- my $dir = $FS::UID::conf_dir. "cache.". $FS::UID::datasrc;
- open(LASTCACHE,"<$dir/cust_main.last")
- or die "can't open $dir/cust_main.last: $!";
- my @array = map { chomp; $_; } <LASTCACHE>;
- close LASTCACHE;
- \@array;
-}
-
-=item all_company
-
-=cut
-
-sub all_company {
- my $dir = $FS::UID::conf_dir. "cache.". $FS::UID::datasrc;
- open(COMPANYCACHE,"<$dir/cust_main.company")
- or die "can't open $dir/cust_main.last: $!";
- my @array = map { chomp; $_; } <COMPANYCACHE>;
- close COMPANYCACHE;
- \@array;
-}
-
-=item append_fuzzyfiles LASTNAME COMPANY
-
-=cut
-
-sub append_fuzzyfiles {
- my( $last, $company ) = @_;
-
- &check_and_rebuild_fuzzyfiles;
-
- use Fcntl qw(:flock);
-
- my $dir = $FS::UID::conf_dir. "cache.". $FS::UID::datasrc;
-
- if ( $last ) {
-
- open(LAST,">>$dir/cust_main.last")
- or die "can't open $dir/cust_main.last: $!";
- flock(LAST,LOCK_EX)
- or die "can't lock $dir/cust_main.last: $!";
-
- print LAST "$last\n";
-
- flock(LAST,LOCK_UN)
- or die "can't unlock $dir/cust_main.last: $!";
- close LAST;
- }
-
- if ( $company ) {
-
- open(COMPANY,">>$dir/cust_main.company")
- or die "can't open $dir/cust_main.company: $!";
- flock(COMPANY,LOCK_EX)
- or die "can't lock $dir/cust_main.company: $!";
-
- print COMPANY "$company\n";
-
- flock(COMPANY,LOCK_UN)
- or die "can't unlock $dir/cust_main.company: $!";
-
- close COMPANY;
- }
-
- 1;
-}
-
-=item batch_import
-
-=cut
-
-sub batch_import {
- my $param = shift;
- #warn join('-',keys %$param);
- my $fh = $param->{filehandle};
- my $agentnum = $param->{agentnum};
- my $refnum = $param->{refnum};
- my $pkgpart = $param->{pkgpart};
- my @fields = @{$param->{fields}};
-
- eval "use Date::Parse;";
- die $@ if $@;
- eval "use Text::CSV_XS;";
- die $@ if $@;
-
- my $csv = new Text::CSV_XS;
- #warn $csv;
- #warn $fh;
-
- my $imported = 0;
- #my $columns;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- #while ( $columns = $csv->getline($fh) ) {
- my $line;
- while ( defined($line=<$fh>) ) {
-
- $csv->parse($line) or do {
- $dbh->rollback if $oldAutoCommit;
- return "can't parse: ". $csv->error_input();
- };
-
- my @columns = $csv->fields();
- #warn join('-',@columns);
-
- my %cust_main = (
- agentnum => $agentnum,
- refnum => $refnum,
- country => 'US', #default
- payby => 'BILL', #default
- paydate => '12/2037', #default
- );
- my $billtime = time;
- my %cust_pkg = ( pkgpart => $pkgpart );
- foreach my $field ( @fields ) {
- if ( $field =~ /^cust_pkg\.(setup|bill|susp|expire|cancel)$/ ) {
- #$cust_pkg{$1} = str2time( shift @$columns );
- if ( $1 eq 'setup' ) {
- $billtime = str2time(shift @columns);
- } else {
- $cust_pkg{$1} = str2time( shift @columns );
- }
- } else {
- #$cust_main{$field} = shift @$columns;
- $cust_main{$field} = shift @columns;
- }
- }
-
- my $cust_pkg = new FS::cust_pkg ( \%cust_pkg ) if $pkgpart;
- my $cust_main = new FS::cust_main ( \%cust_main );
- use Tie::RefHash;
- tie my %hash, 'Tie::RefHash'; #this part is important
- $hash{$cust_pkg} = [] if $pkgpart;
- my $error = $cust_main->insert( \%hash );
-
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "can't insert customer for $line: $error";
- }
-
- #false laziness w/bill.cgi
- $error = $cust_main->bill( 'time' => $billtime );
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "can't bill customer for $line: $error";
- }
-
- $cust_main->apply_payments;
- $cust_main->apply_credits;
-
- $error = $cust_main->collect();
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "can't collect customer for $line: $error";
- }
-
- $imported++;
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
-
- return "Empty file!" unless $imported;
-
- ''; #no error
-
-}
-
-=item batch_charge
-
-=cut
-
-sub batch_charge {
- my $param = shift;
- #warn join('-',keys %$param);
- my $fh = $param->{filehandle};
- my @fields = @{$param->{fields}};
-
- eval "use Date::Parse;";
- die $@ if $@;
- eval "use Text::CSV_XS;";
- die $@ if $@;
-
- my $csv = new Text::CSV_XS;
- #warn $csv;
- #warn $fh;
-
- my $imported = 0;
- #my $columns;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- #while ( $columns = $csv->getline($fh) ) {
- my $line;
- while ( defined($line=<$fh>) ) {
-
- $csv->parse($line) or do {
- $dbh->rollback if $oldAutoCommit;
- return "can't parse: ". $csv->error_input();
- };
-
- my @columns = $csv->fields();
- #warn join('-',@columns);
-
- my %row = ();
- foreach my $field ( @fields ) {
- $row{$field} = shift @columns;
- }
-
- my $cust_main = qsearchs('cust_main', { 'custnum' => $row{'custnum'} } );
- unless ( $cust_main ) {
- $dbh->rollback if $oldAutoCommit;
- return "unknown custnum $row{'custnum'}";
- }
-
- if ( $row{'amount'} > 0 ) {
- my $error = $cust_main->charge($row{'amount'}, $row{'pkg'});
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- $imported++;
- } elsif ( $row{'amount'} < 0 ) {
- my $error = $cust_main->credit( sprintf( "%.2f", 0-$row{'amount'} ),
- $row{'pkg'} );
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- $imported++;
- } else {
- #hmm?
- }
-
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
-
- return "Empty file!" unless $imported;
-
- ''; #no error
-
-}
-
-=back
-
-=head1 BUGS
-
-The delete method.
-
-The delete method should possibly take an FS::cust_main object reference
-instead of a scalar customer number.
-
-Bill and collect options should probably be passed as references instead of a
-list.
-
-There should probably be a configuration file with a list of allowed credit
-card types.
-
-No multiple currency support (probably a larger project than just this module).
-
-=head1 SEE ALSO
-
-L<FS::Record>, L<FS::cust_pkg>, L<FS::cust_bill>, L<FS::cust_credit>
-L<FS::agent>, L<FS::part_referral>, L<FS::cust_main_county>,
-L<FS::cust_main_invoice>, L<FS::UID>, schema.html from the base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/cust_main_county.pm b/FS/FS/cust_main_county.pm
deleted file mode 100644
index ef2793a..0000000
--- a/FS/FS/cust_main_county.pm
+++ /dev/null
@@ -1,290 +0,0 @@
-package FS::cust_main_county;
-
-use strict;
-use vars qw( @ISA @EXPORT_OK $conf
- @cust_main_county %cust_main_county $countyflag );
-use Exporter;
-use FS::Record qw( qsearch );
-
-@ISA = qw( FS::Record );
-@EXPORT_OK = qw( regionselector );
-
-@cust_main_county = ();
-$countyflag = '';
-
-#ask FS::UID to run this stuff for us later
-$FS::UID::callback{'FS::cust_main_county'} = sub {
- $conf = new FS::Conf;
-};
-
-=head1 NAME
-
-FS::cust_main_county - Object methods for cust_main_county objects
-
-=head1 SYNOPSIS
-
- use FS::cust_main_county;
-
- $record = new FS::cust_main_county \%hash;
- $record = new FS::cust_main_county { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
- ($county_html, $state_html, $country_html) =
- FS::cust_main_county::regionselector( $county, $state, $country );
-
-=head1 DESCRIPTION
-
-An FS::cust_main_county object represents a tax rate, defined by locale.
-FS::cust_main_county inherits from FS::Record. The following fields are
-currently supported:
-
-=over 4
-
-=item taxnum - primary key (assigned automatically for new tax rates)
-
-=item state
-
-=item county
-
-=item country
-
-=item tax - percentage
-
-=item taxclass
-
-=item exempt_amount
-
-=item taxname - if defined, printed on invoices instead of "Tax"
-
-=item setuptax - if 'Y', this tax does not apply to setup fees
-
-=item recurtax - if 'Y', this tax does not apply to recurring fees
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new tax rate. To add the tax rate to the database, see L<"insert">.
-
-=cut
-
-sub table { 'cust_main_county'; }
-
-=item insert
-
-Adds this tax rate to the database. If there is an error, returns the error,
-otherwise returns false.
-
-=item delete
-
-Deletes this tax rate from the database. If there is an error, returns the
-error, otherwise returns false.
-
-=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.
-
-=item check
-
-Checks all fields to make sure this is a valid tax rate. If there is an error,
-returns the error, otherwise returns false. Called by the insert and replace
-methods.
-
-=cut
-
-sub check {
- my $self = shift;
-
- $self->exempt_amount(0) unless $self->exempt_amount;
-
- $self->ut_numbern('taxnum')
- || $self->ut_anything('state')
- || $self->ut_textn('county')
- || $self->ut_text('country')
- || $self->ut_float('tax')
- || $self->ut_textn('taxclass') # ...
- || $self->ut_money('exempt_amount')
- || $self->ut_textn('taxname')
- || $self->ut_enum('setuptax', [ '', 'Y' ] )
- || $self->ut_enum('recurtax', [ '', 'Y' ] )
- || $self->SUPER::check
- ;
-
-}
-
-sub taxname {
- my $self = shift;
- if ( $self->dbdef_table->column('taxname') ) {
- return $self->setfield('taxname', $_[0]) if @_;
- return $self->getfield('taxname');
- }
- return '';
-}
-
-sub setuptax {
- my $self = shift;
- if ( $self->dbdef_table->column('setuptax') ) {
- return $self->setfield('setuptax', $_[0]) if @_;
- return $self->getfield('setuptax');
- }
- return '';
-}
-
-sub recurtax {
- my $self = shift;
- if ( $self->dbdef_table->column('recurtax') ) {
- return $self->setfield('recurtax', $_[0]) if @_;
- return $self->getfield('recurtax');
- }
- return '';
-}
-
-=back
-
-=head1 SUBROUTINES
-
-=over 4
-
-=item regionselector [ COUNTY STATE COUNTRY [ PREFIX [ ONCHANGE ] ] ]
-
-=cut
-
-sub regionselector {
- my ( $selected_county, $selected_state, $selected_country,
- $prefix, $onchange ) = @_;
-
- $prefix = '' unless defined $prefix;
-
- $countyflag = 0;
-
-# unless ( @cust_main_county ) { #cache
- @cust_main_county = qsearch('cust_main_county', {} );
- foreach my $c ( @cust_main_county ) {
- $countyflag=1 if $c->county;
- #push @{$cust_main_county{$c->country}{$c->state}}, $c->county;
- $cust_main_county{$c->country}{$c->state}{$c->county} = 1;
- }
-# }
- $countyflag=1 if $selected_county;
-
- my $script_html = <<END;
- <SCRIPT>
- function opt(what,value,text) {
- var optionName = new Option(text, value, false, false);
- var length = what.length;
- what.options[length] = optionName;
- }
- function ${prefix}country_changed(what) {
- country = what.options[what.selectedIndex].text;
- for ( var i = what.form.${prefix}state.length; i >= 0; i-- )
- what.form.${prefix}state.options[i] = null;
-END
- #what.form.${prefix}state.options[0] = new Option('', '', false, true);
-
- foreach my $country ( sort keys %cust_main_county ) {
- $script_html .= "\nif ( country == \"$country\" ) {\n";
- foreach my $state ( sort keys %{$cust_main_county{$country}} ) {
- my $text = $state || '(n/a)';
- $script_html .= qq!opt(what.form.${prefix}state, "$state", "$text");\n!;
- }
- $script_html .= "}\n";
- }
-
- $script_html .= <<END;
- }
- function ${prefix}state_changed(what) {
-END
-
- if ( $countyflag ) {
- $script_html .= <<END;
- state = what.options[what.selectedIndex].text;
- country = what.form.${prefix}country.options[what.form.${prefix}country.selectedIndex].text;
- for ( var i = what.form.${prefix}county.length; i >= 0; i-- )
- what.form.${prefix}county.options[i] = null;
-END
-
- foreach my $country ( sort keys %cust_main_county ) {
- $script_html .= "\nif ( country == \"$country\" ) {\n";
- foreach my $state ( sort keys %{$cust_main_county{$country}} ) {
- $script_html .= "\nif ( state == \"$state\" ) {\n";
- #foreach my $county ( sort @{$cust_main_county{$country}{$state}} ) {
- foreach my $county ( sort keys %{$cust_main_county{$country}{$state}} ) {
- my $text = $county || '(n/a)';
- $script_html .=
- qq!opt(what.form.${prefix}county, "$county", "$text");\n!;
- }
- $script_html .= "}\n";
- }
- $script_html .= "}\n";
- }
- }
-
- $script_html .= <<END;
- }
- </SCRIPT>
-END
-
- my $county_html = $script_html;
- if ( $countyflag ) {
- $county_html .= qq!<SELECT NAME="${prefix}county" onChange="$onchange">!;
- $county_html .= '</SELECT>';
- } else {
- $county_html .=
- qq!<INPUT TYPE="hidden" NAME="${prefix}county" VALUE="$selected_county">!;
- }
-
- my $state_html = qq!<SELECT NAME="${prefix}state" !.
- qq!onChange="${prefix}state_changed(this); $onchange">!;
- foreach my $state ( sort keys %{ $cust_main_county{$selected_country} } ) {
- my $text = $state || '(n/a)';
- my $selected = $state eq $selected_state ? 'SELECTED' : '';
- $state_html .= "\n<OPTION $selected VALUE=$state>$text</OPTION>"
- }
- $state_html .= '</SELECT>';
-
- $state_html .= '</SELECT>';
-
- my $country_html = qq!<SELECT NAME="${prefix}country" !.
- qq!onChange="${prefix}country_changed(this); $onchange">!;
- my $countrydefault = $conf->config('countrydefault') || 'US';
- foreach my $country (
- sort { ($b eq $countrydefault) <=> ($a eq $countrydefault) or $a cmp $b }
- keys %cust_main_county
- ) {
- my $selected = $country eq $selected_country ? ' SELECTED' : '';
- $country_html .= "\n<OPTION$selected>$country</OPTION>"
- }
- $country_html .= '</SELECT>';
-
- ($county_html, $state_html, $country_html);
-
-}
-
-=back
-
-=head1 BUGS
-
-regionselector? putting web ui components in here? they should probably live
-somewhere else...
-
-=head1 SEE ALSO
-
-L<FS::Record>, L<FS::cust_main>, L<FS::cust_bill>, schema.html from the base
-documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/cust_main_invoice.pm b/FS/FS/cust_main_invoice.pm
deleted file mode 100644
index add0cca..0000000
--- a/FS/FS/cust_main_invoice.pm
+++ /dev/null
@@ -1,177 +0,0 @@
-package FS::cust_main_invoice;
-
-use strict;
-use vars qw(@ISA $conf);
-use Exporter;
-use FS::Record qw( qsearchs );
-use FS::Conf;
-use FS::cust_main;
-use FS::svc_acct;
-use FS::Msgcat qw(gettext);
-
-@ISA = qw( FS::Record );
-
-=head1 NAME
-
-FS::cust_main_invoice - Object methods for cust_main_invoice records
-
-=head1 SYNOPSIS
-
- use FS::cust_main_invoice;
-
- $record = new FS::cust_main_invoice \%hash;
- $record = new FS::cust_main_invoice { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
- $email_address = $record->address;
-
-=head1 DESCRIPTION
-
-An FS::cust_main_invoice object represents an invoice destination. FS::cust_main_invoice inherits from
-FS::Record. The following fields are currently supported:
-
-=over 4
-
-=item destnum - primary key
-
-=item custnum - customer (see L<FS::cust_main>)
-
-=item dest - Invoice destination: If numeric, a svcnum (see L<FS::svc_acct>), if string, a literal email address, or `POST' to enable mailing (the default if no cust_main_invoice records exist)
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new invoice destination. To add the invoice destination 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 { 'cust_main_invoice'; }
-
-=item insert
-
-Adds this record to the database. If there is an error, returns the error,
-otherwise returns false.
-
-=item delete
-
-Delete this record from the database.
-
-=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 );
-
- return "Can't change custnum!" unless $old->custnum == $new->custnum;
-
- $new->SUPER::replace($old);
-}
-
-
-=item check
-
-Checks all fields to make sure this is a valid invoice destination. 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 $error = $self->ut_numbern('destnum')
- || $self->ut_number('custnum')
- || $self->checkdest;
- ;
- return $error if $error;
-
- return "Unknown customer"
- unless qsearchs('cust_main',{ 'custnum' => $self->custnum });
-
- $self->SUPER::check;
-}
-
-=item checkdest
-
-Checks the dest field only.
-
-#If it finds that the account ends in the
-#same domain configured as the B<domain> configuration file, it will change the
-#invoice destination from an email address to a service number (see
-#L<FS::svc_acct>).
-
-=cut
-
-sub checkdest {
- my $self = shift;
-
- my $error = $self->ut_text('dest');
- return $error if $error;
-
- if ( $self->dest eq 'POST' ) {
- #contemplate our navel
- } elsif ( $self->dest =~ /^(\d+)$/ ) {
- return "Unknown local account (specified by svcnum: ". $self->dest. ")"
- unless qsearchs( 'svc_acct', { 'svcnum' => $self->dest } );
- } elsif ( $self->dest =~ /^([\w\.\-\&\+]+)\@(([\w\.\-]+\.)+\w+)$/ ) {
- my($user, $domain) = ($1, $2);
- $self->dest("$1\@$2");
- } else {
- return gettext("illegal_email_invoice_address");
- }
-
- ''; #no error
-}
-
-=item address
-
-Returns the literal email address for this record (or `POST').
-
-=cut
-
-sub address {
- my $self = shift;
- if ( $self->dest =~ /^(\d+)$/ ) {
- my $svc_acct = qsearchs( 'svc_acct', { 'svcnum' => $1 } )
- or return undef;
- $svc_acct->email;
- } else {
- $self->dest;
- }
-}
-
-=back
-
-=head1 VERSION
-
-$Id: cust_main_invoice.pm,v 1.14 2003-08-05 00:20:42 khoff Exp $
-
-=head1 BUGS
-
-=head1 SEE ALSO
-
-L<FS::Record>, L<FS::cust_main>
-
-=cut
-
-1;
-
diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm
deleted file mode 100644
index e1943ae..0000000
--- a/FS/FS/cust_pay.pm
+++ /dev/null
@@ -1,418 +0,0 @@
-package FS::cust_pay;
-
-use strict;
-use vars qw( @ISA $conf $unsuspendauto );
-use Date::Format;
-use Business::CreditCard;
-use FS::UID qw( dbh );
-use FS::Record qw( dbh qsearch qsearchs dbh );
-use FS::Misc qw(send_email);
-use FS::cust_bill;
-use FS::cust_bill_pay;
-use FS::cust_main;
-
-@ISA = qw( FS::Record );
-
-#ask FS::UID to run this stuff for us later
-FS::UID->install_callback( sub {
- $conf = new FS::Conf;
- $unsuspendauto = $conf->exists('unsuspendauto');
-} );
-
-=head1 NAME
-
-FS::cust_pay - Object methods for cust_pay objects
-
-=head1 SYNOPSIS
-
- use FS::cust_pay;
-
- $record = new FS::cust_pay \%hash;
- $record = new FS::cust_pay { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
-=head1 DESCRIPTION
-
-An FS::cust_pay object represents a payment; the transfer of money from a
-customer. FS::cust_pay inherits from FS::Record. The following fields are
-currently supported:
-
-=over 4
-
-=item paynum - primary key (assigned automatically for new payments)
-
-=item custnum - customer (see L<FS::cust_main>)
-
-=item paid - Amount of this payment
-
-=item _date - specified as a UNIX timestamp; see L<perlfunc/"time">. Also see
-L<Time::Local> and L<Date::Parse> for conversion functions.
-
-=item payby - `CARD' (credit cards), `CHEK' (electronic check/ACH),
-`LECB' (phone bill billing), `BILL' (billing), or `COMP' (free)
-
-=item payinfo - card number, check #, or comp issuer (4-8 lowercase alphanumerics; think username), respectively
-
-=item paybatch - text field for tracking card processing
-
-=item closed - books closed flag, empty or `Y'
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new payment. To add the payment to the databse, see L<"insert">.
-
-=cut
-
-sub table { 'cust_pay'; }
-
-=item insert
-
-Adds this payment to the database.
-
-For backwards-compatibility and convenience, if the additional field invnum
-is defined, an FS::cust_bill_pay record for the full amount of the payment
-will be created. In this case, custnum is optional.
-
-=cut
-
-sub insert {
- my $self = shift;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- if ( $self->invnum ) {
- my $cust_bill = qsearchs('cust_bill', { 'invnum' => $self->invnum } )
- or do {
- $dbh->rollback if $oldAutoCommit;
- return "Unknown cust_bill.invnum: ". $self->invnum;
- };
- $self->custnum($cust_bill->custnum );
- }
-
- my $cust_main = qsearchs( 'cust_main', { 'custnum' => $self->custnum } );
- my $old_balance = $cust_main->balance;
-
- my $error = $self->check;
- return $error if $error;
-
- $error = $self->SUPER::insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "error inserting $self: $error";
- }
-
- if ( $self->invnum ) {
- my $cust_bill_pay = new FS::cust_bill_pay {
- 'invnum' => $self->invnum,
- 'paynum' => $self->paynum,
- 'amount' => $self->paid,
- '_date' => $self->_date,
- };
- $error = $cust_bill_pay->insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "error inserting $cust_bill_pay: $error";
- }
- }
-
- if ( $self->paybatch =~ /^webui-/ ) {
- my @cust_pay = qsearch('cust_pay', {
- 'custnum' => $self->custnum,
- 'paybatch' => $self->paybatch,
- } );
- if ( scalar(@cust_pay) > 1 ) {
- $dbh->rollback if $oldAutoCommit;
- return "a payment with webui token ". $self->paybatch. " already exists";
- }
- }
-
- #false laziness w/ cust_credit::insert
- if ( $unsuspendauto && $old_balance && $cust_main->balance <= 0 ) {
- my @errors = $cust_main->unsuspend;
- #return
- # side-fx with nested transactions? upstack rolls back?
- warn "WARNING:Errors unsuspending customer ". $cust_main->custnum. ": ".
- join(' / ', @errors)
- if @errors;
- }
- #eslaf
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
-
- '';
-
-}
-
-sub upgrade_replace { #1.3.x->1.4.x
- my $self = shift;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- my $error = $self->check;
- return $error if $error;
-
- my %new = $self->hash;
- my $new = FS::cust_pay->new(\%new);
-
- if ( $self->invnum ) {
- my $cust_bill_pay = new FS::cust_bill_pay {
- 'invnum' => $self->invnum,
- 'paynum' => $self->paynum,
- 'amount' => $self->paid,
- '_date' => $self->_date,
- };
- $error = $cust_bill_pay->insert;
- if ( $error =~
- /total cust_bill_pay.amount and cust_credit_bill.amount .* for invnum .* greater than cust_bill.charged/ ) {
- #warn $error;
- my $cust_bill = qsearchs( 'cust_bill', { 'invnum' => $self->invnum } );
- $new->custnum($cust_bill->custnum);
- } elsif ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- } else {
- $new->custnum($cust_bill_pay->cust_bill->custnum);
- }
- } else {
- die;
- }
-
- $error = $new->SUPER::replace($self);
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
-
- '';
-
-
-}
-
-=item delete
-
-Deletes this payment and all associated applications (see L<FS::cust_bill_pay>),
-unless the closed flag is set.
-
-=cut
-
-sub delete {
- my $self = shift;
- return "Can't delete closed payment" if $self->closed =~ /^Y/i;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- foreach my $cust_bill_pay ( $self->cust_bill_pay ) {
- my $error = $cust_bill_pay->delete;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
-
- my $error = $self->SUPER::delete(@_);
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- if ( $conf->config('deletepayments') ne '' ) {
-
- my $cust_main = qsearchs('cust_main',{ 'custnum' => $self->custnum });
-
- my $error = send_email(
- 'from' => $conf->config('invoice_from'), #??? well as good as any
- 'to' => $conf->config('deletepayments'),
- 'subject' => 'FREESIDE NOTIFICATION: Payment deleted',
- 'body' => [
- "This is an automatic message from your Freeside installation\n",
- "informing you that the following payment has been deleted:\n",
- "\n",
- 'paynum: '. $self->paynum. "\n",
- 'custnum: '. $self->custnum.
- " (". $cust_main->last. ", ". $cust_main->first. ")\n",
- 'paid: $'. sprintf("%.2f", $self->paid). "\n",
- 'date: '. time2str("%a %b %e %T %Y", $self->_date). "\n",
- 'payby: '. $self->payby. "\n",
- 'payinfo: '. $self->payinfo. "\n",
- 'paybatch: '. $self->paybatch. "\n",
- ],
- );
-
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "can't send payment deletion notification: $error";
- }
-
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
-
- '';
-
-}
-
-=item replace OLD_RECORD
-
-Currently unimplemented (accounting reasons).
-
-=cut
-
-sub replace {
- return "Can't (yet?) modify cust_pay records!";
-}
-
-=item check
-
-Checks all fields to make sure this is a valid payment. If there is an error,
-returns the error, otherwise returns false. Called by the insert method.
-
-=cut
-
-sub check {
- my $self = shift;
-
- my $error =
- $self->ut_numbern('paynum')
- || $self->ut_numbern('custnum')
- || $self->ut_money('paid')
- || $self->ut_numbern('_date')
- || $self->ut_textn('paybatch')
- || $self->ut_enum('closed', [ '', 'Y' ])
- ;
- return $error if $error;
-
- return "paid must be > 0 " if $self->paid <= 0;
-
- return "unknown cust_main.custnum: ". $self->custnum
- unless $self->invnum
- || qsearchs( 'cust_main', { 'custnum' => $self->custnum } );
-
- $self->_date(time) unless $self->_date;
-
- $self->payby =~ /^(CARD|CHEK|LECB|BILL|COMP)$/ or return "Illegal payby";
- $self->payby($1);
-
- #false laziness with cust_refund::check
- if ( $self->payby eq 'CARD' ) {
- my $payinfo = $self->payinfo;
- $payinfo =~ s/\D//g;
- $self->payinfo($payinfo);
- if ( $self->payinfo ) {
- $self->payinfo =~ /^(\d{13,16})$/
- or return "Illegal (mistyped?) credit card number (payinfo)";
- $self->payinfo($1);
- validate($self->payinfo) or return "Illegal credit card number";
- return "Unknown card type" if cardtype($self->payinfo) eq "Unknown";
- } else {
- $self->payinfo('N/A');
- }
-
- } else {
- $error = $self->ut_textn('payinfo');
- return $error if $error;
- }
-
- $self->SUPER::check;
-}
-
-=item cust_bill_pay
-
-Returns all applications to invoices (see L<FS::cust_bill_pay>) for this
-payment.
-
-=cut
-
-sub cust_bill_pay {
- my $self = shift;
- sort { $a->_date <=> $b->_date }
- qsearch( 'cust_bill_pay', { 'paynum' => $self->paynum } )
- ;
-}
-
-=item unapplied
-
-Returns the amount of this payment that is still unapplied; which is
-paid minus all payment applications (see L<FS::cust_bill_pay>).
-
-=cut
-
-sub unapplied {
- my $self = shift;
- my $amount = $self->paid;
- $amount -= $_->amount foreach ( $self->cust_bill_pay );
- sprintf("%.2f", $amount );
-}
-
-=item cust_main
-
-Returns the parent customer object (see L<FS::cust_main>).
-
-=cut
-
-sub cust_main {
- my $self = shift;
- qsearchs( 'cust_main', { 'custnum' => $self->custnum } );
-}
-
-
-=back
-
-=head1 VERSION
-
-$Id: cust_pay.pm,v 1.26 2003-09-10 10:54:46 ivan Exp $
-
-=head1 BUGS
-
-Delete and replace methods.
-
-=head1 SEE ALSO
-
-L<FS::cust_bill_pay>, L<FS::cust_bill>, L<FS::Record>, schema.html from the
-base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/cust_pay_batch.pm b/FS/FS/cust_pay_batch.pm
deleted file mode 100644
index 8059f1c..0000000
--- a/FS/FS/cust_pay_batch.pm
+++ /dev/null
@@ -1,397 +0,0 @@
-package FS::cust_pay_batch;
-
-use strict;
-use vars qw( @ISA );
-use FS::Record qw(dbh qsearchs);
-use Business::CreditCard;
-
-@ISA = qw( FS::Record );
-
-=head1 NAME
-
-FS::cust_pay_batch - Object methods for batch cards
-
-=head1 SYNOPSIS
-
- use FS::cust_pay_batch;
-
- $record = new FS::cust_pay_batch \%hash;
- $record = new FS::cust_pay_batch { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
-=head1 DESCRIPTION
-
-An FS::cust_pay_batch object represents a credit card transaction ready to be
-batched (sent to a processor). FS::cust_pay_batch inherits from FS::Record.
-Typically called by the collect method of an FS::cust_main object. The
-following fields are currently supported:
-
-=over 4
-
-=item paybatchnum - primary key (automatically assigned)
-
-=item cardnum
-
-=item exp - card expiration
-
-=item amount
-
-=item invnum - invoice
-
-=item custnum - customer
-
-=item payname - name on card
-
-=item first - name
-
-=item last - name
-
-=item address1
-
-=item address2
-
-=item city
-
-=item state
-
-=item zip
-
-=item country
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new record. To add the record 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 { 'cust_pay_batch'; }
-
-=item insert
-
-Adds this record to the database. If there is an error, returns the error,
-otherwise returns false.
-
-=item delete
-
-Delete this record from the database. If there is an error, returns the error,
-otherwise returns false.
-
-=item replace OLD_RECORD
-
-#inactive
-#
-#Replaces the OLD_RECORD with this one in the database. If there is an error,
-#returns the error, otherwise returns false.
-
-=cut
-
-sub replace {
- return "Can't (yet?) replace batched transactions!";
-}
-
-=item check
-
-Checks all fields to make sure this is a valid transaction. 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 $error =
- $self->ut_numbern('paybatchnum')
- || $self->ut_numbern('trancode') #depriciated
- || $self->ut_number('cardnum')
- || $self->ut_money('amount')
- || $self->ut_number('invnum')
- || $self->ut_number('custnum')
- || $self->ut_text('address1')
- || $self->ut_textn('address2')
- || $self->ut_text('city')
- || $self->ut_textn('state')
- ;
-
- return $error if $error;
-
- $self->getfield('last') =~ /^([\w \,\.\-\']+)$/ or return "Illegal last name";
- $self->setfield('last',$1);
-
- $self->first =~ /^([\w \,\.\-\']+)$/ or return "Illegal first name";
- $self->first($1);
-
- my $cardnum = $self->cardnum;
- $cardnum =~ s/\D//g;
- $cardnum =~ /^(\d{13,16})$/
- or return "Illegal credit card number";
- $cardnum = $1;
- $self->cardnum($cardnum);
- validate($cardnum) or return "Illegal credit card number";
- return "Unknown card type" if cardtype($cardnum) eq "Unknown";
-
- if ( $self->exp eq '' ) {
- return "Expriation date required"; #unless
- $self->exp('');
- } else {
- if ( $self->exp =~ /^(\d{4})[\/\-](\d{1,2})[\/\-](\d{1,2})$/ ) {
- $self->exp("$1-$2-$3");
- } elsif ( $self->exp =~ /^(\d{1,2})[\/\-](\d{2}(\d{2})?)$/ ) {
- if ( length($2) == 4 ) {
- $self->exp("$2-$1-01");
- } elsif ( $2 > 98 ) { #should pry change to check for "this year"
- $self->exp("19$2-$1-01");
- } else {
- $self->exp("20$2-$1-01");
- }
- } else {
- return "Illegal expiration date";
- }
- }
-
- if ( $self->payname eq '' ) {
- $self->payname( $self->first. " ". $self->getfield('last') );
- } else {
- $self->payname =~ /^([\w \,\.\-\']+)$/
- or return "Illegal billing name";
- $self->payname($1);
- }
-
- #$self->zip =~ /^\s*(\w[\w\-\s]{3,8}\w)\s*$/
- # or return "Illegal zip: ". $self->zip;
- #$self->zip($1);
-
- $self->country =~ /^(\w\w)$/ or return "Illegal country: ". $self->country;
- $self->country($1);
-
- $error = $self->ut_zip('zip', $self->country);
- return $error if $error;
-
- #check invnum, custnum, ?
-
- $self->SUPER::check;
-}
-
-=item cust_main
-
-Returns the customer (see L<FS::cust_main>) for this batched credit card
-payment.
-
-=cut
-
-sub cust_main {
- my $self = shift;
- qsearchs( 'cust_main', { 'custnum' => $self->custnum } );
-}
-
-=back
-
-=head1 SUBROUTINES
-
-=over 4
-
-=item import_results
-
-=cut
-
-sub import_results {
- use Time::Local;
- use FS::cust_pay;
- eval "use Text::CSV_XS;";
- die $@ if $@;
-#
- my $param = shift;
- my $fh = $param->{'filehandle'};
- my $format = $param->{'format'};
- my $paybatch = $param->{'paybatch'};
-
- my @fields;
- my $end_condition;
- my $end_hook;
- my $hook;
- my $approved_condition;
- my $declined_condition;
-
- if ( $format eq 'csv-td_canada_trust-merchant_pc_batch' ) {
-
- @fields = (
- 'paybatchnum', # Reference#: Invoice number of the transaction
- 'paid', # Amount: Amount of the transaction. Dollars and cents
- # with no decimal entered.
- '', # Card Type: 0 - MCrd, 1 - Visa, 2 - AMEX, 3 - Discover,
- # 4 - Insignia, 5 - Diners/EnRoute, 6 - JCB
- '_date', # Transaction Date: Date the Transaction was processed
- 'time', # Transaction Time: Time the transaction was processed
- 'payinfo', # Card Number: Card number for the transaction
- '', # Expiry Date: Expiry date of the card
- '', # Auth#: Authorization number entered for force post
- # transaction
- 'type', # Transaction Type: 0 - purchase, 40 - refund,
- # 20 - force post
- 'result', # Processing Result: 3 - Approval,
- # 4 - Declined/Amount over limit,
- # 5 - Invalid/Expired/stolen card,
- # 6 - Comm Error
- '', # Terminal ID: Terminal ID used to process the transaction
- );
-
- $end_condition = sub {
- my $hash = shift;
- $hash->{'type'} eq '0BC';
- };
-
- $end_hook = sub {
- my( $hash, $total) = @_;
- $total = sprintf("%.2f", $total);
- my $batch_total = sprintf("%.2f", $hash->{'paybatchnum'} / 100 );
- return "Our total $total does not match bank total $batch_total!"
- if $total != $batch_total;
- '';
- };
-
- $hook = sub {
- my $hash = shift;
- $hash->{'paid'} = sprintf("%.2f", $hash->{'paid'} / 100 );
- $hash->{'_date'} = timelocal( substr($hash->{'time'}, 4, 2),
- substr($hash->{'time'}, 2, 2),
- substr($hash->{'time'}, 0, 2),
- substr($hash->{'_date'}, 6, 2),
- substr($hash->{'_date'}, 4, 2)-1,
- substr($hash->{'_date'}, 0, 4)-1900, );
- };
-
- $approved_condition = sub {
- my $hash = shift;
- $hash->{'type'} eq '0' && $hash->{'result'} == 3;
- };
-
- $declined_condition = sub {
- my $hash = shift;
- $hash->{'type'} eq '0' && ( $hash->{'result'} == 4
- || $hash->{'result'} == 5 );
- };
-
-
- } else {
- return "Unknown format $format";
- }
-
- my $csv = new Text::CSV_XS;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- my $total = 0;
- my $line;
- while ( defined($line=<$fh>) ) {
-
- next if $line =~ /^\s*$/; #skip blank lines
-
- $csv->parse($line) or do {
- $dbh->rollback if $oldAutoCommit;
- return "can't parse: ". $csv->error_input();
- };
-
- my @values = $csv->fields();
- my %hash;
- foreach my $field ( @fields ) {
- my $value = shift @values;
- next unless $field;
- $hash{$field} = $value;
- }
-
- if ( &{$end_condition}(\%hash) ) {
- my $error = &{$end_hook}(\%hash, $total);
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- last;
- }
-
- my $cust_pay_batch =
- qsearchs('cust_pay_batch', { 'paybatchnum' => $hash{'paybatchnum'} } );
- unless ( $cust_pay_batch ) {
- $dbh->rollback if $oldAutoCommit;
- return "unknown paybatchnum $hash{'paybatchnum'}\n";
- }
- my $custnum = $cust_pay_batch->custnum,
-
- my $error = $cust_pay_batch->delete;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "error removing paybatchnum $hash{'paybatchnum'}: $error\n";
- }
-
- &{$hook}(\%hash);
-
- if ( &{$approved_condition}(\%hash) ) {
-
- my $cust_pay = new FS::cust_pay ( {
- 'custnum' => $custnum,
- 'payby' => 'CARD',
- 'paybatch' => $paybatch,
- map { $_ => $hash{$_} } (qw( paid _date payinfo )),
- } );
- $error = $cust_pay->insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "error adding payment paybatchnum $hash{'paybatchnum'}: $error\n";
- }
- $total += $hash{'paid'};
-
- $cust_pay->cust_main->apply_payments;
-
- } elsif ( &{$declined_condition}(\%hash) ) {
-
- #this should be configurable... if anybody else ever uses batches
- $cust_pay_batch->cust_main->suspend;
-
- }
-
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
- '';
-
-}
-
-=back
-
-=head1 BUGS
-
-There should probably be a configuration file with a list of allowed credit
-card types.
-
-=head1 SEE ALSO
-
-L<FS::cust_main>, L<FS::Record>
-
-=cut
-
-1;
-
diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm
deleted file mode 100644
index db0f7d4..0000000
--- a/FS/FS/cust_pkg.pm
+++ /dev/null
@@ -1,926 +0,0 @@
-package FS::cust_pkg;
-
-use strict;
-use vars qw(@ISA $disable_agentcheck @SVCDB_CANCEL_SEQ $DEBUG);
-use FS::UID qw( getotaker dbh );
-use FS::Record qw( qsearch qsearchs );
-use FS::Misc qw( send_email );
-use FS::cust_svc;
-use FS::part_pkg;
-use FS::cust_main;
-use FS::type_pkgs;
-use FS::pkg_svc;
-use FS::cust_bill_pkg;
-
-# need to 'use' these instead of 'require' in sub { cancel, suspend, unsuspend,
-# setup }
-# because they load configuraion by setting FS::UID::callback (see TODO)
-use FS::svc_acct;
-use FS::svc_domain;
-use FS::svc_www;
-use FS::svc_forward;
-
-# for sending cancel emails in sub cancel
-use FS::Conf;
-
-@ISA = qw( FS::Record );
-
-$DEBUG = 0;
-
-$disable_agentcheck = 0;
-
-# The order in which to unprovision services.
-@SVCDB_CANCEL_SEQ = qw( svc_external
- svc_www
- svc_forward
- svc_acct
- svc_domain
- svc_broadband );
-
-sub _cache {
- my $self = shift;
- my ( $hashref, $cache ) = @_;
- #if ( $hashref->{'pkgpart'} ) {
- if ( $hashref->{'pkg'} ) {
- # #@{ $self->{'_pkgnum'} } = ();
- # my $subcache = $cache->subcache('pkgpart', 'part_pkg');
- # $self->{'_pkgpart'} = $subcache;
- # #push @{ $self->{'_pkgnum'} },
- # FS::part_pkg->new_or_cached($hashref, $subcache);
- $self->{'_pkgpart'} = FS::part_pkg->new($hashref);
- }
- if ( exists $hashref->{'svcnum'} ) {
- #@{ $self->{'_pkgnum'} } = ();
- my $subcache = $cache->subcache('svcnum', 'cust_svc', $hashref->{pkgnum});
- $self->{'_svcnum'} = $subcache;
- #push @{ $self->{'_pkgnum'} },
- FS::cust_svc->new_or_cached($hashref, $subcache) if $hashref->{svcnum};
- }
-}
-
-=head1 NAME
-
-FS::cust_pkg - Object methods for cust_pkg objects
-
-=head1 SYNOPSIS
-
- use FS::cust_pkg;
-
- $record = new FS::cust_pkg \%hash;
- $record = new FS::cust_pkg { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
- $error = $record->cancel;
-
- $error = $record->suspend;
-
- $error = $record->unsuspend;
-
- $part_pkg = $record->part_pkg;
-
- @labels = $record->labels;
-
- $seconds = $record->seconds_since($timestamp);
-
- $error = FS::cust_pkg::order( $custnum, \@pkgparts );
- $error = FS::cust_pkg::order( $custnum, \@pkgparts, \@remove_pkgnums ] );
-
-=head1 DESCRIPTION
-
-An FS::cust_pkg object represents a customer billing item. FS::cust_pkg
-inherits from FS::Record. The following fields are currently supported:
-
-=over 4
-
-=item pkgnum - primary key (assigned automatically for new billing items)
-
-=item custnum - Customer (see L<FS::cust_main>)
-
-=item pkgpart - Billing item definition (see L<FS::part_pkg>)
-
-=item setup - date
-
-=item bill - date (next bill date)
-
-=item last_bill - last bill date
-
-=item susp - date
-
-=item expire - date
-
-=item cancel - date
-
-=item otaker - order taker (assigned automatically if null, see L<FS::UID>)
-
-=item manual_flag - If this field is set to 1, disables the automatic
-unsuspension of this package when using the B<unsuspendauto> config file.
-
-=back
-
-Note: setup, bill, susp, expire and cancel are specified as UNIX timestamps;
-see L<perlfunc/"time">. Also see L<Time::Local> and L<Date::Parse> for
-conversion functions.
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Create a new billing item. To add the item to the database, see L<"insert">.
-
-=cut
-
-sub table { 'cust_pkg'; }
-
-=item insert
-
-Adds this billing item to the database ("Orders" the item). If there is an
-error, returns the error, otherwise returns false.
-
-=cut
-
-sub insert {
- my $self = shift;
-
- # custnum might not have have been defined in sub check (for one-shot new
- # customers), so check it here instead
- # (is this still necessary with transactions?)
-
- my $error = $self->ut_number('custnum');
- return $error if $error;
-
- my $cust_main = $self->cust_main;
- return "Unknown custnum: ". $self->custnum unless $cust_main;
-
- unless ( $disable_agentcheck ) {
- my $agent = qsearchs( 'agent', { 'agentnum' => $cust_main->agentnum } );
- my $pkgpart_href = $agent->pkgpart_hashref;
- return "agent ". $agent->agentnum.
- " can't purchase pkgpart ". $self->pkgpart
- unless $pkgpart_href->{ $self->pkgpart };
- }
-
- $self->SUPER::insert;
-
-}
-
-=item delete
-
-This method now works but you probably shouldn't use it.
-
-You don't want to delete billing items, because there would then be no record
-the customer ever purchased the item. Instead, see the cancel method.
-
-=cut
-
-#sub delete {
-# return "Can't delete cust_pkg records!";
-#}
-
-=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.
-
-Currently, custnum, setup, bill, susp, expire, and cancel may be changed.
-
-Changing pkgpart may have disasterous effects. See the order subroutine.
-
-setup and bill are normally updated by calling the bill method of a customer
-object (see L<FS::cust_main>).
-
-suspend is normally updated by the suspend and unsuspend methods.
-
-cancel is normally updated by the cancel method (and also the order subroutine
-in some cases).
-
-=cut
-
-sub replace {
- my( $new, $old ) = ( shift, shift );
-
- #return "Can't (yet?) change pkgpart!" if $old->pkgpart != $new->pkgpart;
- return "Can't change otaker!" if $old->otaker ne $new->otaker;
-
- #allow this *sigh*
- #return "Can't change setup once it exists!"
- # if $old->getfield('setup') &&
- # $old->getfield('setup') != $new->getfield('setup');
-
- #some logic for bill, susp, cancel?
-
- $new->SUPER::replace($old);
-}
-
-=item check
-
-Checks all fields to make sure this is a valid billing item. If there is an
-error, returns the error, otherwise returns false. Called by the insert and
-replace methods.
-
-=cut
-
-sub check {
- my $self = shift;
-
- my $error =
- $self->ut_numbern('pkgnum')
- || $self->ut_numbern('custnum')
- || $self->ut_number('pkgpart')
- || $self->ut_numbern('setup')
- || $self->ut_numbern('bill')
- || $self->ut_numbern('susp')
- || $self->ut_numbern('cancel')
- ;
- return $error if $error;
-
- if ( $self->custnum ) {
- return "Unknown customer ". $self->custnum unless $self->cust_main;
- }
-
- return "Unknown pkgpart: ". $self->pkgpart
- unless qsearchs( 'part_pkg', { 'pkgpart' => $self->pkgpart } );
-
- $self->otaker(getotaker) unless $self->otaker;
- $self->otaker =~ /^([\w\.\-]{0,16})$/ or return "Illegal otaker";
- $self->otaker($1);
-
- if ( $self->dbdef_table->column('manual_flag') ) {
- $self->manual_flag('') if $self->manual_flag eq ' ';
- $self->manual_flag =~ /^([01]?)$/
- or return "Illegal manual_flag ". $self->manual_flag;
- $self->manual_flag($1);
- }
-
- $self->SUPER::check;
-}
-
-=item cancel [ OPTION => VALUE ... ]
-
-Cancels and removes all services (see L<FS::cust_svc> and L<FS::part_svc>)
-in this package, then cancels the package itself (sets the cancel field to
-now).
-
-Available options are: I<quiet>
-
-I<quiet> can be set true to supress email cancellation notices.
-
-If there is an error, returns the error, otherwise returns false.
-
-=cut
-
-sub cancel {
- my( $self, %options ) = @_;
- my $error;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- my %svc;
- foreach my $cust_svc (
- qsearch( 'cust_svc', { 'pkgnum' => $self->pkgnum } )
- ) {
- push @{ $svc{$cust_svc->part_svc->svcdb} }, $cust_svc;
- }
-
- foreach my $svcdb (@SVCDB_CANCEL_SEQ) {
- foreach my $cust_svc (@{ $svc{$svcdb} }) {
- my $error = $cust_svc->cancel;
-
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "Error cancelling cust_svc: $error";
- }
- }
- }
-
- unless ( $self->getfield('cancel') ) {
- my %hash = $self->hash;
- $hash{'cancel'} = time;
- my $new = new FS::cust_pkg ( \%hash );
- $error = $new->replace($self);
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
-
- my $conf = new FS::Conf;
- my @invoicing_list = grep { $_ ne 'POST' } $self->cust_main->invoicing_list;
- if ( !$options{'quiet'} && $conf->exists('emailcancel') && @invoicing_list ) {
- my $conf = new FS::Conf;
- my $error = send_email(
- 'from' => $conf->config('invoice_from'),
- 'to' => \@invoicing_list,
- 'subject' => $conf->config('cancelsubject'),
- 'body' => [ map "$_\n", $conf->config('cancelmessage') ],
- );
- #should this do something on errors?
- }
-
- ''; #no errors
-
-}
-
-=item suspend
-
-Suspends all services (see L<FS::cust_svc> and L<FS::part_svc>) in this
-package, then suspends the package itself (sets the susp field to now).
-
-If there is an error, returns the error, otherwise returns false.
-
-=cut
-
-sub suspend {
- my $self = shift;
- my $error ;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- foreach my $cust_svc (
- qsearch( 'cust_svc', { 'pkgnum' => $self->pkgnum } )
- ) {
- my $part_svc = qsearchs( 'part_svc', { 'svcpart' => $cust_svc->svcpart } );
-
- $part_svc->svcdb =~ /^([\w\-]+)$/ or do {
- $dbh->rollback if $oldAutoCommit;
- return "Illegal svcdb value in part_svc!";
- };
- my $svcdb = $1;
- require "FS/$svcdb.pm";
-
- my $svc = qsearchs( $svcdb, { 'svcnum' => $cust_svc->svcnum } );
- if ($svc) {
- $error = $svc->suspend;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
-
- }
-
- unless ( $self->getfield('susp') ) {
- my %hash = $self->hash;
- $hash{'susp'} = time;
- my $new = new FS::cust_pkg ( \%hash );
- $error = $new->replace($self);
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
-
- ''; #no errors
-}
-
-=item unsuspend
-
-Unsuspends all services (see L<FS::cust_svc> and L<FS::part_svc>) in this
-package, then unsuspends the package itself (clears the susp field).
-
-If there is an error, returns the error, otherwise returns false.
-
-=cut
-
-sub unsuspend {
- my $self = shift;
- my($error);
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- foreach my $cust_svc (
- qsearch('cust_svc',{'pkgnum'=> $self->pkgnum } )
- ) {
- my $part_svc = qsearchs( 'part_svc', { 'svcpart' => $cust_svc->svcpart } );
-
- $part_svc->svcdb =~ /^([\w\-]+)$/ or do {
- $dbh->rollback if $oldAutoCommit;
- return "Illegal svcdb value in part_svc!";
- };
- my $svcdb = $1;
- require "FS/$svcdb.pm";
-
- my $svc = qsearchs( $svcdb, { 'svcnum' => $cust_svc->svcnum } );
- if ($svc) {
- $error = $svc->unsuspend;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
-
- }
-
- unless ( ! $self->getfield('susp') ) {
- my %hash = $self->hash;
- $hash{'susp'} = '';
- my $new = new FS::cust_pkg ( \%hash );
- $error = $new->replace($self);
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
-
- ''; #no errors
-}
-
-=item last_bill
-
-Returns the last bill date, or if there is no last bill date, the setup date.
-Useful for billing metered services.
-
-=cut
-
-sub last_bill {
- my $self = shift;
- if ( $self->dbdef_table->column('last_bill') ) {
- return $self->setfield('last_bill', $_[0]) if @_;
- return $self->getfield('last_bill') if $self->getfield('last_bill');
- }
- my $cust_bill_pkg = qsearchs('cust_bill_pkg', { 'pkgnum' => $self->pkgnum,
- 'edate' => $self->bill, } );
- $cust_bill_pkg ? $cust_bill_pkg->sdate : $self->setup || 0;
-}
-
-=item part_pkg
-
-Returns the definition for this billing item, as an FS::part_pkg object (see
-L<FS::part_pkg>).
-
-=cut
-
-sub part_pkg {
- my $self = shift;
- #exists( $self->{'_pkgpart'} )
- $self->{'_pkgpart'}
- ? $self->{'_pkgpart'}
- : qsearchs( 'part_pkg', { 'pkgpart' => $self->pkgpart } );
-}
-
-=item cust_svc
-
-Returns the services for this package, as FS::cust_svc objects (see
-L<FS::cust_svc>)
-
-=cut
-
-sub cust_svc {
- my $self = shift;
- #if ( $self->{'_svcnum'} ) {
- # values %{ $self->{'_svcnum'}->cache };
- #} else {
- map { $_->[0] }
- sort { $b->[1] cmp $a->[1] or $a->[2] <=> $b->[2] }
- map {
- my $pkg_svc = qsearchs( 'pkg_svc', { 'pkgpart' => $self->pkgpart,
- 'svcpart' => $_->svcpart } );
- [ $_,
- $pkg_svc ? $pkg_svc->primary_svc : '',
- $pkg_svc ? $pkg_svc->quantity : 0,
- ];
- }
- qsearch ( 'cust_svc', { 'pkgnum' => $self->pkgnum } );
- #}
-}
-
-=item labels
-
-Returns a list of lists, calling the label method for all services
-(see L<FS::cust_svc>) of this billing item.
-
-=cut
-
-sub labels {
- my $self = shift;
- map { [ $_->label ] } $self->cust_svc;
-}
-
-=item cust_main
-
-Returns the parent customer object (see L<FS::cust_main>).
-
-=cut
-
-sub cust_main {
- my $self = shift;
- qsearchs( 'cust_main', { 'custnum' => $self->custnum } );
-}
-
-=item seconds_since TIMESTAMP
-
-Returns the number of seconds all accounts (see L<FS::svc_acct>) in this
-package have been online since TIMESTAMP, according to the session monitor.
-
-TIMESTAMP is specified as a UNIX timestamp; see L<perlfunc/"time">. Also see
-L<Time::Local> and L<Date::Parse> for conversion functions.
-
-=cut
-
-sub seconds_since {
- my($self, $since) = @_;
- my $seconds = 0;
-
- foreach my $cust_svc (
- grep { $_->part_svc->svcdb eq 'svc_acct' } $self->cust_svc
- ) {
- $seconds += $cust_svc->seconds_since($since);
- }
-
- $seconds;
-
-}
-
-=item seconds_since_sqlradacct TIMESTAMP_START TIMESTAMP_END
-
-Returns the numbers of seconds all accounts (see L<FS::svc_acct>) in this
-package have been online between TIMESTAMP_START (inclusive) and TIMESTAMP_END
-(exclusive).
-
-TIMESTAMP_START and TIMESTAMP_END are specified as UNIX timestamps; see
-L<perlfunc/"time">. Also see L<Time::Local> and L<Date::Parse> for conversion
-functions.
-
-
-=cut
-
-sub seconds_since_sqlradacct {
- my($self, $start, $end) = @_;
-
- my $seconds = 0;
-
- foreach my $cust_svc (
- grep {
- my $part_svc = $_->part_svc;
- $part_svc->svcdb eq 'svc_acct'
- && scalar($part_svc->part_export('sqlradius'));
- } $self->cust_svc
- ) {
- $seconds += $cust_svc->seconds_since_sqlradacct($start, $end);
- }
-
- $seconds;
-
-}
-
-=item attribute_since_sqlradacct TIMESTAMP_START TIMESTAMP_END ATTRIBUTE
-
-Returns the sum of the given attribute for all accounts (see L<FS::svc_acct>)
-in this package for sessions ending between TIMESTAMP_START (inclusive) and
-TIMESTAMP_END
-(exclusive).
-
-TIMESTAMP_START and TIMESTAMP_END are specified as UNIX timestamps; see
-L<perlfunc/"time">. Also see L<Time::Local> and L<Date::Parse> for conversion
-functions.
-
-=cut
-
-sub attribute_since_sqlradacct {
- my($self, $start, $end, $attrib) = @_;
-
- my $sum = 0;
-
- foreach my $cust_svc (
- grep {
- my $part_svc = $_->part_svc;
- $part_svc->svcdb eq 'svc_acct'
- && scalar($part_svc->part_export('sqlradius'));
- } $self->cust_svc
- ) {
- $sum += $cust_svc->attribute_since_sqlradacct($start, $end, $attrib);
- }
-
- $sum;
-
-}
-
-=item transfer DEST_PKGNUM | DEST_CUST_PKG, [ OPTION => VALUE ... ]
-
-Transfers as many services as possible from this package to another package.
-
-The destination package can be specified by pkgnum by passing an FS::cust_pkg
-object. The destination package must already exist.
-
-Services are moved only if the destination allows services with the correct
-I<svcpart> (not svcdb), unless the B<change_svcpart> option is set true. Use
-this option with caution! No provision is made for export differences
-between the old and new service definitions. Probably only should be used
-when your exports for all service definitions of a given svcdb are identical.
-(attempt a transfer without it first, to move all possible svcpart-matching
-services)
-
-Any services that can't be moved remain in the original package.
-
-Returns an error, if there is one; otherwise, returns the number of services
-that couldn't be moved.
-
-=cut
-
-sub transfer {
- my ($self, $dest_pkgnum, %opt) = @_;
-
- my $remaining = 0;
- my $dest;
- my %target;
-
- if (ref ($dest_pkgnum) eq 'FS::cust_pkg') {
- $dest = $dest_pkgnum;
- $dest_pkgnum = $dest->pkgnum;
- } else {
- $dest = qsearchs('cust_pkg', { pkgnum => $dest_pkgnum });
- }
-
- return ('Package does not exist: '.$dest_pkgnum) unless $dest;
-
- foreach my $pkg_svc ( $dest->part_pkg->pkg_svc ) {
- $target{$pkg_svc->svcpart} = $pkg_svc->quantity;
- }
-
- foreach my $cust_svc ($dest->cust_svc) {
- $target{$cust_svc->svcpart}--;
- }
-
- my %svcpart2svcparts = ();
- if ( exists $opt{'change_svcpart'} && $opt{'change_svcpart'} ) {
- warn "change_svcpart option received, creating alternates list\n" if $DEBUG;
- foreach my $svcpart ( map { $_->svcpart } $self->cust_svc ) {
- next if exists $svcpart2svcparts{$svcpart};
- my $part_svc = qsearchs('part_svc', { 'svcpart' => $svcpart } );
- $svcpart2svcparts{$svcpart} = [
- map { $_->[0] }
- sort { $b->[1] cmp $a->[1] or $a->[2] <=> $b->[2] }
- map {
- my $pkg_svc = qsearchs( 'pkg_svc', { 'pkgpart' => $dest->pkgpart,
- 'svcpart' => $_ } );
- [ $_,
- $pkg_svc ? $pkg_svc->primary_svc : '',
- $pkg_svc ? $pkg_svc->quantity : 0,
- ];
- }
-
- grep { $_ != $svcpart }
- map { $_->svcpart }
- qsearch('part_svc', { 'svcdb' => $part_svc->svcdb } )
- ];
- warn "alternates for svcpart $svcpart: ".
- join(', ', @{$svcpart2svcparts{$svcpart}}). "\n"
- if $DEBUG;
- }
- }
-
- foreach my $cust_svc ($self->cust_svc) {
- if($target{$cust_svc->svcpart} > 0) {
- $target{$cust_svc->svcpart}--;
- my $new = new FS::cust_svc {
- svcnum => $cust_svc->svcnum,
- svcpart => $cust_svc->svcpart,
- pkgnum => $dest_pkgnum,
- };
- my $error = $new->replace($cust_svc);
- return $error if $error;
- } elsif ( exists $opt{'change_svcpart'} && $opt{'change_svcpart'} ) {
- if ( $DEBUG ) {
- warn "looking for alternates for svcpart ". $cust_svc->svcpart. "\n";
- warn "alternates to consider: ".
- join(', ', @{$svcpart2svcparts{$cust_svc->svcpart}}). "\n";
- }
- my @alternate = grep {
- warn "considering alternate svcpart $_: ".
- "$target{$_} available in new package\n"
- if $DEBUG;
- $target{$_} > 0;
- } @{$svcpart2svcparts{$cust_svc->svcpart}};
- if ( @alternate ) {
- warn "alternate(s) found\n" if $DEBUG;
- my $change_svcpart = $alternate[0];
- $target{$change_svcpart}--;
- my $new = new FS::cust_svc {
- svcnum => $cust_svc->svcnum,
- svcpart => $change_svcpart,
- pkgnum => $dest_pkgnum,
- };
- my $error = $new->replace($cust_svc);
- return $error if $error;
- } else {
- $remaining++;
- }
- } else {
- $remaining++
- }
- }
- return $remaining;
-}
-
-=item reexport
-
-This method is deprecated. See the I<depend_jobnum> option to the insert and
-order_pkgs methods in FS::cust_main for a better way to defer provisioning.
-
-=cut
-
-sub reexport {
- my $self = shift;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- foreach my $cust_svc ( $self->cust_svc ) {
- #false laziness w/svc_Common::insert
- my $svc_x = $cust_svc->svc_x;
- foreach my $part_export ( $cust_svc->part_svc->part_export ) {
- my $error = $part_export->export_insert($svc_x);
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
- '';
-
-}
-
-=back
-
-=head1 SUBROUTINES
-
-=over 4
-
-=item order CUSTNUM, PKGPARTS_ARYREF, [ REMOVE_PKGNUMS_ARYREF [ RETURN_CUST_PKG_ARRAYREF ] ]
-
-CUSTNUM is a customer (see L<FS::cust_main>)
-
-PKGPARTS is a list of pkgparts specifying the the billing item definitions (see
-L<FS::part_pkg>) to order for this customer. Duplicates are of course
-permitted.
-
-REMOVE_PKGNUMS is an optional list of pkgnums specifying the billing items to
-remove for this customer. The services (see L<FS::cust_svc>) are moved to the
-new billing items. An error is returned if this is not possible (see
-L<FS::pkg_svc>). An empty arrayref is equivalent to not specifying this
-parameter.
-
-RETURN_CUST_PKG_ARRAYREF, if specified, will be filled in with the
-newly-created cust_pkg objects.
-
-=cut
-
-sub order {
- my ($custnum, $pkgparts, $remove_pkgnum, $return_cust_pkg) = @_;
-
- my $conf = new FS::Conf;
-
- # Transactionize this whole mess
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- my $error;
- my $cust_main = qsearchs('cust_main', { custnum => $custnum });
- return "Customer not found: $custnum" unless $cust_main;
-
- # Create the new packages.
- my $cust_pkg;
- foreach (@$pkgparts) {
- $cust_pkg = new FS::cust_pkg { custnum => $custnum,
- pkgpart => $_ };
- $error = $cust_pkg->insert;
- if ($error) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- push @$return_cust_pkg, $cust_pkg;
- }
- # $return_cust_pkg now contains refs to all of the newly
- # created packages.
-
- # Transfer services and cancel old packages.
- foreach my $old_pkgnum (@$remove_pkgnum) {
- my $old_pkg = qsearchs ('cust_pkg', { pkgnum => $old_pkgnum });
-
- foreach my $new_pkg (@$return_cust_pkg) {
- $error = $old_pkg->transfer($new_pkg);
- if ($error and $error == 0) {
- # $old_pkg->transfer failed.
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
-
- if ( $error > 0 && $conf->exists('cust_pkg-change_svcpart') ) {
- warn "trying transfer again with change_svcpart option\n" if $DEBUG;
- foreach my $new_pkg (@$return_cust_pkg) {
- $error = $old_pkg->transfer($new_pkg, 'change_svcpart'=>1 );
- if ($error and $error == 0) {
- # $old_pkg->transfer failed.
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
- }
-
- if ($error > 0) {
- # Transfers were successful, but we went through all of the
- # new packages and still had services left on the old package.
- # We can't cancel the package under the circumstances, so abort.
- $dbh->rollback if $oldAutoCommit;
- return "Unable to transfer all services from package ".$old_pkg->pkgnum;
- }
- $error = $old_pkg->cancel;
- if ($error) {
- $dbh->rollback;
- return $error;
- }
- }
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
- '';
-}
-
-=back
-
-=head1 BUGS
-
-sub order is not OO. Perhaps it should be moved to FS::cust_main and made so?
-
-In sub order, the @pkgparts array (passed by reference) is clobbered.
-
-Also in sub order, no money is adjusted. Once FS::part_pkg defines a standard
-method to pass dates to the recur_prog expression, it should do so.
-
-FS::svc_acct, FS::svc_domain, FS::svc_www, FS::svc_ip and FS::svc_forward are
-loaded via 'use' at compile time, rather than via 'require' in sub { setup,
-suspend, unsuspend, cancel } because they use %FS::UID::callback to load
-configuration values. Probably need a subroutine which decides what to do
-based on whether or not we've fetched the user yet, rather than a hash. See
-FS::UID and the TODO.
-
-Now that things are transactional should the check in the insert method be
-moved to check ?
-
-=head1 SEE ALSO
-
-L<FS::Record>, L<FS::cust_main>, L<FS::part_pkg>, L<FS::cust_svc>,
-L<FS::pkg_svc>, schema.html from the base documentation
-
-=cut
-
-1;
-
diff --git a/FS/FS/cust_refund.pm b/FS/FS/cust_refund.pm
deleted file mode 100644
index 250bd20..0000000
--- a/FS/FS/cust_refund.pm
+++ /dev/null
@@ -1,283 +0,0 @@
-package FS::cust_refund;
-
-use strict;
-use vars qw( @ISA );
-use Business::CreditCard;
-use FS::Record qw( qsearchs dbh );
-use FS::UID qw(getotaker);
-use FS::cust_credit;
-use FS::cust_credit_refund;
-use FS::cust_main;
-
-@ISA = qw( FS::Record );
-
-=head1 NAME
-
-FS::cust_refund - Object method for cust_refund objects
-
-=head1 SYNOPSIS
-
- use FS::cust_refund;
-
- $record = new FS::cust_refund \%hash;
- $record = new FS::cust_refund { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
-=head1 DESCRIPTION
-
-An FS::cust_refund represents a refund: the transfer of money to a customer;
-equivalent to a negative payment (see L<FS::cust_pay>). FS::cust_refund
-inherits from FS::Record. The following fields are currently supported:
-
-=over 4
-
-=item refundnum - primary key (assigned automatically for new refunds)
-
-=item custnum - customer (see L<FS::cust_main>)
-
-=item refund - Amount of the refund
-
-=item _date - specified as a UNIX timestamp; see L<perlfunc/"time">. Also see
-L<Time::Local> and L<Date::Parse> for conversion functions.
-
-=item payby - `CARD' (credit cards), `CHEK' (electronic check/ACH),
-`LECB' (Phone bill billing), `BILL' (billing), or `COMP' (free)
-
-=item payinfo - card number, P.O.#, or comp issuer (4-8 lowercase alphanumerics; think username)
-
-=item paybatch - text field for tracking card processing
-
-=item otaker - order taker (assigned automatically, see L<FS::UID>)
-
-=item closed - books closed flag, empty or `Y'
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new refund. To add the refund to the database, see L<"insert">.
-
-=cut
-
-sub table { 'cust_refund'; }
-
-=item insert
-
-Adds this refund to the database.
-
-For backwards-compatibility and convenience, if the additional field crednum is
-defined, an FS::cust_credit_refund record for the full amount of the refund
-will be created. In this case, custnum is optional.
-
-=cut
-
-sub insert {
- my $self = shift;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- if ( $self->crednum ) {
- my $cust_credit = qsearchs('cust_credit', { 'crednum' => $self->crednum } )
- or do {
- $dbh->rollback if $oldAutoCommit;
- return "Unknown cust_credit.crednum: ". $self->crednum;
- };
- $self->custnum($cust_credit->custnum);
- }
-
- my $error = $self->check;
- return $error if $error;
-
- $error = $self->SUPER::insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- if ( $self->crednum ) {
- my $cust_credit_refund = new FS::cust_credit_refund {
- 'crednum' => $self->crednum,
- 'refundnum' => $self->refundnum,
- 'amount' => $self->refund,
- '_date' => $self->_date,
- };
- $error = $cust_credit_refund->insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- #$self->custnum($cust_credit_refund->cust_credit->custnum);
- }
-
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
-
- '';
-
-}
-
-sub upgrade_replace { #1.3.x->1.4.x
- my $self = shift;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- my $error = $self->check;
- return $error if $error;
-
- my %new = $self->hash;
- my $new = FS::cust_refund->new(\%new);
-
- if ( $self->crednum ) {
- my $cust_credit_refund = new FS::cust_credit_refund {
- 'crednum' => $self->crednum,
- 'refundnum' => $self->refundnum,
- 'amount' => $self->refund,
- '_date' => $self->_date,
- };
- $error = $cust_credit_refund->insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- $new->custnum($cust_credit_refund->cust_credit->custnum);
- } else {
- die;
- }
-
- $error = $new->SUPER::replace($self);
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
-
- '';
-
-}
-
-=item delete
-
-Currently unimplemented (accounting reasons).
-
-=cut
-
-sub delete {
- my $self = shift;
- return "Can't delete closed refund" if $self->closed =~ /^Y/i;
- $self->SUPER::delete(@_);
-}
-
-=item replace OLD_RECORD
-
-Currently unimplemented (accounting reasons).
-
-=cut
-
-sub replace {
- return "Can't (yet?) modify cust_refund records!";
-}
-
-=item check
-
-Checks all fields to make sure this is a valid refund. If there is an error,
-returns the error, otherwise returns false. Called by the insert method.
-
-=cut
-
-sub check {
- my $self = shift;
-
- my $error =
- $self->ut_numbern('refundnum')
- || $self->ut_numbern('custnum')
- || $self->ut_money('refund')
- || $self->ut_numbern('_date')
- || $self->ut_textn('paybatch')
- || $self->ut_enum('closed', [ '', 'Y' ])
- ;
- return $error if $error;
-
- return "refund must be > 0 " if $self->refund <= 0;
-
- $self->_date(time) unless $self->_date;
-
- return "unknown cust_main.custnum: ". $self->custnum
- unless $self->crednum
- || qsearchs( 'cust_main', { 'custnum' => $self->custnum } );
-
- $self->payby =~ /^(CARD|CHEK|LECB|BILL|COMP)$/ or return "Illegal payby";
- $self->payby($1);
-
- #false laziness with cust_pay::check
- if ( $self->payby eq 'CARD' ) {
- my $payinfo = $self->payinfo;
- $payinfo =~ s/\D//g;
- $self->payinfo($payinfo);
- if ( $self->payinfo ) {
- $self->payinfo =~ /^(\d{13,16})$/
- or return "Illegal (mistyped?) credit card number (payinfo)";
- $self->payinfo($1);
- validate($self->payinfo) or return "Illegal credit card number";
- return "Unknown card type" if cardtype($self->payinfo) eq "Unknown";
- } else {
- $self->payinfo('N/A');
- }
-
- } else {
- $error = $self->ut_textn('payinfo');
- return $error if $error;
- }
-
- $self->otaker(getotaker);
-
- $self->SUPER::check;
-}
-
-=back
-
-=head1 VERSION
-
-$Id: cust_refund.pm,v 1.21 2003-08-05 00:20:42 khoff Exp $
-
-=head1 BUGS
-
-Delete and replace methods.
-
-=head1 SEE ALSO
-
-L<FS::Record>, L<FS::cust_credit>, schema.html from the base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/cust_svc.pm b/FS/FS/cust_svc.pm
deleted file mode 100644
index b975396..0000000
--- a/FS/FS/cust_svc.pm
+++ /dev/null
@@ -1,616 +0,0 @@
-package FS::cust_svc;
-
-use strict;
-use vars qw( @ISA $ignore_quantity );
-use Carp qw( cluck );
-use FS::Record qw( qsearch qsearchs dbh );
-use FS::cust_pkg;
-use FS::part_pkg;
-use FS::part_svc;
-use FS::pkg_svc;
-use FS::svc_acct;
-use FS::svc_domain;
-use FS::svc_forward;
-use FS::svc_broadband;
-use FS::domain_record;
-use FS::part_export;
-
-@ISA = qw( FS::Record );
-
-$ignore_quantity = 0;
-
-sub _cache {
- my $self = shift;
- my ( $hashref, $cache ) = @_;
- if ( $hashref->{'username'} ) {
- $self->{'_svc_acct'} = FS::svc_acct->new($hashref, '');
- }
- if ( $hashref->{'svc'} ) {
- $self->{'_svcpart'} = FS::part_svc->new($hashref);
- }
-}
-
-=head1 NAME
-
-FS::cust_svc - Object method for cust_svc objects
-
-=head1 SYNOPSIS
-
- use FS::cust_svc;
-
- $record = new FS::cust_svc \%hash
- $record = new FS::cust_svc { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
- ($label, $value) = $record->label;
-
-=head1 DESCRIPTION
-
-An FS::cust_svc represents a service. FS::cust_svc inherits from FS::Record.
-The following fields are currently supported:
-
-=over 4
-
-=item svcnum - primary key (assigned automatically for new services)
-
-=item pkgnum - Package (see L<FS::cust_pkg>)
-
-=item svcpart - Service definition (see L<FS::part_svc>)
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new service. To add the refund to the database, see L<"insert">.
-Services are normally created by creating FS::svc_ objects (see
-L<FS::svc_acct>, L<FS::svc_domain>, and L<FS::svc_forward>, among others).
-
-=cut
-
-sub table { 'cust_svc'; }
-
-=item insert
-
-Adds this service to the database. If there is an error, returns the error,
-otherwise returns false.
-
-=item delete
-
-Deletes this service from the database. If there is an error, returns the
-error, otherwise returns false. Note that this only removes the cust_svc
-record - you should probably use the B<cancel> method instead.
-
-=item cancel
-
-Cancels the relevant service by calling the B<cancel> method of the associated
-FS::svc_XXX object (i.e. an FS::svc_acct object or FS::svc_domain object),
-deleting the FS::svc_XXX record and then deleting this record.
-
-If there is an error, returns the error, otherwise returns false.
-
-=cut
-
-sub cancel {
- my $self = shift;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- my $part_svc = $self->part_svc;
-
- $part_svc->svcdb =~ /^([\w\-]+)$/ or do {
- $dbh->rollback if $oldAutoCommit;
- return "Illegal svcdb value in part_svc!";
- };
- my $svcdb = $1;
- require "FS/$svcdb.pm";
-
- my $svc = $self->svc_x;
- if ($svc) {
- my $error = $svc->cancel;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "Error canceling service: $error";
- }
- $error = $svc->delete;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "Error deleting service: $error";
- }
- }
-
- my $error = $self->delete;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "Error deleting cust_svc: $error";
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
-
- ''; #no errors
-
-}
-
-=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 );
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- my $error = $new->SUPER::replace($old);
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error if $error;
- }
-
- if ( $new->svcpart != $old->svcpart ) {
- my $svc_x = $new->svc_x;
- my $new_svc_x = ref($svc_x)->new({$svc_x->hash});
- my $error = $new_svc_x->replace($svc_x);
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error if $error;
- }
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
- ''; #no error
-
-}
-
-=item check
-
-Checks all fields to make sure this is a valid service. If there is an error,
-returns the error, otehrwise returns false. Called by the insert and
-replace methods.
-
-=cut
-
-sub check {
- my $self = shift;
-
- my $error =
- $self->ut_numbern('svcnum')
- || $self->ut_numbern('pkgnum')
- || $self->ut_number('svcpart')
- ;
- return $error if $error;
-
- my $part_svc = qsearchs( 'part_svc', { 'svcpart' => $self->svcpart } );
- return "Unknown svcpart" unless $part_svc;
-
- if ( $self->pkgnum ) {
- my $cust_pkg = qsearchs( 'cust_pkg', { 'pkgnum' => $self->pkgnum } );
- return "Unknown pkgnum" unless $cust_pkg;
- my $pkg_svc = qsearchs( 'pkg_svc', {
- 'pkgpart' => $cust_pkg->pkgpart,
- 'svcpart' => $self->svcpart,
- });
- # or new FS::pkg_svc ( { 'pkgpart' => $cust_pkg->pkgpart,
- # 'svcpart' => $self->svcpart,
- # 'quantity' => 0 } );
- my $quantity = $pkg_svc ? $pkg_svc->quantity : 0;
-
- my @cust_svc = qsearch('cust_svc', {
- 'pkgnum' => $self->pkgnum,
- 'svcpart' => $self->svcpart,
- });
- return "Already ". scalar(@cust_svc). " ". $part_svc->svc.
- " services for pkgnum ". $self->pkgnum
- if scalar(@cust_svc) >= $quantity && !$ignore_quantity;
- }
-
- $self->SUPER::check;
-}
-
-=item part_svc
-
-Returns the definition for this service, as a FS::part_svc object (see
-L<FS::part_svc>).
-
-=cut
-
-sub part_svc {
- my $self = shift;
- $self->{'_svcpart'}
- ? $self->{'_svcpart'}
- : qsearchs( 'part_svc', { 'svcpart' => $self->svcpart } );
-}
-
-=item cust_pkg
-
-Returns the definition for this service, as a FS::part_svc object (see
-L<FS::part_svc>).
-
-=cut
-
-sub cust_pkg {
- my $self = shift;
- qsearchs( 'cust_pkg', { 'pkgnum' => $self->pkgnum } );
-}
-
-=item label
-
-Returns a list consisting of:
-- The name of this service (from part_svc)
-- A meaningful identifier (username, domain, or mail alias)
-- The table name (i.e. svc_domain) for this service
-
-=cut
-
-sub label {
- my $self = shift;
- my $svcdb = $self->part_svc->svcdb;
- my $svc_x = $self->svc_x
- or die "can't find $svcdb.svcnum ". $self->svcnum;
- my $tag;
- if ( $svcdb eq 'svc_acct' ) {
- $tag = $svc_x->email;
- } elsif ( $svcdb eq 'svc_forward' ) {
- if ( $svc_x->srcsvc ) {
- my $svc_acct = $svc_x->srcsvc_acct;
- $tag = $svc_acct->email;
- } else {
- $tag = $svc_x->src;
- }
- $tag .= '->';
- if ( $svc_x->dstsvc ) {
- my $svc_acct = $svc_x->dstsvc_acct;
- $tag .= $svc_acct->email;
- } else {
- $tag .= $svc_x->dst;
- }
- } elsif ( $svcdb eq 'svc_domain' ) {
- $tag = $svc_x->getfield('domain');
- } elsif ( $svcdb eq 'svc_www' ) {
- my $domain = qsearchs( 'domain_record', { 'recnum' => $svc_x->recnum } );
- $tag = $domain->zone;
- } elsif ( $svcdb eq 'svc_broadband' ) {
- $tag = $svc_x->ip_addr;
- } elsif ( $svcdb eq 'svc_external' ) {
- $tag = $svc_x->id. ': '. $svc_x->title;
- } else {
- cluck "warning: asked for label of unsupported svcdb; using svcnum";
- $tag = $svc_x->getfield('svcnum');
- }
- $self->part_svc->svc, $tag, $svcdb;
-}
-
-=item svc_x
-
-Returns the FS::svc_XXX object for this service (i.e. an FS::svc_acct object or
-FS::svc_domain object, etc.)
-
-=cut
-
-sub svc_x {
- my $self = shift;
- my $svcdb = $self->part_svc->svcdb;
- if ( $svcdb eq 'svc_acct' && $self->{'_svc_acct'} ) {
- $self->{'_svc_acct'};
- } else {
- qsearchs( $svcdb, { 'svcnum' => $self->svcnum } );
- }
-}
-
-=item seconds_since TIMESTAMP
-
-See L<FS::svc_acct/seconds_since>. Equivalent to
-$cust_svc->svc_x->seconds_since, but more efficient. Meaningless for records
-where B<svcdb> is not "svc_acct".
-
-=cut
-
-#note: implementation here, POD in FS::svc_acct
-sub seconds_since {
- my($self, $since) = @_;
- my $dbh = dbh;
- my $sth = $dbh->prepare(' SELECT SUM(logout-login) FROM session
- WHERE svcnum = ?
- AND login >= ?
- AND logout IS NOT NULL'
- ) or die $dbh->errstr;
- $sth->execute($self->svcnum, $since) or die $sth->errstr;
- $sth->fetchrow_arrayref->[0];
-}
-
-=item seconds_since_sqlradacct TIMESTAMP_START TIMESTAMP_END
-
-See L<FS::svc_acct/seconds_since_sqlradacct>. Equivalent to
-$cust_svc->svc_x->seconds_since_sqlradacct, but more efficient. Meaningless
-for records where B<svcdb> is not "svc_acct".
-
-=cut
-
-#note: implementation here, POD in FS::svc_acct
-sub seconds_since_sqlradacct {
- my($self, $start, $end) = @_;
-
- my $svc_x = $self->svc_x;
-
- my @part_export = $self->part_svc->part_export('sqlradius');
- push @part_export, $self->part_svc->part_export('sqlradius_withdomain');
- die "no sqlradius or sqlradius_withdomain export configured for this".
- "service type"
- unless @part_export;
- #or return undef;
-
- my $seconds = 0;
- foreach my $part_export ( @part_export ) {
-
- next if $part_export->option('ignore_accounting');
-
- my $dbh = DBI->connect( map { $part_export->option($_) }
- qw(datasrc username password) )
- or die "can't connect to sqlradius database: ". $DBI::errstr;
-
- #select a unix time conversion function based on database type
- my $str2time;
- if ( $dbh->{Driver}->{Name} =~ /^mysql(PP)?$/ ) {
- $str2time = 'UNIX_TIMESTAMP(';
- } elsif ( $dbh->{Driver}->{Name} eq 'Pg' ) {
- $str2time = 'EXTRACT( EPOCH FROM ';
- } else {
- warn "warning: unknown database type ". $dbh->{Driver}->{Name}.
- "; guessing how to convert to UNIX timestamps";
- $str2time = 'extract(epoch from ';
- }
-
- my $username;
- if ( $part_export->exporttype eq 'sqlradius' ) {
- $username = $svc_x->username;
- } elsif ( $part_export->exporttype eq 'sqlradius_withdomain' ) {
- $username = $svc_x->email;
- } else {
- die 'unknown exporttype '. $part_export->exporttype;
- }
-
- my $query;
-
- #find closed sessions completely within the given range
- my $sth = $dbh->prepare("SELECT SUM(acctsessiontime)
- FROM radacct
- WHERE UserName = ?
- AND $str2time AcctStartTime) >= ?
- AND $str2time AcctStopTime ) < ?
- AND $str2time AcctStopTime ) > 0
- AND AcctStopTime IS NOT NULL"
- ) or die $dbh->errstr;
- $sth->execute($username, $start, $end) or die $sth->errstr;
- my $regular = $sth->fetchrow_arrayref->[0];
-
- #find open sessions which start in the range, count session start->range end
- $query = "SELECT SUM( ? - $str2time AcctStartTime ) )
- FROM radacct
- WHERE UserName = ?
- AND $str2time AcctStartTime ) >= ?
- AND $str2time AcctStartTime ) < ?
- AND ( ? - $str2time AcctStartTime ) ) < 86400
- AND ( $str2time AcctStopTime ) = 0
- OR AcctStopTime IS NULL )";
- $sth = $dbh->prepare($query) or die $dbh->errstr;
- $sth->execute($end, $username, $start, $end, $end)
- or die $sth->errstr. " executing query $query";
- my $start_during = $sth->fetchrow_arrayref->[0];
-
- #find closed sessions which start before the range but stop during,
- #count range start->session end
- $sth = $dbh->prepare("SELECT SUM( $str2time AcctStopTime ) - ? )
- FROM radacct
- WHERE UserName = ?
- AND $str2time AcctStartTime ) < ?
- AND $str2time AcctStopTime ) >= ?
- AND $str2time AcctStopTime ) < ?
- AND $str2time AcctStopTime ) > 0
- AND AcctStopTime IS NOT NULL"
- ) or die $dbh->errstr;
- $sth->execute($start, $username, $start, $start, $end ) or die $sth->errstr;
- my $end_during = $sth->fetchrow_arrayref->[0];
-
- #find closed (not anymore - or open) sessions which start before the range
- # but stop after, or are still open, count range start->range end
- # don't count open sessions (probably missing stop record)
- $sth = $dbh->prepare("SELECT COUNT(*)
- FROM radacct
- WHERE UserName = ?
- AND $str2time AcctStartTime ) < ?
- AND ( $str2time AcctStopTime ) >= ?
- )"
- # OR AcctStopTime = 0
- # OR AcctStopTime IS NULL )"
- ) or die $dbh->errstr;
- $sth->execute($username, $start, $end ) or die $sth->errstr;
- my $entire_range = ($end-$start) * $sth->fetchrow_arrayref->[0];
-
- $seconds += $regular + $end_during + $start_during + $entire_range;
-
- }
-
- $seconds;
-
-}
-
-=item attribute_since_sqlradacct TIMESTAMP_START TIMESTAMP_END ATTRIBUTE
-
-See L<FS::svc_acct/attribute_since_sqlradacct>. Equivalent to
-$cust_svc->svc_x->attribute_since_sqlradacct, but more efficient. Meaningless
-for records where B<svcdb> is not "svc_acct".
-
-=cut
-
-#note: implementation here, POD in FS::svc_acct
-#(false laziness w/seconds_since_sqlradacct above)
-sub attribute_since_sqlradacct {
- my($self, $start, $end, $attrib) = @_;
-
- my $svc_x = $self->svc_x;
-
- my @part_export = $self->part_svc->part_export('sqlradius');
- push @part_export, $self->part_svc->part_export('sqlradius_withdomain');
- die "no sqlradius or sqlradius_withdomain export configured for this".
- "service type"
- unless @part_export;
- #or return undef;
-
- my $sum = 0;
-
- foreach my $part_export ( @part_export ) {
-
- next if $part_export->option('ignore_accounting');
-
- my $dbh = DBI->connect( map { $part_export->option($_) }
- qw(datasrc username password) )
- or die "can't connect to sqlradius database: ". $DBI::errstr;
-
- #select a unix time conversion function based on database type
- my $str2time;
- if ( $dbh->{Driver}->{Name} =~ /^mysql(PP)?$/ ) {
- $str2time = 'UNIX_TIMESTAMP(';
- } elsif ( $dbh->{Driver}->{Name} eq 'Pg' ) {
- $str2time = 'EXTRACT( EPOCH FROM ';
- } else {
- warn "warning: unknown database type ". $dbh->{Driver}->{Name}.
- "; guessing how to convert to UNIX timestamps";
- $str2time = 'extract(epoch from ';
- }
-
- my $username;
- if ( $part_export->exporttype eq 'sqlradius' ) {
- $username = $svc_x->username;
- } elsif ( $part_export->exporttype eq 'sqlradius_withdomain' ) {
- $username = $svc_x->email;
- } else {
- die 'unknown exporttype '. $part_export->exporttype;
- }
-
- my $sth = $dbh->prepare("SELECT SUM($attrib)
- FROM radacct
- WHERE UserName = ?
- AND $str2time AcctStopTime ) >= ?
- AND $str2time AcctStopTime ) < ?
- AND AcctStopTime IS NOT NULL"
- ) or die $dbh->errstr;
- $sth->execute($username, $start, $end) or die $sth->errstr;
-
- $sum += $sth->fetchrow_arrayref->[0];
-
- }
-
- $sum;
-
-}
-
-=item get_session_history_sqlradacct TIMESTAMP_START TIMESTAMP_END
-
-See L<FS::svc_acct/get_session_history_sqlradacct>. Equivalent to
-$cust_svc->svc_x->get_session_history_sqlradacct, but more efficient.
-Meaningless for records where B<svcdb> is not "svc_acct".
-
-=cut
-
-sub get_session_history {
- my($self, $start, $end, $attrib) = @_;
-
- my $username = $self->svc_x->username;
-
- my @part_export = $self->part_svc->part_export('sqlradius')
- or die "no sqlradius export configured for this service type";
- #or return undef;
-
- my @sessions = ();
-
- foreach my $part_export ( @part_export ) {
-
- my $dbh = DBI->connect( map { $part_export->option($_) }
- qw(datasrc username password) )
- or die "can't connect to sqlradius database: ". $DBI::errstr;
-
- #select a unix time conversion function based on database type
- my $str2time;
- if ( $dbh->{Driver}->{Name} =~ /^mysql(PP)?$/ ) {
- $str2time = 'UNIX_TIMESTAMP(';
- } elsif ( $dbh->{Driver}->{Name} eq 'Pg' ) {
- $str2time = 'EXTRACT( EPOCH FROM ';
- } else {
- warn "warning: unknown database type ". $dbh->{Driver}->{Name}.
- "; guessing how to convert to UNIX timestamps";
- $str2time = 'extract(epoch from ';
- }
-
- my @fields = qw( acctstarttime acctstoptime acctsessiontime
- acctinputoctets acctoutputoctets framedipaddress );
-
- my $sth = $dbh->prepare('SELECT '. join(', ', @fields).
- " FROM radacct
- WHERE UserName = ?
- AND $str2time AcctStopTime ) >= ?
- AND $str2time AcctStopTime ) <= ?
- ORDER BY AcctStartTime DESC
- ") or die $dbh->errstr;
- $sth->execute($username, $start, $end) or die $sth->errstr;
-
- push @sessions, map { { %$_ } } @{ $sth->fetchall_arrayref({}) };
-
- }
- \@sessions
-
-}
-
-=back
-
-=head1 BUGS
-
-Behaviour of changing the svcpart of cust_svc records is undefined and should
-possibly be prohibited, and pkg_svc records are not checked.
-
-pkg_svc records are not checked in general (here).
-
-Deleting this record doesn't check or delete the svc_* record associated
-with this record.
-
-In seconds_since_sqlradacct, specifying a DATASRC/USERNAME/PASSWORD instead of
-a DBI database handle is not yet implemented.
-
-=head1 SEE ALSO
-
-L<FS::Record>, L<FS::cust_pkg>, L<FS::part_svc>, L<FS::pkg_svc>,
-schema.html from the base documentation
-
-=cut
-
-1;
-
diff --git a/FS/FS/cust_tax_exempt.pm b/FS/FS/cust_tax_exempt.pm
deleted file mode 100644
index da0de00..0000000
--- a/FS/FS/cust_tax_exempt.pm
+++ /dev/null
@@ -1,132 +0,0 @@
-package FS::cust_tax_exempt;
-
-use strict;
-use vars qw( @ISA );
-use FS::Record qw( qsearch qsearchs );
-
-@ISA = qw(FS::Record);
-
-=head1 NAME
-
-FS::cust_tax_exempt - Object methods for cust_tax_exempt records
-
-=head1 SYNOPSIS
-
- use FS::cust_tax_exempt;
-
- $record = new FS::cust_tax_exempt \%hash;
- $record = new FS::cust_tax_exempt { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
-=head1 DESCRIPTION
-
-An FS::cust_tax_exempt object represents a historical record of a customer tax
-exemption. Currently this is only used for "texas tax". FS::cust_tax_exempt
-inherits from FS::Record. The following fields are currently supported:
-
-=over 4
-
-=item exemptnum - primary key
-
-=item custnum - customer (see L<FS::cust_main>)
-
-=item taxnum - tax rate (see L<FS::cust_main_county>)
-
-=item year
-
-=item month
-
-=item amount
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new exemption record. 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 { 'cust_tax_exempt'; }
-
-=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;
-
- $self->ut_numbern('exemptnum')
- || $self->ut_foreign_key('custnum', 'cust_main', 'custnum')
- || $self->ut_foreign_key('taxnum', 'cust_main_county', 'taxnum')
- || $self->ut_number('year') #check better
- || $self->ut_number('month') #check better
- || $self->ut_money('amount')
- || $self->SUPER::check
- ;
-}
-
-=back
-
-=head1 BUGS
-
-Texas tax is a royal pain in the ass.
-
-=head1 SEE ALSO
-
-L<FS::cust_main_county>, L<FS::cust_main>, L<FS::Record>, schema.html from the
-base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/domain_record.pm b/FS/FS/domain_record.pm
deleted file mode 100644
index ea0c48d..0000000
--- a/FS/FS/domain_record.pm
+++ /dev/null
@@ -1,351 +0,0 @@
-package FS::domain_record;
-
-use strict;
-use vars qw( @ISA $noserial_hack );
-#use FS::Record qw( qsearch qsearchs );
-use FS::Record qw( qsearchs dbh );
-use FS::svc_domain;
-use FS::svc_www;
-
-@ISA = qw(FS::Record);
-
-=head1 NAME
-
-FS::domain_record - Object methods for domain_record records
-
-=head1 SYNOPSIS
-
- use FS::domain_record;
-
- $record = new FS::domain_record \%hash;
- $record = new FS::domain_record { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
-=head1 DESCRIPTION
-
-An FS::domain_record object represents an entry in a DNS zone.
-FS::domain_record inherits from FS::Record. The following fields are currently
-supported:
-
-=over 4
-
-=item recnum - primary key
-
-=item svcnum - Domain (see L<FS::svc_domain>) of this entry
-
-=item reczone - partial (or full) zone for this entry
-
-=item recaf - address family for this entry, currently only `IN' is recognized.
-
-=item rectype - record type for this entry (A, MX, etc.)
-
-=item recdata - data for this entry
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new entry. 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 { 'domain_record'; }
-
-=item insert
-
-Adds this record to the database. If there is an error, returns the error,
-otherwise returns false.
-
-=cut
-
-sub insert {
- my $self = shift;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- if ( $self->rectype eq '_mstr' ) { #delete all other records
- foreach my $domain_record ( reverse $self->svc_domain->domain_record ) {
- my $error = $domain_record->delete;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
- }
-
- my $error = $self->SUPER::insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- unless ( $self->rectype =~ /^(SOA|_mstr)$/ ) {
- my $error = $self->increment_serial;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
-
- '';
-
-}
-
-=item delete
-
-Delete this record from the database.
-
-=cut
-
-sub delete {
- my $self = shift;
-
- return "Can't delete a domain record which has a website!"
- if qsearchs( 'svc_www', { 'recnum' => $self->recnum } );
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- my $error = $self->SUPER::delete;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- unless ( $self->rectype =~ /^(SOA|_mstr)$/ ) {
- my $error = $self->increment_serial;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
-
- '';
-
-}
-
-=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 $self = shift;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- my $error = $self->SUPER::replace(@_);
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- unless ( $self->rectype eq 'SOA' ) {
- my $error = $self->increment_serial;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
-
- '';
-
-}
-
-=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;
-
- my $error =
- $self->ut_numbern('recnum')
- || $self->ut_number('svcnum')
- ;
- return $error if $error;
-
- return "Unknown svcnum (in svc_domain)"
- unless qsearchs('svc_domain', { 'svcnum' => $self->svcnum } );
-
- $self->reczone =~ /^(@|[a-z0-9\.\-\*]+)$/i
- or return "Illegal reczone: ". $self->reczone;
- $self->reczone($1);
-
- $self->recaf =~ /^(IN)$/ or return "Illegal recaf: ". $self->recaf;
- $self->recaf($1);
-
- $self->rectype =~ /^(SOA|NS|MX|A|PTR|CNAME|_mstr)$/
- or return "Illegal rectype (only SOA NS MX A PTR CNAME recognized): ".
- $self->rectype;
- $self->rectype($1);
-
- return "Illegal reczone for ". $self->rectype. ": ". $self->reczone
- if $self->rectype !~ /^MX$/i && $self->reczone =~ /\*/;
-
- if ( $self->rectype eq 'SOA' ) {
- my $recdata = $self->recdata;
- $recdata =~ s/\s+/ /g;
- $recdata =~ /^([a-z0-9\.\-]+ [\w\-\+]+\.[a-z0-9\.\-]+ \( ((\d+|((\d+[WDHMS])+)) ){5}\))$/i
- or return "Illegal data for SOA record: $recdata";
- $self->recdata($1);
- } elsif ( $self->rectype eq 'NS' ) {
- $self->recdata =~ /^([a-z0-9\.\-]+)$/i
- or return "Illegal data for NS record: ". $self->recdata;
- $self->recdata($1);
- } elsif ( $self->rectype eq 'MX' ) {
- $self->recdata =~ /^(\d+)\s+([a-z0-9\.\-]+)$/i
- or return "Illegal data for MX record: ". $self->recdata;
- $self->recdata("$1 $2");
- } elsif ( $self->rectype eq 'A' ) {
- $self->recdata =~ /^((\d{1,3}\.){3}\d{1,3})$/
- or return "Illegal data for A record: ". $self->recdata;
- $self->recdata($1);
- } elsif ( $self->rectype eq 'PTR' ) {
- $self->recdata =~ /^([a-z0-9\.\-]+)$/i
- or return "Illegal data for PTR record: ". $self->recdata;
- $self->recdata($1);
- } elsif ( $self->rectype eq 'CNAME' ) {
- $self->recdata =~ /^([a-z0-9\.\-]+|\@)$/i
- or return "Illegal data for CNAME record: ". $self->recdata;
- $self->recdata($1);
- } elsif ( $self->rectype eq '_mstr' ) {
- $self->recdata =~ /^((\d{1,3}\.){3}\d{1,3})$/
- or return "Illegal data for _master pseudo-record: ". $self->recdata;
- } else {
- die "ack!";
- }
-
- $self->SUPER::check;
-}
-
-=item increment_serial
-
-=cut
-
-sub increment_serial {
- return '' if $noserial_hack;
- my $self = shift;
-
- my $soa = qsearchs('domain_record', {
- svcnum => $self->svcnum,
- reczone => '@', #or full domain ?
- recaf => 'IN',
- rectype => 'SOA',
- } ) or return "soa record not found; can't increment serial";
-
- my $data = $soa->recdata;
- $data =~ s/(\(\D*)(\d+)/$1.($2+1)/e; #well, it works.
-
- my %hash = $soa->hash;
- $hash{recdata} = $data;
- my $new = new FS::domain_record \%hash;
- $new->replace($soa);
-}
-
-=item svc_domain
-
-Returns the domain (see L<FS::svc_domain>) for this record.
-
-=cut
-
-sub svc_domain {
- my $self = shift;
- qsearchs('svc_domain', { svcnum => $self->svcnum } );
-}
-
-=item zone
-
-Returns the canonical zone name.
-
-=cut
-
-sub zone {
- my $self = shift;
- my $zone = $self->reczone; # or die ?
- if ( $zone =~ /\.$/ ) {
- $zone =~ s/\.$//;
- } else {
- my $svc_domain = $self->svc_domain; # or die ?
- $zone .= '.'. $svc_domain->domain;
- $zone =~ s/^\@\.//;
- }
- $zone;
-}
-
-=back
-
-=head1 VERSION
-
-$Id: domain_record.pm,v 1.16 2003-08-05 00:20:43 khoff Exp $
-
-=head1 BUGS
-
-The data validation doesn't check everything it could. In particular,
-there is no protection against bad data that passes the regex, duplicate
-SOA records, forgetting the trailing `.', impossible IP addersses, etc. Of
-course, it's still better than editing the zone files directly. :)
-
-=head1 SEE ALSO
-
-L<FS::Record>, schema.html from the base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/export_svc.pm b/FS/FS/export_svc.pm
deleted file mode 100644
index c104e45..0000000
--- a/FS/FS/export_svc.pm
+++ /dev/null
@@ -1,124 +0,0 @@
-package FS::export_svc;
-
-use strict;
-use vars qw( @ISA );
-use FS::Record qw( qsearch qsearchs );
-use FS::part_export;
-use FS::part_svc;
-
-@ISA = qw(FS::Record);
-
-=head1 NAME
-
-FS::export_svc - Object methods for export_svc records
-
-=head1 SYNOPSIS
-
- use FS::export_svc;
-
- $record = new FS::export_svc \%hash;
- $record = new FS::export_svc { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
-=head1 DESCRIPTION
-
-An FS::export_svc object links a service definition (see L<FS::part_svc>) to
-an export (see L<FS::part_export>). FS::export_svc inherits from FS::Record.
-The following fields are currently supported:
-
-=over 4
-
-=item exportsvcnum - primary key
-
-=item exportnum - export (see L<FS::part_export>)
-
-=item svcpart - service definition (see L<FS::part_svc>)
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new record. To add the record 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 { 'export_svc'; }
-
-=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 record. 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;
-
- $self->ut_numbern('exportsvcnum')
- || $self->ut_number('exportnum')
- || $self->ut_foreign_key('exportnum', 'part_export', 'exportnum')
- || $self->ut_number('svcpart')
- || $self->ut_foreign_key('svcpart', 'part_svc', 'svcpart')
- || $self->SUPER::check
- ;
-}
-
-=back
-
-=head1 BUGS
-
-=head1 SEE ALSO
-
-L<FS::part_export>, L<FS::part_svc>, L<FS::Record>, schema.html from the base
-documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/msgcat.pm b/FS/FS/msgcat.pm
deleted file mode 100644
index 855b8b2..0000000
--- a/FS/FS/msgcat.pm
+++ /dev/null
@@ -1,132 +0,0 @@
-package FS::msgcat;
-
-use strict;
-use vars qw( @ISA );
-use Exporter;
-use FS::UID;
-use FS::Record qw( qsearchs );
-
-@ISA = qw(FS::Record);
-
-=head1 NAME
-
-FS::msgcat - Object methods for message catalog entries
-
-=head1 SYNOPSIS
-
- use FS::msgcat;
-
- $record = new FS::msgcat \%hash;
- $record = new FS::msgcat { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
-=head1 DESCRIPTION
-
-An FS::msgcat object represents an message catalog entry. FS::msgcat inherits
-from FS::Record. The following fields are currently supported:
-
-=over 4
-
-=item msgnum - primary key
-
-=item msgcode - Error code
-
-=item locale - Locale
-
-=item msg - Message
-
-=back
-
-If you just want to B<use> message catalogs, see L<FS::Msgcat>.
-
-=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 { 'msgcat'; }
-
-=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;
-
- my $error =
- $self->ut_numbern('msgnum')
- || $self->ut_text('msgcode')
- || $self->ut_text('msg')
- ;
- return $error if $error;
-
- $self->locale =~ /^([\w\@]+)$/ or return "illegal locale: ". $self->locale;
- $self->locale($1);
-
- $self->SUPER::check
-}
-
-=back
-
-=head1 BUGS
-
-i18n/l10n, eek
-
-=head1 SEE ALSO
-
-L<FS::Msgcat>, L<FS::Record>, schema.html from the base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/nas.pm b/FS/FS/nas.pm
deleted file mode 100644
index 2d17df8..0000000
--- a/FS/FS/nas.pm
+++ /dev/null
@@ -1,154 +0,0 @@
-package FS::nas;
-
-use strict;
-use vars qw( @ISA );
-use FS::Record qw(qsearchs); #qsearch);
-use FS::UID qw( dbh );
-
-@ISA = qw(FS::Record);
-
-=head1 NAME
-
-FS::nas - Object methods for nas records
-
-=head1 SYNOPSIS
-
- use FS::nas;
-
- $record = new FS::nas \%hash;
- $record = new FS::nas {
- 'nasnum' => 1,
- 'nasip' => '10.4.20.23',
- 'nasfqdn' => 'box1.brc.nv.us.example.net',
- };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
- $error = $record->heartbeat($timestamp);
-
-=head1 DESCRIPTION
-
-An FS::nas object represents an Network Access Server on your network, such as
-a terminal server or equivalent. FS::nas inherits from FS::Record. The
-following fields are currently supported:
-
-=over 4
-
-=item nasnum - primary key
-
-=item nas - NAS name
-
-=item nasip - NAS ip address
-
-=item nasfqdn - NAS fully-qualified domain name
-
-=item last - timestamp indicating the last instant the NAS was in a known
- state (used by the session monitoring).
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new NAS. To add the NAS 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 { 'nas'; }
-
-=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;
-
- $self->ut_numbern('nasnum')
- || $self->ut_text('nas')
- || $self->ut_ip('nasip')
- || $self->ut_domain('nasfqdn')
- || $self->ut_numbern('last')
- || $self->SUPER::check
- ;
-}
-
-=item heartbeat TIMESTAMP
-
-Updates the timestamp for this nas
-
-=cut
-
-sub heartbeat {
- my($self, $timestamp) = @_;
- my $dbh = dbh;
- my $sth =
- $dbh->prepare("UPDATE nas SET last = ? WHERE nasnum = ? AND last < ?");
- $sth->execute($timestamp, $self->nasnum, $timestamp) or die $sth->errstr;
- $self->last($timestamp);
-}
-
-=back
-
-=head1 VERSION
-
-$Id: nas.pm,v 1.7 2003-08-05 00:20:43 khoff Exp $
-
-=head1 BUGS
-
-heartbeat method uses SQL directly and doesn't update history tables.
-
-=head1 SEE ALSO
-
-L<FS::Record>, schema.html from the base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/part_bill_event.pm b/FS/FS/part_bill_event.pm
deleted file mode 100644
index 86f9294..0000000
--- a/FS/FS/part_bill_event.pm
+++ /dev/null
@@ -1,188 +0,0 @@
-package FS::part_bill_event;
-
-use strict;
-use vars qw( @ISA );
-use FS::Record qw( qsearch qsearchs );
-use FS::Conf;
-
-@ISA = qw(FS::Record);
-
-=head1 NAME
-
-FS::part_bill_event - Object methods for part_bill_event records
-
-=head1 SYNOPSIS
-
- use FS::part_bill_event;
-
- $record = new FS::part_bill_event \%hash;
- $record = new FS::part_bill_event { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
-=head1 DESCRIPTION
-
-An FS::part_bill_event object represents an invoice event definition -
-a callback which is triggered when an invoice is a certain amount of time
-overdue. FS::part_bill_event inherits from
-FS::Record. The following fields are currently supported:
-
-=over 4
-
-=item eventpart - primary key
-
-=item payby - CARD, DCRD, CHEK, DCHK, LECB, BILL, or COMP
-
-=item event - event name
-
-=item eventcode - event action
-
-=item seconds - how long after the invoice date events of this type are triggered
-
-=item weight - ordering for events with identical seconds
-
-=item plan - eventcode plan
-
-=item plandata - additional plan data
-
-=item disabled - Disabled flag, empty or `Y'
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new invoice event definition. 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 { 'part_bill_event'; }
-
-=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 invoice event definition. 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;
-
- $self->weight(0) unless $self->weight;
-
- my $conf = new FS::Conf;
- if ( $conf->exists('safe-part_bill_event') ) {
- my $error = $self->ut_anything('eventcode');
- return $error if $error;
-
- my $c = $self->eventcode;
-
- $c =~ /^\s*\$cust_main\->(suspend|cancel|invoicing_list_addpost|bill|collect)\(\);\s*("";)?\s*$/
-
- or $c =~ /^\s*\$cust_bill\->(comp|realtime_(card|ach|lec)|realtime_card_cybercash|batch_card|send)\(\);\s*$/
-
- or $c =~ /^\s*\$cust_bill\->send\(\'\w+\'\);\s*$/
-
- or $c =~ /^\s*\$cust_main\->apply_payments; \$cust_main->apply_credits; "";\s*$/
-
- or $c =~ /^\s*\$cust_main\->charge\( \s*\d*\.?\d*\s*,\s*\'[\w \!\@\#\$\%\&\(\)\-\+\;\:\"\,\.\?\/]*\'\s*\);\s*$/
-
- or do {
- #log
- return "illegal eventcode: $c";
- };
-
- }
-
- my $error = $self->ut_numbern('eventpart')
- || $self->ut_enum('payby', [qw( CARD DCRD CHEK DCHK LECB BILL COMP )] )
- || $self->ut_text('event')
- || $self->ut_anything('eventcode')
- || $self->ut_number('seconds')
- || $self->ut_enum('disabled', [ '', 'Y' ] )
- || $self->ut_number('weight')
- || $self->ut_textn('plan')
- || $self->ut_anything('plandata')
- ;
- return $error if $error;
-
- #quelle kludge
- if ( $self->plandata =~ /^templatename\s+(.*)$/ ) {
- my $name= $1;
- unless ( $conf->exists("invoice_template_$name") ) {
- $conf->set(
- "invoice_template_$name" =>
- join("\n", $conf->config('invoice_template') )
- );
- }
- unless ( $conf->exists("invoice_latex_$name") ) {
- $conf->set(
- "invoice_latex_$name" =>
- join("\n", $conf->config('invoice_latex') )
- );
- }
- }
-
- $self->SUPER::check;
-}
-
-=back
-
-=head1 BUGS
-
-Alas.
-
-=head1 SEE ALSO
-
-L<FS::cust_bill>, L<FS::cust_bill_event>, L<FS::Record>, schema.html from the
-base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/part_export.pm b/FS/FS/part_export.pm
deleted file mode 100644
index bd12389..0000000
--- a/FS/FS/part_export.pm
+++ /dev/null
@@ -1,590 +0,0 @@
-package FS::part_export;
-
-use strict;
-use vars qw( @ISA @EXPORT_OK $DEBUG %exports );
-use Exporter;
-use Tie::IxHash;
-use FS::Record qw( qsearch qsearchs dbh );
-use FS::part_svc;
-use FS::part_export_option;
-use FS::export_svc;
-
-@ISA = qw(FS::Record);
-@EXPORT_OK = qw(export_info);
-
-$DEBUG = 0;
-
-=head1 NAME
-
-FS::part_export - Object methods for part_export records
-
-=head1 SYNOPSIS
-
- use FS::part_export;
-
- $record = new FS::part_export \%hash;
- $record = new FS::part_export { 'column' => 'value' };
-
- #($new_record, $options) = $template_recored->clone( $svcpart );
-
- $error = $record->insert( { 'option' => 'value' } );
- $error = $record->insert( \%options );
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
-=head1 DESCRIPTION
-
-An FS::part_export object represents an export of Freeside data to an external
-provisioning system. FS::part_export inherits from FS::Record. The following
-fields are currently supported:
-
-=over 4
-
-=item exportnum - primary key
-
-=item machine - Machine name
-
-=item exporttype - Export type
-
-=item nodomain - blank or "Y" : usernames are exported to this service with no domain
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new export. To add the export 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 { 'part_export'; }
-
-=cut
-
-#=item clone SVCPART
-#
-#An alternate constructor. Creates a new export by duplicating an existing
-#export. The given svcpart is assigned to the new export.
-#
-#Returns a list consisting of the new export object and a hashref of options.
-#
-#=cut
-#
-#sub clone {
-# my $self = shift;
-# my $class = ref($self);
-# my %hash = $self->hash;
-# $hash{'exportnum'} = '';
-# $hash{'svcpart'} = shift;
-# ( $class->new( \%hash ),
-# { map { $_->optionname => $_->optionvalue }
-# qsearch('part_export_option', { 'exportnum' => $self->exportnum } )
-# }
-# );
-#}
-
-=item insert HASHREF
-
-Adds this record to the database. If there is an error, returns the error,
-otherwise returns false.
-
-If a hash reference of options is supplied, part_export_option records are
-created (see L<FS::part_export_option>).
-
-=cut
-
-#false laziness w/queue.pm
-sub insert {
- my $self = shift;
- my $options = shift;
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- my $error = $self->SUPER::insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- foreach my $optionname ( keys %{$options} ) {
- my $part_export_option = new FS::part_export_option ( {
- 'exportnum' => $self->exportnum,
- 'optionname' => $optionname,
- 'optionvalue' => $options->{$optionname},
- } );
- $error = $part_export_option->insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
-
- '';
-
-}
-
-=item delete
-
-Delete this record from the database.
-
-=cut
-
-#foreign keys would make this much less tedious... grr dumb mysql
-sub delete {
- my $self = shift;
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- my $error = $self->SUPER::delete;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- foreach my $part_export_option ( $self->part_export_option ) {
- my $error = $part_export_option->delete;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
-
- foreach my $export_svc ( $self->export_svc ) {
- my $error = $export_svc->delete;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
-
- '';
-
-}
-
-=item replace OLD_RECORD HASHREF
-
-Replaces the OLD_RECORD with this one in the database. If there is an error,
-returns the error, otherwise returns false.
-
-If a hash reference of options is supplied, part_export_option records are
-created or modified (see L<FS::part_export_option>).
-
-=cut
-
-sub replace {
- my $self = shift;
- my $old = shift;
- my $options = shift;
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- my $error = $self->SUPER::replace($old);
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- foreach my $optionname ( keys %{$options} ) {
- my $old = qsearchs( 'part_export_option', {
- 'exportnum' => $self->exportnum,
- 'optionname' => $optionname,
- } );
- my $new = new FS::part_export_option ( {
- 'exportnum' => $self->exportnum,
- 'optionname' => $optionname,
- 'optionvalue' => $options->{$optionname},
- } );
- $new->optionnum($old->optionnum) if $old;
- my $error = $old ? $new->replace($old) : $new->insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
-
- #remove extraneous old options
- foreach my $opt (
- grep { !exists $options->{$_->optionname} } $old->part_export_option
- ) {
- my $error = $opt->delete;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
-
- '';
-
-};
-
-=item check
-
-Checks all fields to make sure this is a valid export. If there is
-an error, returns the error, otherwise returns false. Called by the insert
-and replace methods.
-
-=cut
-
-sub check {
- my $self = shift;
- my $error =
- $self->ut_numbern('exportnum')
- || $self->ut_domain('machine')
- || $self->ut_alpha('exporttype')
- ;
- return $error if $error;
-
- $self->nodomain =~ /^(Y?)$/ or return "Illegal nodomain: ". $self->nodomain;
- $self->nodomain($1);
-
- $self->deprecated(1); #BLAH
-
- #check exporttype?
-
- $self->SUPER::check;
-}
-
-#=item part_svc
-#
-#Returns the service definition (see L<FS::part_svc>) for this export.
-#
-#=cut
-#
-#sub part_svc {
-# my $self = shift;
-# qsearchs('part_svc', { svcpart => $self->svcpart } );
-#}
-
-sub part_svc {
- use Carp;
- croak "FS::part_export::part_svc deprecated";
- #confess "FS::part_export::part_svc deprecated";
-}
-
-=item svc_x
-
-Returns a list of associated FS::svc_* records.
-
-=cut
-
-sub svc_x {
- my $self = shift;
- map { $_->svc_x } $self->cust_svc;
-}
-
-=item cust_svc
-
-Returns a list of associated FS::cust_svc records.
-
-=cut
-
-sub cust_svc {
- my $self = shift;
- map { qsearch('cust_svc', { 'svcpart' => $_->svcpart } ) }
- grep { qsearch('cust_svc', { 'svcpart' => $_->svcpart } ) }
- $self->export_svc;
-}
-
-=item export_svc
-
-Returns a list of associated FS::export_svc records.
-
-=cut
-
-sub export_svc {
- my $self = shift;
- qsearch('export_svc', { 'exportnum' => $self->exportnum } );
-}
-
-=item part_export_option
-
-Returns all options as FS::part_export_option objects (see
-L<FS::part_export_option>).
-
-=cut
-
-sub part_export_option {
- my $self = shift;
- qsearch('part_export_option', { 'exportnum' => $self->exportnum } );
-}
-
-=item options
-
-Returns a list of option names and values suitable for assigning to a hash.
-
-=cut
-
-sub options {
- my $self = shift;
- map { $_->optionname => $_->optionvalue } $self->part_export_option;
-}
-
-=item option OPTIONNAME
-
-Returns the option value for the given name, or the empty string.
-
-=cut
-
-sub option {
- my $self = shift;
- my $part_export_option =
- qsearchs('part_export_option', {
- exportnum => $self->exportnum,
- optionname => shift,
- } );
- $part_export_option ? $part_export_option->optionvalue : '';
-}
-
-=item rebless
-
-Reblesses the object into the FS::part_export::EXPORTTYPE class, where
-EXPORTTYPE is the object's I<exporttype> field. There should be better docs
-on how to create new exports (and they should live in their own files and be
-autoloaded-on-demand), but until then, see L</NEW EXPORT CLASSES>.
-
-=cut
-
-sub rebless {
- my $self = shift;
- my $exporttype = $self->exporttype;
- my $class = ref($self). "::$exporttype";
- eval "use $class;";
- die $@ if $@;
- bless($self, $class);
-}
-
-=item export_insert SVC_OBJECT
-
-=cut
-
-sub export_insert {
- my $self = shift;
- $self->rebless;
- $self->_export_insert(@_);
-}
-
-#sub AUTOLOAD {
-# my $self = shift;
-# $self->rebless;
-# my $method = $AUTOLOAD;
-# #$method =~ s/::(\w+)$/::_$1/; #infinite loop prevention
-# $method =~ s/::(\w+)$/_$1/; #infinite loop prevention
-# $self->$method(@_);
-#}
-
-=item export_replace NEW OLD
-
-=cut
-
-sub export_replace {
- my $self = shift;
- $self->rebless;
- $self->_export_replace(@_);
-}
-
-=item export_delete
-
-=cut
-
-sub export_delete {
- my $self = shift;
- $self->rebless;
- $self->_export_delete(@_);
-}
-
-=item export_suspend
-
-=cut
-
-sub export_suspend {
- my $self = shift;
- $self->rebless;
- $self->_export_suspend(@_);
-}
-
-=item export_unsuspend
-
-=cut
-
-sub export_unsuspend {
- my $self = shift;
- $self->rebless;
- $self->_export_unsuspend(@_);
-}
-
-#fallbacks providing useful error messages intead of infinite loops
-sub _export_insert {
- my $self = shift;
- return "_export_insert: unknown export type ". $self->exporttype;
-}
-
-sub _export_replace {
- my $self = shift;
- return "_export_replace: unknown export type ". $self->exporttype;
-}
-
-sub _export_delete {
- my $self = shift;
- return "_export_delete: unknown export type ". $self->exporttype;
-}
-
-#call svcdb-specific fallbacks
-
-sub _export_suspend {
- my $self = shift;
- #warn "warning: _export_suspened unimplemented for". ref($self);
- my $svc_x = shift;
- my $new = $svc_x->clone_suspended;
- $self->_export_replace( $new, $svc_x );
-}
-
-sub _export_unsuspend {
- my $self = shift;
- #warn "warning: _export_unsuspend unimplemented for ". ref($self);
- my $svc_x = shift;
- my $old = $svc_x->clone_kludge_unsuspend;
- $self->_export_replace( $svc_x, $old );
-}
-
-=back
-
-=head1 SUBROUTINES
-
-=over 4
-
-=item export_info [ SVCDB ]
-
-Returns a hash reference of the exports for the given I<svcdb>, or if no
-I<svcdb> is specified, for all exports. The keys of the hash are
-I<exporttype>s and the values are again hash references containing information
-on the export:
-
- 'desc' => 'Description',
- 'options' => {
- 'option' => { label=>'Option Label' },
- 'option2' => { label=>'Another label' },
- },
- 'nodomain' => 'Y', #or ''
- 'notes' => 'Additional notes',
-
-=cut
-
-sub export_info {
- #warn $_[0];
- return $exports{$_[0]} || {} if @_;
- #{ map { %{$exports{$_}} } keys %exports };
- my $r = { map { %{$exports{$_}} } keys %exports };
-}
-
-#=item exporttype2svcdb EXPORTTYPE
-#
-#Returns the applicable I<svcdb> for an I<exporttype>.
-#
-#=cut
-#
-#sub exporttype2svcdb {
-# my $exporttype = $_[0];
-# foreach my $svcdb ( keys %exports ) {
-# return $svcdb if grep { $exporttype eq $_ } keys %{$exports{$svcdb}};
-# }
-# '';
-#}
-
-foreach my $INC ( @INC ) {
- foreach my $file ( glob("$INC/FS/part_export/*.pm") ) {
- warn "attempting to load export info from $file\n" if $DEBUG;
- $file =~ /\/(\w+)\.pm$/ or do {
- warn "unrecognized file in $INC/FS/part_export/: $file\n";
- next;
- };
- my $mod = $1;
- my $info = eval "use FS::part_export::$mod; ".
- "\\%FS::part_export::$mod\::info;";
- if ( $@ ) {
- die "error using FS::part_export::$mod (skipping): $@\n" if $@;
- next;
- }
- unless ( keys %$info ) {
- warn "no %info hash found in FS::part_export::$mod, skipping\n"
- unless $mod =~ /^(passwdfile|null)$/; #hack but what the heck
- next;
- }
- warn "got export info from FS::part_export::$mod: $info\n" if $DEBUG;
- no strict 'refs';
- foreach my $svc (
- ref($info->{'svc'}) ? @{$info->{'svc'}} : $info->{'svc'}
- ) {
- unless ( $svc ) {
- warn "blank svc for FS::part_export::$mod (skipping)\n";
- next;
- }
- $exports{$svc}->{$mod} = $info;
- }
- }
-}
-
-=back
-
-=head1 NEW EXPORT CLASSES
-
-A module should be added in FS/FS/part_export/ (an example may be found in
-eg/export_template.pm)
-
-=head1 BUGS
-
-Hmm... cust_export class (not necessarily a database table...) ... ?
-
-deprecated column...
-
-=head1 SEE ALSO
-
-L<FS::part_export_option>, L<FS::export_svc>, L<FS::svc_acct>,
-L<FS::svc_domain>,
-L<FS::svc_forward>, L<FS::Record>, schema.html from the base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/part_export/apache.pm b/FS/FS/part_export/apache.pm
deleted file mode 100644
index b16b304..0000000
--- a/FS/FS/part_export/apache.pm
+++ /dev/null
@@ -1,43 +0,0 @@
-package FS::part_export::apache;
-
-use vars qw(@ISA %info);
-use Tie::IxHash;
-use FS::part_export::null;
-
-@ISA = qw(FS::part_export::null);
-
-tie my %options, 'Tie::IxHash',
- 'user' => { label=>'Remote username', default=>'root' },
- 'httpd_conf' => { label=>'httpd.conf snippet location',
- default=>'/etc/apache/httpd-freeside.conf', },
- 'template' => {
- label => 'Template',
- type => 'textarea',
- default => <<'END',
-<VirtualHost $domain> #generic
-#<VirtualHost ip.addr> #preferred, http://httpd.apache.org/docs/dns-caveats.html
-DocumentRoot /var/www/$zone
-ServerName $zone
-ServerAlias *.$zone
-#BandWidthModule On
-#LargeFileLimit 4096 12288
-</VirtualHost>
-
-END
- },
-;
-
-%info = (
- 'svc' => 'svc_www',
- 'desc' => 'Export an Apache httpd.conf file snippet.',
- 'options' => \%options,
- 'notes' => <<'END'
-Batch export of an httpd.conf snippet from a template. Typically used with
-something like <code>Include /etc/apache/httpd-freeside.conf</code> in
-httpd.conf. <a href="http://search.cpan.org/dist/File-Rsync">File::Rsync</a>
-must be installed. Run bin/apache.export to export the files.
-END
-);
-
-1;
-
diff --git a/FS/FS/part_export/bind.pm b/FS/FS/part_export/bind.pm
deleted file mode 100644
index 1ef7b65..0000000
--- a/FS/FS/part_export/bind.pm
+++ /dev/null
@@ -1,35 +0,0 @@
-package FS::part_export::bind;
-
-use vars qw(@ISA %info %options);
-use Tie::IxHash;
-use FS::part_export::null;
-
-@ISA = qw(FS::part_export::null);
-
-tie %options, 'Tie::IxHash',
- 'named_conf' => { label => 'named.conf location',
- default=> '/etc/bind/named.conf' },
- 'zonepath' => { label => 'path to zone files',
- default=> '/etc/bind/', },
- 'bind_release' => { label => 'ISC BIND Release',
- type => 'select',
- options => [qw(BIND8 BIND9)],
- default => 'BIND8' },
- 'bind9_minttl' => { label => 'The minttl required by bind9 and RFC1035.',
- default => '1D' },
- 'reload' => { label => 'Optional reload command. If not specified, defaults to "ndc" under BIND8 and "rndc" under BIND9.', },
-;
-
-%info = (
- 'svc' => 'svc_domain',
- 'desc' => 'Batch export to BIND named',
- 'options' => \%options,
- 'notes' => <<'END'
-Batch export of BIND zone and configuration files to a primary nameserver.
-<a href="http://search.cpan.org/search?dist=File-Rsync">File::Rsync</a>
-must be installed. Run bin/bind.export to export the files.
-END
-);
-
-1;
-
diff --git a/FS/FS/part_export/bind_slave.pm b/FS/FS/part_export/bind_slave.pm
deleted file mode 100644
index c89325f..0000000
--- a/FS/FS/part_export/bind_slave.pm
+++ /dev/null
@@ -1,28 +0,0 @@
-package FS::part_export::bind_slave;
-
-use vars qw(@ISA %info);
-use Tie::IxHash;
-use FS::part_export::null;
-
-@ISA = qw(FS::part_export::null);
-
-tie my %options, 'Tie::IxHash',
- 'master' => { label=> 'Master IP address(s) (semicolon-separated)' },
- %FS::part_export::bind::options,
-;
-delete $options{'zonepath'};
-
-%info = (
- 'svc' => 'svc_domain',
- 'desc' =>'Batch export to slave BIND named',
- 'options' => \%options,
- 'notes' => <<'END'
-Batch export of BIND configuration file to a secondary nameserver. Zones are
-slaved from the listed masters.
-<a href="http://search.cpan.org/dist/File-Rsync">File::Rsync</a>
-must be installed. Run bin/bind.export to export the files.
-END
-);
-
-1;
-
diff --git a/FS/FS/part_export/bsdshell.pm b/FS/FS/part_export/bsdshell.pm
deleted file mode 100644
index 7b5feb2..0000000
--- a/FS/FS/part_export/bsdshell.pm
+++ /dev/null
@@ -1,25 +0,0 @@
-package FS::part_export::bsdshell;
-
-use vars qw(@ISA %info);
-use Tie::IxHash;
-use FS::part_export::passwdfile;
-
-@ISA = qw(FS::part_export::passwdfile);
-
-tie my %options, 'Tie::IxHash', %FS::part_export::passwdfile::options;
-
-%info = (
- 'svc' => 'svc_acct',
- 'desc' =>
- 'Batch export of /etc/passwd and /etc/master.passwd files (BSD)',
- 'options' => \%options,
- 'nodomain' => 'Y',
- 'notes' => <<'END'
-MD5 crypt requires installation of
-<a href="http://search.cpan.org/dist/Crypt-PasswdMD5">Crypt::PasswdMD5</a>
-from CPAN. Run bin/bsdshell.export to export the files.
-END
-);
-
-1;
-
diff --git a/FS/FS/part_export/communigate_pro.pm b/FS/FS/part_export/communigate_pro.pm
deleted file mode 100644
index 6da2017..0000000
--- a/FS/FS/part_export/communigate_pro.pm
+++ /dev/null
@@ -1,178 +0,0 @@
-package FS::part_export::communigate_pro;
-
-use vars qw(@ISA %info %options);
-use Tie::IxHash;
-use FS::part_export;
-use FS::queue;
-
-@ISA = qw(FS::part_export);
-
-tie %options, 'Tie::IxHash',
- 'port' => { label=>'Port number', default=>'106', },
- 'login' => { label=>'The administrator account name. The name can contain a domain part.', },
- 'password' => { label=>'The administrator account password.', },
- 'accountType' => { label=>'Type for newly-created accounts',
- type=>'select',
- options=>[qw( MultiMailbox TextMailbox MailDirMailbox )],
- default=>'MultiMailbox',
- },
- 'externalFlag' => { label=> 'Create accounts with an external (visible for legacy mailers) INBOX.',
- type=>'checkbox',
- },
- 'AccessModes' => { label=>'Access modes',
- default=>'Mail POP IMAP PWD WebMail WebSite',
- },
-;
-
-%info = (
- 'svc' => 'svc_acct',
- 'desc' => 'Real-time export to a CommuniGate Pro mail server',
- 'options' => \%options,
- 'notes' => <<'END'
-Real time export to a
-<a href="http://www.stalker.com/CommuniGatePro/">CommuniGate Pro</a>
-mail server. The
-<a href="http://www.stalker.com/CGPerl/">CommuniGate Pro Perl Interface</a>
-must be installed as CGP::CLI.
-END
-);
-
-sub rebless { shift; }
-
-sub export_username {
- my($self, $svc_acct) = (shift, shift);
- $svc_acct->email;
-}
-
-sub _export_insert {
- my( $self, $svc_acct ) = (shift, shift);
- my @options = ( $svc_acct->svcnum, 'CreateAccount',
- 'accountName' => $self->export_username($svc_acct),
- 'accountType' => $self->option('accountType'),
- 'AccessModes' => $self->option('AccessModes'),
- 'RealName' => $svc_acct->finger,
- 'Password' => $svc_acct->_password,
- );
- push @options, 'MaxAccountSize' => $svc_acct->quota if $svc_acct->quota;
- push @options, 'externalFlag' => $self->option('externalFlag')
- if $self->option('externalFlag');
-
- $self->communigate_pro_queue( @options );
-}
-
-sub _export_replace {
- my( $self, $new, $old ) = (shift, shift, shift);
- return "can't (yet) change username with CommuniGate Pro"
- if $old->username ne $new->username;
- return "can't (yet) change domain with CommuniGate Pro"
- if $self->export_username($old) ne $self->export_username($new);
- return "can't (yet) change GECOS with CommuniGate Pro"
- if $old->finger ne $new->finger;
- return "can't (yet) change quota with CommuniGate Pro"
- if $old->quota ne $new->quota;
- return '' unless $old->username ne $new->username
- || $old->_password ne $new->_password
- || $old->finger ne $new->finger
- || $old->quota ne $new->quota;
-
- return '' if '*SUSPENDED* '. $old->_password eq $new->_password;
-
- #my $err_or_queue = $self->communigate_pro_queue( $new->svcnum,'RenameAccount',
- # $old->email, $new->email );
- #return $err_or_queue unless ref($err_or_queue);
- #my $jobnum = $err_or_queue->jobnum;
-
- $self->communigate_pro_queue( $new->svcnum, 'SetAccountPassword',
- $self->export_username($new), $new->_password )
- if $new->_password ne $old->_password;
-
-}
-
-sub _export_delete {
- my( $self, $svc_acct ) = (shift, shift);
- $self->communigate_pro_queue( $svc_acct->svcnum, 'DeleteAccount',
- $self->export_username($svc_acct),
- );
-}
-
-sub _export_suspend {
- my( $self, $svc_acct ) = (shift, shift);
- $self->communigate_pro_queue( $svc_acct->svcnum, 'UpdateAccountSettings',
- 'accountName' => $self->export_username($svc_acct),
- 'AccessModes' => 'Mail',
- );
-}
-
-sub _export_unsuspend {
- my( $self, $svc_acct ) = (shift, shift);
- $self->communigate_pro_queue( $svc_acct->svcnum, 'UpdateAccountSettings',
- 'accountName' => $self->export_username($svc_acct),
- 'AccessModes' => $self->option('AccessModes'),
- );
-}
-
-sub communigate_pro_queue {
- my( $self, $svcnum, $method ) = (shift, shift, shift);
- my @kludge_methods = qw(CreateAccount UpdateAccountSettings);
- my $sub = 'communigate_pro_command';
- $sub = $method if grep { $method eq $_ } @kludge_methods;
- my $queue = new FS::queue {
- 'svcnum' => $svcnum,
- 'job' => "FS::part_export::communigate_pro::$sub",
- };
- $queue->insert(
- $self->machine,
- $self->option('port'),
- $self->option('login'),
- $self->option('password'),
- $method,
- @_,
- );
-
-}
-
-sub CreateAccount {
- my( $machine, $port, $login, $password, $method, %args ) = @_;
- my $accountName = delete $args{'accountName'};
- my $accountType = delete $args{'accountType'};
- my $externalFlag = delete $args{'externalFlag'};
- $args{'AccessModes'} = [ split(' ', $args{'AccessModes'}) ];
- my @args = ( accountName => $accountName,
- accountType => $accountType,
- settings => \%args,
- );
- #externalFlag => $externalFlag,
- push @args, externalFlag => $externalFlag if $externalFlag;
-
- communigate_pro_command( $machine, $port, $login, $password, $method, @args );
-
-}
-
-sub UpdateAccountSettings {
- my( $machine, $port, $login, $password, $method, %args ) = @_;
- my $accountName = delete $args{'accountName'};
- $args{'AccessModes'} = [ split(' ', $args{'AccessModes'}) ];
- @args = ( $accountName, \%args );
- communigate_pro_command( $machine, $port, $login, $password, $method, @args );
-}
-
-sub communigate_pro_command { #subroutine, not method
- my( $machine, $port, $login, $password, $method, @args ) = @_;
-
- eval "use CGP::CLI";
-
- my $cli = new CGP::CLI( {
- 'PeerAddr' => $machine,
- 'PeerPort' => $port,
- 'login' => $login,
- 'password' => $password,
- } ) or die "Can't login to CGPro: $CGP::ERR_STRING\n";
-
- $cli->$method(@args) or die "CGPro error: ". $cli->getErrMessage;
-
- $cli->Logout or die "Can't logout of CGPro: $CGP::ERR_STRING\n";
-
-}
-
-1;
-
diff --git a/FS/FS/part_export/communigate_pro_singledomain.pm b/FS/FS/part_export/communigate_pro_singledomain.pm
deleted file mode 100644
index 6a1bf60..0000000
--- a/FS/FS/part_export/communigate_pro_singledomain.pm
+++ /dev/null
@@ -1,37 +0,0 @@
-package FS::part_export::communigate_pro_singledomain;
-
-use vars qw(@ISA %info);
-use Tie::IxHash;
-use FS::part_export::communigate_pro;
-
-@ISA = qw(FS::part_export::communigate_pro);
-
-tie my %options, 'Tie::IxHash', %FS::part_export::communigate_pro::options,
- 'domain' => { label=>'Domain', },
-;
-
-%info = (
- 'svc' => 'svc_acct',
- 'desc' =>
- 'Real-time export to a CommuniGate Pro mail server, one domain only',
- 'options' => \%options,
- 'nodomain' => 'Y',
- 'notes' => <<'END'
-Real time export to a
-<a href="http://www.stalker.com/CommuniGatePro/">CommuniGate Pro</a>
-mail server. This is an unusual export to CommuniGate Pro that forces all
-accounts into a single domain. As CommuniGate Pro supports multipledomains,
-unless you have a specific reason for using this export, you probably want to
-use the communigate_pro export instead. The
-<a href="http://www.stalker.com/CGPerl/">CommuniGate Pro Perl Interface</a>
-must be installed as CGP::CLI.
-END
-);
-
-sub export_username {
- my($self, $svc_acct) = (shift, shift);
- $svc_acct->username. '@'. $self->option('domain');
-}
-
-1;
-
diff --git a/FS/FS/part_export/cp.pm b/FS/FS/part_export/cp.pm
deleted file mode 100644
index a295c57..0000000
--- a/FS/FS/part_export/cp.pm
+++ /dev/null
@@ -1,160 +0,0 @@
-package FS::part_export::cp;
-
-use vars qw(@ISA %info);
-use Tie::IxHash;
-use FS::part_export;
-
-@ISA = qw(FS::part_export);
-
-tie my %options, 'Tie::IxHash',
- 'port' => { label=>'Port number' },
- 'username' => { label=>'Username' },
- 'password' => { label=>'Password' },
- 'domain' => { label=>'Domain' },
- 'workgroup' => { label=>'Default Workgroup' },
-;
-
-%info = (
- 'svc' => 'svc_acct',
- 'desc' => 'Real-time export to Critical Path Account Provisioning Protocol',
- 'options'=> \%options,
- 'notes' => <<'END'
-Real-time export to
-<a href="http://www.cp.net/">Critial Path Account Provisioning Protocol</a>.
-Requires installation of
-<a href="http://search.cpan.org/dist/Net-APP">Net::APP</a>
-from CPAN.
-END
-);
-
-sub rebless { shift; }
-
-sub _export_insert {
- my( $self, $svc_acct ) = (shift, shift);
- $self->cp_queue( $svc_acct->svcnum, 'create_mailbox',
- 'Mailbox' => $svc_acct->username,
- 'Password' => $svc_acct->_password,
- 'Workgroup' => $self->option('workgroup'),
- 'Domain' => $svc_acct->domain,
- );
-}
-
-sub _export_replace {
- my( $self, $new, $old ) = (shift, shift, shift);
- return "can't change domain with Critical Path"
- if $old->domain ne $new->domain;
- return '' unless $old->username ne $new->username
- || $old->_password ne $new->_password;
- $self->cp_queue( $new->svcnum, 'replace', $new->domain,
- $old->username, $new->username, $old->_password, $new->_password );
-}
-
-sub _export_delete {
- my( $self, $svc_acct ) = (shift, shift);
- $self->cp_queue( $svc_acct->svcnum, 'delete_mailbox',
- 'Mailbox' => $svc_acct->username,
- 'Domain' => $svc_acct->domain,
- );
-}
-
-sub _export_suspend {
- my( $self, $svc_acct ) = (shift, shift);
- $self->cp_queue( $svc_acct->svcnum, 'set_mailbox_status',
- 'Mailbox' => $svc_acct->username,
- 'Domain' => $svc_acct->domain,
- 'OTHER' => 'T',
- 'OTHER_SUSPEND' => 'T',
- );
-}
-
-sub _export_unsuspend {
- my( $self, $svc_acct ) = (shift, shift);
- $self->cp_queue( $svc_acct->svcnum, 'set_mailbox_status',
- 'Mailbox' => $svc_acct->username,
- 'Domain' => $svc_acct->domain,
- 'PAYMENT' => 'F',
- 'OTHER' => 'F',
- 'OTHER_SUSPEND' => 'F',
- 'OTHER_BOUNCE' => 'F',
- );
-}
-
-sub cp_queue {
- my( $self, $svcnum, $method ) = (shift, shift, shift);
- my $queue = new FS::queue {
- 'svcnum' => $svcnum,
- 'job' => 'FS::part_export::cp::cp_command',
- };
- $queue->insert(
- $self->machine,
- $self->option('port'),
- $self->option('username'),
- $self->option('password'),
- $self->option('domain'),
- $method,
- @_,
- );
-}
-
-sub cp_command { #subroutine, not method
- my($host, $port, $username, $password, $login_domain, $method, @args) = @_;
-
- #quelle hack
- if ( $method eq 'replace' ) {
-
- my( $domain, $old_username, $new_username, $old_password, $new_password)
- = @args;
-
- if ( $old_username ne $new_username ) {
- cp_command($host, $port, $username, $password, 'rename_mailbox',
- Domain => $domain,
- Old_Mailbox => $old_username,
- New_Mailbox => $new_username,
- );
- }
-
- #my $other = 'F';
- if ( $new_password =~ /^\*SUSPENDED\* (.*)$/ ) {
- $new_password = $1;
- # $other = 'T';
- }
- #cp_command($host, $port, $username, $password, $login_domain,
- # 'set_mailbox_status',
- # Domain => $domain,
- # Mailbox => $new_username,
- # Other => $other,
- # Other_Bounce => $other,
- #);
-
- if ( $old_password ne $new_password ) {
- cp_command($host, $port, $username, $password, $login_domain,
- 'change_mailbox',
- Domain => $domain,
- Mailbox => $new_username,
- Password => $new_password,
- );
- }
-
- return;
- }
- #eof quelle hack
-
- eval "use Net::APP;";
-
- my $app = new Net::APP (
- "$host:$port",
- User => $username,
- Password => $password,
- Domain => $login_domain,
- Timeout => 60,
- #Debug => 1,
- ) or die "$@\n";
-
- $app->$method( @args );
-
- die $app->message."\n" unless $app->ok;
-
-}
-
-1;
-
diff --git a/FS/FS/part_export/cyrus.pm b/FS/FS/part_export/cyrus.pm
deleted file mode 100644
index 84c9e5a..0000000
--- a/FS/FS/part_export/cyrus.pm
+++ /dev/null
@@ -1,120 +0,0 @@
-package FS::part_export::cyrus;
-
-use vars qw(@ISA %info);
-use Tie::IxHash;
-use FS::part_export;
-
-@ISA = qw(FS::part_export);
-
-tie my %options, 'Tie::IxHash',
- 'server' => { label=>'IMAP server' },
- 'username' => { label=>'Admin username' },
- 'password' => { label=>'Admin password' },
-;
-
-%info = (
- 'svc' => 'svc_acct',
- 'desc' => 'Real-time export to Cyrus IMAP server',
- 'options' => \%options,
- 'nodomain' => 'Y',
- 'notes' => <<'END'
-Integration with
-<a href="http://asg.web.cmu.edu/cyrus/imapd/">Cyrus IMAP Server</a>.
-Cyrus::IMAP::Admin should be installed locally and the connection to the
-server secured. <B>svc_acct.quota</B>, if available, is used to set the
-Cyrus quota.
-END
-);
-
-sub rebless { shift; }
-
-sub _export_insert {
- my($self, $svc_acct) = (shift, shift);
- $self->cyrus_queue( $svc_acct->svcnum, 'insert',
- $svc_acct->username, $svc_acct->quota );
-}
-
-sub _export_replace {
- my( $self, $new, $old ) = (shift, shift, shift);
- return "can't change username using Cyrus"
- if $old->username ne $new->username;
- return '';
-# #return '' unless $old->_password ne $new->_password;
-# $self->cyrus_queue( $new->svcnum,
-# 'replace', $new->username, $new->_password );
-}
-
-sub _export_delete {
- my( $self, $svc_acct ) = (shift, shift);
- $self->cyrus_queue( $svc_acct->svcnum, 'delete',
- $svc_acct->username );
-}
-
-#a good idea to queue anything that could fail or take any time
-sub cyrus_queue {
- my( $self, $svcnum, $method ) = (shift, shift, shift);
- my $queue = new FS::queue {
- 'svcnum' => $svcnum,
- 'job' => "FS::part_export::cyrus::cyrus_$method",
- };
- $queue->insert(
- $self->option('server'),
- $self->option('username'),
- $self->option('password'),
- @_
- );
-}
-
-sub cyrus_insert { #subroutine, not method
- my $client = cyrus_connect(shift, shift, shift);
- my( $username, $quota ) = @_;
- my $rc = $client->create("user.$username");
- my $error = $client->error;
- die "creating user.$username: $error" if $error;
-
- $rc = $client->setacl("user.$username", $username => 'all' );
- $error = $client->error;
- die "setacl user.$username: $error" if $error;
-
- if ( $quota ) {
- $rc = $client->setquota("user.$username", 'STORAGE' => $quota );
- $error = $client->error;
- die "setquota user.$username: $error" if $error;
- }
-
-}
-
-sub cyrus_delete { #subroutine, not method
- my ( $server, $admin_username, $password_username, $username ) = @_;
- my $client = cyrus_connect($server, $admin_username, $password_username);
-
- my $rc = $client->setacl("user.$username", $admin_username => 'all' );
- my $error = $client->error;
- die $error if $error;
-
- $rc = $client->delete("user.$username");
- $error = $client->error;
- die $error if $error;
-}
-
-sub cyrus_connect {
-
- my( $server, $admin_username, $admin_password ) = @_;
-
- eval "use Cyrus::IMAP::Admin;";
-
- my $client = Cyrus::IMAP::Admin->new($server);
- $client->authenticate(
- -user => $admin_username,
- -mechanism => "login",
- -password => $admin_password,
- );
- $client;
-
-}
-
-#sub cyrus_replace { #subroutine, not method
-#}
-
-1;
-
diff --git a/FS/FS/part_export/domain_shellcommands.pm b/FS/FS/part_export/domain_shellcommands.pm
deleted file mode 100644
index 0ba5617..0000000
--- a/FS/FS/part_export/domain_shellcommands.pm
+++ /dev/null
@@ -1,161 +0,0 @@
-package FS::part_export::domain_shellcommands;
-
-use strict;
-use vars qw(@ISA %info);
-use Tie::IxHash;
-use FS::part_export;
-
-@ISA = qw(FS::part_export);
-
-tie my %options, 'Tie::IxHash',
- 'user' => { label=>'Remote username', default=>'root' },
- 'useradd' => { label=>'Insert command',
- default=>'',
- },
- 'userdel' => { label=>'Delete command',
- default=>'',
- },
- 'usermod' => { label=>'Modify command',
- default=>'',
- },
-;
-
-%info = (
- 'svc' => 'svc_domain',
- 'desc' => 'Run remote commands via SSH, for domains (qmail, ISPMan).',
- 'options' => \%options,
- 'notes' => <<'END'
-Run remote commands via SSH, for domains. You will need to
-<a href="../docs/ssh.html">setup SSH for unattended operation</a>.
-<BR><BR>Use these buttons for some useful presets:
-<UL>
- <LI>
- <INPUT TYPE="button" VALUE="qmail catchall .qmail-domain-default maintenance" onClick='
- this.form.useradd.value = "[ \"$uid\" -a \"$gid\" -a \"$dir\" -a \"$qdomain\" ] && [ -e $dir/.qmail-$qdomain-default ] || { touch $dir/.qmail-$qdomain-default; chown $uid:$gid $dir/.qmail-$qdomain-default; }";
- this.form.userdel.value = "";
- this.form.usermod.value = "";
- '>
- <LI>
- <INPUT TYPE="button" VALUE="ISPMan CLI" onClick='
- this.form.useradd.value = "/usr/local/ispman/bin/ispman.addDomain -d $domain changeme";
- this.form.userdel.value = "/usr/local/ispman/bin/ispman.deleteDomain -d $domain";
- this.form.usermod.value = "";
- '>
-</UL>
-The following variables are available for interpolation (prefixed with <code>new_</code> or <code>old_</code> for replace operations):
-<UL>
- <LI><code>$domain</code>
- <LI><code>$qdomain</code> - domain with periods replaced by colons
- <LI><code>$uid</code> - of catchall account
- <LI><code>$gid</code> - of catchall account
- <LI><code>$dir</code> - home directory of catchall account
- <LI>All other fields in
- <a href="../docs/schema.html#svc_domain">svc_domain</a> are also available.
-</UL>
-END
-);
-
-sub rebless { shift; }
-
-sub _export_insert {
- my($self) = shift;
- $self->_export_command('useradd', @_);
-}
-
-sub _export_delete {
- my($self) = shift;
- $self->_export_command('userdel', @_);
-}
-
-sub _export_command {
- my ( $self, $action, $svc_domain) = (shift, shift, shift);
- my $command = $self->option($action);
-
- #set variable for the command
- no strict 'vars';
- {
- no strict 'refs';
- ${$_} = $svc_domain->getfield($_) foreach $svc_domain->fields;
- }
- ( $qdomain = $domain ) =~ s/\./:/g; #see dot-qmail(5): EXTENSION ADDRESSES
-
- if ( $svc_domain->catchall ) {
- no strict 'refs';
- my $svc_acct = $svc_domain->catchall_svc_acct;
- ${$_} = $svc_acct->getfield($_) foreach qw(uid gid dir);
- } else {
- no strict 'refs';
- ${$_} = '' foreach qw(uid gid dir);
- }
-
- #done setting variables for the command
-
- $self->shellcommands_queue( $svc_domain->svcnum,
- user => $self->option('user')||'root',
- host => $self->machine,
- command => eval(qq("$command")),
- );
-}
-
-sub _export_replace {
- my($self, $new, $old ) = (shift, shift, shift);
- my $command = $self->option('usermod');
-
- #set variable for the command
- no strict 'vars';
- {
- no strict 'refs';
- ${"old_$_"} = $old->getfield($_) foreach $old->fields;
- ${"new_$_"} = $new->getfield($_) foreach $new->fields;
- }
- ( $old_qdomain = $old_domain ) =~ s/\./:/g; #see dot-qmail(5): EXTENSION ADDRESSES
- ( $new_qdomain = $new_domain ) =~ s/\./:/g; #see dot-qmail(5): EXTENSION ADDRESSES
-
- if ( $old->catchall ) {
- no strict 'refs';
- my $svc_acct = $old->catchall_svc_acct;
- ${"old_$_"} = $svc_acct->getfield($_) foreach qw(uid gid dir);
- } else {
- ${"old_$_"} = '' foreach qw(uid gid dir);
- }
- if ( $new->catchall ) {
- no strict 'refs';
- my $svc_acct = $new->catchall_svc_acct;
- ${"new_$_"} = $svc_acct->getfield($_) foreach qw(uid gid dir);
- } else {
- ${"new_$_"} = '' foreach qw(uid gid dir);
- }
-
- #done setting variables for the command
-
- $self->shellcommands_queue( $new->svcnum,
- user => $self->option('user')||'root',
- host => $self->machine,
- command => eval(qq("$command")),
- );
-}
-
-#a good idea to queue anything that could fail or take any time
-sub shellcommands_queue {
- my( $self, $svcnum ) = (shift, shift);
- my $queue = new FS::queue {
- 'svcnum' => $svcnum,
- 'job' => "FS::part_export::domain_shellcommands::ssh_cmd",
- };
- $queue->insert( @_ );
-}
-
-sub ssh_cmd { #subroutine, not method
- use Net::SSH '0.08';
- &Net::SSH::ssh_cmd( { @_ } );
-}
-
-#sub shellcommands_insert { #subroutine, not method
-#}
-#sub shellcommands_replace { #subroutine, not method
-#}
-#sub shellcommands_delete { #subroutine, not method
-#}
-
-1;
-
diff --git a/FS/FS/part_export/forward_shellcommands.pm b/FS/FS/part_export/forward_shellcommands.pm
deleted file mode 100644
index fe30435..0000000
--- a/FS/FS/part_export/forward_shellcommands.pm
+++ /dev/null
@@ -1,159 +0,0 @@
-package FS::part_export::forward_shellcommands;
-
-use strict;
-use vars qw(@ISA %info);
-use Tie::IxHash;
-use FS::part_export;
-
-@ISA = qw(FS::part_export);
-
-tie my %options, 'Tie::IxHash',
- 'user' => { label=>'Remote username', default=>'root' },
- 'useradd' => { label=>'Insert command',
- default=>'',
- },
- 'userdel' => { label=>'Delete command',
- default=>'',
- },
- 'usermod' => { label=>'Modify command',
- default=>'',
- },
-;
-
-%info = (
- 'svc' => 'svc_forward',
- 'desc' => 'Run remote commands via SSH, for forwards',
- 'options' => \%options,
- 'notes' => <<'END'
-Run remote commands via SSH, for forwards. You will need to
-<a href="../docs/ssh.html">setup SSH for unattended operation</a>.
-<BR><BR>Use these buttons for some useful presets:
-<UL>
- <LI>
- <INPUT TYPE="button" VALUE="text vpopmail maintenance" onClick='
- this.form.useradd.value = "[ -d /home/vpopmail/domains/$domain/$username ] && { echo \"$destination\" > /home/vpopmail/domains/$domain/$username/.qmail; chown vpopmail:vchkpw /home/vpopmail/domains/$domain/$username/.qmail; }";
- this.form.userdel.value = "rm /home/vpopmail/domains/$domain/$username/.qmail";
- this.form.usermod.value = "mv /home/vpopmail/domains/$old_domain/$old_username/.qmail /home/vpopmail/domains/$new_domain/$new_username; [ \"$old_destination\" != \"$new_destination\" ] && { echo \"$new_destination\" > /home/vpopmail/domains/$new_domain/$new_username/.qmail; chown vpopmail:vchkpw /home/vpopmail/domains/$new_domain/$new_username/.qmail; }";
- '>
- <LI>
- <INPUT TYPE="button" VALUE="ISPMan CLI" onClick='
- this.form.useradd.value = "";
- this.form.userdel.value = "";
- this.form.usermod.value = "";
- '>
-</UL>
-The following variables are available for interpolation (prefixed with
-<code>new_</code> or <code>old_</code> for replace operations):
-<UL>
- <LI><code>$username</code>
- <LI><code>$domain</code>
- <LI><code>$destination</code> - forward destination
- <LI>All other fields in <a href="../docs/schema.html#svc_forward">svc_forward</a> are also available.
-</UL>
-END
-);
-
-sub rebless { shift; }
-
-sub _export_insert {
- my($self) = shift;
- $self->_export_command('useradd', @_);
-}
-
-sub _export_delete {
- my($self) = shift;
- $self->_export_command('userdel', @_);
-}
-
-sub _export_command {
- my ( $self, $action, $svc_forward ) = (shift, shift, shift);
- my $command = $self->option($action);
-
- #set variable for the command
- no strict 'vars';
- {
- no strict 'refs';
- ${$_} = $svc_forward->getfield($_) foreach $svc_forward->fields;
- }
-
- my $svc_acct = $svc_forward->srcsvc_acct;
- $username = $svc_acct->username;
- $domain = $svc_acct->domain;
- if ($svc_forward->dstsvc_acct) {
- $destination = $svc_forward->dstsvc_acct->email;
- } else {
- $destination = $svc_forward->dst;
- }
-
- #done setting variables for the command
-
- $self->shellcommands_queue( $svc_forward->svcnum,
- user => $self->option('user')||'root',
- host => $self->machine,
- command => eval(qq("$command")),
- );
-}
-
-sub _export_replace {
- my( $self, $new, $old ) = (shift, shift, shift);
- my $command = $self->option('usermod');
-
- #set variable for the command
- no strict 'vars';
- {
- no strict 'refs';
- ${"old_$_"} = $old->getfield($_) foreach $old->fields;
- ${"new_$_"} = $new->getfield($_) foreach $new->fields;
- }
-
- my $old_svc_acct = $old->srcsvc_acct;
- $old_username = $old_svc_acct->username;
- $old_domain = $old_svc_acct->domain;
- if ($old->dstsvc_acct) {
- $old_destination = $old->dstsvc_acct->email;
- } else {
- $old_destination = $old->dst;
- }
-
- my $new_svc_acct = $new->srcsvc_acct;
- $new_username = $new_svc_acct->username;
- $new_domain = $new_svc_acct->domain;
- if ($new->dstsvc) {
- $new_destination = $new->dstsvc_acct->email;
- } else {
- $new_destination = $new->dst;
- }
-
- #done setting variables for the command
-
- $self->shellcommands_queue( $new->svcnum,
- user => $self->option('user')||'root',
- host => $self->machine,
- command => eval(qq("$command")),
- );
-}
-
-#a good idea to queue anything that could fail or take any time
-sub shellcommands_queue {
- my( $self, $svcnum ) = (shift, shift);
- my $queue = new FS::queue {
- 'svcnum' => $svcnum,
- 'job' => "FS::part_export::forward_shellcommands::ssh_cmd",
- };
- $queue->insert( @_ );
-}
-
-sub ssh_cmd { #subroutine, not method
- use Net::SSH '0.08';
- &Net::SSH::ssh_cmd( { @_ } );
-}
-
-#sub shellcommands_insert { #subroutine, not method
-#}
-#sub shellcommands_replace { #subroutine, not method
-#}
-#sub shellcommands_delete { #subroutine, not method
-#}
-
-1;
-
diff --git a/FS/FS/part_export/http.pm b/FS/FS/part_export/http.pm
deleted file mode 100644
index 0be2a0f..0000000
--- a/FS/FS/part_export/http.pm
+++ /dev/null
@@ -1,134 +0,0 @@
-package FS::part_export::http;
-
-use vars qw(@ISA %info);
-use Tie::IxHash;
-use FS::part_export;
-
-@ISA = qw(FS::part_export);
-
-tie my %options, 'Tie::IxHash',
- 'method' => { label =>'Method',
- type =>'select',
- #options =>[qw(POST GET)],
- options =>[qw(POST)],
- default =>'POST' },
- 'url' => { label => 'URL', default => 'http://', },
- 'insert_data' => {
- label => 'Insert data',
- type => 'textarea',
- default => join("\n",
- 'DomainName $svc_x->domain',
- 'Email ( grep { $_ ne "POST" } $svc_x->cust_svc->cust_pkg->cust_main->invoicing_list)[0]',
- 'test 1',
- 'reseller $svc_x->cust_svc->cust_pkg->part_pkg->pkg =~ /reseller/i',
- ),
- },
- 'delete_data' => {
- label => 'Delete data',
- type => 'textarea',
- default => join("\n",
- ),
- },
- 'replace_data' => {
- label => 'Replace data',
- type => 'textarea',
- default => join("\n",
- ),
- },
-;
-
-%info = (
- 'svc' => 'svc_domain',
- 'desc' => 'Send an HTTP or HTTPS GET or POST request',
- 'options' => \%options,
- 'notes' => <<'END'
-Send an HTTP or HTTPS GET or POST to the specified URL. For HTTPS support,
-<a href="http://search.cpan.org/dist/Crypt-SSLeay">Crypt::SSLeay</a>
-or <a href="http://search.cpan.org/dist/IO-Socket-SSL">IO::Socket::SSL</a>
-is required.
-END
-);
-
-sub rebless { shift; }
-
-sub _export_insert {
- my $self = shift;
- $self->_export_command('insert', @_);
-}
-
-sub _export_delete {
- my $self = shift;
- $self->_export_command('delete', @_);
-}
-
-sub _export_command {
- my( $self, $action, $svc_x ) = ( shift, shift, shift );
-
- return unless $self->option("${action}_data");
-
- $self->http_queue( $svc_x->svcnum,
- $self->option('method'),
- $self->option('url'),
- map {
- /^\s*(\S+)\s+(.*)$/ or /()()/;
- my( $field, $value_expression ) = ( $1, $2 );
- my $value = eval $value_expression;
- die $@ if $@;
- ( $field, $value );
- } split(/\n/, $self->option("${action}_data") )
- );
-
-}
-
-sub _export_replace {
- my( $self, $new, $old ) = ( shift, shift, shift );
-
- return unless $self->option('replace_data');
-
- $self->http_queue( $svc_x->svcnum,
- $self->option('method'),
- $self->option('url'),
- map {
- /^\s*(\S+)\s+(.*)$/ or /()()/;
- my( $field, $value_expression ) = ( $1, $2 );
- die $@ if $@;
- ( $field, $value );
- } split(/\n/, $self->option('replace_data') )
- );
-
-}
-
-sub http_queue {
- my($self, $svcnum) = (shift, shift);
- my $queue = new FS::queue {
- 'svcnum' => $svcnum,
- 'job' => "FS::part_export::http::http",
- };
- $queue->insert( @_ );
-}
-
-sub http {
- my($method, $url, @data) = @_;
-
- $method = lc($method);
-
- eval "use LWP::UserAgent;";
- die "using LWP::UserAgent: $@" if $@;
- eval "use HTTP::Request::Common;";
- die "using HTTP::Request::Common: $@" if $@;
-
- my $ua = LWP::UserAgent->new;
-
- #my $response = $ua->$method(
- # $url, \%data,
- # 'Content-Type'=>'application/x-www-form-urlencoded'
- #);
- my $req = HTTP::Request::Common::POST( $url, \@data );
- my $response = $ua->request($req);
-
- die $response->error_as_HTML if $response->is_error;
-
-}
-
-1;
-
diff --git a/FS/FS/part_export/infostreet.pm b/FS/FS/part_export/infostreet.pm
deleted file mode 100644
index 309e7ce..0000000
--- a/FS/FS/part_export/infostreet.pm
+++ /dev/null
@@ -1,277 +0,0 @@
-package FS::part_export::infostreet;
-
-use vars qw(@ISA %info %infostreet2cust_main $DEBUG);
-use Tie::IxHash;
-use FS::UID qw(dbh);
-use FS::part_export;
-
-@ISA = qw(FS::part_export);
-
-tie my %options, 'Tie::IxHash',
- 'url' => { label=>'XML-RPC Access URL', },
- 'login' => { label=>'InfoStreet login', },
- 'password' => { label=>'InfoStreet password', },
- 'groupID' => { label=>'InfoStreet groupID', },
-;
-
-%info = (
- 'svc' => 'svc_acct',
- 'desc' => 'Real-time export to InfoStreet streetSmartAPI',
- 'options' => \%options,
- 'nodomain' => 'Y',
- 'notes' => <<'END'
-Real-time export to
-<a href="http://www.infostreet.com/">InfoStreet</a> streetSmartAPI.
-Requires installation of
-<a href="http://search.cpan.org/dist/Frontier-Client">Frontier::Client</a> from CPAN.
-END
-);
-
-$DEBUG = 0;
-
-%infostreet2cust_main = (
- 'firstName' => 'first',
- 'lastName' => 'last',
- 'address1' => 'address1',
- 'address2' => 'address2',
- 'city' => 'city',
- 'state' => 'state',
- 'zipCode' => 'zip',
- 'country' => 'country',
- 'phoneNumber' => 'daytime',
- 'faxNumber' => 'night', #noment-request...
-);
-
-sub rebless { shift; }
-
-sub _export_insert {
- my( $self, $svc_acct ) = (shift, shift);
- my $cust_main = $svc_acct->cust_svc->cust_pkg->cust_main;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- my $err_or_queue = $self->infostreet_err_or_queue( $svc_acct->svcnum,
- 'createUser', $svc_acct->username, $svc_acct->_password );
- return $err_or_queue unless ref($err_or_queue);
- my $jobnum = $err_or_queue->jobnum;
-
- my %contact_info = ( map {
- $_ => $cust_main->getfield( $infostreet2cust_main{$_} );
- } keys %infostreet2cust_main );
-
- my @emails = grep { $_ ne 'POST' } $cust_main->invoicing_list;
- $contact_info{'email'} = $emails[0] if @emails;
-
- #this one is kinda noment-specific
- $contact_info{'organization'} = $cust_main->agent->agent;
-
- $err_or_queue = $self->infostreet_queueContact( $svc_acct->svcnum,
- $svc_acct->username, %contact_info );
- return $err_or_queue unless ref($err_or_queue);
-
- # If a quota has been specified set the quota because it is not the default
- $err_or_queue = $self->infostreet_queueSetQuota( $svc_acct->svcnum,
- $svc_acct->username, $svc_acct->quota ) if $svc_acct->quota;
- return $err_or_queue unless ref($err_or_queue);
-
- my $error = $err_or_queue->depend_insert( $jobnum );
- return $error if $error;
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
-
- '';
-
-}
-
-sub _export_replace {
- my( $self, $new, $old ) = (shift, shift, shift);
- return "can't change username with InfoStreet"
- if $old->username ne $new->username;
-
- # If the quota has changed then do the export to setQuota
- my $err_or_queue = $self->infostreet_queueSetQuota( $new->svcnum, $new->username, $new->quota )
- if ( $old->quota != $new->quota );
- return $err_or_queue unless ref($err_or_queue);
-
-
- return '' unless $old->_password ne $new->_password;
- $self->infostreet_queue( $new->svcnum,
- 'passwd', $new->username, $new->_password );
-}
-
-sub _export_delete {
- my( $self, $svc_acct ) = (shift, shift);
- $self->infostreet_queue( $svc_acct->svcnum,
- 'purgeAccount,releaseUsername', $svc_acct->username );
-}
-
-sub _export_suspend {
- my( $self, $svc_acct ) = (shift, shift);
- $self->infostreet_queue( $svc_acct->svcnum,
- 'setStatus', $svc_acct->username, 'DISABLED' );
-}
-
-sub _export_unsuspend {
- my( $self, $svc_acct ) = (shift, shift);
- $self->infostreet_queue( $svc_acct->svcnum,
- 'setStatus', $svc_acct->username, 'ACTIVE' );
-}
-
-sub infostreet_queue {
- my( $self, $svcnum, $method ) = (shift, shift, shift);
- my $queue = new FS::queue {
- 'svcnum' => $svcnum,
- 'job' => 'FS::part_export::infostreet::infostreet_command',
- };
- $queue->insert(
- $self->option('url'),
- $self->option('login'),
- $self->option('password'),
- $self->option('groupID'),
- $method,
- @_,
- );
-}
-
-#ick false laziness
-sub infostreet_err_or_queue {
- my( $self, $svcnum, $method ) = (shift, shift, shift);
- my $queue = new FS::queue {
- 'svcnum' => $svcnum,
- 'job' => 'FS::part_export::infostreet::infostreet_command',
- };
- $queue->insert(
- $self->option('url'),
- $self->option('login'),
- $self->option('password'),
- $self->option('groupID'),
- $method,
- @_,
- ) or $queue;
-}
-
-sub infostreet_queueContact {
- my( $self, $svcnum ) = (shift, shift);
- my $queue = new FS::queue {
- 'svcnum' => $svcnum,
- 'job' => 'FS::part_export::infostreet::infostreet_setContact',
- };
- $queue->insert(
- $self->option('url'),
- $self->option('login'),
- $self->option('password'),
- $self->option('groupID'),
- @_,
- ) or $queue;
-}
-
-sub infostreet_setContact {
- my($url, $is_username, $is_password, $groupID, $username, %contact_info) = @_;
- my $accountID = infostreet_command($url, $is_username, $is_password, $groupID,
- 'getAccountID', $username);
- foreach my $field ( keys %contact_info ) {
- infostreet_command($url, $is_username, $is_password, $groupID,
- 'setContactField', [ 'int'=>$accountID ], $field, $contact_info{$field} );
- }
-
-}
-
-sub infostreet_queueSetQuota {
-
- my( $self, $svcnum) = (shift, shift);
- my $queue = new FS::queue {
- 'svcnum' => $svcnum,
- 'job' => 'FS::part_export::infostreet::infostreet_setQuota',
- };
-
- $queue->insert(
- $self->option('url'),
- $self->option('login'),
- $self->option('password'),
- $self->option('groupID'),
- @_,
- ) or $queue;
-
-}
-
-sub infostreet_setQuota {
- my($url, $is_username, $is_password, $groupID, $username, $quota) = @_;
- infostreet_command($url, $is_username, $is_password, $groupID, 'setQuota', $username, [ 'int'=> $quota ] );
-}
-
-
-sub infostreet_command { #subroutine, not method
- my($url, $username, $password, $groupID, $method, @args) = @_;
-
- warn "[FS::part_export::infostreet] $method ".join(' ', @args)."\n" if $DEBUG;
-
- #quelle hack
- if ( $method =~ /,/ ) {
- foreach my $part ( split(/,\s*/, $method) ) {
- infostreet_command($url, $username, $password, $groupID, $part, @args);
- }
- return;
- }
-
- eval "use Frontier::Client;";
- die $@ if $@;
-
- eval 'sub Frontier::RPC2::String::repr {
- my $self = shift;
- my $value = $$self;
- $value =~ s/([&<>\"])/$Frontier::RPC2::char_entities{$1}/ge;
- $value;
- }';
- die $@ if $@;
-
- my $conn = Frontier::Client->new( url => $url );
- my $key_result = $conn->call( 'authenticate', $username, $password, $groupID);
- my %key_result = _infostreet_parse($key_result);
- die $key_result{error} unless $key_result{success};
- my $key = $key_result{data};
-
- #my $result = $conn->call($method, $key, @args);
- my $result = $conn->call( $method, $key,
- map {
- if ( ref($_) ) {
- my( $type, $value) = @{$_};
- $conn->$type($value);
- } else {
- $conn->string($_);
- }
- } @args );
- my %result = _infostreet_parse($result);
- die $result{error} unless $result{success};
-
- $result->{data};
-
-}
-
-#sub infostreet_command_byid { #subroutine, not method;
-# my($url, $username, $password, $groupID, $method, @args ) = @_;
-#
-# infostreet_command
-#
-#}
-
-sub _infostreet_parse { #subroutine, not method
- my $arg = shift;
- map {
- my $value = $arg->{$_};
- #warn ref($value);
- $value = $value->value()
- if ref($value) && $value->isa('Frontier::RPC2::DataType');
- $_=>$value;
- } keys %$arg;
-}
-
-1;
-
diff --git a/FS/FS/part_export/ldap.pm b/FS/FS/part_export/ldap.pm
deleted file mode 100644
index 823d99d..0000000
--- a/FS/FS/part_export/ldap.pm
+++ /dev/null
@@ -1,294 +0,0 @@
-package FS::part_export::ldap;
-
-use vars qw(@ISA %info @saltset);
-use Tie::IxHash;
-use FS::Record qw( dbh );
-use FS::part_export;
-
-@ISA = qw(FS::part_export);
-
-tie my %options, 'Tie::IxHash',
- 'dn' => { label=>'Root DN' },
- 'password' => { label=>'Root DN password' },
- 'userdn' => { label=>'User DN' },
- 'attributes' => { label=>'Attributes',
- type=>'textarea',
- default=>join("\n",
- 'uid $username',
- 'mail $username\@$domain',
- 'uidno $uid',
- 'gidno $gid',
- 'cn $first',
- 'sn $last',
- 'mailquota $quota',
- 'vmail',
- 'location',
- 'mailtag',
- 'mailhost',
- 'mailmessagestore $dir',
- 'userpassword $crypt_password',
- 'hint',
- 'answer $sec_phrase',
- 'objectclass top,person,inetOrgPerson',
- ),
- },
- 'radius' => { label=>'Export RADIUS attributes', type=>'checkbox', },
-;
-
-%info = (
- 'svc' => 'svc_acct',
- 'desc' => 'Real-time export to LDAP',
- 'options' => \%options,
- 'notes' => <<'END'
-Real-time export to arbitrary LDAP attributes. Requires installation of
-<a href="http://search.cpan.org/dist/Net-LDAP">Net::LDAP</a> from CPAN.
-END
-);
-
-@saltset = ( 'a'..'z' , 'A'..'Z' , '0'..'9' , '.' , '/' );
-
-sub rebless { shift; }
-
-sub _export_insert {
- my($self, $svc_acct) = (shift, shift);
-
- #false laziness w/shellcommands.pm
- {
- no strict 'refs';
- ${$_} = $svc_acct->getfield($_) foreach $svc_acct->fields;
- ${$_} = $svc_acct->$_() foreach qw( domain );
- my $cust_pkg = $svc_acct->cust_svc->cust_pkg;
- if ( $cust_pkg ) {
- my $cust_main = $cust_pkg->cust_main;
- ${$_} = $cust_main->getfield($_) foreach qw(first last);
- }
- }
- $crypt_password = ''; #surpress "used only once" warnings
- $crypt_password = '{crypt}'. crypt( $svc_acct->_password,
- $saltset[int(rand(64))].$saltset[int(rand(64))] );
-
- my $username_attrib;
- my %attrib = map { /^\s*(\w+)\s+(.*\S)\s*$/;
- $username_attrib = $1 if $2 eq '$username';
- ( $1 => eval(qq("$2")) ); }
- grep { /^\s*(\w+)\s+(.*\S)\s*$/ }
- split("\n", $self->option('attributes'));
-
- if ( $self->option('radius') ) {
- foreach my $table (qw(reply check)) {
- my $method = "radius_$table";
- my %radius = $svc_acct->$method();
- foreach my $radius ( keys %radius ) {
- ( my $ldap = $radius ) =~ s/\-//g;
- $attrib{$ldap} = $radius{$radius};
- }
- }
- }
-
- my $err_or_queue = $self->ldap_queue( $svc_acct->svcnum, 'insert',
- #$svc_acct->username,
- $username_attrib,
- %attrib );
- return $err_or_queue unless ref($err_or_queue);
-
- #groups with LDAP?
- #my @groups = $svc_acct->radius_groups;
- #if ( @groups ) {
- # my $err_or_queue = $self->ldap_queue(
- # $svc_acct->svcnum, 'usergroup_insert',
- # $svc_acct->username, @groups );
- # return $err_or_queue unless ref($err_or_queue);
- #}
-
- '';
-}
-
-sub _export_replace {
- my( $self, $new, $old ) = (shift, shift, shift);
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- return "can't (yet?) change username with ldap"
- if $old->username ne $new->username;
-
- return "ldap replace unimplemented";
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- my $jobnum = '';
- #if ( $old->username ne $new->username ) {
- # my $err_or_queue = $self->ldap_queue( $new->svcnum, 'rename',
- # $new->username, $old->username );
- # unless ( ref($err_or_queue) ) {
- # $dbh->rollback if $oldAutoCommit;
- # return $err_or_queue;
- # }
- # $jobnum = $err_or_queue->jobnum;
- #}
-
- foreach my $table (qw(reply check)) {
- my $method = "radius_$table";
- my %new = $new->$method();
- my %old = $old->$method();
- if ( grep { !exists $old{$_} #new attributes
- || $new{$_} ne $old{$_} #changed
- } keys %new
- ) {
- my $err_or_queue = $self->ldap_queue( $new->svcnum, 'insert',
- $table, $new->username, %new );
- unless ( ref($err_or_queue) ) {
- $dbh->rollback if $oldAutoCommit;
- return $err_or_queue;
- }
- if ( $jobnum ) {
- my $error = $err_or_queue->depend_insert( $jobnum );
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
- }
-
- my @del = grep { !exists $new{$_} } keys %old;
- if ( @del ) {
- my $err_or_queue = $self->ldap_queue( $new->svcnum, 'attrib_delete',
- $table, $new->username, @del );
- unless ( ref($err_or_queue) ) {
- $dbh->rollback if $oldAutoCommit;
- return $err_or_queue;
- }
- if ( $jobnum ) {
- my $error = $err_or_queue->depend_insert( $jobnum );
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
- }
- }
-
- # (sorta) false laziness with FS::svc_acct::replace
- my @oldgroups = @{$old->usergroup}; #uuuh
- my @newgroups = $new->radius_groups;
- my @delgroups = ();
- foreach my $oldgroup ( @oldgroups ) {
- if ( grep { $oldgroup eq $_ } @newgroups ) {
- @newgroups = grep { $oldgroup ne $_ } @newgroups;
- next;
- }
- push @delgroups, $oldgroup;
- }
-
- if ( @delgroups ) {
- my $err_or_queue = $self->ldap_queue( $new->svcnum, 'usergroup_delete',
- $new->username, @delgroups );
- unless ( ref($err_or_queue) ) {
- $dbh->rollback if $oldAutoCommit;
- return $err_or_queue;
- }
- if ( $jobnum ) {
- my $error = $err_or_queue->depend_insert( $jobnum );
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
- }
-
- if ( @newgroups ) {
- my $err_or_queue = $self->ldap_queue( $new->svcnum, 'usergroup_insert',
- $new->username, @newgroups );
- unless ( ref($err_or_queue) ) {
- $dbh->rollback if $oldAutoCommit;
- return $err_or_queue;
- }
- if ( $jobnum ) {
- my $error = $err_or_queue->depend_insert( $jobnum );
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
-
- '';
-}
-
-sub _export_delete {
- my( $self, $svc_acct ) = (shift, shift);
- return "ldap delete unimplemented";
- my $err_or_queue = $self->ldap_queue( $svc_acct->svcnum, 'delete',
- $svc_acct->username );
- ref($err_or_queue) ? '' : $err_or_queue;
-}
-
-sub ldap_queue {
- my( $self, $svcnum, $method ) = (shift, shift, shift);
- my $queue = new FS::queue {
- 'svcnum' => $svcnum,
- 'job' => "FS::part_export::ldap::ldap_$method",
- };
- $queue->insert(
- $self->machine,
- $self->option('dn'),
- $self->option('password'),
- $self->option('userdn'),
- @_,
- ) or $queue;
-}
-
-sub ldap_insert { #subroutine, not method
- my $ldap = ldap_connect(shift, shift, shift);
- my( $userdn, $username_attrib, %attrib ) = @_;
-
- $userdn = "$username_attrib=$attrib{$username_attrib}, $userdn"
- if $username_attrib;
- #icky hack, but should be unsurprising to the LDAPers
- foreach my $key ( grep { $attrib{$_} =~ /,/ } keys %attrib ) {
- $attrib{$key} = [ split(/,/, $attrib{$key}) ];
- }
-
- my $status = $ldap->add( $userdn, attrs => [ %attrib ] );
- die 'LDAP error: '. $status->error. "\n" if $status->is_error;
-
- $ldap->unbind;
-}
-
-#sub ldap_delete { #subroutine, not method
-# my $dbh = ldap_connect(shift, shift, shift);
-# my $username = shift;
-#
-# foreach my $table (qw( radcheck radreply usergroup )) {
-# my $sth = $dbh->prepare( "DELETE FROM $table WHERE UserName = ?" );
-# $sth->execute($username)
-# or die "can't delete from $table table: ". $sth->errstr;
-# }
-# $dbh->disconnect;
-#}
-
-sub ldap_connect {
- my( $machine, $dn, $password ) = @_;
- my %bind_options;
- $bind_options{password} = $password if length($password);
-
- eval "use Net::LDAP";
- die $@ if $@;
-
- my $ldap = Net::LDAP->new($machine) or die $@;
- my $status = $ldap->bind( $dn, %bind_options );
- die 'LDAP error: '. $status->error. "\n" if $status->is_error;
-
- $ldap;
-}
-
-1;
-
diff --git a/FS/FS/part_export/null.pm b/FS/FS/part_export/null.pm
deleted file mode 100644
index 0145af3..0000000
--- a/FS/FS/part_export/null.pm
+++ /dev/null
@@ -1,13 +0,0 @@
-package FS::part_export::null;
-
-use vars qw(@ISA);
-use FS::part_export;
-
-@ISA = qw(FS::part_export);
-
-sub rebless { shift; }
-
-sub _export_insert {}
-sub _export_replace {}
-sub _export_delete {}
-
diff --git a/FS/FS/part_export/passwdfile.pm b/FS/FS/part_export/passwdfile.pm
deleted file mode 100644
index 2978d25..0000000
--- a/FS/FS/part_export/passwdfile.pm
+++ /dev/null
@@ -1,18 +0,0 @@
-package FS::part_export::passwdfile;
-
-use strict;
-use vars qw(@ISA %options);
-use Tie::IxHash;
-use FS::part_export::null;
-
-@ISA = qw(FS::part_export::null);
-
-tie %options, 'Tie::IxHash',
- 'crypt' => { label=>'Password encryption',
- type=>'select', options=>[qw(crypt md5)],
- default=>'crypt',
- },
-;
-
-1;
-
diff --git a/FS/FS/part_export/postfix.pm b/FS/FS/part_export/postfix.pm
deleted file mode 100644
index c24cf19..0000000
--- a/FS/FS/part_export/postfix.pm
+++ /dev/null
@@ -1,27 +0,0 @@
-package FS::part_export::postfix;
-
-use vars qw(@ISA %info);
-use Tie::IxHash;
-use FS::part_export::null;
-
-@ISA = qw(FS::part_export::null);
-
-tie my %options, 'Tie::IxHash',
- 'user' => { label=>'Remote username', default=>'root' },
- 'aliases' => { label=>'aliases file location', default=>'/etc/aliases' },
- 'virtual' => { label=>'virtual file location', default=>'/etc/postfix/virtual' },
- 'mydomain' => { label=>'local domain', default=>'' },
-;
-
-%info = (
- 'svc' => 'svc_forward',
- 'desc' => 'Postfix text files',
- 'options' => \%options,
- 'notes' => <<'END'
-Batch export of Postfix aliases and virtual files.
-<a href="http://search.cpan.org/dist/File-Rsync">File::Rsync</a>
-must be installed. Run bin/postfix.export to export the files.
-END
-);
-
-1;
diff --git a/FS/FS/part_export/router.pm b/FS/FS/part_export/router.pm
deleted file mode 100644
index 648a437..0000000
--- a/FS/FS/part_export/router.pm
+++ /dev/null
@@ -1,190 +0,0 @@
-package FS::part_export::router;
-
-=head1 FS::part_export::router
-
-This export connects to a router and transmits commands via telnet or SSH.
-It requires the following custom router fields:
-
-=over 4
-
-=item admin_address - IP address (or hostname) to connect
-
-=item admin_user - username for admin access
-
-=item admin_password - password for admin access
-
-=back
-
-The export itself needs the following options:
-
-=over 4
-
-=item insert, replace, delete - command strings (to be interpolated)
-
-=item Prompt - prompt string to expect from router after successful login
-
-=item Timeout - time to wait for prompt string
-
-=back
-
-(Prompt and Timeout are required only for telnet connections.)
-
-=cut
-
-use vars qw(@ISA %info @saltset);
-use Tie::IxHash;
-use String::ShellQuote;
-use FS::part_export;
-
-@ISA = qw(FS::part_export);
-
-tie my %options, 'Tie::IxHash',
- 'protocol' => {
- label=>'Protocol',
- type =>'select',
- options => [qw(telnet ssh)],
- default => 'telnet'},
- 'insert' => {label=>'Insert command', default=>'' },
- 'delete' => {label=>'Delete command', default=>'' },
- 'replace' => {label=>'Replace command', default=>'' },
- 'Timeout' => {label=>'Time to wait for prompt', default=>'20' },
- 'Prompt' => {label=>'Prompt string', default=>'#' }
-;
-
-%info = (
- 'svc' => 'svc_broadband',
- 'desc' => 'Send a command to a router.',
- 'options' => \%options,
- 'notes' => 'Installation of Net::Telnet from CPAN is required for telnet connections. ( more detailed description from Kristian / fire2wire? )',
-);
-
-@saltset = ( 'a'..'z' , 'A'..'Z' , '0'..'9' , '.' , '/' );
-
-sub rebless { shift; }
-
-sub _export_insert {
- my($self) = shift;
- $self->_export_command('insert', @_);
-}
-
-sub _export_delete {
- my($self) = shift;
- $self->_export_command('delete', @_);
-}
-
-sub _export_suspend {
- my($self) = shift;
- $self->_export_command('suspend', @_);
-}
-
-sub _export_unsuspend {
- my($self) = shift;
- $self->_export_command('unsuspend', @_);
-}
-
-sub _export_command {
- my ( $self, $action, $svc_broadband) = (shift, shift, shift);
- my $command = $self->option($action);
- return '' if $command =~ /^\s*$/;
-
- no strict 'vars';
- {
- no strict 'refs';
- ${$_} = $svc_broadband->getfield($_) foreach $svc_broadband->fields;
- }
- # fetch router info
- my $router = $svc_broadband->addr_block->router;
- my %r;
- $r{$_} = $router->getfield($_) foreach $router->virtual_fields;
- #warn qq("$command");
- #warn eval(qq("$command"));
-
- warn "admin_address: '$r{admin_address}'";
-
- if ($r{admin_address} ne '') {
- $self->router_queue( $svc_broadband->svcnum, $self->option('protocol'),
- user => $r{admin_user},
- password => $r{admin_password},
- host => $r{admin_address},
- Timeout => $self->option('Timeout'),
- Prompt => $self->option('Prompt'),
- command => eval(qq("$command")),
- );
- } else {
- return '';
- }
-}
-
-sub _export_replace {
-
- # We don't handle the case of a svc_broadband moving between routers.
- # If you want to do that, reprovision the service.
-
- my($self, $new, $old ) = (shift, shift, shift);
- my $command = $self->option('replace');
- no strict 'vars';
- {
- no strict 'refs';
- ${"old_$_"} = $old->getfield($_) foreach $old->fields;
- ${"new_$_"} = $new->getfield($_) foreach $new->fields;
- }
-
- my $router = $new->addr_block->router;
- my %r;
- $r{$_} = $router->getfield($_) foreach $router->virtual_fields;
-
- if ($r{admin_address} ne '') {
- $self->router_queue( $new->svcnum, $self->option('protocol'),
- user => $r{admin_user},
- password => $r{admin_password},
- host => $r{admin_address},
- Timeout => $self->option('Timeout'),
- Prompt => $self->option('Prompt'),
- command => eval(qq("$command")),
- );
- } else {
- return '';
- }
-}
-
-#a good idea to queue anything that could fail or take any time
-sub router_queue {
- #warn join ':', @_;
- my( $self, $svcnum, $protocol ) = (shift, shift, shift);
- my $queue = new FS::queue {
- 'svcnum' => $svcnum,
- };
- $queue->job ("FS::part_export::router::".$protocol."_cmd");
- $queue->insert( @_ );
-}
-
-sub ssh_cmd { #subroutine, not method
- use Net::SSH '0.08';
- &Net::SSH::ssh_cmd( { @_ } );
-}
-
-sub telnet_cmd {
- eval 'use Net::Telnet;';
- die $@ if $@;
-
- warn join(', ', @_);
-
- my %arg = @_;
-
- my $t = new Net::Telnet (Timeout => $arg{Timeout},
- Prompt => $arg{Prompt});
- $t->open($arg{host});
- $t->login($arg{user}, $arg{password});
- my @error = $t->cmd($arg{command});
- die @error if (grep /^ERROR/, @error);
-}
-
-#sub router_insert { #subroutine, not method
-#}
-#sub router_replace { #subroutine, not method
-#}
-#sub router_delete { #subroutine, not method
-#}
-
-1;
-
diff --git a/FS/FS/part_export/shellcommands.pm b/FS/FS/part_export/shellcommands.pm
deleted file mode 100644
index 78f9e96..0000000
--- a/FS/FS/part_export/shellcommands.pm
+++ /dev/null
@@ -1,317 +0,0 @@
-package FS::part_export::shellcommands;
-
-use vars qw(@ISA %info @saltset);
-use Tie::IxHash;
-use String::ShellQuote;
-use FS::part_export;
-
-@ISA = qw(FS::part_export);
-
-tie my %options, 'Tie::IxHash',
- 'user' => { label=>'Remote username', default=>'root' },
- 'useradd' => { label=>'Insert command',
- default=>'useradd -c $finger -d $dir -m -s $shell -u $uid -p $crypt_password $username'
- #default=>'cp -pr /etc/skel $dir; chown -R $uid.$gid $dir'
- },
- 'useradd_stdin' => { label=>'Insert command STDIN',
- type =>'textarea',
- default=>'',
- },
- 'userdel' => { label=>'Delete command',
- default=>'userdel -r $username',
- #default=>'rm -rf $dir',
- },
- 'userdel_stdin' => { label=>'Delete command STDIN',
- type =>'textarea',
- default=>'',
- },
- 'usermod' => { label=>'Modify command',
- default=>'usermod -c $new_finger -d $new_dir -m -l $new_username -s $new_shell -u $new_uid -p $new_crypt_password $old_username',
- #default=>'[ -d $old_dir ] && mv $old_dir $new_dir || ( '.
- # 'chmod u+t $old_dir; mkdir $new_dir; cd $old_dir; '.
- # 'find . -depth -print | cpio -pdm $new_dir; '.
- # 'chmod u-t $new_dir; chown -R $uid.$gid $new_dir; '.
- # 'rm -rf $old_dir'.
- #')'
- },
- 'usermod_stdin' => { label=>'Modify command STDIN',
- type =>'textarea',
- default=>'',
- },
- 'usermod_pwonly' => { label=>'Disallow username changes',
- type =>'checkbox',
- },
- 'suspend' => { label=>'Suspension command',
- default=>'usermod -L $username',
- },
- 'suspend_stdin' => { label=>'Suspension command STDIN',
- default=>'',
- },
- 'unsuspend' => { label=>'Unsuspension command',
- default=>'usermod -U $username',
- },
- 'unsuspend_stdin' => { label=>'Unsuspension command STDIN',
- default=>'',
- },
-;
-
-%info = (
- 'svc' => 'svc_acct',
- 'desc' =>
- 'Real-time export via remote SSH (i.e. useradd, userdel, etc.)',
- 'options' => \%options,
- 'nodomain' => 'Y',
- 'notes' => <<'END'
-Run remote commands via SSH. Usernames are considered unique (also see
-shellcommands_withdomain). You probably want this if the commands you are
-running will not accept a domain as a parameter. You will need to
-<a href="../docs/ssh.html">setup SSH for unattended operation</a>.
-
-<BR><BR>Use these buttons for some useful presets:
-<UL>
- <LI>
- <INPUT TYPE="button" VALUE="Linux" onClick='
- this.form.useradd.value = "useradd -c $finger -d $dir -m -s $shell -u $uid -p $crypt_password $username";
- this.form.useradd_stdin.value = "";
- this.form.userdel.value = "userdel -r $username";
- this.form.userdel_stdin.value="";
- this.form.usermod.value = "usermod -c $new_finger -d $new_dir -m -l $new_username -s $new_shell -u $new_uid -p $new_crypt_password $old_username";
- this.form.usermod_stdin.value = "";
- this.form.suspend.value = "usermod -L $username";
- this.form.suspend_stdin.value="";
- this.form.unsuspend.value = "usermod -U $username";
- this.form.unsuspend_stdin.value="";
- '>
- <LI>
- <INPUT TYPE="button" VALUE="FreeBSD before 4.10 / 5.3" onClick='
- this.form.useradd.value = "lockf /etc/passwd.lock pw useradd $username -d $dir -m -s $shell -u $uid -g $gid -c $finger -h 0";
- this.form.useradd_stdin.value = "$_password\n";
- this.form.userdel.value = "lockf /etc/passwd.lock pw userdel $username -r"; this.form.userdel_stdin.value="";
- this.form.usermod.value = "lockf /etc/passwd.lock pw usermod $old_username -d $new_dir -m -l $new_username -s $new_shell -u $new_uid -c $new_finger -h 0";
- this.form.usermod_stdin.value = "$new__password\n"; this.form.suspend.value = "lockf /etc/passwd.lock pw lock $username";
- this.form.suspend_stdin.value="";
- this.form.unsuspend.value = "lockf /etc/passwd.lock pw unlock $username"; this.form.unsuspend_stdin.value="";
- '>
- Note: On FreeBSD versions before 5.3 and 4.10 (4.10 is after 4.9, not
- 4.1!), due to deficient locking in pw(1), you must disable the chpass(1),
- chsh(1), chfn(1), passwd(1), and vipw(1) commands, or replace them with
- wrappers that prepend "lockf /etc/passwd.lock". Alternatively, apply the
- patch in
- <A HREF="http://www.freebsd.org/cgi/query-pr.cgi?pr=23501">FreeBSD PR#23501</A>
- and use the "FreeBSD 4.10 / 5.3 or later" button below.
- <LI>
- <INPUT TYPE="button" VALUE="FreeBSD 4.10 / 5.3 or later" onClick='
- this.form.useradd.value = "pw useradd $username -d $dir -m -s $shell -u $uid -g $gid -c $finger -h 0";
- this.form.useradd_stdin.value = "$_password\n";
- this.form.userdel.value = "pw userdel $username -r";
- this.form.userdel_stdin.value="";
- this.form.usermod.value = "pw usermod $old_username -d $new_dir -m -l $new_username -s $new_shell -u $new_uid -c $new_finger -h 0";
- this.form.usermod_stdin.value = "$new__password\n";
- this.form.suspend.value = "pw lock $username";
- this.form.suspend_stdin.value="";
- this.form.unsuspend.value = "pw unlock $username";
- this.form.unsuspend_stdin.value="";
- '>
- <LI>
- <INPUT TYPE="button" VALUE="NetBSD/OpenBSD" onClick='
- this.form.useradd.value = "useradd -c $finger -d $dir -m -s $shell -u $uid -p $crypt_password $username";
- this.form.useradd_stdin.value = "";
- this.form.userdel.value = "userdel -r $username";
- this.form.userdel_stdin.value="";
- this.form.usermod.value = "usermod -c $new_finger -d $new_dir -m -l $new_username -s $new_shell -u $new_uid -p $new_crypt_password $old_username";
- this.form.usermod_stdin.value = "";
- this.form.suspend.value = "";
- this.form.suspend_stdin.value="";
- this.form.unsuspend.value = "";
- this.form.unsuspend_stdin.value="";
- '>
- <LI>
- <INPUT TYPE="button" VALUE="Just maintain directories (use with sysvshell or bsdshell)" onClick='
- this.form.useradd.value = "cp -pr /etc/skel $dir; chown -R $uid.$gid $dir"; this.form.useradd_stdin.value = "";
- this.form.usermod.value = "[ -d $old_dir ] && mv $old_dir $new_dir || ( chmod u+t $old_dir; mkdir $new_dir; cd $old_dir; find . -depth -print | cpio -pdm $new_dir; chmod u-t $new_dir; chown -R $new_uid.$new_gid $new_dir; rm -rf $old_dir )";
- this.form.usermod_stdin.value = "";
- this.form.userdel.value = "rm -rf $dir";
- this.form.userdel_stdin.value="";
- this.form.suspend.value = "";
- this.form.suspend_stdin.value="";
- this.form.unsuspend.value = "";
- this.form.unsuspend_stdin.value="";
- '>
-</UL>
-
-The following variables are available for interpolation (prefixed with new_ or
-old_ for replace operations):
-<UL>
- <LI><code>$username</code>
- <LI><code>$_password</code>
- <LI><code>$quoted_password</code> - unencrypted password quoted for the shell
- <LI><code>$crypt_password</code> - encrypted password
- <LI><code>$uid</code>
- <LI><code>$gid</code>
- <LI><code>$finger</code> - GECOS, already quoted for the shell (do not add additional quotes)
- <LI><code>$first</code> - First name of GECOS, already quoted for the shell (do not add additional quotes)
- <LI><code>$last</code> - Last name of GECOS, already quoted for the shell (do not add additional quotes)
- <LI><code>$dir</code> - home directory
- <LI><code>$shell</code>
- <LI><code>$quota</code>
- <LI>All other fields in <a href="../docs/schema.html#svc_acct">svc_acct</a> are also available.
-</UL>
-END
-);
-
-@saltset = ( 'a'..'z' , 'A'..'Z' , '0'..'9' , '.' , '/' );
-
-sub rebless { shift; }
-
-sub _export_insert {
- my($self) = shift;
- $self->_export_command('useradd', @_);
-}
-
-sub _export_delete {
- my($self) = shift;
- $self->_export_command('userdel', @_);
-}
-
-sub _export_suspend {
- my($self) = shift;
- $self->_export_command('suspend', @_);
-}
-
-sub _export_unsuspend {
- my($self) = shift;
- $self->_export_command('unsuspend', @_);
-}
-
-sub _export_command {
- my ( $self, $action, $svc_acct) = (shift, shift, shift);
- my $command = $self->option($action);
- return '' if $command =~ /^\s*$/;
- my $stdin = $self->option($action."_stdin");
-
- no strict 'vars';
- {
- no strict 'refs';
- ${$_} = $svc_acct->getfield($_) foreach $svc_acct->fields;
-
- my $count = 1;
- foreach my $acct_snarf ( $svc_acct->acct_snarf ) {
- ${"snarf_$_$count"} = shell_quote( $acct_snarf->get($_) )
- foreach qw( machine username _password );
- $count++;
- }
- }
-
- my $cust_pkg = $svc_acct->cust_svc->cust_pkg;
- if ( $cust_pkg ) {
- $email = ( grep { $_ ne 'POST' } $cust_pkg->cust_main->invoicing_list )[0];
- } else {
- $email = '';
- }
-
- $finger =~ /^(.*)\s+(\S+)$/ or $finger =~ /^((.*))$/;
- ($first, $last ) = ( $1, $2 );
- $first = shell_quote $first;
- $last = shell_quote $last;
- $finger = shell_quote $finger;
- $quoted_password = shell_quote $_password;
- $domain = $svc_acct->domain;
-
- #eventually should check a "password-encoding" field
- if ( length($svc_acct->_password) == 13
- || $svc_acct->_password =~ /^\$(1|2a?)\$/ ) {
- $crypt_password = shell_quote $svc_acct->_password;
- } else {
- $crypt_password = crypt(
- $svc_acct->_password,
- $saltset[int(rand(64))].$saltset[int(rand(64))]
- );
- }
-
- $self->shellcommands_queue( $svc_acct->svcnum,
- user => $self->option('user')||'root',
- host => $self->machine,
- command => eval(qq("$command")),
- stdin_string => eval(qq("$stdin")),
- );
-}
-
-sub _export_replace {
- my($self, $new, $old ) = (shift, shift, shift);
- my $command = $self->option('usermod');
- my $stdin = $self->option('usermod_stdin');
- no strict 'vars';
- {
- no strict 'refs';
- ${"old_$_"} = $old->getfield($_) foreach $old->fields;
- ${"new_$_"} = $new->getfield($_) foreach $new->fields;
- }
- $new_finger =~ /^(.*)\s+(\S+)$/ or $finger =~ /^((.*))$/;
- ($new_first, $new_last ) = ( $1, $2 );
- $new_first = shell_quote $new_first;
- $new_last = shell_quote $new_last;
- $new_finger = shell_quote $new_finger;
- $quoted_new__password = shell_quote $new__password; #old, wrong?
- $new_quoted_password = shell_quote $new__password; #new, better?
- $old_domain = $old->domain;
- $new_domain = $new->domain;
-
- #eventuall should check a "password-encoding" field
- if ( length($new->_password) == 13
- || $new->_password =~ /^\$(1|2a?)\$/ ) {
- $new_crypt_password = shell_quote $new->_password;
- } else {
- $new_crypt_password =
- crypt( $new->_password, $saltset[int(rand(64))].$saltset[int(rand(64))]
- );
- }
-
- if ( $self->option('usermod_pwonly') ) {
- my $error = '';
- if ( $old_username ne $new_username ) {
- $error ||= "can't change username";
- }
- if ( $old_domain ne $new_domain ) {
- $error ||= "can't change domain";
- }
- if ( $old_uid != $new_uid ) {
- $error ||= "can't change uid";
- }
- if ( $old_dir ne $new_dir ) {
- $error ||= "can't change dir";
- }
- return $error. ' ('. $self->exporttype. ' to '. $self->machine. ')'
- if $error;
- }
- $self->shellcommands_queue( $new->svcnum,
- user => $self->option('user')||'root',
- host => $self->machine,
- command => eval(qq("$command")),
- stdin_string => eval(qq("$stdin")),
- );
-}
-
-#a good idea to queue anything that could fail or take any time
-sub shellcommands_queue {
- my( $self, $svcnum ) = (shift, shift);
- my $queue = new FS::queue {
- 'svcnum' => $svcnum,
- 'job' => "FS::part_export::shellcommands::ssh_cmd",
- };
- $queue->insert( @_ );
-}
-
-sub ssh_cmd { #subroutine, not method
- use Net::SSH '0.08';
- &Net::SSH::ssh_cmd( { @_ } );
-}
-
-#sub shellcommands_insert { #subroutine, not method
-#}
-#sub shellcommands_replace { #subroutine, not method
-#}
-#sub shellcommands_delete { #subroutine, not method
-#}
-
-1;
-
diff --git a/FS/FS/part_export/shellcommands_withdomain.pm b/FS/FS/part_export/shellcommands_withdomain.pm
deleted file mode 100644
index 8a56bab..0000000
--- a/FS/FS/part_export/shellcommands_withdomain.pm
+++ /dev/null
@@ -1,104 +0,0 @@
-package FS::part_export::shellcommands_withdomain;
-
-use vars qw(@ISA %info);
-use Tie::IxHash;
-use FS::part_export::shellcommands;
-
-@ISA = qw(FS::part_export::shellcommands);
-
-tie my %options, 'Tie::IxHash',
- 'user' => { label=>'Remote username', default=>'root' },
- 'useradd' => { label=>'Insert command',
- #default=>''
- },
- 'useradd_stdin' => { label=>'Insert command STDIN',
- type =>'textarea',
- #default=>"$_password\n$_password\n",
- },
- 'userdel' => { label=>'Delete command',
- #default=>'',
- },
- 'userdel_stdin' => { label=>'Delete command STDIN',
- type =>'textarea',
- #default=>'',
- },
- 'usermod' => { label=>'Modify command',
- default=>'',
- },
- 'usermod_stdin' => { label=>'Modify command STDIN',
- type =>'textarea',
- #default=>"$_password\n$_password\n",
- },
- 'usermod_pwonly' => { label=>'Disallow username changes',
- type =>'checkbox',
- },
- 'suspend' => { label=>'Suspension command',
- default=>'',
- },
- 'suspend_stdin' => { label=>'Suspension command STDIN',
- default=>'',
- },
- 'unsuspend' => { label=>'Unsuspension command',
- default=>'',
- },
- 'unsuspend_stdin' => { label=>'Unsuspension command STDIN',
- default=>'',
- },
-;
-
-%info = (
- 'svc' => 'svc_acct',
- 'desc' => 'Real-time export via remote SSH (vpopmail, ISPMan)',
- 'options' => \%options,
- 'notes' => <<'END'
-Run remote commands via SSH. username@domain (rather than just usernames) are
-considered unique (also see shellcommands). You probably want this if the
-commands you are running will accept a domain as a parameter, and will allow
-the same username with different domains. You will need to
-<a href="../docs/ssh.html">setup SSH for unattended operation</a>.
-
-<BR><BR>Use these buttons for some useful presets:
-<UL>
- <LI><INPUT TYPE="button" VALUE="vpopmail" onClick='
- this.form.useradd.value = "/home/vpopmail/bin/vadduser $username\\\@$domain $quoted_password";
- this.form.useradd_stdin.value = "";
- this.form.userdel.value = "/home/vpopmail/bin/vdeluser $username\\\@$domain";
- this.form.userdel_stdin.value="";
- this.form.usermod.value = "/home/vpopmail/bin/vpasswd $new_username\\\@$new_domain $new_quoted_password";
- this.form.usermod_stdin.value = "";
- this.form.usermod_pwonly.checked = true;
- '>
- <LI><INPUT TYPE="button" VALUE="ISPMan CLI" onClick='
- this.form.useradd.value = "/usr/local/ispman/bin/ispman.addUser -d $domain -f $first -l $last -q $quota -p $quoted_password $username";
- this.form.useradd_stdin.value = "";
- this.form.userdel.value = "/usr/local/ispman/bin/ispman.delUser -d $domain $username";
- this.form.userdel_stdin.value="";
- this.form.usermod.value = "/usr/local/ispman/bin/ispman.passwd.user $username\\\@$domain $new_quoted_password";
- this.form.usermod_stdin.value = "";
- this.form.usermod_pwonly.checked = true;
- '>
-</UL>
-
-The following variables are available for interpolation (prefixed with
-<code>new_</code> or <code>old_</code> for replace operations):
-<UL>
- <LI><code>$username</code>
- <LI><code>$domain</code>
- <LI><code>$_password</code>
- <LI><code>$quoted_password</code> - unencrypted password quoted for the shell
- <LI><code>$crypt_password</code> - encrypted password
- <LI><code>$uid</code>
- <LI><code>$gid</code>
- <LI><code>$finger</code> - GECOS, already quoted for the shell (do not add additional quotes)
- <LI><code>$first</code> - First name of GECOS, already quoted for the shell (do not add additional quotes)
- <LI><code>$last</code> - Last name of GECOS, already quoted for the shell (do not add additional quotes)
- <LI><code>$dir</code> - home directory
- <LI><code>$shell</code>
- <LI><code>$quota</code>
- <LI>All other fields in <a href="../docs/schema.html#svc_acct">svc_acct</a> are also available.
-</UL>
-END
-);
-
-1;
-
diff --git a/FS/FS/part_export/sqlmail.pm b/FS/FS/part_export/sqlmail.pm
deleted file mode 100644
index 6d61e0e..0000000
--- a/FS/FS/part_export/sqlmail.pm
+++ /dev/null
@@ -1,220 +0,0 @@
-package FS::part_export::sqlmail;
-
-use vars qw(@ISA %info);
-use Tie::IxHash;
-use Digest::MD5 qw(md5_hex);
-use FS::Record qw(qsearchs);
-use FS::part_export;
-use FS::svc_domain;
-
-@ISA = qw(FS::part_export);
-
-tie my %options, 'Tie::IxHash',
- 'datasrc' => { label => 'DBI data source' },
- 'username' => { label => 'Database username' },
- 'password' => { label => 'Database password' },
- 'server_type' => {
- label => 'Server type',
- type => 'select',
- options => [qw(dovecot_plain dovecot_crypt dovecot_digest_md5 courier_plain
- courier_crypt)],
- default => ['dovecot_plain'], },
- 'svc_acct_table' => { label => 'User Table', default => 'user_acct' },
- 'svc_forward_table' => { label => 'Forward Table', default => 'forward' },
- 'svc_domain_table' => { label => 'Domain Table', default => 'domain' },
- 'svc_acct_fields' => { label => 'svc_acct Export Fields',
- default => 'username _password domsvc svcnum' },
- 'svc_forward_fields' => { label => 'svc_forward Export Fields',
- default => 'domain svcnum catchall' },
- 'svc_domain_fields' => { label => 'svc_domain Export Fields',
- default => 'srcsvc dstsvc dst' },
- 'resolve_dstsvc' => { label => q{Resolve svc_forward.dstsvc to an email address and store it in dst. (Doesn't require that you also export dstsvc.)},
- type => 'checkbox' },
-;
-
-%info = (
- 'svc' => [qw( svc_acct svc_domain svc_forward )],
- 'desc' => 'Real-time export to SQL-backed mail server',
- 'options' => \%options,
- 'nodomain' => '',
- 'notes' => <<'END'
-Database schema can be made to work with Courier IMAP, Exim and Dovecot.
-Others could work but are untested. (more detailed description from
-Kristian / fire2wire? )
-END
-);
-
-sub rebless { shift; }
-
-sub _export_insert {
- my($self, $svc) = (shift, shift);
- # this is a svc_something.
-
- my $svcdb = $svc->cust_svc->part_svc->svcdb;
- my $export_table = $self->option($svcdb . '_table')
- or die('Export table not defined for svcdb: ' . $svcdb);
- my @export_fields = split(/\s+/, $self->option($svcdb . '_fields'));
- my $svchash = update_values($self, $svc, $svcdb);
-
- foreach my $key (keys(%$svchash)) {
- unless (grep { $key eq $_ } @export_fields) {
- delete $svchash->{$key};
- }
- }
-
- my $error = $self->sqlmail_queue( $svc->svcnum, 'insert',
- $self->option('server_type'), $export_table,
- (map { ($_, $svchash->{$_}); } keys(%$svchash)));
- return $error if $error;
- '';
-
-}
-
-sub _export_replace {
- my( $self, $new, $old ) = (shift, shift, shift);
-
- my $svcdb = $new->cust_svc->part_svc->svcdb;
- my $export_table = $self->option($svcdb . '_table')
- or die('Export table not defined for svcdb: ' . $svcdb);
- my @export_fields = split(/\s+/, $self->option($svcdb . '_fields'));
- my $svchash = update_values($self, $new, $svcdb);
-
- foreach my $key (keys(%$svchash)) {
- unless (grep { $key eq $_ } @export_fields) {
- delete $svchash->{$key};
- }
- }
-
- my $error = $self->sqlmail_queue( $new->svcnum, 'replace',
- $old->svcnum, $self->option('server_type'), $export_table,
- (map { ($_, $svchash->{$_}); } keys(%$svchash)));
- return $error if $error;
- '';
-
-}
-
-sub _export_delete {
- my( $self, $svc ) = (shift, shift);
-
- my $svcdb = $svc->cust_svc->part_svc->svcdb;
- my $table = $self->option($svcdb . '_table')
- or die('Export table not defined for svcdb: ' . $svcdb);
-
- $self->sqlmail_queue( $svc->svcnum, 'delete', $table,
- $svc->svcnum );
-}
-
-sub sqlmail_queue {
- my( $self, $svcnum, $method ) = (shift, shift, shift);
- my $queue = new FS::queue {
- 'svcnum' => $svcnum,
- 'job' => "FS::part_export::sqlmail::sqlmail_$method",
- };
- $queue->insert(
- $self->option('datasrc'),
- $self->option('username'),
- $self->option('password'),
- @_,
- );
-}
-
-sub sqlmail_insert { #subroutine, not method
- my $dbh = sqlmail_connect(shift, shift, shift);
- my( $server_type, $table ) = (shift, shift);
-
- my %attrs = @_;
-
- map { $attrs{$_} = $attrs{$_} ? qq!'$attrs{$_}'! : 'NULL'; } keys(%attrs);
- my $query = sprintf("INSERT INTO %s (%s) values (%s)",
- $table, join(",", keys(%attrs)),
- join(',', values(%attrs)));
-
- $dbh->do($query) or die $dbh->errstr;
- $dbh->disconnect;
-
- '';
-}
-
-sub sqlmail_delete { #subroutine, not method
- my $dbh = sqlmail_connect(shift, shift, shift);
- my( $table, $svcnum ) = @_;
-
- $dbh->do("DELETE FROM $table WHERE svcnum = $svcnum") or die $dbh->errstr;
- $dbh->disconnect;
-
- '';
-}
-
-sub sqlmail_replace {
- my $dbh = sqlmail_connect(shift, shift, shift);
- my($oldsvcnum, $server_type, $table) = (shift, shift, shift);
-
- my %attrs = @_;
- map { $attrs{$_} = $attrs{$_} ? qq!'$attrs{$_}'! : 'NULL'; } keys(%attrs);
-
- my $query = "SELECT COUNT(*) FROM $table WHERE svcnum = $oldsvcnum";
- my $result = $dbh->selectrow_arrayref($query) or die $dbh->errstr;
-
- if (@$result[0] == 0) {
- $query = sprintf("INSERT INTO %s (%s) values (%s)",
- $table, join(",", keys(%attrs)),
- join(',', values(%attrs)));
- $dbh->do($query) or die $dbh->errstr;
- } else {
- $query = sprintf('UPDATE %s SET %s WHERE svcnum = %s',
- $table, join(', ', map {"$_ = $attrs{$_}"} keys(%attrs)),
- $oldsvcnum);
- $dbh->do($query) or die $dbh->errstr;
- }
-
- $dbh->disconnect;
-
- '';
-}
-
-sub sqlmail_connect {
- DBI->connect(@_) or die $DBI::errstr;
-}
-
-sub update_values {
-
- # Update records to conform to a particular server_type.
-
- my ($self, $svc, $svcdb) = (shift,shift,shift);
- my $svchash = { %{$svc->hashref} } or return ''; # We need a copy.
-
- if ($svcdb eq 'svc_acct') {
- if ($self->option('server_type') eq 'courier_crypt') {
- my $salt = join '', ('.', '/', 0..9,'A'..'Z', 'a'..'z')[rand 64, rand 64];
- $svchash->{_password} = crypt($svchash->{_password}, $salt);
-
- } elsif ($self->option('server_type') eq 'dovecot_plain') {
- $svchash->{_password} = '{PLAIN}' . $svchash->{_password};
-
- } elsif ($self->option('server_type') eq 'dovecot_crypt') {
- my $salt = join '', ('.', '/', 0..9,'A'..'Z', 'a'..'z')[rand 64, rand 64];
- $svchash->{_password} = '{CRYPT}' . crypt($svchash->{_password}, $salt);
-
- } elsif ($self->option('server_type') eq 'dovecot_digest_md5') {
- my $svc_domain = qsearchs('svc_domain', { svcnum => $svc->domsvc });
- die('Unable to lookup svc_domain with domsvc: ' . $svc->domsvc)
- unless ($svc_domain);
-
- my $domain = $svc_domain->domain;
- my $md5hash = '{DIGEST-MD5}' . md5_hex(join(':', $svchash->{username},
- $domain, $svchash->{_password}));
- $svchash->{_password} = $md5hash;
- }
- } elsif ($svcdb eq 'svc_forward') {
- if ($self->option('resolve_dstsvc') && $svc->dstsvc_acct) {
- $svchash->{dst} = $svc->dstsvc_acct->username . '@' .
- $svc->dstsvc_acct->svc_domain->domain;
- }
- }
-
- return($svchash);
-
-}
-
-1;
-
diff --git a/FS/FS/part_export/sqlradius.pm b/FS/FS/part_export/sqlradius.pm
deleted file mode 100644
index fd5bb89..0000000
--- a/FS/FS/part_export/sqlradius.pm
+++ /dev/null
@@ -1,337 +0,0 @@
-package FS::part_export::sqlradius;
-
-use vars qw(@ISA %info %options $notes1 $notes2);
-use Tie::IxHash;
-use FS::Record qw( dbh );
-use FS::part_export;
-
-@ISA = qw(FS::part_export);
-
-tie %options, 'Tie::IxHash',
- 'datasrc' => { label=>'DBI data source ' },
- 'username' => { label=>'Database username' },
- 'password' => { label=>'Database password' },
- 'ignore_accounting' => {
- type => 'checkbox',
- label=>'Ignore accounting records from this database'
- },
-;
-
-$notes1 = <<'END';
-Real-time export of radcheck, radreply and usergroup tables to any SQL database
-for <a href="http://www.freeradius.org/">FreeRADIUS</a>,
-<a href="http://radius.innercite.com/">ICRADIUS</a>
-or <a href="http://www.open.com.au/radiator/">Radiator</a>.
-END
-
-$notes2 = <<'END';
-An existing RADIUS database will be updated in realtime, but you can use
-<a href="../docs/man/bin/freeside-sqlradius-reset">freeside-sqlradius-reset</a>
-to delete the entire RADIUS database and repopulate the tables from the
-Freeside database. See the
-<a href="http://search.cpan.org/dist/DBI/DBI.pm#connect">DBI documentation</a>
-and the
-<a href="http://search.cpan.org/search?mode=module&query=DBD%3A%3A">documentation for your DBD</a>
-for the exact syntax of a DBI data source.
-<ul>
- <li>Using FreeRADIUS 0.9.0 with the PostgreSQL backend, the db_postgresql.sql schema and postgresql.conf queries contain incompatible changes. This is fixed in 0.9.1. Only new installs with 0.9.0 and PostgreSQL are affected - upgrades and other database backends and versions are unaffected.
- <li>Using ICRADIUS, add a dummy "op" column to your database:
- <blockquote><code>
- ALTER&nbsp;TABLE&nbsp;radcheck&nbsp;ADD&nbsp;COLUMN&nbsp;op&nbsp;VARCHAR(2)&nbsp;NOT&nbsp;NULL&nbsp;DEFAULT&nbsp;'=='<br>
- ALTER&nbsp;TABLE&nbsp;radreply&nbsp;ADD&nbsp;COLUMN&nbsp;op&nbsp;VARCHAR(2)&nbsp;NOT&nbsp;NULL&nbsp;DEFAULT&nbsp;'=='<br>
- ALTER&nbsp;TABLE&nbsp;radgroupcheck&nbsp;ADD&nbsp;COLUMN&nbsp;op&nbsp;VARCHAR(2)&nbsp;NOT&nbsp;NULL&nbsp;DEFAULT&nbsp;'=='<br>
- ALTER&nbsp;TABLE&nbsp;radgroupreply&nbsp;ADD&nbsp;COLUMN&nbsp;op&nbsp;VARCHAR(2)&nbsp;NOT&nbsp;NULL&nbsp;DEFAULT&nbsp;'=='
- </code></blockquote>
- <li>Using Radiator, see the
- <a href="http://www.open.com.au/radiator/faq.html#38">Radiator FAQ</a>
- for configuration information.
-</ul>
-END
-
-%info = (
- 'svc' => 'svc_acct',
- 'desc' => 'Real-time export to SQL-backed RADIUS (FreeRADIUS, ICRADIUS, Radiator)',
- 'options' => \%options,
- 'nodomain' => 'Y',
- 'notes' => $notes1.
- 'This export does not export RADIUS realms (see also '.
- 'sqlradius_withdomain). '.
- $notes2
-);
-
-sub rebless { shift; }
-
-sub export_username {
- my($self, $svc_acct) = (shift, shift);
- $svc_acct->username;
-}
-
-sub _export_insert {
- my($self, $svc_acct) = (shift, shift);
-
- foreach my $table (qw(reply check)) {
- my $method = "radius_$table";
- my %attrib = $svc_acct->$method();
- next unless keys %attrib;
- my $err_or_queue = $self->sqlradius_queue( $svc_acct->svcnum, 'insert',
- $table, $self->export_username($svc_acct), %attrib );
- return $err_or_queue unless ref($err_or_queue);
- }
- my @groups = $svc_acct->radius_groups;
- if ( @groups ) {
- my $err_or_queue = $self->sqlradius_queue(
- $svc_acct->svcnum, 'usergroup_insert',
- $self->export_username($svc_acct), @groups );
- return $err_or_queue unless ref($err_or_queue);
- }
- '';
-}
-
-sub _export_replace {
- my( $self, $new, $old ) = (shift, shift, shift);
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- my $jobnum = '';
- if ( $self->export_username($old) ne $self->export_username($new) ) {
- my $err_or_queue = $self->sqlradius_queue( $new->svcnum, 'rename',
- $self->export_username($new), $self->export_username($old) );
- unless ( ref($err_or_queue) ) {
- $dbh->rollback if $oldAutoCommit;
- return $err_or_queue;
- }
- $jobnum = $err_or_queue->jobnum;
- }
-
- foreach my $table (qw(reply check)) {
- my $method = "radius_$table";
- my %new = $new->$method();
- my %old = $old->$method();
- if ( grep { !exists $old{$_} #new attributes
- || $new{$_} ne $old{$_} #changed
- } keys %new
- ) {
- my $err_or_queue = $self->sqlradius_queue( $new->svcnum, 'insert',
- $table, $self->export_username($new), %new );
- unless ( ref($err_or_queue) ) {
- $dbh->rollback if $oldAutoCommit;
- return $err_or_queue;
- }
- if ( $jobnum ) {
- my $error = $err_or_queue->depend_insert( $jobnum );
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
- }
-
- my @del = grep { !exists $new{$_} } keys %old;
- if ( @del ) {
- my $err_or_queue = $self->sqlradius_queue( $new->svcnum, 'attrib_delete',
- $table, $self->export_username($new), @del );
- unless ( ref($err_or_queue) ) {
- $dbh->rollback if $oldAutoCommit;
- return $err_or_queue;
- }
- if ( $jobnum ) {
- my $error = $err_or_queue->depend_insert( $jobnum );
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
- }
- }
-
- # (sorta) false laziness with FS::svc_acct::replace
- my @oldgroups = @{$old->usergroup}; #uuuh
- my @newgroups = $new->radius_groups;
- my @delgroups = ();
- foreach my $oldgroup ( @oldgroups ) {
- if ( grep { $oldgroup eq $_ } @newgroups ) {
- @newgroups = grep { $oldgroup ne $_ } @newgroups;
- next;
- }
- push @delgroups, $oldgroup;
- }
-
- if ( @delgroups ) {
- my $err_or_queue = $self->sqlradius_queue( $new->svcnum, 'usergroup_delete',
- $self->export_username($new), @delgroups );
- unless ( ref($err_or_queue) ) {
- $dbh->rollback if $oldAutoCommit;
- return $err_or_queue;
- }
- if ( $jobnum ) {
- my $error = $err_or_queue->depend_insert( $jobnum );
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
- }
-
- if ( @newgroups ) {
- my $err_or_queue = $self->sqlradius_queue( $new->svcnum, 'usergroup_insert',
- $self->export_username($new), @newgroups );
- unless ( ref($err_or_queue) ) {
- $dbh->rollback if $oldAutoCommit;
- return $err_or_queue;
- }
- if ( $jobnum ) {
- my $error = $err_or_queue->depend_insert( $jobnum );
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
-
- '';
-}
-
-sub _export_delete {
- my( $self, $svc_acct ) = (shift, shift);
- my $err_or_queue = $self->sqlradius_queue( $svc_acct->svcnum, 'delete',
- $self->export_username($svc_acct) );
- ref($err_or_queue) ? '' : $err_or_queue;
-}
-
-sub sqlradius_queue {
- my( $self, $svcnum, $method ) = (shift, shift, shift);
- my $queue = new FS::queue {
- 'svcnum' => $svcnum,
- 'job' => "FS::part_export::sqlradius::sqlradius_$method",
- };
- $queue->insert(
- $self->option('datasrc'),
- $self->option('username'),
- $self->option('password'),
- @_,
- ) or $queue;
-}
-
-sub sqlradius_insert { #subroutine, not method
- my $dbh = sqlradius_connect(shift, shift, shift);
- my( $table, $username, %attributes ) = @_;
-
- foreach my $attribute ( keys %attributes ) {
-
- my $s_sth = $dbh->prepare(
- "SELECT COUNT(*) FROM rad$table WHERE UserName = ? AND Attribute = ?"
- ) or die $dbh->errstr;
- $s_sth->execute( $username, $attribute ) or die $s_sth->errstr;
-
- if ( $s_sth->fetchrow_arrayref->[0] ) {
-
- my $u_sth = $dbh->prepare(
- "UPDATE rad$table SET Value = ? WHERE UserName = ? AND Attribute = ?"
- ) or die $dbh->errstr;
- $u_sth->execute($attributes{$attribute}, $username, $attribute)
- or die $u_sth->errstr;
-
- } else {
-
- my $i_sth = $dbh->prepare(
- "INSERT INTO rad$table ( UserName, Attribute, op, Value ) ".
- "VALUES ( ?, ?, ?, ? )"
- ) or die $dbh->errstr;
- $i_sth->execute(
- $username,
- $attribute,
- ( $attribute =~ /Password/i ? '==' : ':=' ),
- $attributes{$attribute},
- ) or die $i_sth->errstr;
-
- }
-
- }
- $dbh->disconnect;
-}
-
-sub sqlradius_usergroup_insert { #subroutine, not method
- my $dbh = sqlradius_connect(shift, shift, shift);
- my( $username, @groups ) = @_;
-
- my $sth = $dbh->prepare(
- "INSERT INTO usergroup ( UserName, GroupName ) VALUES ( ?, ? )"
- ) or die $dbh->errstr;
- foreach my $group ( @groups ) {
- $sth->execute( $username, $group )
- or die "can't insert into groupname table: ". $sth->errstr;
- }
- $dbh->disconnect;
-}
-
-sub sqlradius_usergroup_delete { #subroutine, not method
- my $dbh = sqlradius_connect(shift, shift, shift);
- my( $username, @groups ) = @_;
-
- my $sth = $dbh->prepare(
- "DELETE FROM usergroup WHERE UserName = ? AND GroupName = ?"
- ) or die $dbh->errstr;
- foreach my $group ( @groups ) {
- $sth->execute( $username, $group )
- or die "can't delete from groupname table: ". $sth->errstr;
- }
- $dbh->disconnect;
-}
-
-sub sqlradius_rename { #subroutine, not method
- my $dbh = sqlradius_connect(shift, shift, shift);
- my($new_username, $old_username) = @_;
- foreach my $table (qw(radreply radcheck usergroup )) {
- my $sth = $dbh->prepare("UPDATE $table SET Username = ? WHERE UserName = ?")
- or die $dbh->errstr;
- $sth->execute($new_username, $old_username)
- or die "can't update $table: ". $sth->errstr;
- }
- $dbh->disconnect;
-}
-
-sub sqlradius_attrib_delete { #subroutine, not method
- my $dbh = sqlradius_connect(shift, shift, shift);
- my( $table, $username, @attrib ) = @_;
-
- foreach my $attribute ( @attrib ) {
- my $sth = $dbh->prepare(
- "DELETE FROM rad$table WHERE UserName = ? AND Attribute = ?" )
- or die $dbh->errstr;
- $sth->execute($username,$attribute)
- or die "can't delete from rad$table table: ". $sth->errstr;
- }
- $dbh->disconnect;
-}
-
-sub sqlradius_delete { #subroutine, not method
- my $dbh = sqlradius_connect(shift, shift, shift);
- my $username = shift;
-
- foreach my $table (qw( radcheck radreply usergroup )) {
- my $sth = $dbh->prepare( "DELETE FROM $table WHERE UserName = ?" );
- $sth->execute($username)
- or die "can't delete from $table table: ". $sth->errstr;
- }
- $dbh->disconnect;
-}
-
-sub sqlradius_connect {
- #my($datasrc, $username, $password) = @_;
- #DBI->connect($datasrc, $username, $password) or die $DBI::errstr;
- DBI->connect(@_) or die $DBI::errstr;
-}
-
-1;
-
diff --git a/FS/FS/part_export/sqlradius_withdomain.pm b/FS/FS/part_export/sqlradius_withdomain.pm
deleted file mode 100644
index 6130e5e..0000000
--- a/FS/FS/part_export/sqlradius_withdomain.pm
+++ /dev/null
@@ -1,28 +0,0 @@
-package FS::part_export::sqlradius_withdomain;
-
-use vars qw(@ISA %info);
-use Tie::IxHash;
-use FS::part_export::sqlradius;
-
-tie my %options, 'Tie::IxHash', %FS::part_export::sqlradius::options;
-
-%info = (
- 'svc' => 'svc_acct',
- 'desc' => 'Real-time export to SQL-backed RADIUS (FreeRADIUS, ICRADIUS, Radiator) with realms',
- 'options' => \%options,
- 'nodomain' => '',
- 'notes' => $FS::part_export::sqlradius::notes1.
- 'This export exports domains to RADIUS realms (see also '.
- 'sqlradius). '.
- $FS::part_export::sqlradius::notes2
-);
-
-@ISA = qw(FS::part_export::sqlradius);
-
-sub export_username {
- my($self, $svc_acct) = (shift, shift);
- $svc_acct->email;
-}
-
-1;
-
diff --git a/FS/FS/part_export/sysvshell.pm b/FS/FS/part_export/sysvshell.pm
deleted file mode 100644
index 244c3bf..0000000
--- a/FS/FS/part_export/sysvshell.pm
+++ /dev/null
@@ -1,25 +0,0 @@
-package FS::part_export::sysvshell;
-
-use vars qw(@ISA %info);
-use Tie::IxHash;
-use FS::part_export::passwdfile;
-
-@ISA = qw(FS::part_export::passwdfile);
-
-tie my %options, 'Tie::IxHash', %FS::part_export::passwdfile::options;
-
-%info = (
- 'svc' => 'svc_acct',
- 'desc' =>
- 'Batch export of /etc/passwd and /etc/shadow files (Linux, Solaris)',
- 'options' => \%options,
- 'nodomain' => 'Y',
- 'notes' => <<'END'
-MD5 crypt requires installation of
-<a href="http://search.cpan.org/dist/Crypt-PasswdMD5">Crypt::PasswdMD5</a>
-from CPAN. Run bin/sysvshell.export to export the files.
-END
-);
-
-1;
-
diff --git a/FS/FS/part_export/textradius.pm b/FS/FS/part_export/textradius.pm
deleted file mode 100644
index 65936ea..0000000
--- a/FS/FS/part_export/textradius.pm
+++ /dev/null
@@ -1,191 +0,0 @@
-package FS::part_export::textradius;
-
-use vars qw(@ISA %info $prefix);
-use Fcntl qw(:flock);
-use Tie::IxHash;
-use FS::UID qw(datasrc);
-use FS::part_export;
-
-@ISA = qw(FS::part_export);
-
-tie my %options, 'Tie::IxHash',
- 'user' => { label=>'Remote username', default=>'root' },
- 'users' => { label=>'users file location', default=>'/etc/raddb/users' },
-;
-
-%info = (
- 'svc' => 'svc_acct',
- 'desc' =>
- 'Real-time export to a text /etc/raddb/users file (Livingston, Cistron)',
- 'options' => \%options,
- 'notes' => <<'END'
-This will edit a text RADIUS users file in place on a remote server.
-Requires installation of
-<a href="http://search.cpan.org/dist/RADIUS-UserFile">RADIUS::UserFile</a>
-from CPAN. If using RADIUS::UserFile 1.01, make sure to apply
-<a href="http://rt.cpan.org/NoAuth/Bug.html?id=1210">this patch</a>. Also
-make sure <a href="http://rsync.samba.org/">rsync</a> is installed on the
-remote machine, and <a href="../docs/ssh.html">SSH is setup for unattended
-operation</a>.
-END
-);
-
-$prefix = "/usr/local/etc/freeside/export.";
-
-sub rebless { shift; }
-
-sub _export_insert {
- my($self, $svc_acct) = (shift, shift);
- $err_or_queue = $self->textradius_queue( $svc_acct->svcnum, 'insert',
- $svc_acct->username, $svc_acct->radius_check, '-', $svc_acct->radius_reply);
- ref($err_or_queue) ? '' : $err_or_queue;
-}
-
-sub _export_replace {
- my( $self, $new, $old ) = (shift, shift, shift);
- return "can't (yet?) change username with textradius"
- if $old->username ne $new->username;
- #return '' unless $old->_password ne $new->_password;
- $err_or_queue = $self->textradius_queue( $new->svcnum, 'insert',
- $new->username, $new->radius_check, '-', $new->radius_reply);
- ref($err_or_queue) ? '' : $err_or_queue;
-}
-
-sub _export_delete {
- my( $self, $svc_acct ) = (shift, shift);
- $err_or_queue = $self->textradius_queue( $svc_acct->svcnum, 'delete',
- $svc_acct->username );
- ref($err_or_queue) ? '' : $err_or_queue;
-}
-
-#a good idea to queue anything that could fail or take any time
-sub textradius_queue {
- my( $self, $svcnum, $method ) = (shift, shift, shift);
- my $queue = new FS::queue {
- 'svcnum' => $svcnum,
- 'job' => "FS::part_export::textradius::textradius_$method",
- };
- $queue->insert(
- $self->option('user')||'root',
- $self->machine,
- $self->option('users'),
- @_,
- ) or $queue;
-}
-
-sub textradius_insert { #subroutine, not method
- my( $user, $host, $users, $username, @attributes ) = @_;
-
- #silly arg processing
- my($att, @check);
- push @check, $att while @attributes && ($att=shift @attributes) ne '-';
- my %check = @check;
- my %reply = @attributes;
-
- my $file = textradius_download($user, $host, $users);
-
- eval "use RADIUS::UserFile;";
- die $@ if $@;
-
- my $userfile = new RADIUS::UserFile(
- File => $file,
- Who => [ $username ],
- Check_Items => [ keys %check ],
- ) or die "error parsing $file";
-
- $userfile->remove($username);
- $userfile->add(
- Who => $username,
- Attributes => { %check, %reply },
- Comment => 'user added by Freeside',
- ) or die "error adding to $file";
-
- $userfile->update( Who => [ $username ] )
- or die "error updating $file";
-
- textradius_upload($user, $host, $users);
-
-}
-
-sub textradius_delete { #subroutine, not method
- my( $user, $host, $users, $username ) = @_;
-
- my $file = textradius_download($user, $host, $users);
-
- eval "use RADIUS::UserFile;";
- die $@ if $@;
-
- my $userfile = new RADIUS::UserFile(
- File => $file,
- Who => [ $username ],
- ) or die "error parsing $file";
-
- $userfile->remove($username);
-
- $userfile->update( Who => [ $username ] )
- or die "error updating $file";
-
- textradius_upload($user, $host, $users);
-}
-
-sub textradius_download {
- my( $user, $host, $users ) = @_;
-
- my $dir = $prefix. datasrc;
- mkdir $dir, 0700 or die $! unless -d $dir;
- $dir .= "/$host";
- mkdir $dir, 0700 or die $! unless -d $dir;
-
- my $dest = "$dir/users";
-
- eval "use File::Rsync;";
- die $@ if $@;
- my $rsync = File::Rsync->new({ rsh => 'ssh' });
-
- open(LOCK, "+>>$dest.lock")
- and flock(LOCK,LOCK_EX)
- or die "can't open $dest.lock: $!";
-
- $rsync->exec( {
- src => "$user\@$host:$users",
- dest => $dest,
- } ); # true/false return value from exec is not working, alas
- if ( $rsync->err ) {
- die "error downloading $user\@$host:$users : ".
- 'exit status: '. $rsync->status. ', '.
- 'STDERR: '. join(" / ", $rsync->err). ', '.
- 'STDOUT: '. join(" / ", $rsync->out);
- }
-
- $dest;
-}
-
-sub textradius_upload {
- my( $user, $host, $users ) = @_;
-
- my $dir = $prefix. datasrc. "/$host";
-
- eval "use File::Rsync;";
- die $@ if $@;
- my $rsync = File::Rsync->new({
- rsh => 'ssh',
- #dry_run => 1,
- });
- $rsync->exec( {
- src => "$dir/users",
- dest => "$user\@$host:$users",
- } ); # true/false return value from exec is not working, alas
- if ( $rsync->err ) {
- die "error uploading to $user\@$host:$users : ".
- 'exit status: '. $rsync->status. ', '.
- 'STDERR: '. join(" / ", $rsync->err). ', '.
- 'STDOUT: '. join(" / ", $rsync->out);
- }
-
- flock(LOCK,LOCK_UN);
- close LOCK;
-
-}
-
-1;
-
diff --git a/FS/FS/part_export/vpopmail.pm b/FS/FS/part_export/vpopmail.pm
deleted file mode 100644
index 62fa8ba..0000000
--- a/FS/FS/part_export/vpopmail.pm
+++ /dev/null
@@ -1,252 +0,0 @@
-package FS::part_export::vpopmail;
-
-use vars qw(@ISA %info @saltset $exportdir);
-use Fcntl qw(:flock);
-use Tie::IxHash;
-use File::Path;
-use FS::UID qw( datasrc );
-use FS::part_export;
-
-@ISA = qw(FS::part_export);
-
-tie my %options, 'Tie::IxHash',
- #'machine' => { label=>'vpopmail machine', },
- 'dir' => { label=>'directory', }, # ?more info? default?
- 'uid' => { label=>'vpopmail uid' },
- 'gid' => { label=>'vpopmail gid' },
- 'restart' => { label=> 'vpopmail restart command',
- default=> 'cd /home/vpopmail/domains; for domain in *; do /home/vpopmail/bin/vmkpasswd $domain; done; /var/qmail/bin/qmail-newu; killall -HUP qmail-send',
- },
-;
-
-%info = (
- 'svc' => 'svc_acct',
- 'desc' => 'Real-time export to vpopmail text files',
- 'options' => \%options,
- 'notes' => <<'END'
-Real time export to <a href="http://inter7.com/vpopmail/">vpopmail</a> text
-files. <a href="http://search.cpan.org/dist/File-Rsync">File::Rsync</a>
-must be installed, and you will need to
-<a href="../docs/ssh.html">setup SSH for unattended operation</a>
-to <b>vpopmail</b>@<i>export.host</i>. See shellcommands_withdomain for an
-export that uses vpopmail commands instead.
-END
-);
-
-@saltset = ( 'a'..'z' , 'A'..'Z' , '0'..'9' , '.' , '/' );
-
-sub rebless { shift; }
-
-sub _export_insert {
- my($self, $svc_acct) = (shift, shift);
- $self->vpopmail_queue( $svc_acct->svcnum, 'insert',
- $svc_acct->username,
- crypt($svc_acct->_password,$saltset[int(rand(64))].$saltset[int(rand(64))]),
- $svc_acct->domain,
- $svc_acct->quota,
- $svc_acct->finger,
- );
-}
-
-sub _export_replace {
- my( $self, $new, $old ) = (shift, shift, shift);
-
- my $cpassword = crypt(
- $new->_password, $saltset[int(rand(64))].$saltset[int(rand(64))]
- );
-
- return "can't change username with vpopmail"
- if $old->username ne $new->username;
-
- #no.... if mail can't be preserved, better to disallow username changes
- #if ($old->username ne $new->username || $old->domain ne $new->domain ) {
- # vpopmail_queue( $svc_acct->svcnum, 'delete',
- # $old->username, $old->domain
- # );
- # vpopmail_queue( $svc_acct->svcnum, 'insert',
- # $new->username,
- # $cpassword,
- # $new->domain,
- # );
-
- return '' unless $old->_password ne $new->_password;
-
- $self->vpopmail_queue( $new->svcnum, 'replace',
- $new->username, $cpassword, $new->domain, $new->quota, $new->finger );
-}
-
-sub _export_delete {
- my( $self, $svc_acct ) = (shift, shift);
- $self->vpopmail_queue( $svc_acct->svcnum, 'delete',
- $svc_acct->username, $svc_acct->domain );
-}
-
-#a good idea to queue anything that could fail or take any time
-sub vpopmail_queue {
- my( $self, $svcnum, $method ) = (shift, shift, shift);
-
- my $exportdir = "/usr/local/etc/freeside/export." . datasrc;
- mkdir $exportdir, 0700 or die $! unless -d $exportdir;
- $exportdir .= "/vpopmail";
- mkdir $exportdir, 0700 or die $! unless -d $exportdir;
- $exportdir .= '/'. $self->machine;
- mkdir $exportdir, 0700 or die $! unless -d $exportdir;
- mkdir "$exportdir/domains", 0700 or die $! unless -d "$exportdir/domains";
-
- my $queue = new FS::queue {
- 'svcnum' => $svcnum,
- 'job' => "FS::part_export::vpopmail::vpopmail_$method",
- };
- $queue->insert(
- $exportdir,
- $self->machine,
- $self->option('dir'),
- $self->option('uid'),
- $self->option('gid'),
- $self->option('restart'),
- @_
- );
-}
-
-sub vpopmail_insert { #subroutine, not method
- my( $exportdir, $machine, $dir, $uid, $gid, $restart ) = splice @_,0,6;
- my( $username, $password, $domain, $quota, $finger ) = @_;
-
- mkdir "$exportdir/domains/$domain", 0700 or die $!
- unless -d "$exportdir/domains/$domain";
-
- (open(VPASSWD, ">>$exportdir/domains/$domain/vpasswd")
- and flock(VPASSWD,LOCK_EX)
- ) or die "can't open vpasswd file for $username\@$domain: ".
- "$exportdir/domains/$domain/vpasswd: $!";
- print VPASSWD join(":",
- $username,
- $password,
- '1',
- '0',
- $finger,
- "$dir/domains/$domain/$username",
- $quota ? $quota.'S' : 'NOQUOTA',
- ), "\n";
-
- flock(VPASSWD,LOCK_UN);
- close(VPASSWD);
-
- for my $mkdir (
- grep { ! -d $_ } map { "$exportdir/domains/$domain/$username$_" }
- ( '', qw( /Maildir /Maildir/cur /Maildir/new /Maildir/tmp ) )
- ) {
- mkdir $mkdir, 0700 or die "can't mkdir $mkdir: $!";
- }
-
- vpopmail_sync( $exportdir, $machine, $dir, $uid, $gid, $restart );
-
-}
-
-sub vpopmail_replace { #subroutine, not method
- my( $exportdir, $machine, $dir, $uid, $gid, $restart ) = splice @_,0,6;
- my( $username, $password, $domain, $quota, $finger ) = @_;
-
- (open(VPASSWD, "$exportdir/domains/$domain/vpasswd")
- and flock(VPASSWD,LOCK_EX)
- ) or die "can't open $exportdir/domains/$domain/vpasswd: $!";
-
- open(VPASSWDTMP, ">$exportdir/domains/$domain/vpasswd.tmp")
- or die "Can't open $exportdir/domains/$domain/vpasswd.tmp: $!";
-
- while (<VPASSWD>) {
- my ($mailbox, $pw, $vuid, $vgid, $vfinger, $vdir, $vquota, @rest) =
- split(':', $_);
- if ( $username ne $mailbox ) {
- print VPASSWDTMP $_;
- next
- }
- print VPASSWDTMP join (':',
- $mailbox,
- $password,
- '1',
- '0',
- $finger,
- "$dir/domains/$domain/$username", #$vdir
- $quota ? $quota.'S' : 'NOQUOTA',
- ), "\n";
- }
-
- close(VPASSWDTMP);
-
- rename "$exportdir/domains/$domain/vpasswd.tmp", "$exportdir/domains/$domain/vpasswd"
- or die "Can't rename $exportdir/domains/$domain/vpasswd.tmp: $!";
-
- flock(VPASSWD,LOCK_UN);
- close(VPASSWD);
-
- vpopmail_sync( $exportdir, $machine, $dir, $uid, $gid, $restart );
-
-}
-
-sub vpopmail_delete { #subroutine, not method
- my( $exportdir, $machine, $dir, $uid, $gid, $restart ) = splice @_,0,6;
- my( $username, $domain ) = @_;
-
- (open(VPASSWD, "$exportdir/domains/$domain/vpasswd")
- and flock(VPASSWD,LOCK_EX)
- ) or die "can't open $exportdir/domains/$domain/vpasswd: $!";
-
- open(VPASSWDTMP, ">$exportdir/domains/$domain/vpasswd.tmp")
- or die "Can't open $exportdir/domains/$domain/vpasswd.tmp: $!";
-
- while (<VPASSWD>) {
- my ($mailbox, $rest) = split(':', $_);
- print VPASSWDTMP $_ unless $username eq $mailbox;
- }
-
- close(VPASSWDTMP);
-
- rename "$exportdir/domains/$domain/vpasswd.tmp",
- "$exportdir/domains/$domain/vpasswd"
- or die "Can't rename $exportdir/domains/$domain/vpasswd.tmp: $!";
-
- flock(VPASSWD,LOCK_UN);
- close(VPASSWD);
-
- rmtree "$exportdir/domains/$domain/$username"
- or die "can't rmtree $exportdir/domains/$domain/$username: $!";
-
- vpopmail_sync( $exportdir, $machine, $dir, $uid, $gid, $restart );
-}
-
-sub vpopmail_sync {
- my( $exportdir, $machine, $dir, $uid, $gid, $restart ) = splice @_,0,6;
-
- chdir $exportdir;
-# my @args = ( $rsync, "-rlpt", "-e", $ssh, "domains/",
-# "vpopmail\@$machine:$dir/domains/" );
-# system {$args[0]} @args;
-
- eval "use File::Rsync;";
- die $@ if $@;
-
- my $rsync = File::Rsync->new({ rsh => 'ssh' });
-
- $rsync->exec( {
- recursive => 1,
- perms => 1,
- times => 1,
- src => "$exportdir/domains/",
- dest => "vpopmail\@$machine:$dir/domains/",
- } ); # true/false return value from exec is not working, alas
- if ( $rsync->err ) {
- die "error uploading to vpopmail\@$machine:$dir/domains/ : ".
- 'exit status: '. $rsync->status. ', '.
- 'STDERR: '. join(" / ", $rsync->err). ', '.
- 'STDOUT: '. join(" / ", $rsync->out);
- }
-
- eval "use Net::SSH qw(ssh);";
- die $@ if $@;
-
- ssh("vpopmail\@$machine", $restart) if $restart;
-}
-
-1;
-
diff --git a/FS/FS/part_export/www_shellcommands.pm b/FS/FS/part_export/www_shellcommands.pm
deleted file mode 100644
index 6847f64..0000000
--- a/FS/FS/part_export/www_shellcommands.pm
+++ /dev/null
@@ -1,158 +0,0 @@
-package FS::part_export::www_shellcommands;
-
-use strict;
-use vars qw(@ISA %info);
-use Tie::IxHash;
-use FS::part_export;
-
-@ISA = qw(FS::part_export);
-
-tie my %options, 'Tie::IxHash',
- 'user' => { label=>'Remote username', default=>'root' },
- 'useradd' => { label=>'Insert command',
- default=>'mkdir /var/www/$zone; chown $username /var/www/$zone; ln -s /var/www/$zone $homedir/$zone',
- },
- 'userdel' => { label=>'Delete command',
- default=>'[ -n &quot;$zone&quot; ] && rm -rf /var/www/$zone; rm $homedir/$zone',
- },
- 'usermod' => { label=>'Modify command',
- default=>'[ -n &quot;$old_zone&quot; ] && rm $old_homedir/$old_zone; [ &quot;$old_zone&quot; != &quot;$new_zone&quot; -a -n &quot;$new_zone&quot; ] && mv /var/www/$old_zone /var/www/$new_zone; [ &quot;$old_username&quot; != &quot;$new_username&quot; ] && chown -R $new_username /var/www/$new_zone; ln -s /var/www/$new_zone $new_homedir/$new_zone',
- },
-;
-
-%info = (
- 'svc' => 'svc_www',
- 'desc' => 'Run remote commands via SSH, for virtual web sites.',
- 'options' => \%options,
- 'notes' => <<'END'
-Run remote commands via SSH, for virtual web sites. You will need to
-<a href="../docs/ssh.html">setup SSH for unattended operation</a>.
-<BR><BR>Use these buttons for some useful presets:
-<UL>
- <LI>
- <INPUT TYPE="button" VALUE="Maintain directories" onClick='
- this.form.user.value = "root";
- this.form.useradd.value = "mkdir /var/www/$zone; chown $username /var/www/$zone; ln -s /var/www/$zone $homedir/$zone";
- this.form.userdel.value = "[ -n &quot;$zone&quot; ] && rm -rf /var/www/$zone; rm $homedir/$zone";
- this.form.usermod.value = "[ -n &quot;$old_zone&quot; ] && rm $old_homedir/$old_zone; [ &quot;$old_zone&quot; != &quot;$new_zone&quot; -a -n &quot;$new_zone&quot; ] && mv /var/www/$old_zone /var/www/$new_zone; [ &quot;$old_username&quot; != &quot;$new_username&quot; ] && chown -R $new_username /var/www/$new_zone; ln -s /var/www/$new_zone $new_homedir/$new_zone";
- '>
- <LI>
- <INPUT TYPE="button" VALUE="ISPMan CLI" onClick='
- this.form.user.value = "root";
- this.form.useradd.value = "/usr/local/ispman/bin/ispman.addvhost -d $domain $bare_zone";
- this.form.userdel.value = "/usr/local/ispman/bin/ispman.deletevhost -d $domain $bare_zone";
- this.form.usermod.value = "";
- '>
-</UL>
-The following variables are available for interpolation (prefixed with
-<code>new_</code> or <code>old_</code> for replace operations):
-<UL>
- <LI><code>$zone</code> - fully-qualified zone of this virtual host
- <LI><code>$bare_zone</code> - just the zone of this virtual host, without the domain portion
- <LI><code>$domain</code> - base domain
- <LI><code>$username</code>
- <LI><code>$homedir</code>
- <LI>All other fields in <a href="../docs/schema.html#svc_www">svc_www</a>
- are also available.
-</UL>
-END
-);
-
-
-sub rebless { shift; }
-
-sub _export_insert {
- my($self) = shift;
- $self->_export_command('useradd', @_);
-}
-
-sub _export_delete {
- my($self) = shift;
- $self->_export_command('userdel', @_);
-}
-
-sub _export_command {
- my ( $self, $action, $svc_www) = (shift, shift, shift);
- my $command = $self->option($action);
-
- #set variable for the command
- no strict 'vars';
- {
- no strict 'refs';
- ${$_} = $svc_www->getfield($_) foreach $svc_www->fields;
- }
- my $domain_record = $svc_www->domain_record; # or die ?
- my $zone = $domain_record->zone; # or die ?
- my $domain = $domain_record->svc_domain->domain;
- ( my $bare_zone = $zone ) =~ s/\.$domain$//;
- my $svc_acct = $svc_www->svc_acct; # or die ?
- my $username = $svc_acct->username;
- my $homedir = $svc_acct->dir; # or die ?
-
- #done setting variables for the command
-
- $self->shellcommands_queue( $svc_www->svcnum,
- user => $self->option('user')||'root',
- host => $self->machine,
- command => eval(qq("$command")),
- );
-}
-
-sub _export_replace {
- my($self, $new, $old ) = (shift, shift, shift);
- my $command = $self->option('usermod');
-
- #set variable for the command
- no strict 'vars';
- {
- no strict 'refs';
- ${"old_$_"} = $old->getfield($_) foreach $old->fields;
- ${"new_$_"} = $new->getfield($_) foreach $new->fields;
- }
- my $old_domain_record = $old->domain_record; # or die ?
- my $old_zone = $old_domain_record->zone; # or die ?
- my $old_domain = $old_domain_record->svc_domain->domain;
- ( my $old_bare_zone = $old_zone ) =~ s/\.$old_domain$//;
- my $old_svc_acct = $old->svc_acct; # or die ?
- my $old_username = $old_svc_acct->username;
- my $old_homedir = $old_svc_acct->dir; # or die ?
-
- my $new_domain_record = $new->domain_record; # or die ?
- my $new_zone = $new_domain_record->zone; # or die ?
- my $new_domain = $new_domain_record->svc_domain->domain;
- ( my $new_bare_zone = $new_zone ) =~ s/\.$new_domain$//;
- my $new_svc_acct = $new->svc_acct; # or die ?
- my $new_username = $new_svc_acct->username;
- my $new_homedir = $new_svc_acct->dir; # or die ?
-
- #done setting variables for the command
-
- $self->shellcommands_queue( $new->svcnum,
- user => $self->option('user')||'root',
- host => $self->machine,
- command => eval(qq("$command")),
- );
-}
-
-#a good idea to queue anything that could fail or take any time
-sub shellcommands_queue {
- my( $self, $svcnum ) = (shift, shift);
- my $queue = new FS::queue {
- 'svcnum' => $svcnum,
- 'job' => "FS::part_export::www_shellcommands::ssh_cmd",
- };
- $queue->insert( @_ );
-}
-
-sub ssh_cmd { #subroutine, not method
- use Net::SSH '0.08';
- &Net::SSH::ssh_cmd( { @_ } );
-}
-
-#sub shellcommands_insert { #subroutine, not method
-#}
-#sub shellcommands_replace { #subroutine, not method
-#}
-#sub shellcommands_delete { #subroutine, not method
-#}
-
diff --git a/FS/FS/part_export_option.pm b/FS/FS/part_export_option.pm
deleted file mode 100644
index 33b5e5a..0000000
--- a/FS/FS/part_export_option.pm
+++ /dev/null
@@ -1,134 +0,0 @@
-package FS::part_export_option;
-
-use strict;
-use vars qw( @ISA );
-use FS::Record qw( qsearch qsearchs );
-use FS::part_export;
-
-@ISA = qw(FS::Record);
-
-=head1 NAME
-
-FS::part_export_option - Object methods for part_export_option records
-
-=head1 SYNOPSIS
-
- use FS::part_export_option;
-
- $record = new FS::part_export_option \%hash;
- $record = new FS::part_export_option { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
-=head1 DESCRIPTION
-
-An FS::part_export_option object represents an export option.
-FS::part_export_option inherits from FS::Record. The following fields are
-currently supported:
-
-=over 4
-
-=item optionnum - primary key
-
-=item exportnum - export (see L<FS::part_export>)
-
-=item optionname - option name
-
-=item optionvalue - option value
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new export option. To add the export option 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 { 'part_export_option'; }
-
-=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 export option. 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;
-
- my $error =
- $self->ut_numbern('optionnum')
- || $self->ut_number('exportnum')
- || $self->ut_alpha('optionname')
- || $self->ut_anything('optionvalue')
- ;
- return $error if $error;
-
- return "Unknown exportnum: ". $self->exportnum
- unless qsearchs('part_export', { 'exportnum' => $self->exportnum } );
-
- #check options & values?
-
- $self->SUPER::check;
-}
-
-=back
-
-=head1 BUGS
-
-Possibly.
-
-=head1 SEE ALSO
-
-L<FS::part_export>, L<FS::Record>, schema.html from the base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/part_pkg.pm b/FS/FS/part_pkg.pm
deleted file mode 100644
index dcce66b..0000000
--- a/FS/FS/part_pkg.pm
+++ /dev/null
@@ -1,333 +0,0 @@
-package FS::part_pkg;
-
-use strict;
-use vars qw( @ISA );
-use FS::Record qw( qsearch dbh dbdef );
-use FS::pkg_svc;
-use FS::agent_type;
-use FS::type_pkgs;
-use FS::Conf;
-
-@ISA = qw( FS::Record );
-
-=head1 NAME
-
-FS::part_pkg - Object methods for part_pkg objects
-
-=head1 SYNOPSIS
-
- use FS::part_pkg;
-
- $record = new FS::part_pkg \%hash
- $record = new FS::part_pkg { 'column' => 'value' };
-
- $custom_record = $template_record->clone;
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
- @pkg_svc = $record->pkg_svc;
-
- $svcnum = $record->svcpart;
- $svcnum = $record->svcpart( 'svc_acct' );
-
-=head1 DESCRIPTION
-
-An FS::part_pkg object represents a billing item definition. FS::part_pkg
-inherits from FS::Record. The following fields are currently supported:
-
-=over 4
-
-=item pkgpart - primary key (assigned automatically for new billing item definitions)
-
-=item pkg - Text name of this billing item definition (customer-viewable)
-
-=item comment - Text name of this billing item definition (non-customer-viewable)
-
-=item setup - Setup fee expression
-
-=item freq - Frequency of recurring fee
-
-=item recur - Recurring fee expression
-
-=item setuptax - Setup fee tax exempt flag, empty or `Y'
-
-=item recurtax - Recurring fee tax exempt flag, empty or `Y'
-
-=item taxclass - Tax class flag
-
-=item plan - Price plan
-
-=item plandata - Price plan data
-
-=item disabled - Disabled flag, empty or `Y'
-
-=back
-
-setup and recur are evaluated as Safe perl expressions. You can use numbers
-just as you would normally. More advanced semantics are not yet defined.
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new billing item definition. To add the billing item definition to
-the database, see L<"insert">.
-
-=cut
-
-sub table { 'part_pkg'; }
-
-=item clone
-
-An alternate constructor. Creates a new billing item definition by duplicating
-an existing definition. A new pkgpart is assigned and `(CUSTOM) ' is prepended
-to the comment field. To add the billing item definition to the database, see
-L<"insert">.
-
-=cut
-
-sub clone {
- my $self = shift;
- my $class = ref($self);
- my %hash = $self->hash;
- $hash{'pkgpart'} = '';
- $hash{'comment'} = "(CUSTOM) ". $hash{'comment'}
- unless $hash{'comment'} =~ /^\(CUSTOM\) /;
- #new FS::part_pkg ( \%hash ); # ?
- new $class ( \%hash ); # ?
-}
-
-=item insert
-
-Adds this billing item definition to the database. If there is an error,
-returns the error, otherwise returns false.
-
-=cut
-
-sub insert {
- my $self = shift;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- my $error = $self->SUPER::insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- my $conf = new FS::Conf;
-
- if ( $conf->exists('agent_defaultpkg') ) {
- foreach my $agent_type ( qsearch('agent_type', {} ) ) {
- my $type_pkgs = new FS::type_pkgs({
- 'typenum' => $agent_type->typenum,
- 'pkgpart' => $self->pkgpart,
- });
- my $error = $type_pkgs->insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
-
- '';
-}
-
-=item delete
-
-Currently unimplemented.
-
-=cut
-
-sub delete {
- return "Can't (yet?) delete package definitions.";
-# check & make sure the pkgpart isn't in cust_pkg or type_pkgs?
-}
-
-=item replace OLD_RECORD
-
-Replaces OLD_RECORD with this one in the database. If there is an error,
-returns the error, otherwise returns false.
-
-=item check
-
-Checks all fields to make sure this is a valid billing item definition. If
-there is an error, returns the error, otherwise returns false. Called by the
-insert and replace methods.
-
-=cut
-
-sub check {
- my $self = shift;
-
- for (qw(setup recur)) { $self->set($_=>0) if $self->get($_) =~ /^\s*$/; }
-
- my $conf = new FS::Conf;
- if ( $conf->exists('safe-part_pkg') ) {
-
- my $error = $self->ut_anything('setup')
- || $self->ut_anything('recur');
- return $error if $error;
-
- my $s = $self->setup;
-
- $s =~ /^\s*\d*\.?\d*\s*$/
-
- or $s =~ /^my \$d = \$cust_pkg->bill || \$time; \$d += 86400 \* \s*\d+\s*; \$cust_pkg->bill\(\$d\); \$cust_pkg_mod_flag=1; \s*\d*\.?\d*\s*$/
-
- or do {
- #log!
- return "illegal setup: $s";
- };
-
- my $r = $self->recur;
-
- $r =~ /^\s*\d*\.?\d*\s*$/
-
- #or $r =~ /^\$sdate += 86400 \* \s*\d+\s*; \s*\d*\.?\d*\s*$/
-
- or $r =~ /^my \$mnow = \$sdate; my \(\$sec,\$min,\$hour,\$mday,\$mon,\$year\) = \(localtime\(\$sdate\) \)\[0,1,2,3,4,5\]; my \$mstart = timelocal\(0,0,0,1,\$mon,\$year\); my \$mend = timelocal\(0,0,0,1, \$mon == 11 \? 0 : \$mon\+1, \$year\+\(\$mon==11\)\); \$sdate = \$mstart; \( \$part_pkg->freq \- 1 \) \* \d*\.?\d* \/ \$part_pkg\-\>freq \+ \d*\.?\d* \/ \$part_pkg\-\>freq \* \(\$mend\-\$mnow\) \/ \(\$mend\-\$mstart\) ;\s*$/
-
- or $r =~ /^my \$mnow = \$sdate; my \(\$sec,\$min,\$hour,\$mday,\$mon,\$year\) = \(localtime\(\$sdate\) \)\[0,1,2,3,4,5\]; \$sdate = timelocal\(0,0,0,1,\$mon,\$year\); \s*\d*\.?\d*\s*;\s*$/
-
- or $r =~ /^my \$error = \$cust_pkg\->cust_main\->credit\( \s*\d*\.?\d*\s* \* scalar\(\$cust_pkg\->cust_main\->referral_cust_main_ncancelled\(\s*\d+\s*\)\), "commission" \); die \$error if \$error; \s*\d*\.?\d*\s*;\s*$/
-
- or $r =~ /^my \$error = \$cust_pkg\->cust_main\->credit\( \s*\d*\.?\d*\s* \* scalar\(\$cust_pkg\->cust_main->referral_cust_pkg\(\s*\d+\s*\)\), "commission" \); die \$error if \$error; \s*\d*\.?\d*\s*;\s*$/
-
- or $r =~ /^my \$error = \$cust_pkg\->cust_main\->credit\( \s*\d*\.?\d*\s* \* scalar\( grep \{ my \$pkgpart = \$_\->pkgpart; grep \{ \$_ == \$pkgpart \} \(\s*(\s*\d+,\s*)*\s*\) \} \$cust_pkg\->cust_main->referral_cust_pkg\(\s*\d+\s*\)\), "commission" \); die \$error if \$error; \s*\d*\.?\d*\s*;\s*$/
-
- or $r =~ /^my \$hours = \$cust_pkg\->seconds_since\(\$cust_pkg\->bill \|\| 0\) \/ 3600 \- \s*\d*\.?\d*\s*; \$hours = 0 if \$hours < 0; \s*\d*\.?\d*\s* \+ \s*\d*\.?\d*\s* \* \$hours;\s*$/
-
- or $r =~ /^my \$min = \$cust_pkg\->seconds_since\(\$cust_pkg\->bill \|\| 0\) \/ 60 \- \s*\d*\.?\d*\s*; \$min = 0 if \$min < 0; \s*\d*\.?\d*\s* \+ \s*\d*\.?\d*\s* \* \$min;\s*$/
-
- or $r =~ /^my \$last_bill = \$cust_pkg\->last_bill; my \$hours = \$cust_pkg\->seconds_since_sqlradacct\(\$last_bill, \$sdate \) \/ 3600 - \s*\d\.?\d*\s*; \$hours = 0 if \$hours < 0; my \$input = \$cust_pkg\->attribute_since_sqlradacct\(\$last_bill, \$sdate, "AcctInputOctets" \) \/ 1048576; my \$output = \$cust_pkg\->attribute_since_sqlradacct\(\$last_bill, \$sdate, "AcctOutputOctets" \) \/ 1048576; my \$total = \$input \+ \$output \- \s*\d\.?\d*\s*; \$total = 0 if \$total < 0; my \$input = \$input - \s*\d\.?\d*\s*; \$input = 0 if \$input < 0; my \$output = \$output - \s*\d\.?\d*\s*; \$output = 0 if \$output < 0; \s*\d\.?\d*\s* \+ \s*\d\.?\d*\s* \* \$hours \+ \s*\d\.?\d*\s* \* \$input \+ \s*\d\.?\d*\s* \* \$output \+ \s*\d\.?\d*\s* \* \$total *;\s*$/
-
- or do {
- #log!
- return "illegal recur: $r";
- };
-
- }
-
- if ( $self->dbdef_table->column('freq')->type =~ /(int)/i ) {
- my $error = $self->ut_number('freq');
- return $error if $error;
- } else {
- $self->freq =~ /^(\d+[dw]?)$/
- or return "Illegal or empty freq: ". $self->freq;
- $self->freq($1);
- }
-
- $self->ut_numbern('pkgpart')
- || $self->ut_text('pkg')
- || $self->ut_text('comment')
- || $self->ut_anything('setup')
- || $self->ut_anything('recur')
- || $self->ut_alphan('plan')
- || $self->ut_anything('plandata')
- || $self->ut_enum('setuptax', [ '', 'Y' ] )
- || $self->ut_enum('recurtax', [ '', 'Y' ] )
- || $self->ut_textn('taxclass')
- || $self->ut_enum('disabled', [ '', 'Y' ] )
- || $self->SUPER::check
- ;
-}
-
-=item pkg_svc
-
-Returns all FS::pkg_svc objects (see L<FS::pkg_svc>) for this package
-definition (with non-zero quantity).
-
-=cut
-
-sub pkg_svc {
- my $self = shift;
- grep { $_->quantity } qsearch( 'pkg_svc', { 'pkgpart' => $self->pkgpart } );
-}
-
-=item svcpart [ SVCDB ]
-
-Returns the svcpart of the primary service definition (see L<FS::part_svc>)
-associated with this billing item definition (see L<FS::pkg_svc>). Returns
-false if there not a primary service definition or exactly one service
-definition with quantity 1, or if SVCDB is specified and does not match the
-svcdb of the service definition,
-
-=cut
-
-sub svcpart {
- my $self = shift;
- my $svcdb = scalar(@_) ? shift : '';
- my @svcdb_pkg_svc =
- grep { ( $svcdb eq $_->part_svc->svcdb || !$svcdb ) } $self->pkg_svc;
- my @pkg_svc = ();
- @pkg_svc = grep { $_->primary_svc =~ /^Y/i } @svcdb_pkg_svc
- if dbdef->table('pkg_svc')->column('primary_svc');
- @pkg_svc = grep {$_->quantity == 1 } @svcdb_pkg_svc
- unless @pkg_svc;
- return '' if scalar(@pkg_svc) != 1;
- $pkg_svc[0]->svcpart;
-}
-
-=item payby
-
-Returns a list of the acceptable payment types for this package. Eventually
-this should come out of a database table and be editable, but currently has the
-following logic instead;
-
-If the package has B<0> setup and B<0> recur, the single item B<BILL> is
-returned, otherwise, the single item B<CARD> is returned.
-
-(CHEK? LEC? Probably shouldn't accept those by default, prone to abuse)
-
-=cut
-
-sub payby {
- my $self = shift;
- #if ( $self->setup == 0 && $self->recur == 0 ) {
- if ( $self->setup =~ /^\s*0+(\.0*)?\s*$/
- && $self->recur =~ /^\s*0+(\.0*)?\s*$/ ) {
- ( 'BILL' );
- } else {
- ( 'CARD' );
- }
-}
-
-=back
-
-=head1 BUGS
-
-The delete method is unimplemented.
-
-setup and recur semantics are not yet defined (and are implemented in
-FS::cust_bill. hmm.).
-
-=head1 SEE ALSO
-
-L<FS::Record>, L<FS::cust_pkg>, L<FS::type_pkgs>, L<FS::pkg_svc>, L<Safe>.
-schema.html from the base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/part_pop_local.pm b/FS/FS/part_pop_local.pm
deleted file mode 100644
index f7d5eac..0000000
--- a/FS/FS/part_pop_local.pm
+++ /dev/null
@@ -1,117 +0,0 @@
-package FS::part_pop_local;
-
-use strict;
-use vars qw( @ISA );
-use FS::Record; # qw( qsearchs );
-
-@ISA = qw( FS::Record );
-
-=head1 NAME
-
-FS::part_pop_local - Object methods for part_pop_local records
-
-=head1 SYNOPSIS
-
- use FS::part_pop_local;
-
- $record = new FS::part_pop_local \%hash;
- $record = new FS::part_pop_local { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
-=head1 DESCRIPTION
-
-An FS::part_pop_local object represents a local call area. Each
-FS::part_pop_local record maps a NPA/NXX (area code and exchange) to the POP
-(see L<FS::svc_acct_pop>) which is a local call. FS::part_pop_local inherits
-from FS::Record. The following fields are currently supported:
-
-=over 4
-
-=item localnum - primary key (assigned automatically for new accounts)
-
-=item popnum - see L<FS::svc_acct_pop>
-
-=item city
-
-=item state
-
-=item npa - area code
-
-=item nxx - exchange
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new point of presence (if only it were that easy!). To add the
-point of presence to the database, see L<"insert">.
-
-=cut
-
-sub table { 'part_pop_local'; }
-
-=item insert
-
-Adds this point of presence to the database. If there is an error, returns the
-error, otherwise returns false.
-
-=item delete
-
-Removes this point of presence from the database.
-
-=item replace OLD_RECORD
-
-Replaces OLD_RECORD with this one in the database. If there is an error,
-returns the error, otherwise returns false.
-
-=item check
-
-Checks all fields to make sure this is a valid point of presence. If there is
-an error, returns the error, otherwise returns false. Called by the insert
-and replace methods.
-
-=cut
-
-sub check {
- my $self = shift;
-
- $self->ut_numbern('localnum')
- or $self->ut_numbern('popnum')
- or $self->ut_text('city')
- or $self->ut_text('state')
- or $self->ut_number('npa')
- or $self->ut_number('nxx')
- or $self->SUPER::check
- ;
-
-}
-
-=back
-
-=head1 VERSION
-
-$Id: part_pop_local.pm,v 1.2 2003-08-05 00:20:44 khoff Exp $
-
-=head1 BUGS
-
-US/CA-centric.
-
-=head1 SEE ALSO
-
-L<FS::Record>, L<FS::svc_acct_pop>, schema.html from the base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/part_referral.pm b/FS/FS/part_referral.pm
deleted file mode 100644
index c0858c0..0000000
--- a/FS/FS/part_referral.pm
+++ /dev/null
@@ -1,126 +0,0 @@
-package FS::part_referral;
-
-use strict;
-use vars qw( @ISA );
-use FS::Record;
-
-@ISA = qw( FS::Record );
-
-=head1 NAME
-
-FS::part_referral - Object methods for part_referral objects
-
-=head1 SYNOPSIS
-
- use FS::part_referral;
-
- $record = new FS::part_referral \%hash
- $record = new FS::part_referral { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
-=head1 DESCRIPTION
-
-An FS::part_referral represents a advertising source - where a customer heard
-of your services. This can be used to track the effectiveness of a particular
-piece of advertising, for example. FS::part_referral inherits from FS::Record.
-The following fields are currently supported:
-
-=over 4
-
-=item refnum - primary key (assigned automatically for new referrals)
-
-=item referral - Text name of this advertising source
-
-=item disabled - Disabled flag, empty or 'Y'
-
-=back
-
-=head1 NOTE
-
-These were called B<referrals> before version 1.4.0 - the name was changed
-so as not to be confused with the new customer-to-customer referrals.
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new advertising source. To add the referral to the database, see
-L<"insert">.
-
-=cut
-
-sub table { 'part_referral'; }
-
-=item insert
-
-Adds this advertising source to the database. If there is an error, returns
-the error, otherwise returns false.
-
-=item delete
-
-Currently unimplemented.
-
-=cut
-
-sub delete {
- my $self = shift;
- return "Can't (yet?) delete part_referral records";
- #need to make sure no customers have this referral!
-}
-
-=item replace OLD_RECORD
-
-Replaces OLD_RECORD with this one in the database. If there is an error,
-returns the error, otherwise returns false.
-
-=item check
-
-Checks all fields to make sure this is a valid advertising source. If there is
-an error, returns the error, otherwise returns false. Called by the insert and
-replace methods.
-
-=cut
-
-sub check {
- my $self = shift;
-
- my $error = $self->ut_numbern('refnum')
- || $self->ut_text('referral')
- ;
- return $error if $error;
-
- if ( $self->dbdef_table->column('disabled') ) {
- $error = $self->ut_enum('disabled', [ '', 'Y' ] );
- return $error if $error;
- }
-
- $self->SUPER::check;
-}
-
-=back
-
-=head1 BUGS
-
-The delete method is unimplemented.
-
-`Advertising source'. Yes, it's a sucky name. The only other ones I could
-come up with were "Marketing channel" and "Heard Abouts" and those are
-definately both worse.
-
-=head1 SEE ALSO
-
-L<FS::Record>, L<FS::cust_main>, schema.html from the base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/part_svc.pm b/FS/FS/part_svc.pm
deleted file mode 100644
index aacc3ab..0000000
--- a/FS/FS/part_svc.pm
+++ /dev/null
@@ -1,324 +0,0 @@
-package FS::part_svc;
-
-use strict;
-use vars qw( @ISA );
-use FS::Record qw( qsearch qsearchs fields dbh );
-use FS::part_svc_column;
-use FS::part_export;
-use FS::export_svc;
-
-@ISA = qw(FS::Record);
-
-=head1 NAME
-
-FS::part_svc - Object methods for part_svc objects
-
-=head1 SYNOPSIS
-
- use FS::part_svc;
-
- $record = new FS::part_svc \%hash
- $record = new FS::part_svc { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
-=head1 DESCRIPTION
-
-An FS::part_svc represents a service definition. FS::part_svc inherits from
-FS::Record. The following fields are currently supported:
-
-=over 4
-
-=item svcpart - primary key (assigned automatically for new service definitions)
-
-=item svc - text name of this service definition
-
-=item svcdb - table used for this service. See L<FS::svc_acct>,
-L<FS::svc_domain>, and L<FS::svc_forward>, among others.
-
-=item disabled - Disabled flag, empty or `Y'
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new service definition. To add the service definition to the
-database, see L<"insert">.
-
-=cut
-
-sub table { 'part_svc'; }
-
-=item insert EXTRA_FIELDS_ARRAYREF
-
-Adds this service definition to the database. If there is an error, returns
-the error, otherwise returns false.
-
-TODOC:
-
-=item I<svcdb>__I<field> - Default or fixed value for I<field> in I<svcdb>.
-
-=item I<svcdb>__I<field>_flag - defines I<svcdb>__I<field> action: null, `D' for default, or `F' for fixed. For virtual fields, can also be 'X' for excluded.
-
-TODOC: EXTRA_FIELDS_ARRAYREF
-
-=cut
-
-sub insert {
- my $self = shift;
- my @fields = ();
- @fields = @{shift(@_)} if @_;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- my $error = $self->SUPER::insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- my $svcdb = $self->svcdb;
-# my @rows = map { /^${svcdb}__(.*)$/; $1 }
-# grep ! /_flag$/,
-# grep /^${svcdb}__/,
-# fields('part_svc');
- foreach my $field (
- grep { $_ ne 'svcnum'
- && defined( $self->getfield($svcdb.'__'.$_.'_flag') )
- } (fields($svcdb), @fields)
- ) {
- my $part_svc_column = $self->part_svc_column($field);
- my $previous = qsearchs('part_svc_column', {
- 'svcpart' => $self->svcpart,
- 'columnname' => $field,
- } );
-
- my $flag = $self->getfield($svcdb.'__'.$field.'_flag');
- if ( uc($flag) =~ /^([DFX])$/ ) {
- $part_svc_column->setfield('columnflag', $1);
- $part_svc_column->setfield('columnvalue',
- $self->getfield($svcdb.'__'.$field)
- );
- if ( $previous ) {
- $error = $part_svc_column->replace($previous);
- } else {
- $error = $part_svc_column->insert;
- }
- } else {
- $error = $previous ? $previous->delete : '';
- }
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
-
- '';
-}
-
-=item delete
-
-Currently unimplemented.
-
-=cut
-
-sub delete {
- return "Can't (yet?) delete service definitions.";
-# check & make sure the svcpart isn't in cust_svc or pkg_svc (in any packages)?
-}
-
-=item replace OLD_RECORD [ '1.3-COMPAT' [ , EXTRA_FIELDS_ARRAYREF ] ]
-
-Replaces OLD_RECORD with this one in the database. If there is an error,
-returns the error, otherwise returns false.
-
-TODOC: 1.3-COMPAT
-
-TODOC: EXTRA_FIELDS_ARRAYREF
-
-=cut
-
-sub replace {
- my ( $new, $old ) = ( shift, shift );
-
- return "Can't change svcdb for an existing service definition!"
- unless $old->svcdb eq $new->svcdb;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- my $error = $new->SUPER::replace( $old );
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- if ( @_ && $_[0] eq '1.3-COMPAT' ) {
- shift;
- my @fields = ();
- @fields = @{shift(@_)} if @_;
-
- my $svcdb = $new->svcdb;
- foreach my $field (
- grep { $_ ne 'svcnum'
- && defined( $new->getfield($svcdb.'__'.$_.'_flag') )
- } (fields($svcdb),@fields)
- ) {
- my $part_svc_column = $new->part_svc_column($field);
- my $previous = qsearchs('part_svc_column', {
- 'svcpart' => $new->svcpart,
- 'columnname' => $field,
- } );
-
- my $flag = $new->getfield($svcdb.'__'.$field.'_flag');
- if ( uc($flag) =~ /^([DFX])$/ ) {
- $part_svc_column->setfield('columnflag', $1);
- $part_svc_column->setfield('columnvalue',
- $new->getfield($svcdb.'__'.$field)
- );
- if ( $previous ) {
- $error = $part_svc_column->replace($previous);
- } else {
- $error = $part_svc_column->insert;
- }
- } else {
- $error = $previous ? $previous->delete : '';
- }
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
- } else {
- $dbh->rollback if $oldAutoCommit;
- return 'non-1.3-COMPAT interface not yet written';
- #not yet implemented
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
-
- '';
-}
-
-=item check
-
-Checks all fields to make sure this is a valid service definition. If there is
-an error, returns the error, otherwise returns false. Called by the insert
-and replace methods.
-
-=cut
-
-sub check {
- my $self = shift;
- my $recref = $self->hashref;
-
- my $error;
- $error=
- $self->ut_numbern('svcpart')
- || $self->ut_text('svc')
- || $self->ut_alpha('svcdb')
- || $self->ut_enum('disabled', [ '', 'Y' ] )
- ;
- return $error if $error;
-
- my @fields = eval { fields( $recref->{svcdb} ) }; #might die
- return "Unknown svcdb!" unless @fields;
-
- $self->SUPER::check;
-}
-
-=item part_svc_column COLUMNNAME
-
-Returns the part_svc_column object (see L<FS::part_svc_column>) for the given
-COLUMNNAME, or a new part_svc_column object if none exists.
-
-=cut
-
-sub part_svc_column {
- my( $self, $columnname) = @_;
- $self->svcpart &&
- qsearchs('part_svc_column', {
- 'svcpart' => $self->svcpart,
- 'columnname' => $columnname,
- }
- ) or new FS::part_svc_column {
- 'svcpart' => $self->svcpart,
- 'columnname' => $columnname,
- };
-}
-
-=item all_part_svc_column
-
-=cut
-
-sub all_part_svc_column {
- my $self = shift;
- qsearch('part_svc_column', { 'svcpart' => $self->svcpart } );
-}
-
-=item part_export [ EXPORTTYPE ]
-
-Returns all exports (see L<FS::part_export>) for this service, or, if an
-export type is specified, only returns exports of the given type.
-
-=cut
-
-sub part_export {
- my $self = shift;
- my %search;
- $search{'exporttype'} = shift if @_;
- map { qsearchs('part_export', { 'exportnum' => $_->exportnum, %search } ) }
- qsearch('export_svc', { 'svcpart' => $self->svcpart } );
-}
-
-=back
-
-=head1 BUGS
-
-Delete is unimplemented.
-
-The list of svc_* tables is hardcoded. When svc_acct_pop is renamed, this
-should be fixed.
-
-all_part_svc_column method should be documented
-
-=head1 SEE ALSO
-
-L<FS::Record>, L<FS::part_svc_column>, L<FS::part_pkg>, L<FS::pkg_svc>,
-L<FS::cust_svc>, L<FS::svc_acct>, L<FS::svc_forward>, L<FS::svc_domain>,
-schema.html from the base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/part_svc_column.pm b/FS/FS/part_svc_column.pm
deleted file mode 100644
index 885155b..0000000
--- a/FS/FS/part_svc_column.pm
+++ /dev/null
@@ -1,118 +0,0 @@
-package FS::part_svc_column;
-
-use strict;
-use vars qw( @ISA );
-use FS::Record qw( fields );
-
-@ISA = qw(FS::Record);
-
-=head1 NAME
-
-FS::part_svc_column - Object methods for part_svc_column objects
-
-=head1 SYNOPSIS
-
- use FS::part_svc_column;
-
- $record = new FS::part_svc_column \%hash
- $record = new FS::part_svc_column { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
-=head1 DESCRIPTION
-
-An FS::part_svc_column record represents a service definition column
-constraint. FS::part_svc_column inherits from FS::Record. The following
-fields are currently supported:
-
-=over 4
-
-=item columnnum - primary key (assigned automatcially for new records)
-
-=item svcpart - service definition (see L<FS::part_svc>)
-
-=item columnname - column name in part_svc.svcdb table
-
-=item columnvalue - default or fixed value for the column
-
-=item columnflag - null, D, F, X (virtual fields)
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new column constraint. To add the column constraint to the database, see L<"insert">.
-
-=cut
-
-sub table { 'part_svc_column'; }
-
-=item insert
-
-Adds this service definition to the database. If there is an error, returns
-the error, otherwise returns false.
-
-=item delete
-
-Deletes this record from the database. If there is an error, returns the
-error, otherwise returns false.
-
-=item replace OLD_RECORD
-
-Replaces OLD_RECORD with this one in the database. If there is an error,
-returns the error, otherwise returns false.
-
-=item check
-
-Checks all fields to make sure this is a valid record. If there is an error,
-returns the error, otherwise returns false. Called by the insert and replace
-methods.
-
-=cut
-
-sub check {
- my $self = shift;
-
- my $error =
- $self->ut_numbern('columnnum')
- || $self->ut_number('svcpart')
- || $self->ut_alpha('columnname')
- || $self->ut_anything('columnvalue')
- ;
- return $error if $error;
-
- $self->columnflag =~ /^([DFX])$/
- or return "illegal columnflag ". $self->columnflag;
- $self->columnflag(uc($1));
-
- $self->SUPER::check;
-}
-
-=back
-
-=head1 VERSION
-
-$Id: part_svc_column.pm,v 1.2 2003-08-05 00:20:44 khoff Exp $
-
-=head1 BUGS
-
-=head1 SEE ALSO
-
-L<FS::Record>, L<FS::part_svc>, L<FS::part_pkg>, L<FS::pkg_svc>,
-L<FS::cust_svc>, L<FS::svc_acct>, L<FS::svc_forward>, L<FS::svc_domain>,
-schema.html from the base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/part_svc_router.pm b/FS/FS/part_svc_router.pm
deleted file mode 100755
index 0b23ab5..0000000
--- a/FS/FS/part_svc_router.pm
+++ /dev/null
@@ -1,32 +0,0 @@
-package FS::part_svc_router;
-
-use strict;
-use vars qw( @ISA );
-use FS::Record qw(qsearchs);
-use FS::router;
-use FS::part_svc;
-
-@ISA = qw(FS::Record);
-
-sub table { 'part_svc_router'; }
-
-sub check {
- my $self = shift;
- my $error =
- $self->ut_foreign_key('svcpart', 'part_svc', 'svcpart')
- || $self->ut_foreign_key('routernum', 'router', 'routernum');
- return $error if $error;
- ''; #no error
-}
-
-sub router {
- my $self = shift;
- return qsearchs('router', { routernum => $self->routernum });
-}
-
-sub part_svc {
- my $self = shift;
- return qsearchs('part_svc', { svcpart => $self->svcpart });
-}
-
-1;
diff --git a/FS/FS/part_virtual_field.pm b/FS/FS/part_virtual_field.pm
deleted file mode 100755
index 03c34cc..0000000
--- a/FS/FS/part_virtual_field.pm
+++ /dev/null
@@ -1,303 +0,0 @@
-package FS::part_virtual_field;
-
-use strict;
-use vars qw( @ISA );
-use FS::Record qw( qsearchs qsearch dbdef );
-
-@ISA = qw( FS::Record );
-
-=head1 NAME
-
-FS::part_virtual_field - Object methods for part_virtual_field records
-
-=head1 SYNOPSIS
-
- use FS::part_virtual_field;
-
- $record = new FS::part_virtual_field \%hash;
- $record = new FS::part_virtual_field { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
-=head1 DESCRIPTION
-
-An FS::part_virtual_field object represents the definition of a virtual field
-(see the BACKGROUND section). FS::part_virtual_field contains the name and
-base table of the field, as well as validation rules and UI hints about the
-display of the field. The actual data is stored in FS::virtual_field; see
-its manpage for details.
-
-FS::part_virtual_field inherits from FS::Record. The following fields are
-currently supported:
-
-=over 2
-
-=item vfieldpart - primary key (assigned automatically)
-
-=item name - name of the field
-
-=item dbtable - table for which this virtual field is defined
-
-=item check_block - Perl code to validate/normalize data
-
-=item list_source - Perl code to generate a list of values (UI hint)
-
-=item length - expected length of the value (UI hint)
-
-=item label - descriptive label for the field (UI hint)
-
-=item sequence - sort key (UI hint; unimplemented)
-
-=back
-
-=head1 BACKGROUND
-
-"Form is none other than emptiness,
- and emptiness is none other than form."
--- Heart Sutra
-
-The virtual field mechanism allows site admins to make trivial changes to
-the Freeside database schema without modifying the code. Specifically, the
-user can add custom-defined 'fields' to the set of data tracked by Freeside
-about objects such as customers and services. These fields are not associated
-with any logic in the core Freeside system, but may be referenced in peripheral
-code such as exports, price calculations, or alternate interfaces, or may just
-be stored in the database for future reference.
-
-This system was originally devised for svc_broadband, which (by necessity)
-comprises such a wide range of access technologies that no static set of fields
-could contain all the information needed by the exports. In an appalling
-display of False Laziness, a parallel mechanism was implemented for the
-router table, to store properties such as passwords to configure routers.
-
-The original system treated svc_broadband custom fields (sb_fields) as records
-in a completely separate table. Any code that accessed or manipulated these
-fields had to be aware that they were I<not> fields in svc_broadband, but
-records in sb_field. For example, code that inserted a svc_broadband with
-several custom fields had to create an FS::svc_broadband object, call its
-insert() method, and then create several FS::sb_field objects and call I<their>
-insert() methods.
-
-This created a problem for exports. The insert method on any FS::svc_Common
-object (including svc_broadband) automatically triggers exports after the
-record has been inserted. However, at this point, the sb_fields had not yet
-been inserted, so the export could not rely on their presence, which was the
-original purpose of sb_fields.
-
-Hence the new system. Virtual fields are appended to the field list of every
-record at the FS::Record level, whether the object is created ex nihilo with
-new() or fetched with qsearch(). The fields() method now returns a list of
-both real and virtual fields. The insert(), replace(), and delete() methods
-now update both the base table and the virtual fields, in a single transaction.
-
-A new method is provided, virtual_fields(), which gives only the virtual
-fields. UI code that dynamically generates form widgets to edit virtual field
-data should use this to figure out what fields are defined. (See below.)
-
-Subclasses may override virtual_fields() to restrict the set of virtual
-fields available. Some discipline and sanity on the part of the programmer
-are required; in particular, this function should probably not depend on any
-fields in the record other than the primary key, since the others may change
-after the object is instantiated. (Making it depend on I<virtual> fields is
-just asking for pain.) One use of this is seen in FS::svc_Common; another
-possibility is field-level access control based on FS::UID::getotaker().
-
-As a trivial case, a subclass may opt out of supporting virtual fields with
-the following code:
-
-sub virtual_fields { () }
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Create a new record. To add the record to the database, see "insert".
-
-=cut
-
-sub table { 'part_virtual_field'; }
-sub virtual_fields { () }
-
-=item insert
-
-Adds this record to the database. If there is an error, returns the error,
-otherwise returns false.
-
-=item delete
-
-Deletes this record from the database. If there is an error, returns the
-error, otherwise returns false.
-
-=item replace OLD_RECORD
-
-Replaces OLD_RECORD with this one in the database. If there is an error,
-returns the error, otherwise returns false.
-
-=item check
-
-If there is an error, returns the error, otherwise returns false.
-Called by the insert and replace methods.
-
-=back
-
-=cut
-
-sub check {
- my $self = shift;
-
- my $error = $self->ut_text('name') ||
- $self->ut_text('dbtable') ||
- $self->ut_number('length')
- ;
- return $error if $error;
-
- # Make sure it's a real table with a numeric primary key
- my ($table, $pkey);
- if($table = $FS::Record::dbdef->table($self->dbtable)) {
- if($pkey = $table->primary_key) {
- if($table->column($pkey)->type =~ /int/i) {
- # this is what it should be
- } else {
- $error = "$table.$pkey is not an integer";
- }
- } else {
- $error = "$table does not have a single-field primary key";
- }
- } else {
- $error = "$table does not exist in the schema";
- }
- return $error if $error;
-
- # Possibly some sanity checks for check_block and list_source?
-
- $self->SUPER::check;
-}
-
-=item list
-
-Evaluates list_source.
-
-=cut
-
-sub list {
- my $self = shift;
- return () unless $self->list_source;
-
- my @opts = eval($self->list_source);
- if($@) {
- warn $@;
- return ();
- } else {
- return @opts;
- }
-}
-
-=item widget UI_TYPE MODE [ VALUE ]
-
-Generates UI code for a widget suitable for editing/viewing the field, based on
-list_source and length.
-
-The only UI_TYPE currently supported is 'HTML', and the only MODE is 'view'.
-Others will be added later.
-
-In HTML, all widgets are assumed to be table rows. View widgets look like
-<TR><TD ALIGN="right">Label</TD><TD BGCOLOR="#ffffff">Value</TD></TR>
-
-(Most of the display style stuff, such as the colors, should probably go into
-a separate module specific to the UI. That can wait, though. The API for
-this function won't change.)
-
-VALUE (optional) is the current value of the field.
-
-=cut
-
-sub widget {
- my $self = shift;
- my ($ui_type, $mode, $value) = @_;
- my $text;
- my $label = $self->label || $self->name;
-
- if ($ui_type eq 'HTML') {
- if ($mode eq 'view') {
- $text = q!<TR><TD ALIGN="right">! . $label .
- q!</TD><TD BGCOLOR="#ffffff">! . $value .
- q!</TD></TR>! . "\n";
- } elsif ($mode eq 'edit') {
- $text = q!<TR><TD ALIGN="right">! . $label .
- q!</TD><TD>!;
- if ($self->list_source) {
- $text .= q!<SELECT NAME="! . $self->name .
- q!" SIZE=1>! . "\n";
- foreach ($self->list) {
- $text .= q!<OPTION VALUE="! . $_ . q!"!;
- $text .= ' SELECTED' if ($_ eq $value);
- $text .= '>' . $_ . '</OPTION>' . "\n";
- }
- } else {
- $text .= q!<INPUT NAME="! . $self->name .
- q!" VALUE="! . $value . q!"!;
- if ($self->length) {
- $text .= q! SIZE="! . $self->length . q!"!;
- }
- $text .= '>';
- }
- $text .= q!</TD></TR>! . "\n";
- } else {
- return '';
- }
- } else {
- return '';
- }
- return $text;
-}
-
-=head1 VERSION
-
-$Id: part_virtual_field.pm,v 1.2 2003-08-05 00:20:45 khoff Exp $
-
-=head1 NOTES
-
-=head2 Semantics of check_block:
-
-This has been changed from the sb_field implementation to make check_blocks
-simpler and more natural to Perl programmers who work on things other than
-Freeside.
-
-The check_block is eval'd with the (proposed) new value of the field in $_,
-and the object to be updated in $self. Its return value is ignored. The
-check_block may change the value of $_ to override the proposed value, or
-call die() (with an appropriate error message) to reject the update entirely;
-the error string will be returned as the output of the check() method.
-
-This makes check_blocks like
-
-C<s/foo/bar/>
-
-do what you expect.
-
-The check_block is expected NOT to do anything freaky to $self, like modifying
-other fields or calling $self->check(). You have been warned.
-
-(FIXME: Rewrite some of the warnings from part_sb_field and insert here.)
-
-=head1 BUGS
-
-None. It's absolutely falwless.
-
-=head1 SEE ALSO
-
-L<FS::Record>, L<FS::virtual_field>
-
-=cut
-
-1;
-
-
diff --git a/FS/FS/pkg_svc.pm b/FS/FS/pkg_svc.pm
deleted file mode 100644
index ea52176..0000000
--- a/FS/FS/pkg_svc.pm
+++ /dev/null
@@ -1,155 +0,0 @@
-package FS::pkg_svc;
-
-use strict;
-use vars qw( @ISA );
-use FS::Record qw( qsearchs );
-use FS::part_pkg;
-use FS::part_svc;
-
-@ISA = qw( FS::Record );
-
-=head1 NAME
-
-FS::pkg_svc - Object methods for pkg_svc records
-
-=head1 SYNOPSIS
-
- use FS::pkg_svc;
-
- $record = new FS::pkg_svc \%hash;
- $record = new FS::pkg_svc { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
- $part_pkg = $record->part_pkg;
-
- $part_svc = $record->part_svc;
-
-=head1 DESCRIPTION
-
-An FS::pkg_svc record links a billing item definition (see L<FS::part_pkg>) to
-a service definition (see L<FS::part_svc>). FS::pkg_svc inherits from
-FS::Record. The following fields are currently supported:
-
-=over 4
-
-=item pkgpart - Billing item definition (see L<FS::part_pkg>)
-
-=item svcpart - Service definition (see L<FS::part_svc>)
-
-=item quantity - Quantity of this service definition that this billing item
-definition includes
-
-=item primary_svc - primary flag, empty or 'Y'
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Create a new record. To add the record to the database, see L<"insert">.
-
-=cut
-
-sub table { 'pkg_svc'; }
-
-=item insert
-
-Adds this record to the database. If there is an error, returns the error,
-otherwise returns false.
-
-=item delete
-
-Deletes this record from the database. If there is an error, returns the
-error, otherwise returns false.
-
-=item replace OLD_RECORD
-
-Replaces 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 );
-
- return "Can't change pkgpart!" if $old->pkgpart != $new->pkgpart;
- return "Can't change svcpart!" if $old->svcpart != $new->svcpart;
-
- $new->SUPER::replace($old);
-}
-
-=item check
-
-Checks all fields to make sure this is a valid record. If there is an error,
-returns the error, otherwise returns false. Called by the insert and replace
-methods.
-
-=cut
-
-sub check {
- my $self = shift;
-
- my $error;
- $error =
- $self->ut_number('pkgpart')
- || $self->ut_number('svcpart')
- || $self->ut_number('quantity')
- ;
- return $error if $error;
-
- return "Unknown pkgpart!" unless $self->part_pkg;
- return "Unknown svcpart!" unless $self->part_svc;
-
- if ( $self->dbdef_table->column('primary_svc') ) {
- $error = $self->ut_enum('primary_svc', [ '', 'Y' ] );
- return $error if $error;
- }
-
- $self->SUPER::check;
-}
-
-=item part_pkg
-
-Returns the FS::part_pkg object (see L<FS::part_pkg>).
-
-=cut
-
-sub part_pkg {
- my $self = shift;
- qsearchs( 'part_pkg', { 'pkgpart' => $self->pkgpart } );
-}
-
-=item part_svc
-
-Returns the FS::part_svc object (see L<FS::part_svc>).
-
-=cut
-
-sub part_svc {
- my $self = shift;
- qsearchs( 'part_svc', { 'svcpart' => $self->svcpart } );
-}
-
-=back
-
-=head1 BUGS
-
-=head1 SEE ALSO
-
-L<FS::Record>, L<FS::part_pkg>, L<FS::part_svc>, schema.html from the base
-documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/port.pm b/FS/FS/port.pm
deleted file mode 100644
index 620030a..0000000
--- a/FS/FS/port.pm
+++ /dev/null
@@ -1,160 +0,0 @@
-package FS::port;
-
-use strict;
-use vars qw( @ISA );
-use FS::Record qw( qsearchs );
-use FS::nas;
-use FS::session;
-
-@ISA = qw(FS::Record);
-
-=head1 NAME
-
-FS::port - Object methods for port records
-
-=head1 SYNOPSIS
-
- use FS::port;
-
- $record = new FS::port \%hash;
- $record = new FS::port { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
- $session = $port->session;
-
-=head1 DESCRIPTION
-
-An FS::port object represents an individual port on a NAS. FS::port inherits
-from FS::Record. The following fields are currently supported:
-
-=over 4
-
-=item portnum - primary key
-
-=item ip - IP address of this port
-
-=item nasport - port number on the NAS
-
-=item nasnum - NAS this port is on - see L<FS::nas>
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new port. 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 { 'port'; }
-
-=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;
- my $error =
- $self->ut_numbern('portnum')
- || $self->ut_ipn('ip')
- || $self->ut_numbern('nasport')
- || $self->ut_number('nasnum');
- ;
- return $error if $error;
- return "Either ip or nasport must be specified"
- unless $self->ip || $self->nasport;
- return "Unknown nasnum"
- unless qsearchs('nas', { 'nasnum' => $self->nasnum } );
- $self->SUPER::check;
-}
-
-=item session
-
-Returns the currently open session on this port, or if no session is currently
-open, the most recent session. See L<FS::session>.
-
-=cut
-
-sub session {
- my $self = shift;
- qsearchs('session', { 'portnum' => $self->portnum }, '*',
- 'ORDER BY login DESC LIMIT 1' );
-}
-
-=back
-
-=head1 VERSION
-
-$Id: port.pm,v 1.6 2003-08-05 00:20:45 khoff Exp $
-
-=head1 BUGS
-
-The author forgot to customize this manpage.
-
-The session method won't deal well if you have multiple open sessions on a
-port, for example if your RADIUS server drops B<stop> records. Suggestions for
-how to deal with this sort of lossage welcome; should we close the session
-when we get a new session on that port? Tag it as invalid somehow? Close it
-one second after it was opened? *sigh* Maybe FS::session shouldn't let you
-create overlapping sessions, at least folks will find out their logging is
-dropping records.
-
-If you think the above refers multiple user logins you need to read the
-manpages again.
-
-=head1 SEE ALSO
-
-L<FS::Record>, schema.html from the base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/prepay_credit.pm b/FS/FS/prepay_credit.pm
deleted file mode 100644
index a9d26d1..0000000
--- a/FS/FS/prepay_credit.pm
+++ /dev/null
@@ -1,127 +0,0 @@
-package FS::prepay_credit;
-
-use strict;
-use vars qw( @ISA );
-#use FS::Record qw( qsearch qsearchs );
-use FS::Record qw();
-
-@ISA = qw(FS::Record);
-
-=head1 NAME
-
-FS::prepay_credit - Object methods for prepay_credit records
-
-=head1 SYNOPSIS
-
- use FS::prepay_credit;
-
- $record = new FS::prepay_credit \%hash;
- $record = new FS::prepay_credit {
- 'identifier' => '4198123455512121'
- 'amount' => '19.95',
- };
-
- $record = new FS::prepay_credit {
- 'identifier' => '4198123455512121'
- 'seconds' => '7200',
- };
-
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
-=head1 DESCRIPTION
-
-An FS::table_name object represents an pre--paid credit, such as a pre-paid
-"calling card". FS::prepay_credit inherits from FS::Record. The following
-fields are currently supported:
-
-=over 4
-
-=item field - description
-
-=item identifier - identifier entered by the user to receive the credit
-
-=item amount - amount of the credit
-
-=item seconds - time amount of credit (see L<FS::svc_acct/seconds>)
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new pre-paid credit. 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 { 'prepay_credit'; }
-
-=item insert
-
-Adds this record to the database. If there is an error, returns the error,
-otherwise returns false.
-
-=cut
-
-=item delete
-
-Delete this record from the database.
-
-=cut
-
-=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
-
-=item check
-
-Checks all fields to make sure this is a valid pre-paid credit. If there is
-an error, returns the error, otherwise returns false. Called by the insert
-and replace methods.
-
-=cut
-
-sub check {
- my $self = shift;
-
- my $identifier = $self->identifier;
- $identifier =~ s/\W//g; #anything else would just confuse things
- $self->identifier($identifier);
-
- $self->ut_numbern('prepaynum')
- || $self->ut_alpha('identifier')
- || $self->ut_money('amount')
- || $self->utnumbern('seconds')
- || $self->SUPER::check
- ;
-
-}
-
-=back
-
-=head1 BUGS
-
-=head1 SEE ALSO
-
-L<FS::svc_acct>, L<FS::Record>, schema.html from the base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/queue.pm b/FS/FS/queue.pm
deleted file mode 100644
index 9dcb2e3..0000000
--- a/FS/FS/queue.pm
+++ /dev/null
@@ -1,440 +0,0 @@
-package FS::queue;
-
-use strict;
-use vars qw( @ISA @EXPORT_OK $DEBUG $conf $jobnums);
-use Exporter;
-use FS::UID;
-use FS::Conf;
-use FS::Record qw( qsearch qsearchs dbh );
-#use FS::queue;
-use FS::queue_arg;
-use FS::queue_depend;
-use FS::cust_svc;
-
-@ISA = qw(FS::Record);
-@EXPORT_OK = qw( joblisting );
-
-$DEBUG = 0;
-#$DEBUG = 1;
-
-$FS::UID::callback{'FS::queue'} = sub {
- $conf = new FS::Conf;
-};
-
-$jobnums = '';
-
-=head1 NAME
-
-FS::queue - Object methods for queue records
-
-=head1 SYNOPSIS
-
- use FS::queue;
-
- $record = new FS::queue \%hash;
- $record = new FS::queue { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
-=head1 DESCRIPTION
-
-An FS::queue object represents an queued job. FS::queue inherits from
-FS::Record. The following fields are currently supported:
-
-=over 4
-
-=item jobnum - primary key
-
-=item job - fully-qualified subroutine name
-
-=item status - job status
-
-=item statustext - freeform text status message
-
-=item _date - UNIX timestamp
-
-=item svcnum - optional link to service (see L<FS::cust_svc>)
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new job. 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 { 'queue'; }
-
-=item insert [ ARGUMENT, ARGUMENT... ]
-
-Adds this record to the database. If there is an error, returns the error,
-otherwise returns false.
-
-If any arguments are supplied, a queue_arg record for each argument is also
-created (see L<FS::queue_arg>).
-
-=cut
-
-#false laziness w/part_export.pm
-sub insert {
- my $self = shift;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- my $error = $self->SUPER::insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- foreach my $arg ( @_ ) {
- my $queue_arg = new FS::queue_arg ( {
- 'jobnum' => $self->jobnum,
- 'arg' => $arg,
- } );
- $error = $queue_arg->insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
-
- if ( $jobnums ) {
- warn "jobnums global is active: $jobnums\n" if $DEBUG;
- push @$jobnums, $self->jobnum;
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
-
- '';
-
-}
-
-=item delete
-
-Delete this record from the database. Any corresponding queue_arg records are
-deleted as well
-
-=cut
-
-sub delete {
- my $self = shift;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- my @del = qsearch( 'queue_arg', { 'jobnum' => $self->jobnum } );
- push @del, qsearch( 'queue_depend', { 'depend_jobnum' => $self->jobnum } );
-
- my $error = $self->SUPER::delete;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- foreach my $del ( @del ) {
- $error = $del->delete;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
-
- '';
-
-}
-
-=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 job. If there is
-an error, returns the error, otherwise returns false. Called by the insert
-and replace methods.
-
-=cut
-
-sub check {
- my $self = shift;
- my $error =
- $self->ut_numbern('jobnum')
- || $self->ut_anything('job')
- || $self->ut_numbern('_date')
- || $self->ut_enum('status',['', qw( new locked failed )])
- || $self->ut_anything('statustext')
- || $self->ut_numbern('svcnum')
- ;
- return $error if $error;
-
- $error = $self->ut_foreign_keyn('svcnum', 'cust_svc', 'svcnum');
- $self->svcnum('') if $error;
-
- $self->status('new') unless $self->status;
- $self->_date(time) unless $self->_date;
-
- $self->SUPER::check;
-}
-
-=item args
-
-Returns a list of the arguments associated with this job.
-
-=cut
-
-sub args {
- my $self = shift;
- map $_->arg, qsearch( 'queue_arg',
- { 'jobnum' => $self->jobnum },
- '',
- 'ORDER BY argnum'
- );
-}
-
-=item cust_svc
-
-Returns the FS::cust_svc object associated with this job, if any.
-
-=cut
-
-sub cust_svc {
- my $self = shift;
- qsearchs('cust_svc', { 'svcnum' => $self->svcnum } );
-}
-
-=item queue_depend
-
-Returns the FS::queue_depend objects associated with this job, if any.
-(Dependancies that must complete before this job can be run).
-
-=cut
-
-sub queue_depend {
- my $self = shift;
- qsearch('queue_depend', { 'jobnum' => $self->jobnum } );
-}
-
-=item depend_insert OTHER_JOBNUM
-
-Inserts a dependancy for this job - it will not be run until the other job
-specified completes. If there is an error, returns the error, otherwise
-returns false.
-
-When using job dependancies, you should wrap the insertion of all relevant jobs
-in a database transaction.
-
-=cut
-
-sub depend_insert {
- my($self, $other_jobnum) = @_;
- my $queue_depend = new FS::queue_depend ( {
- 'jobnum' => $self->jobnum,
- 'depend_jobnum' => $other_jobnum,
- } );
- $queue_depend->insert;
-}
-
-=item queue_depended
-
-Returns the FS::queue_depend objects that associate other jobs with this job,
-if any. (The jobs that are waiting for this job to complete before they can
-run).
-
-=cut
-
-sub queue_depended {
- my $self = shift;
- qsearch('queue_depend', { 'depend_jobnum' => $self->jobnum } );
-}
-
-=item depended_delete
-
-Deletes the other queued jobs (FS::queue objects) that are waiting for this
-job, if any. If there is an error, returns the error, otherwise returns false.
-
-=cut
-
-sub depended_delete {
- my $self = shift;
- my $error;
- foreach my $job (
- map { qsearchs('queue', { 'jobnum' => $_->jobnum } ) } $self->queue_depended
- ) {
- $error = $job->depended_delete;
- return $error if $error;
- $error = $job->delete;
- return $error if $error
- }
-}
-
-=back
-
-=head1 SUBROUTINES
-
-=over 4
-
-=item joblisting HASHREF NOACTIONS
-
-=cut
-
-sub joblisting {
- my($hashref, $noactions) = @_;
-
- use Date::Format;
- use HTML::Entities;
- use FS::CGI;
-
- my @queue = qsearch( 'queue', $hashref );
- return '' unless scalar(@queue);
-
- my $p = FS::CGI::popurl(2);
-
- my $html = qq!<FORM ACTION="$p/misc/queue.cgi" METHOD="POST">!.
- FS::CGI::table(). <<END;
- <TR>
- <TH COLSPAN=2>Job</TH>
- <TH>Args</TH>
- <TH>Date</TH>
- <TH>Status</TH>
-END
- $html .= '<TH>Account</TH>' unless $hashref->{svcnum};
- $html .= '</TR>';
-
- my $dangerous = $conf->exists('queue_dangerous_controls');
-
- my $areboxes = 0;
-
- foreach my $queue ( sort {
- $a->getfield('jobnum') <=> $b->getfield('jobnum')
- } @queue ) {
- my $queue_hashref = $queue->hashref;
- my $jobnum = $queue->jobnum;
-
- my $args;
- if ( $dangerous || $queue->job !~ /^FS::part_export::/ || !$noactions ) {
- $args = encode_entities( join(' ',
- map { length($_)<54 ? $_ : substr($_,0,32)."..." } $queue->args #1&g
- ) );
- } else {
- $args = '';
- }
-
- my $date = time2str( "%a %b %e %T %Y", $queue->_date );
- my $status = $queue->status;
- $status .= ': '. $queue->statustext if $queue->statustext;
- my @queue_depend = $queue->queue_depend;
- $status .= ' (waiting for '.
- join(', ', map { $_->depend_jobnum } @queue_depend ).
- ')'
- if @queue_depend;
- my $changable = $dangerous
- || ( ! $noactions && $status =~ /^failed/ || $status =~ /^locked/ );
- if ( $changable ) {
- $status .=
- qq! (&nbsp;<A HREF="$p/misc/queue.cgi?jobnum=$jobnum&action=new">retry</A>&nbsp;|!.
- qq!&nbsp;<A HREF="$p/misc/queue.cgi?jobnum=$jobnum&action=del">remove</A>&nbsp;)!;
- }
- my $cust_svc = $queue->cust_svc;
-
- $html .= <<END;
- <TR>
- <TD>$jobnum</TD>
- <TD>$queue_hashref->{job}</TD>
- <TD>$args</TD>
- <TD>$date</TD>
- <TD>$status</TD>
-END
-
- unless ( $hashref->{svcnum} ) {
- my $account;
- if ( $cust_svc ) {
- my $table = $cust_svc->part_svc->svcdb;
- my $label = ( $cust_svc->label )[1];
- $account = qq!<A HREF="../view/$table.cgi?!. $queue->svcnum.
- qq!">$label</A>!;
- } else {
- $account = '';
- }
- $html .= "<TD>$account</TD>";
- }
-
- if ( $changable ) {
- $areboxes=1;
- $html .=
- qq!<TD><INPUT NAME="jobnum$jobnum" TYPE="checkbox" VALUE="1"></TD>!;
-
- }
-
- $html .= '</TR>';
-
-}
-
- $html .= '</TABLE>';
-
- if ( $areboxes ) {
- $html .= '<BR><INPUT TYPE="submit" NAME="action" VALUE="retry selected">'.
- '<INPUT TYPE="submit" NAME="action" VALUE="remove selected"><BR>';
- }
-
- $html;
-
-}
-
-=back
-
-=head1 VERSION
-
-$Id: queue.pm,v 1.17 2004-03-03 13:42:08 ivan Exp $
-
-=head1 BUGS
-
-$jobnums global
-
-=head1 SEE ALSO
-
-L<FS::Record>, schema.html from the base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/queue_arg.pm b/FS/FS/queue_arg.pm
deleted file mode 100644
index d23ee2a..0000000
--- a/FS/FS/queue_arg.pm
+++ /dev/null
@@ -1,121 +0,0 @@
-package FS::queue_arg;
-
-use strict;
-use vars qw( @ISA );
-use FS::Record qw( qsearch qsearchs );
-
-@ISA = qw(FS::Record);
-
-=head1 NAME
-
-FS::queue_arg - Object methods for queue_arg records
-
-=head1 SYNOPSIS
-
- use FS::queue_arg;
-
- $record = new FS::queue_arg \%hash;
- $record = new FS::queue_arg { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
-=head1 DESCRIPTION
-
-An FS::queue_arg object represents job argument. FS::queue_arg inherits from
-FS::Record. The following fields are currently supported:
-
-=over 4
-
-=item argnum - primary key
-
-=item jobnum - see L<FS::queue>
-
-=item arg - argument
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new argument. 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 { 'queue_arg'; }
-
-=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 argument. If there is
-an error, returns the error, otherwise returns false. Called by the insert
-and replace methods.
-
-=cut
-
-sub check {
- my $self = shift;
- my $error =
- $self->ut_numbern('argnum')
- || $self->ut_numbern('jobnum')
- || $self->ut_anything('arg')
- ;
- return $error if $error;
-
- $self->SUPER::check;
-}
-
-=back
-
-=head1 VERSION
-
-$Id: queue_arg.pm,v 1.2 2003-08-05 00:20:46 khoff Exp $
-
-=head1 BUGS
-
-=head1 SEE ALSO
-
-L<FS::queue>, L<FS::Record>, schema.html from the base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/queue_depend.pm b/FS/FS/queue_depend.pm
deleted file mode 100644
index bc910d8..0000000
--- a/FS/FS/queue_depend.pm
+++ /dev/null
@@ -1,121 +0,0 @@
-package FS::queue_depend;
-
-use strict;
-use vars qw( @ISA );
-use FS::Record qw( qsearch qsearchs );
-use FS::queue;
-
-@ISA = qw(FS::Record);
-
-=head1 NAME
-
-FS::queue_depend - Object methods for queue_depend records
-
-=head1 SYNOPSIS
-
- use FS::queue_depend;
-
- $record = new FS::queue_depend \%hash;
- $record = new FS::queue_depend { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
-=head1 DESCRIPTION
-
-An FS::queue_depend object represents an job dependancy. FS::queue_depend
-inherits from FS::Record. The following fields are currently supported:
-
-=over 4
-
-=item dependnum - primary key
-
-=item jobnum - source jobnum (see L<FS::queue>).
-
-=item depend_jobnum - dependancy jobnum (see L<FS::queue>)
-
-=back
-
-The job specified by B<jobnum> depends on the job specified B<depend_jobnum> -
-the B<jobnum> job will not be run until the B<depend_jobnum> job has completed
-sucessfully (or manually removed).
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new dependancy. To add the dependancy 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 { 'queue_depend'; }
-
-=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 dependancy. If there is
-an error, returns the error, otherwise returns false. Called by the insert
-and replace methods.
-
-=cut
-
-sub check {
- my $self = shift;
-
- $self->ut_numbern('dependnum')
- || $self->ut_foreign_key('jobnum', 'queue', 'jobnum')
- || $self->ut_foreign_key('depend_jobnum', 'queue', 'jobnum')
- || $self->SUPER::check
- ;
-}
-
-=back
-
-=head1 BUGS
-
-=head1 SEE ALSO
-
-L<FS::queue>, L<FS::Record>, schema.html from the base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/raddb.pm b/FS/FS/raddb.pm
deleted file mode 100644
index efeb739..0000000
--- a/FS/FS/raddb.pm
+++ /dev/null
@@ -1,1599 +0,0 @@
-package FS::raddb;
-use vars qw(%attrib);
-
-%attrib = (
- 'usr_at_zip_output_filter' => 'USR-AT-Zip-Output-Filter',
- 'ms_filter' => 'MS-Filter',
- 'annex_compression_protoc' => 'Annex-Compression-Protocol',
- 'xedia_ssh_privileges' => 'Xedia-SSH-Privileges',
- 'usr_blocks_received' => 'USR-Blocks-Received',
- 'shiva_called_number' => 'Shiva-Called-Number',
- 'annex_filter' => 'Annex-Filter',
- 'usr_channel_expansion' => 'USR-Channel-Expansion',
- 'erx_tunnel_tos' => 'ERX-Tunnel-Tos',
- 'session_timeout' => 'Session-Timeout',
- 'ascend_route_ipx' => 'Ascend-Route-IPX',
- 'annex_error_correction_p' => 'Annex-Error-Correction-Prot',
- 'acc_callback_mode' => 'Acc-Callback-Mode',
- 'usr_filter_zones' => 'USR-Filter-Zones',
- 'erx_input_gigapkts' => 'ERX-Input-Gigapkts',
- 'ascend_session_svr_key' => 'Ascend-Session-Svr-Key',
- 'bind_l2tp_tunnel_namf' => 'Bind_L2TP_Tunnel_Name',
- 'ascend_dsl_cir_recv_limi' => 'Ascend-Dsl-CIR-Recv-Limit',
- 'altiga_secondary_wins_g' => 'Altiga-Secondary-WINS-G',
- 'ascend_ts_idle_limit' => 'Ascend-TS-Idle-Limit',
- 'usr_port_tap_priority' => 'USR-Port-Tap-Priority',
- 'cvpn3000_ipsec_client_fw' => 'CVPN3000-IPSec-Client-Fw-Filter-Name',
- 'ascend_private_route_req' => 'Ascend-Private-Route-Required',
- 'ascend_private_route' => 'Ascend-Private-Route',
- 'prompt' => 'Prompt',
- 'acct_link_count' => 'Acct-Link-Count',
- 'bind_auth_service_grq' => 'Bind_Auth_Service_Grp',
- 'itk_tunnel_ip' => 'ITK-Tunnel-IP',
- 'login_lat_node' => 'Login-LAT-Node',
- 'usr_mbi_ct_pri_card_slot' => 'USR-Mbi_Ct_PRI_Card_Slot',
- 'lac_real_poru' => 'LAC_Real_Port',
- 'erx_ingress_statistics' => 'ERX-Ingress-Statistics',
- 'digest_nonce' => 'Digest-Nonce',
- 'annex_system_disc_reason' => 'Annex-System-Disc-Reason',
- 'pool_name' => 'Pool-Name',
- 'altiga_use_client_addres' => 'Altiga-Use-Client-Address-G/U',
- 'police_bursu' => 'Police_Burst',
- 'usr_call_arrival_time' => 'USR-Call-Arrival-Time',
- 'ascend_disconnect_cause' => 'Ascend-Disconnect-Cause',
- 'ascend_user_acct_time' => 'Ascend-User-Acct-Time',
- 'chap_challenge' => 'CHAP-Challenge',
- 'ascend_mpp_idle_percent' => 'Ascend-MPP-Idle-Percent',
- 'ascend_user_acct_port' => 'Ascend-User-Acct-Port',
- 'ldap_group' => 'Ldap-Group',
- 'ascend_numbering_plan_id' => 'Ascend-Numbering-Plan-ID',
- 'usr_last_number_dialed_o' => 'USR-Last-Number-Dialed-Out',
- 'pvc_encapsulation_type' => 'PVC-Encapsulation-Type',
- 'ascend_bir_bridge_group' => 'Ascend-BIR-Bridge-Group',
- 'ascend_atm_group' => 'Ascend-ATM-Group',
- 'ascend_fr_svc_addr' => 'Ascend-FR-SVC-Addr',
- 'x_ascend_send_auth' => 'X-Ascend-Send-Auth',
- 'le_ip_pool' => 'LE-IP-Pool',
- 'post_proxy_type' => 'Post-Proxy-Type',
- 'wispr_session_terminate_' => 'WISPr-Session-Terminate-Time',
- 'bintec_pppextiftable' => 'BinTec-pppExtIfTable',
- 'nomadix_subnet' => 'Nomadix-Subnet',
- 'login_port' => 'Login-Port',
- 'ms_chap2_response' => 'MS-CHAP2-Response',
- 'ascend_ipsec_profile' => 'Ascend-IPSEC-Profile',
- 'usr_compression_algorith' => 'USR-Compression-Algorithm',
- 'usr_accm_type' => 'USR-ACCM-Type',
- 'simultaneous_use' => 'Simultaneous-Use',
- 'cisco_account_info' => 'Cisco-Account-Info',
- 'framed_protocol' => 'Framed-Protocol',
- 'erx_tunnel_maximum_sessi' => 'ERX-Tunnel-Maximum-Sessions',
- 'redcreek_tunneled_wins_t' => 'RedCreek-Tunneled-WINS-Server2',
- 'ascend_recv_name' => 'Ascend-Recv-Name',
- 'usr_call_connecting_time' => 'USR-Call-Connecting-Time',
- 'quintum_h323_gw_id' => 'Quintum-h323-gw-id',
- 'acct_dyn_ac_ent' => 'Acct-Dyn-Ac-Ent',
- 'tunnel_remote_name' => 'Tunnel-Remote-Name',
- 'annex_ppp_trace_level' => 'Annex-PPP-Trace-Level',
- 'cisco_call_type' => 'Cisco-Call-Type',
- 'cisco_fax_recipient_coun' => 'Cisco-Fax-Recipient-Count',
- 'altiga_ipsec_authenticat' => 'Altiga-IPSec-Authentication-G',
- 'wispr_location_id' => 'WISPr-Location-ID',
- 'itk_start_delay' => 'ITK-Start-Delay',
- 'ascend_pre_output_packet' => 'Ascend-Pre-Output-Packets',
- 'usr_rmmie_firmware_versi' => 'USR-RMMIE-Firmware-Version',
- 'usr_vts_session_key' => 'USR-VTS-Session-Key',
- 'ascend_fr_dce_n393' => 'Ascend-FR-DCE-N393',
- 'login_host' => 'Login-Host',
- 'usr_reply_script3' => 'USR-Reply-Script3',
- 'cvpn3000_ipsec_split_tuo' => 'CVPN3000-IPSec-Split-Tunneling-Policy',
- 'ascend_pppoe_enable' => 'Ascend-PPPoE-Enable',
- 'annex_primary_dns_server' => 'Annex-Primary-DNS-Server',
- 'x_ascend_bridge_address' => 'X-Ascend-Bridge-Address',
- 'usr_number_of_link_naks' => 'USR-Number-of-Link-NAKs',
- 'altiga_priority_on_sep_g' => 'Altiga-Priority-on-SEP-G/U',
- 'annex_cli_command' => 'Annex-CLI-Command',
- 'usr_pw_framed_routing_v2' => 'USR-PW_Framed_Routing_V2',
- 'session_error_codf' => 'Session_Error_Code',
- 'annex_user_server_locati' => 'Annex-User-Server-Location',
- 'cisco_fax_mdn_address' => 'Cisco-Fax-Mdn-Address',
- 'ascend_calling_subaddres' => 'Ascend-Calling-Subaddress',
- 'ascend_call_by_call' => 'Ascend-Call-By-Call',
- 'ascend_first_dest' => 'Ascend-First-Dest',
- 'annex_tunnel_authen_type' => 'Annex-Tunnel-Authen-Type',
- 'acct_type' => 'Acct-Type',
- 'sql_user_name' => 'SQL-User-Name',
- 'erx_secondary_dns' => 'ERX-Secondary-Dns',
- 'bridge_grouq' => 'Bridge_Group',
- 'h323_return_code' => 'h323-return-code',
- 'annex_host_allow' => 'Annex-Host-Allow',
- 'cvx_modem_end_recv_line_' => 'CVX-Modem-End-Recv-Line-Lvl',
- 'sip_method' => 'Sip-Method',
- 'x_ascend_require_auth' => 'X-Ascend-Require-Auth',
- 'cvpn3000_sep_card_assign' => 'CVPN3000-SEP-Card-Assignment',
- 'le_ipsec_deny_action' => 'LE-IPSec-Deny-Action',
- 'annex_edo' => 'Annex-EDO',
- 'acct_delay_time' => 'Acct-Delay-Time',
- 'login_tcp_port' => 'Login-TCP-Port',
- 'ascend_temporary_rtes' => 'Ascend-Temporary-Rtes',
- 'versanet_termination_cau' => 'Versanet-Termination-Cause',
- 'ascend_dialed_number' => 'Ascend-Dialed-Number',
- 'cvpn3000_ipsec_authentic' => 'CVPN3000-IPSec-Authentication',
- 'ascend_fr_dlci' => 'Ascend-FR-DLCI',
- 'annex_modem_disc_reason' => 'Annex-Modem-Disc-Reason',
- 'x_ascend_receive_secret' => 'X-Ascend-Receive-Secret',
- 'usr_ospf_addressless_ind' => 'USR-OSPF-Addressless-Index',
- 'usr_ip_default_route_opt' => 'USR-IP-Default-Route-Option',
- 'char_noecho' => 'Char-Noecho',
- 'redcreek_tunneled_search' => 'RedCreek-Tunneled-Search-List',
- 'ascend_pri_number_type' => 'Ascend-PRI-Number-Type',
- 'aat_ip_tos_apply_to' => 'AAT-IP-TOS-Apply-To',
- 'x_ascend_modem_shelfno' => 'X-Ascend-Modem-ShelfNo',
- 'prefix' => 'Prefix',
- 'usr_rad_dvmrp_metric' => 'USR-Rad-Dvmrp-Metric',
- 'x_ascend_call_attempt_li' => 'X-Ascend-Call-Attempt-Limit',
- 'usr_ip_saa_filter' => 'USR-IP-SAA-Filter',
- 'itk_prompt' => 'ITK-Prompt',
- 'ascend_port_redir_protoc' => 'Ascend-Port-Redir-Protocol',
- 'cvx_modem_tx_packets' => 'CVX-Modem-Tx-Packets',
- 'usr_tunnel_switch_endpoi' => 'USR-Tunnel-Switch-Endpoint',
- 'ascend_home_network_name' => 'Ascend-Home-Network-Name',
- 'acc_customer_id' => 'Acc-Customer-Id',
- 'message_authenticator' => 'Message-Authenticator',
- 'cisco_fax_coverpage_flag' => 'Cisco-Fax-Coverpage-Flag',
- 'usr_multicast_forwarding' => 'USR-Multicast-Forwarding',
- 'cvpn3000_allow_network_e' => 'CVPN3000-Allow-Network-Extension-Mode',
- 'ascend_call_direction' => 'Ascend-Call-Direction',
- 'acc_connect_rx_speed' => 'Acc-Connect-Rx-Speed',
- 'ascend_force_56' => 'Ascend-Force-56',
- 'st_service_domain' => 'ST-Service-Domain',
- 'usr_harc_disconnect_code' => 'USR-HARC-Disconnect-Code',
- 'shasta_service_profile' => 'Shasta-Service-Profile',
- 'cisco_maximum_time' => 'Cisco-Maximum-Time',
- 'usr_tunnel_auth_hostname' => 'USR-Tunnel-Auth-Hostname',
- 'acc_ip_gateway_pri' => 'Acc-Ip-Gateway-Pri',
- 'ascend_bridge_address' => 'Ascend-Bridge-Address',
- 'altiga_pptp_min_authenti' => 'Altiga-PPTP-Min-Authentication-G/U',
- 'ns_secondary_wins' => 'NS-Secondary-WINS',
- 'cbbsm_bandwidth' => 'CBBSM-Bandwidth',
- 'x_ascend_fr_link_mgt' => 'X-Ascend-FR-Link-Mgt',
- 'altiga_ipsec_banner_g' => 'Altiga-IPSec-Banner-G',
- 'ascend_handle_ipx' => 'Ascend-Handle-IPX',
- 'ascend_x25_pad_alias_2' => 'Ascend-X25-Pad-Alias-2',
- 'st_policy_name' => 'ST-Policy-Name',
- 'ascend_group' => 'Ascend-Group',
- 'ascend_dsl_rate_type' => 'Ascend-Dsl-Rate-Type',
- 'tunnel_contexu' => 'Tunnel_Context',
- 'ascend_require_auth' => 'Ascend-Require-Auth',
- 'cvx_modem_local_retrains' => 'CVX-Modem-Local-Retrains',
- 'cvpn5000_echo' => 'CVPN5000-Echo',
- 'cvx_secondary_dns' => 'CVX-Secondary-DNS',
- 'x_ascend_billing_number' => 'X-Ascend-Billing-Number',
- 'usr_orig_nas_type' => 'USR-Orig-NAS-Type',
- 'ascend_remote_fw' => 'Ascend-Remote-FW',
- 'acct_output_packets' => 'Acct-Output-Packets',
- 'lm_password' => 'LM-Password',
- 'tunnel_window' => 'Tunnel-Window',
- 'cisco_avpair' => 'Cisco-AVPair',
- 'st_service_name' => 'ST-Service-Name',
- 'shiva_event_flags' => 'Shiva-Event-Flags',
- 'annex_retrain_requests_s' => 'Annex-Retrain-Requests-Sent',
- 'ascend_ts_idle_mode' => 'Ascend-TS-Idle-Mode',
- 'usr_ip_rip_simple_auth_p' => 'USR-IP-RIP-Simple-Auth-Password',
- 'tunnel_deadtimf' => 'Tunnel_Deadtime',
- 'state' => 'State',
- 'usr_keypress_timeout' => 'USR-Keypress-Timeout',
- 'usr_pw_vpn_neighbor' => 'USR-PW_VPN_Neighbor',
- 'erx_pppoe_description' => 'ERX-Pppoe-Description',
- 'ldap_userdn' => 'Ldap-UserDn',
- 'x_ascend_fr_n391' => 'X-Ascend-FR-N391',
- 'ascend_calling_id_presen' => 'Ascend-Calling-Id-Presentatn',
- 'erx_local_loopback_inter' => 'ERX-Local-Loopback-Interface',
- 'x_ascend_fr_direct' => 'X-Ascend-FR-Direct',
- 'nas_ip_address' => 'NAS-IP-Address',
- 'usr_call_end_time' => 'USR-Call-End-Time',
- 'acct_mcast_out_packett' => 'Acct_Mcast_Out_Packets',
- 'tunnel_algorithm' => 'Tunnel-Algorithm',
- 'usr_vpn_encrypter' => 'USR-VPN-Encrypter',
- 'tunnel_grouq' => 'Tunnel_Group',
- 'ascend_atm_connect_group' => 'Ascend-ATM-Connect-Group',
- 'x_ascend_ft1_caller' => 'X-Ascend-FT1-Caller',
- 'usr_dnis_reauthenticatio' => 'USR-DNIS-ReAuthentication',
- 'login_callback_number' => 'Login-Callback-Number',
- 'usr_ip_rip_input_filter' => 'USR-IP-RIP-Input-Filter',
- 'usr_rmmie_rcv_pwrlvl_330' => 'USR-RMMIE-Rcv-PwrLvl-3300Hz',
- 'h323_disconnect_cause' => 'h323-disconnect-cause',
- 'x_ascend_handle_ipx' => 'X-Ascend-Handle-IPX',
- 'usr_igmp_version' => 'USR-IGMP-Version',
- 'usr_imsi' => 'USR-IMSI',
- 'group_name' => 'Group-Name',
- 'usr_nas_type' => 'USR-NAS-Type',
- 'context_namf' => 'Context-Name',
- 'ascend_ip_tos' => 'Ascend-IP-TOS',
- 'x_ascend_token_immediate' => 'X-Ascend-Token-Immediate',
- 'tunnel_session_auth_serw' => 'Tunnel_Session_Auth_Service_Grp',
- 'ms_chap2_cpw' => 'MS-CHAP2-CPW',
- 'tunnel_session_auth_ctx' => 'Tunnel-Session-Auth-Ctx',
- 'usr_mobile_numbytes_rxed' => 'USR-Mobile-NumBytes-Rxed',
- 'usr_mbi_ct_tdm_time_slot' => 'USR-Mbi_Ct_TDM_Time_Slot',
- 'ascend_x25_nui' => 'Ascend-X25-Nui',
- 'x_ascend_first_dest' => 'X-Ascend-First-Dest',
- 'usr_send_password' => 'USR-Send-Password',
- 'x_ascend_fr_direct_profi' => 'X-Ascend-FR-Direct-Profile',
- 'x_ascend_fr_t391' => 'X-Ascend-FR-T391',
- 'altiga_ipsec_sec_associa' => 'Altiga-IPSec-Sec-Association-G/U',
- 'ip_address_pool_namf' => 'Ip_Address_Pool_Name',
- 'acct_input_octets' => 'Acct-Input-Octets',
- 'cvx_modem_begin_modulati' => 'CVX-Modem-Begin-Modulation',
- 'wispr_session_terminatea' => 'WISPr-Session-Terminate-End-Of-Day',
- 'cvpn3000_use_client_addr' => 'CVPN3000-Use-Client-Address',
- 'bridge_group' => 'Bridge-Group',
- 'annex_sec_profile_index' => 'Annex-Sec-Profile-Index',
- 'acc_dns_server_pri' => 'Acc-Dns-Server-Pri',
- 'ms_acct_auth_type' => 'MS-Acct-Auth-Type',
- 'x_ascend_maximum_call_du' => 'X-Ascend-Maximum-Call-Duration',
- 'tunnel_password' => 'Tunnel-Password',
- 'framed_ipv6_prefix' => 'Framed-IPv6-Prefix',
- 'usr_reply_script5' => 'USR-Reply-Script5',
- 'shiva_links_in_bundle' => 'Shiva-Links-In-Bundle',
- 'ascend_fr_profile_name' => 'Ascend-FR-Profile-Name',
- 'ascend_mtu' => 'Ascend-MTU',
- 'nokia_charging_id' => 'Nokia-Charging-Id',
- 'cvpn3000_ms_client_subne' => 'CVPN3000-MS-Client-Subnet-Mask',
- 'cvpn3000_ipsec_sec_assoc' => 'CVPN3000-IPSec-Sec-Association',
- 'cisco_ppp_async_map' => 'Cisco-PPP-Async-Map',
- 'cvpn3000_user_auth_servf' => 'CVPN3000-User-Auth-Server-Port',
- 'cisco_num_in_multilink' => 'Cisco-Num-In-Multilink',
- 'wispr_logoff_url' => 'WISPr-Logoff-URL',
- 'usr_mobile_ip_address' => 'USR-Mobile-IP-Address',
- 'usr_final_tx_link_data_r' => 'USR-Final-Tx-Link-Data-Rate',
- 'itk_ppp_compression_prot' => 'ITK-PPP-Compression-Prot',
- 'ascend_bridge' => 'Ascend-Bridge',
- 'x_ascend_presession_time' => 'X-Ascend-PreSession-Time',
- 'aat_client_primary_dns' => 'AAT-Client-Primary-DNS',
- 'cvpn3000_strip_realm' => 'CVPN3000-Strip-Realm',
- 'tunnel_cmd_timeout' => 'Tunnel-Cmd-Timeout',
- 'ascend_multicast_client' => 'Ascend-Multicast-Client',
- 'cvx_modem_remote_rate_ne' => 'CVX-Modem-Remote-Rate-Negs',
- 'tunnel_private_group_id' => 'Tunnel-Private-Group-Id',
- 'usr_rmmie_rcv_tot_pwrlvl' => 'USR-RMMIE-Rcv-Tot-PwrLvl',
- 'calling_station_id' => 'Calling-Station-Id',
- 'tunnel_rate_limit_burst' => 'Tunnel-Rate-Limit-Burst',
- 'usr_device_connected_to' => 'USR-Device-Connected-To',
- 'aat_source_ip_check' => 'AAT-Source-IP-Check',
- 'login_lat_service' => 'Login-LAT-Service',
- 'ascend_h323_fegw_address' => 'Ascend-H323-Fegw-Address',
- 'usr_called_party_number' => 'USR-Called-Party-Number',
- 'bintec_ipnatpresettable' => 'BinTec-ipNatPresetTable',
- 'ascend_remove_seconds' => 'Ascend-Remove-Seconds',
- 'shiva_user_attributes' => 'Shiva-User-Attributes',
- 'cisco_fax_dsn_flag' => 'Cisco-Fax-Dsn-Flag',
- 'x_ascend_route_ipx' => 'X-Ascend-Route-IPX',
- 'acc_route_policy' => 'Acc-Route-Policy',
- 'bind_l2tp_flow_controm' => 'Bind_L2TP_Flow_Control',
- 'erx_qos_profile_name' => 'ERX-Qos-Profile-Name',
- 'x_ascend_client_gateway' => 'X-Ascend-Client-Gateway',
- 'pre_proxy_type' => 'Pre-Proxy-Type',
- 'smb_account_ctrl_text' => 'SMB-Account-CTRL-TEXT',
- 'x_ascend_data_filter' => 'X-Ascend-Data-Filter',
- 'usr_rmmie_last_update_ti' => 'USR-RMMIE-Last-Update-Time',
- 'ascend_atm_direct' => 'Ascend-ATM-Direct',
- 'ascend_session_type' => 'Ascend-Session-Type',
- 'x_ascend_fr_linkup' => 'X-Ascend-FR-LinkUp',
- 'ascend_metric' => 'Ascend-Metric',
- 'x_ascend_assign_ip_clien' => 'X-Ascend-Assign-IP-Client',
- 'usr_speed_of_connection' => 'USR-Speed-Of-Connection',
- 'cvpn3000_require_hw_clie' => 'CVPN3000-Require-HW-Client-Auth',
- 'session_type' => 'Session-Type',
- 'acct_input_octets_65' => 'Acct_Input_Octets_64',
- 'le_nat_outsource_outmap' => 'LE-NAT-Outsource-Outmap',
- 'cvx_modem_local_rate_neg' => 'CVX-Modem-Local-Rate-Negs',
- 'mcast_sene' => 'Mcast_Send',
- 'pppoe_url' => 'PPPOE-URL',
- 'erx_service_bundle' => 'ERX-Service-Bundle',
- 'altiga_secondary_dns_g' => 'Altiga-Secondary-DNS-G',
- 'bg_trans_bpdv' => 'BG_Trans_BPDU',
- 'cvx_data_filter' => 'CVX-Data-Filter',
- 'acct_mcast_out_octets' => 'Acct-Mcast-Out-Octets',
- 'ascend_callback' => 'Ascend-Callback',
- 'tunnel_client_auth_id' => 'Tunnel-Client-Auth-Id',
- 'acct_unique_session_id' => 'Acct-Unique-Session-Id',
- 'usr_port_tap_format' => 'USR-Port-Tap-Format',
- 'ascend_ckt_type' => 'Ascend-Ckt-Type',
- 'ascend_ppp_async_map' => 'Ascend-PPP-Async-Map',
- 'usr_rmmie_rcv_pwrlvl_375' => 'USR-RMMIE-Rcv-PwrLvl-3750Hz',
- 'usr_acct_reason_code' => 'USR-Acct-Reason-Code',
- 'ascend_filter' => 'Ascend-Filter',
- 'h323_redirect_number' => 'h323-redirect-number',
- 'port_limit' => 'Port-Limit',
- 'rewrite_rule' => 'Rewrite-Rule',
- 'tunnel_police_rate' => 'Tunnel-Police-Rate',
- 'usr_multicast_proxy' => 'USR-Multicast-Proxy',
- 'ascend_max_shared_users' => 'Ascend-Max-Shared-Users',
- 'usr_bridging' => 'USR-Bridging',
- 'cvx_presession_time' => 'CVX-PreSession-Time',
- 'cvpn5000_vpn_groupinfo' => 'CVPN5000-VPN-GroupInfo',
- 'autz_type' => 'Autz-Type',
- 'x_ascend_fr_dlci' => 'X-Ascend-FR-DLCI',
- 'usr_request_type' => 'USR-Request-Type',
- 'acc_igmp_admin_state' => 'Acc-Igmp-Admin-State',
- 'ascend_host_info' => 'Ascend-Host-Info',
- 'ascend_dhcp_maximum_leas' => 'Ascend-DHCP-Maximum-Leases',
- 'usr_rmmie_num_of_updates' => 'USR-RMMIE-Num-Of-Updates',
- 'x_ascend_fr_profile_name' => 'X-Ascend-FR-Profile-Name',
- 'ascend_fr_direct_profile' => 'Ascend-FR-Direct-Profile',
- 'x_ascend_bridge' => 'X-Ascend-Bridge',
- 'tunnel_deadtime' => 'Tunnel-Deadtime',
- 'ms_chap_error' => 'MS-CHAP-Error',
- 'framed_route' => 'Framed-Route',
- 'sip_from' => 'Sip-From',
- 'expiration' => 'Expiration',
- 'ascend_backup' => 'Ascend-Backup',
- 'ascend_pre_output_octets' => 'Ascend-Pre-Output-Octets',
- 'ascend_calling_id_number' => 'Ascend-Calling-Id-Number-Plan',
- 'framed_appletalk_zone' => 'Framed-AppleTalk-Zone',
- 'annex_audit_level' => 'Annex-Audit-Level',
- 'digest_algorithm' => 'Digest-Algorithm',
- 'bind_auth_context' => 'Bind-Auth-Context',
- 'ascend_user_acct_base' => 'Ascend-User-Acct-Base',
- 'st_secondary_dns_server' => 'ST-Secondary-DNS-Server',
- 'mcast_receive' => 'Mcast-Receive',
- 'usr_ds0' => 'USR-DS0',
- 'aat_atm_traffic_profile' => 'AAT-ATM-Traffic-Profile',
- 'ms_ras_vendor' => 'MS-RAS-Vendor',
- 'tunnel_domain' => 'Tunnel-Domain',
- 'tunnel_max_sessions' => 'Tunnel-Max-Sessions',
- 'ascend_ip_direct' => 'Ascend-IP-Direct',
- 'xedia_address_pool' => 'Xedia-Address-Pool',
- 'idle_timeout' => 'Idle-Timeout',
- 'tunnel_rate_limit_ratf' => 'Tunnel_Rate_Limit_Rate',
- 'annex_rate_reneg_req_sen' => 'Annex-Rate-Reneg-Req-Sent',
- 'usr_initial_tx_link_data' => 'USR-Initial-Tx-Link-Data-Rate',
- 'tunnel_server_auth_id' => 'Tunnel-Server-Auth-Id',
- 'cvpn3000_ipsec_banner1' => 'CVPN3000-IPSec-Banner1',
- 'usr_start_time' => 'USR-Start-Time',
- 'usr_ip' => 'USR-IP',
- 'cvpn3000_reqrd_client_fw' => 'CVPN3000-Reqrd-Client-Fw-Vendor-Code',
- 'altiga_ipsec_secondary_d' => 'Altiga-IPSec-Secondary-Domains-G',
- 'usr_gateway_ip_address' => 'USR-Gateway-IP-Address',
- 'ascend_dba_monitor' => 'Ascend-DBA-Monitor',
- 'ms_link_utilization_thre' => 'MS-Link-Utilization-Threshold',
- 'st_primary_dns_server' => 'ST-Primary-DNS-Server',
- 'acc_ace_token_ttl' => 'Acc-Ace-Token-Ttl',
- 'ms_chap_domain' => 'MS-CHAP-Domain',
- 'cisco_pre_input_octets' => 'Cisco-Pre-Input-Octets',
- 'ascend_primary_home_agen' => 'Ascend-Primary-Home-Agent',
- 'acct_session_time' => 'Acct-Session-Time',
- 'framed_ip_address' => 'Framed-IP-Address',
- 'ns_admin_privilege' => 'NS-Admin-Privilege',
- 'medium_type' => 'Medium-Type',
- 'acct_output_octets_64' => 'Acct-Output-Octets-64',
- 'ascend_cir_timer' => 'Ascend-CIR-Timer',
- 'police_rate' => 'Police-Rate',
- 'tunnel_functioo' => 'Tunnel_Function',
- 'quintum_h323_time_and_da' => 'Quintum-h323-time-and-day',
- 'ip_tos_fiele' => 'IP_TOS_Field',
- 'erx_framed_ip_route_tag' => 'ERX-Framed-Ip-Route-Tag',
- 'ms_mppe_send_key' => 'MS-MPPE-Send-Key',
- 'ascend_maximum_call_dura' => 'Ascend-Maximum-Call-Duration',
- 'pppoe_motn' => 'PPPOE_MOTM',
- 'lac_poru' => 'LAC_Port',
- 'bind_dot1q_slou' => 'Bind_Dot1q_Slot',
- 'ascend_secondary_home_ag' => 'Ascend-Secondary-Home-Agent',
- 'usr_ip_call_output_filte' => 'USR-IP-Call-Output-Filter',
- 'x_ascend_host_info' => 'X-Ascend-Host-Info',
- 'erx_egress_policy_name' => 'ERX-Egress-Policy-Name',
- 'erx_ppp_password' => 'ERX-PPP-Password',
- 'user_name' => 'User-Name',
- 'usr_number_of_characters' => 'USR-Number-Of-Characters-Lost',
- 'bind_bypass_bypass' => 'Bind-Bypass-Bypass',
- 'usr_rad_multicast_routip' => 'USR-Rad-Multicast-Routing-Proto',
- 'annex_acct_servers' => 'Annex-Acct-Servers',
- 'cvpn5000_tunnel_throughp' => 'CVPN5000-Tunnel-Throughput',
- 'usr_chassis_call_channel' => 'USR-Chassis-Call-Channel',
- 'annex_input_filter' => 'Annex-Input-Filter',
- 'wispr_billing_class_of_s' => 'WISPr-Billing-Class-Of-Service',
- 'nas_port_type' => 'NAS-Port-Type',
- 'cvx_client_assign_dns' => 'CVX-Client-Assign-DNS',
- 'nomadix_maxbytesdown' => 'Nomadix-MaxBytesDown',
- 'ascend_endpoint_disc' => 'Ascend-Endpoint-Disc',
- 'tunnel_police_burst' => 'Tunnel-Police-Burst',
- 'bind_auth_max_sessions' => 'Bind-Auth-Max-Sessions',
- 'cvx_identification' => 'CVX-Identification',
- 'cvpn3000_ipsec_allow_pas' => 'CVPN3000-IPSec-Allow-Passwd-Store',
- 'ascend_calling_id_type_o' => 'Ascend-Calling-Id-Type-Of-Num',
- 'x_ascend_fr_dce_n392' => 'X-Ascend-FR-DCE-N392',
- 'usr_connect_term_reason' => 'USR-Connect-Term-Reason',
- 'erx_egress_statistics' => 'ERX-Egress-Statistics',
- 'ascend_fr_dte_n392' => 'Ascend-FR-DTE-N392',
- 'usr_esn' => 'USR-ESN',
- 'x_ascend_fr_dte_n392' => 'X-Ascend-FR-DTE-N392',
- 'itk_modem_init_string' => 'ITK-Modem-Init-String',
- 'x_ascend_fr_nailed_grp' => 'X-Ascend-FR-Nailed-Grp',
- 'ascend_bridge_non_pppoe' => 'Ascend-Bridge-Non-PPPoE',
- 'cvpn3000_ipsec_reqrd_cli' => 'CVPN3000-IPSec-Reqrd-Client-Fw-Cap',
- 'ascend_ipx_alias' => 'Ascend-IPX-Alias',
- 'acc_tunnel_port' => 'Acc-Tunnel-Port',
- 'quintum_h323_return_code' => 'Quintum-h323-return-code',
- 'cvpn3000_l2tp_encryption' => 'CVPN3000-L2TP-Encryption',
- 'acct_input_gigawords' => 'Acct-Input-Gigawords',
- 'bind_dot1q_poru' => 'Bind_Dot1q_Port',
- 'altiga_primary_wins_g' => 'Altiga-Primary-WINS-G',
- 'ascend_maximum_channels' => 'Ascend-Maximum-Channels',
- 'x_ascend_home_agent_pass' => 'X-Ascend-Home-Agent-Password',
- 'x_ascend_ppp_async_map' => 'X-Ascend-PPP-Async-Map',
- 'usr_rmmie_manufacturer_i' => 'USR-RMMIE-Manufacturer-ID',
- 'usr_retrains_requested' => 'USR-Retrains-Requested',
- 'x_ascend_metric' => 'X-Ascend-Metric',
- 'acc_apsm_oversubscribed' => 'Acc-Apsm-Oversubscribed',
- 'usr_originate_answer_mod' => 'USR-Originate-Answer-Mode',
- 'erx_atm_pcr' => 'ERX-Atm-PCR',
- 'itk_nas_name' => 'ITK-NAS-Name',
- 'usr_ipx_routing' => 'USR-IPX-Routing',
- 'usr_tunneled_mlpp' => 'USR-Tunneled-MLPP',
- 'usr_send_script5' => 'USR-Send-Script5',
- 'ascend_traffic_shaper' => 'Ascend-Traffic-Shaper',
- 'ascend_client_secondarya' => 'Ascend-Client-Secondary-DNS',
- 'ascend_bacp_enable' => 'Ascend-BACP-Enable',
- 'usr_call_terminate_in_gm' => 'USR-Call-Terminate-in-GMT',
- 'login_time' => 'Login-Time',
- 'bg_path_cosu' => 'BG_Path_Cost',
- 'aat_require_auth' => 'AAT-Require-Auth',
- 'cvpn3000_reqrd_client_fy' => 'CVPN3000-Reqrd-Client-Fw-Description',
- 'ascend_call_type' => 'Ascend-Call-Type',
- 'erx_address_pool_name' => 'ERX-Address-Pool-Name',
- 'cvpn3000_ipsec_backup_sf' => 'CVPN3000-IPSec-Backup-Server-List',
- 'h323_incoming_conf_id' => 'h323-incoming-conf-id',
- 'user_profile' => 'User-Profile',
- 'ip_host_adds' => 'Ip_Host_Addr',
- 'ns_primary_wins' => 'NS-Primary-WINS',
- 'packet_type' => 'Packet-Type',
- 'bind_auth_max_sessiont' => 'Bind_Auth_Max_Sessions',
- 'altiga_allow_alpha_only_' => 'Altiga-Allow-Alpha-Only-Passwords-G',
- 'usr_security_resp_limit' => 'USR-Security-Resp-Limit',
- 'ip_address_pool_name' => 'Ip-Address-Pool-Name',
- 'ascend_ipx_node_addr' => 'Ascend-IPX-Node-Addr',
- 'ascend_cbcp_trunk_group' => 'Ascend-CBCP-Trunk-Group',
- 'ascend_menu_selector' => 'Ascend-Menu-Selector',
- 'ascend_assign_ip_global_' => 'Ascend-Assign-IP-Global-Pool',
- 'usr_ds0s' => 'USR-DS0s',
- 'usr_actual_voltage' => 'USR-Actual-Voltage',
- 'quintum_h323_call_type' => 'Quintum-h323-call-type',
- 'annex_sw_version' => 'Annex-SW-Version',
- 'ascend_receive_secret' => 'Ascend-Receive-Secret',
- 'bintec_qospolicytable' => 'BinTec-qosPolicyTable',
- 'usr_ip_rip_policies' => 'USR-IP-RIP-Policies',
- 'redcreek_tunneled_ip_add' => 'RedCreek-Tunneled-IP-Addr',
- 'ascend_pw_warntime' => 'Ascend-PW-Warntime',
- 'x_ascend_inc_channel_cou' => 'X-Ascend-Inc-Channel-Count',
- 'usr_blocks_resent' => 'USR-Blocks-Resent',
- 'usr_fallback_enabled' => 'USR-Fallback-Enabled',
- 'arap_challenge_response' => 'ARAP-Challenge-Response',
- 'tunnel_session_auth' => 'Tunnel-Session-Auth',
- 'usr_sync_async_mode' => 'USR-Sync-Async-Mode',
- 'itk_dialout_type' => 'ITK-Dialout-Type',
- 'extreme_netlogin_url' => 'Extreme-Netlogin-Url',
- 'client_port_dnis' => 'Client-Port-DNIS',
- 'digest_realm' => 'Digest-Realm',
- 'ascend_ppp_vj_1172' => 'Ascend-PPP-VJ-1172',
- 'ascend_fr_n391' => 'Ascend-FR-N391',
- 'ascend_remote_addr' => 'Ascend-Remote-Addr',
- 'client_port_id' => 'Client-Port-Id',
- 'digest_body_digest' => 'Digest-Body-Digest',
- 'le_ipsec_active_profile' => 'LE-IPSec-Active-Profile',
- 'digest_cnonce' => 'Digest-CNonce',
- 'usr_port_tap_facility' => 'USR-Port-Tap-Facility',
- 'usr_callback_type' => 'USR-Callback-Type',
- 'client_dns_prj' => 'Client_DNS_Pri',
- 'digest_response' => 'Digest-Response',
- 'login_lat_group' => 'Login-LAT-Group',
- 'x_ascend_call_type' => 'X-Ascend-Call-Type',
- 'ascend_route_ip' => 'Ascend-Route-IP',
- 'usr_rad_multicast_routio' => 'USR-Rad-Multicast-Routing-RtLim',
- 'usr_pw_vpn_id' => 'USR-PW_VPN_ID',
- 'cvx_modem_end_modulation' => 'CVX-Modem-End-Modulation',
- 'cvpn3000_pptp_mppc_compr' => 'CVPN3000-PPTP-MPPC-Compression',
- 'cisco_pre_output_octets' => 'Cisco-Pre-Output-Octets',
- 'h323_billing_model' => 'h323-billing-model',
- 'usr_equalization_type' => 'USR-Equalization-Type',
- 'acc_clearing_cause' => 'Acc-Clearing-Cause',
- 'altiga_access_hours_g_u' => 'Altiga-Access-Hours-G/U',
- 'cvpn3000_ipsec_user_grou' => 'CVPN3000-IPSec-User-Group-Lock',
- 'x_ascend_menu_selector' => 'X-Ascend-Menu-Selector',
- 'x_ascend_netware_timeout' => 'X-Ascend-Netware-timeout',
- 'ascend_fr_linkup' => 'Ascend-FR-LinkUp',
- 'annex_num_in_multilink' => 'Annex-Num-In-Multilink',
- 'police_burst' => 'Police-Burst',
- 'altiga_l2tp_min_authenti' => 'Altiga-L2TP-Min-Authentication-G/U',
- 'ascend_filter_required' => 'Ascend-Filter-Required',
- 'x_ascend_idle_limit' => 'X-Ascend-Idle-Limit',
- 'nomadix_logoff_url' => 'Nomadix-Logoff-URL',
- 'cvpn3000_ms_client_icpt_' => 'CVPN3000-MS-Client-Icpt-DHCP-Conf-Msg',
- 'ip_tos_field' => 'IP-TOS-Field',
- 'ascend_ip_tos_apply_to' => 'Ascend-IP-TOS-Apply-To',
- 'usr_call_event_code' => 'USR-Call-Event-Code',
- 'usr_et_bridge_output_fil' => 'USR-ET-Bridge-Output-Filter',
- 'le_nat_sess_dir_fail_act' => 'LE-NAT-Sess-Dir-Fail-Action',
- 'usr_rmmie_product_code' => 'USR-RMMIE-Product-Code',
- 'usr_host_type' => 'USR-Host-Type',
- 'erx_tunnel_interface_id' => 'ERX-Tunnel-Interface-Id',
- 'ascend_send_auth' => 'Ascend-Send-Auth',
- 'shiva_compression_type' => 'Shiva-Compression-Type',
- 'itk_banner' => 'ITK-Banner',
- 'ascend_ft1_caller' => 'Ascend-FT1-Caller',
- 'filter_id' => 'Filter-Id',
- 'annex_pre_output_octets' => 'Annex-Pre-Output-Octets',
- 'acct_mcast_in_octett' => 'Acct_Mcast_In_Octets',
- 'usr_log_filter_packets' => 'USR-Log-Filter-Packets',
- 'ascend_fr_nailed_grp' => 'Ascend-FR-Nailed-Grp',
- 'ascend_atm_loopback_cell' => 'Ascend-ATM-Loopback-Cell-Loss',
- 'usr_at_rtmp_output_filte' => 'USR-AT-RTMP-Output-Filter',
- 'acc_input_errors' => 'Acc-Input-Errors',
- 'x_ascend_user_acct_port' => 'X-Ascend-User-Acct-Port',
- 'erx_secondary_wins' => 'ERX-Secondary-Wins',
- 'usr_rmmie_serial_number' => 'USR-RMMIE-Serial-Number',
- 'usr_et_bridge_input_filt' => 'USR-ET-Bridge-Input-Filter',
- 'ns_primary_dns' => 'NS-Primary-DNS',
- 'usr_slot_connected_to' => 'USR-Slot-Connected-To',
- 'shiva_disconnect_reason' => 'Shiva-Disconnect-Reason',
- 'cvpn5000_client_assignee' => 'CVPN5000-Client-Assigned-IPX',
- 'cvx_radius_redirect' => 'CVX-Radius-Redirect',
- 'usr_receive_acc_map' => 'USR-Receive-Acc-Map',
- 'x_ascend_tunneling_proto' => 'X-Ascend-Tunneling-Protocol',
- 'itk_acct_serv_ip' => 'ITK-Acct-Serv-IP',
- 'ascend_fr_type' => 'Ascend-FR-Type',
- 'ascend_client_assign_dns' => 'Ascend-Client-Assign-DNS',
- 'annex_retrain_requests_r' => 'Annex-Retrain-Requests-Rcvd',
- 'x_ascend_assign_ip_globa' => 'X-Ascend-Assign-IP-Global-Pool',
- 'tunnel_client_endpoint' => 'Tunnel-Client-Endpoint',
- 'alteon_service_type' => 'Alteon-Service-Type',
- 'x_ascend_send_secret' => 'X-Ascend-Send-Secret',
- 'x_ascend_call_filter' => 'X-Ascend-Call-Filter',
- 'usr_ipx_rip_input_filter' => 'USR-IPX-RIP-Input-Filter',
- 'x_ascend_maximum_time' => 'X-Ascend-Maximum-Time',
- 'pvc_profile_name' => 'PVC-Profile-Name',
- 'usr_framed_ip_address_po' => 'USR-Framed_IP_Address_Pool_Name',
- 'cvpn3000_ipsec_split_dns' => 'CVPN3000-IPSec-Split-DNS-Names',
- 'ascend_global_call_id' => 'Ascend-Global-Call-Id',
- 'usr_initial_rx_link_data' => 'USR-Initial-Rx-Link-Data-Rate',
- 'st_primary_nbns_server' => 'ST-Primary-NBNS-Server',
- 'usr_number_of_rings_limi' => 'USR-Number-of-Rings-Limit',
- 'tunnel_local_name' => 'Tunnel-Local-Name',
- 'ascend_fr_t392' => 'Ascend-FR-T392',
- 'annex_pool_id' => 'Annex-Pool-Id',
- 'ascend_token_immediate' => 'Ascend-Token-Immediate',
- 'usr_rmmie_firmware_build' => 'USR-RMMIE-Firmware-Build-Date',
- 'wispr_bandwidth_min_down' => 'WISPr-Bandwidth-Min-Down',
- 'usr_chassis_call_slot' => 'USR-Chassis-Call-Slot',
- 'rate_limit_burst' => 'Rate-Limit-Burst',
- 'cisco_route_ip' => 'Cisco-Route-IP',
- 'xedia_netbios_server' => 'Xedia-NetBios-Server',
- 'session_error_msg' => 'Session-Error-Msg',
- 'dhcp_max_leases' => 'DHCP-Max-Leases',
- 'acc_vpsm_reject_cause' => 'Acc-Vpsm-Reject-Cause',
- 'user_category' => 'User-Category',
- 'x_ascend_multicast_rate_' => 'X-Ascend-Multicast-Rate-Limit',
- 'cvpn3000_ipsec_auth_on_r' => 'CVPN3000-IPSec-Auth-On-Rekey',
- 'altiga_min_password_leng' => 'Altiga-Min-Password-Length-G',
- 'bind_type' => 'Bind-Type',
- 'ascend_tunneling_protoco' => 'Ascend-Tunneling-Protocol',
- 'cvx_modem_retx_packets' => 'CVX-Modem-ReTx-Packets',
- 'usr_framed_ipx_route' => 'USR-Framed-IPX-Route',
- 'rate_limit_rate' => 'Rate-Limit-Rate',
- 'ascend_atm_connect_vpi' => 'Ascend-ATM-Connect-Vpi',
- 'connect_info' => 'Connect-Info',
- 'usr_port_tap_address' => 'USR-Port-Tap-Address',
- 'usr_simplified_mnp_level' => 'USR-Simplified-MNP-Levels',
- 'mcast_receivf' => 'Mcast_Receive',
- 'annex_begin_modulation' => 'Annex-Begin-Modulation',
- 'usr_pw_usr_ifilter_ip' => 'USR-PW_USR_IFilter_IP',
- 'ascend_route_appletalk' => 'Ascend-Route-Appletalk',
- 'ms_chap_lm_enc_pw' => 'MS-CHAP-LM-Enc-PW',
- 'altiga_ipsec_over_nat_po' => 'Altiga-IPSec-Over-NAT-Port-Num-G',
- 'itk_isdn_prot' => 'ITK-ISDN-Prot',
- 'ascend_callback_delay' => 'Ascend-Callback-Delay',
- 'session_error_code' => 'Session-Error-Code',
- 'nomadix_endofsession' => 'Nomadix-EndofSession',
- 'x_ascend_bacp_enable' => 'X-Ascend-BACP-Enable',
- 'bg_trans_bpdu' => 'BG-Trans-BPDU',
- 'bind_int_interface_namf' => 'Bind_Int_Interface_Name',
- 'foundry_privilege_level' => 'Foundry-Privilege-Level',
- 'huntgroup_name' => 'Huntgroup-Name',
- 'x_ascend_ipx_alias' => 'X-Ascend-IPX-Alias',
- 'tunnel_l2f_second_passwp' => 'Tunnel_L2F_Second_Password',
- 'xedia_dns_server' => 'Xedia-DNS-Server',
- 'usr_ipx_wan' => 'USR-IPX-WAN',
- 'annex_addr_resolution_se' => 'Annex-Addr-Resolution-Servers',
- 'acct_output_octets_65' => 'Acct_Output_Octets_64',
- 'menu' => 'Menu',
- 'erx_tunnel_nas_port_meth' => 'ERX-Tunnel-Nas-Port-Method',
- 'aat_output_octets_diff' => 'AAT-Output-Octets-Diff',
- 'x_ascend_fr_direct_dlci' => 'X-Ascend-FR-Direct-DLCI',
- 'acct_status_type' => 'Acct-Status-Type',
- 'ascend_port_redir_server' => 'Ascend-Port-Redir-Server',
- 'telebit_port_name' => 'Telebit-Port-Name',
- 'acc_dns_server_sec' => 'Acc-Dns-Server-Sec',
- 'cvx_modem_remote_retrain' => 'CVX-Modem-Remote-Retrains',
- 'ascend_minimum_channels' => 'Ascend-Minimum-Channels',
- 'ascend_ipx_route' => 'Ascend-IPX-Route',
- 'ascend_telnet_profile' => 'Ascend-Telnet-Profile',
- 'usr_call_connect_in_gmt' => 'USR-Call-Connect-in-GMT',
- 'usr_cusr_hat_script_rule' => 'USR-CUSR-hat-Script-Rules',
- 'x_ascend_dba_monitor' => 'X-Ascend-DBA-Monitor',
- 'response_packet_type' => 'Response-Packet-Type',
- 'usr_event_id' => 'USR-Event-Id',
- 'cvpn3000_ipsec_over_udp_' => 'CVPN3000-IPSec-Over-UDP-Port',
- 'ascend_inc_channel_count' => 'Ascend-Inc-Channel-Count',
- 'usr_send_script3' => 'USR-Send-Script3',
- 'annex_pre_input_packets' => 'Annex-Pre-Input-Packets',
- 'framed_callback_id' => 'Framed-Callback-Id',
- 'xedia_client_access_netw' => 'Xedia-Client-Access-Network',
- 'arap_zone_access' => 'ARAP-Zone-Access',
- 'ascend_port_redir_portnu' => 'Ascend-Port-Redir-Portnum',
- 'service_type' => 'Service-Type',
- 'usr_nfas_id' => 'USR-NFAS-ID',
- 'shiva_calling_number' => 'Shiva-Calling-Number',
- 'ascend_user_acct_host' => 'Ascend-User-Acct-Host',
- 'tunnel_session_auth_serv' => 'Tunnel-Session-Auth-Service-Grp',
- 'juniper_deny_commands' => 'Juniper-Deny-Commands',
- 'ascend_fr_link_mgt' => 'Ascend-FR-Link-Mgt',
- 'nokia_imsi' => 'Nokia-IMSI',
- 'quintum_h323_prompt_id' => 'Quintum-h323-prompt-id',
- 'cvpn3000_require_individ' => 'CVPN3000-Require-Individual-User-Auth',
- 'tunnel_retransmiu' => 'Tunnel_Retransmit',
- 'source_validatioo' => 'Source_Validation',
- 'sip_to' => 'Sip-To',
- 'ms_primary_nbns_server' => 'MS-Primary-NBNS-Server',
- 'quintum_avpair' => 'Quintum-AVPair',
- 'ascend_transit_number' => 'Ascend-Transit-Number',
- 'ascend_cache_refresh' => 'Ascend-Cache-Refresh',
- 'ascend_user_acct_type' => 'Ascend-User-Acct-Type',
- 'usr_num_fax_pages_proces' => 'USR-Num-Fax-Pages-Processed',
- 'usr_mic' => 'USR-MIC',
- 'usr_failure_to_connect_r' => 'USR-Failure-to-Connect-Reason',
- 'cisco_fax_auth_status' => 'Cisco-Fax-Auth-Status',
- 'bind_dot1q_vlan_tag_ie' => 'Bind_Dot1q_Vlan_Tag_Id',
- 'ms_chap2_success' => 'MS-CHAP2-Success',
- 'erx_tunnel_virtual_route' => 'ERX-Tunnel-Virtual-Router',
- 'cisco_idle_limit' => 'Cisco-Idle-Limit',
- 'ascend_pw_lifetime' => 'Ascend-PW-Lifetime',
- 'cvpn3000_access_hours' => 'CVPN3000-Access-Hours',
- 'bintec_sapcirctable' => 'BinTec-sapCircTable',
- 'usr_packet_bus_session' => 'USR-Packet-Bus-Session',
- 'acct_input_packets_64' => 'Acct-Input-Packets-64',
- 'ascend_x25_pad_x3_parame' => 'Ascend-X25-Pad-X3-Parameters',
- 'usr_secondary_nbns_serve' => 'USR-Secondary_NBNS_Server',
- 'ascend_modem_slotno' => 'Ascend-Modem-SlotNo',
- 'digest_qop' => 'Digest-QOP',
- 'usr_characters_received' => 'USR-Characters-Received',
- 'rate_limit_ratf' => 'Rate_Limit_Rate',
- 'ms_bap_usage' => 'MS-BAP-Usage',
- 'cisco_data_filter' => 'Cisco-Data-Filter',
- 'usr_simplified_v42bis_us' => 'USR-Simplified-V42bis-Usage',
- 'h323_setup_time' => 'h323-setup-time',
- 'annex_wan_number' => 'Annex-Wan-Number',
- 'cvx_vpop_id' => 'CVX-VPOP-ID',
- 'usr_pw_tunnel_authentica' => 'USR-PW_Tunnel_Authentication',
- 'le_nat_outsource_inmap' => 'LE-NAT-Outsource-Inmap',
- 'cvx_modem_begin_recv_lin' => 'CVX-Modem-Begin-Recv-Line-Lvl',
- 'telebit_login_command' => 'Telebit-Login-Command',
- 'cisco_command_code' => 'Cisco-Command-Code',
- 'itk_ppp_auth_type' => 'ITK-PPP-Auth-Type',
- 'bintec_qosiftable' => 'BinTec-qosIfTable',
- 'x_ascend_mpp_idle_percen' => 'X-Ascend-MPP-Idle-Percent',
- 'usr_sap_filter_in' => 'USR-SAP-Filter-In',
- 'framed_appletalk_link' => 'Framed-AppleTalk-Link',
- 'tunnel_domaio' => 'Tunnel_Domain',
- 'usr_ipx' => 'USR-IPX',
- 'nas_real_poru' => 'NAS_Real_Port',
- 'shiva_connect_reason' => 'Shiva-Connect-Reason',
- 'x_ascend_pre_output_octe' => 'X-Ascend-Pre-Output-Octets',
- 'cisco_ppp_vj_slot_comp' => 'Cisco-PPP-VJ-Slot-Comp',
- 'freeradius_proxied_to' => 'Freeradius-Proxied-To',
- 'ascend_atm_vpi' => 'Ascend-ATM-Vpi',
- 'acc_ml_mlx_admin_state' => 'Acc-ML-MLX-Admin-State',
- 'cvx_modem_snr' => 'CVX-Modem-SNR',
- 'usr_igmp_robustness' => 'USR-IGMP-Robustness',
- 'annex_rate_reneg_req_rcv' => 'Annex-Rate-Reneg-Req-Rcvd',
- 'add_prefix' => 'Add-Prefix',
- 'x_ascend_call_by_call' => 'X-Ascend-Call-By-Call',
- 'usr_last_callers_number_' => 'USR-Last-Callers-Number-ANI',
- 'postauth_type' => 'PostAuth-Type',
- 'pvc_circuit_paddinh' => 'PVC_Circuit_Padding',
- 'usr_at_rtmp_input_filter' => 'USR-AT-RTMP-Input-Filter',
- 'erx_igmp_enable' => 'ERX-Igmp-Enable',
- 'bind_bypass_contexu' => 'Bind_Bypass_Context',
- 'x_ascend_num_in_multilin' => 'X-Ascend-Num-In-Multilink',
- 'usr_pw_packet' => 'USR-PW_Packet',
- 'dialback_no' => 'Dialback-No',
- 'ascend_ip_tos_precedence' => 'Ascend-IP-TOS-Precedence',
- 'cvpn5000_vpn_password' => 'CVPN5000-VPN-Password',
- 'annex_cli_filter' => 'Annex-CLI-Filter',
- 'x_ascend_dial_number' => 'X-Ascend-Dial-Number',
- 'usr_iwf_call_identifier' => 'USR-IWF-Call-Identifier',
- 'ms_secondary_dns_server' => 'MS-Secondary-DNS-Server',
- 'shiva_type_of_service' => 'Shiva-Type-Of-Service',
- 'bind_ses_context' => 'Bind-Ses-Context',
- 'acc_reason_code' => 'Acc-Reason-Code',
- 'ms_chap_cpw_1' => 'MS-CHAP-CPW-1',
- 'wispr_bandwidth_max_down' => 'WISPr-Bandwidth-Max-Down',
- 'h323_call_type' => 'h323-call-type',
- 'bind_bypass_bypast' => 'Bind_Bypass_Bypass',
- 'usr_number_of_link_timeo' => 'USR-Number-of-Link-Timeouts',
- 'ascend_fr_08_mode' => 'Ascend-FR-08-Mode',
- 'usr_calling_party_number' => 'USR-Calling-Party-Number',
- 'usr_reply_script2' => 'USR-Reply-Script2',
- 'usr_security_login_limit' => 'USR-Security-Login-Limit',
- 'cisco_link_compression' => 'Cisco-Link-Compression',
- 'ascend_vrouter_name' => 'Ascend-VRouter-Name',
- 'erx_ppp_auth_protocol' => 'ERX-PPP-Auth-Protocol',
- 'x_ascend_call_block_dura' => 'X-Ascend-Call-Block-Duration',
- 'usr_modem_setup_time' => 'USR-Modem-Setup-Time',
- 'pppoe_urm' => 'PPPOE_URL',
- 'cisco_ip_direct' => 'Cisco-IP-Direct',
- 'x_ascend_temporary_rtes' => 'X-Ascend-Temporary-Rtes',
- 'ascend_x25_pad_alias_3' => 'Ascend-X25-Pad-Alias-3',
- 'annex_multilink_id' => 'Annex-Multilink-Id',
- 'mcast_maxgroupt' => 'Mcast_MaxGroups',
- 'configuration_token' => 'Configuration-Token',
- 'ascend_h323_conference_i' => 'Ascend-H323-Conference-Id',
- 'ascend_ipx_header_compre' => 'Ascend-IPX-Header-Compression',
- 'stripped_user_name' => 'Stripped-User-Name',
- 'usr_ipx_rip_output_filte' => 'USR-IPX-RIP-Output-Filter',
- 'cisco_call_filter' => 'Cisco-Call-Filter',
- 'nas_ipv6_address' => 'NAS-IPv6-Address',
- 'termination_menu' => 'Termination-Menu',
- 'ascend_shared_profile_en' => 'Ascend-Shared-Profile-Enable',
- 'port_message' => 'Port-Message',
- 'erx_ingress_policy_name' => 'ERX-Ingress-Policy-Name',
- 'acc_service_profile' => 'Acc-Service-Profile',
- 'ascend_bir_proxy' => 'Ascend-BIR-Proxy',
- 'aat_ppp_address' => 'AAT-PPP-Address',
- 'usr_mbi_ct_pri_card_span' => 'USR-Mbi_Ct_PRI_Card_Span_Line',
- 'ascend_x25_nui_prompt' => 'Ascend-X25-Nui-Prompt',
- 'itk_modem_pool_id' => 'ITK-Modem-Pool-Id',
- 'usr_compression_reset_mo' => 'USR-Compression-Reset-Mode',
- 'usr_unauthenticated_time' => 'USR-Unauthenticated-Time',
- 'ascend_multicast_gleave_' => 'Ascend-Multicast-GLeave-Delay',
- 'acc_callback_cbcp_type' => 'Acc-Callback-CBCP-Type',
- 'medium_typf' => 'Medium_Type',
- 'login_service' => 'Login-Service',
- 'itk_username_prompt' => 'ITK-Username-Prompt',
- 'ascend_dial_number' => 'Ascend-Dial-Number',
- 'framed_ipv6_route' => 'Framed-IPv6-Route',
- 'x_ascend_remote_addr' => 'X-Ascend-Remote-Addr',
- 'usr_call_end_date_time' => 'USR-Call-End-Date-Time',
- 'bind_dot1q_slot' => 'Bind-Dot1q-Slot',
- 'le_connect_detail' => 'LE-Connect-Detail',
- 'annex_user_level' => 'Annex-User-Level',
- 'tunnel_dnis' => 'Tunnel-DNIS',
- 'assigned_ip_address' => 'Assigned-IP-Address',
- 'acc_bridging_support' => 'Acc-Bridging-Support',
- 'usr_channel' => 'USR-Channel',
- 'arap_security_data' => 'ARAP-Security-Data',
- 'bind_auth_service_grp' => 'Bind-Auth-Service-Grp',
- 'cisco_abort_cause' => 'Cisco-Abort-Cause',
- 'bg_span_dit' => 'BG_Span_Dis',
- 'h323_voice_quality' => 'h323-voice-quality',
- 'lac_real_port_typf' => 'LAC_Real_Port_Type',
- 'usr_channel_connected_to' => 'USR-Channel-Connected-To',
- 'ascend_client_assign_win' => 'Ascend-Client-Assign-WINS',
- 'redcreek_tunneled_gatewa' => 'RedCreek-Tunneled-Gateway',
- 'usr_number_of_fallbacks' => 'USR-Number-of-Fallbacks',
- 'nokia_prepaid_ind' => 'Nokia-Prepaid-Ind',
- 'nomadix_maxbytesup' => 'Nomadix-MaxBytesUp',
- 'login_hosu' => 'Login-Host',
- 'ascend_bir_enable' => 'Ascend-BIR-Enable',
- 'usr_connect_time_limit' => 'USR-Connect-Time-Limit',
- 'ascend_presession_time' => 'Ascend-PreSession-Time',
- 'altiga_simultaneous_logi' => 'Altiga-Simultaneous-Logins-G/U',
- 'cvpn3000_ipsec_default_d' => 'CVPN3000-IPSec-Default-Domain',
- 'aat_atm_vci' => 'AAT-ATM-VCI',
- 'extreme_netlogin_url_des' => 'Extreme-Netlogin-Url-Desc',
- 'itk_auth_serv_ip' => 'ITK-Auth-Serv-IP',
- 'erx_alternate_cli_vroute' => 'ERX-Alternate-Cli-Vrouter-Name',
- 'framed_compression' => 'Framed-Compression',
- 'ascend_svc_enabled' => 'Ascend-SVC-Enabled',
- 'proxy_state' => 'Proxy-State',
- 'aat_vrouter_name' => 'AAT-Vrouter-Name',
- 'usr_rmmie_pwrlvl_farecho' => 'USR-RMMIE-PwrLvl-FarEcho-Canc',
- 'nas_poru' => 'NAS-Port',
- 'wispr_location_name' => 'WISPr-Location-Name',
- 'digest_user_name' => 'Digest-User-Name',
- 'ascend_modem_shelfno' => 'Ascend-Modem-ShelfNo',
- 'shasta_user_privilege' => 'Shasta-User-Privilege',
- 'bind_auth_protocol' => 'Bind-Auth-Protocol',
- 'ascend_home_agent_passwo' => 'Ascend-Home-Agent-Password',
- 'acct_interim_interval' => 'Acct-Interim-Interval',
- 'ascend_history_weigh_typ' => 'Ascend-History-Weigh-Type',
- 'ms_link_drop_time_limit' => 'MS-Link-Drop-Time-Limit',
- 'hint' => 'Hint',
- 'x_ascend_target_util' => 'X-Ascend-Target-Util',
- 'acc_access_partition' => 'Acc-Access-Partition',
- 'usr_power_supply_number' => 'USR-Power-Supply-Number',
- 'x_ascend_multilink_id' => 'X-Ascend-Multilink-ID',
- 'redcreek_tunneled_domain' => 'RedCreek-Tunneled-DomainName',
- 'nomadix_bw_down' => 'Nomadix-Bw-Down',
- 'acc_ipx_compression' => 'Acc-Ipx-Compression',
- 'quintum_h323_setup_time' => 'Quintum-h323-setup-time',
- 'cisco_target_util' => 'Cisco-Target-Util',
- 'acc_ip_gateway_sec' => 'Acc-Ip-Gateway-Sec',
- 'ascend_dsl_cir_xmit_limi' => 'Ascend-Dsl-CIR-Xmit-Limit',
- 'ascend_ip_pool_definitio' => 'Ascend-IP-Pool-Definition',
- 'bind_sub_user_at_contexu' => 'Bind_Sub_User_At_Context',
- 'itk_dest_no' => 'ITK-Dest-No',
- 'usr_connect_time' => 'USR-Connect-Time',
- 'usr_call_start_date_time' => 'USR-Call-Start-Date-Time',
- 'altiga_l2tp_encryption_g' => 'Altiga-L2TP-Encryption-G',
- 'ascend_auth_delay' => 'Ascend-Auth-Delay',
- 'ascend_x25_pad_x3_profil' => 'Ascend-X25-Pad-X3-Profile',
- 'ascend_access_intercepta' => 'Ascend-Access-Intercept-Log',
- 'ascend_home_agent_udp_po' => 'Ascend-Home-Agent-UDP-Port',
- 'bind_tun_context' => 'Bind-Tun-Context',
- 'dialback_name' => 'Dialback-Name',
- 'h323_redirect_ip_address' => 'h323-redirect-ip-address',
- 'annex_keypress_timeout' => 'Annex-Keypress-Timeout',
- 'x_ascend_home_network_na' => 'X-Ascend-Home-Network-Name',
- 'ascend_x25_pad_alias_1' => 'Ascend-X25-Pad-Alias-1',
- 'ascend_call_attempt_limi' => 'Ascend-Call-Attempt-Limit',
- 'quintum_h323_currency_ty' => 'Quintum-h323-currency-type',
- 'ms_chap_response' => 'MS-CHAP-Response',
- 'st_secondary_nbns_server' => 'ST-Secondary-NBNS-Server',
- 'x_ascend_history_weigh_t' => 'X-Ascend-History-Weigh-Type',
- 'usr_max_channels' => 'USR-Max-Channels',
- 'ascend_fr_dte_n393' => 'Ascend-FR-DTE-N393',
- 'ascend_pre_input_octets' => 'Ascend-Pre-Input-Octets',
- 'erx_atm_mbs' => 'ERX-Atm-MBS',
- 'cvpn3000_simultaneous_lo' => 'CVPN3000-Simultaneous-Logins',
- 'juniper_allow_commands' => 'Juniper-Allow-Commands',
- 'usr_line_reversals' => 'USR-Line-Reversals',
- 'itk_users_default_pw' => 'ITK-Users-Default-Pw',
- 'x_ascend_third_prompt' => 'X-Ascend-Third-Prompt',
- 'cisco_fax_msg_id' => 'Cisco-Fax-Msg-Id',
- 'x_ascend_pw_warntime' => 'X-Ascend-PW-Warntime',
- 'ascend_data_filter' => 'Ascend-Data-Filter',
- 'framed_address' => 'Framed-Address',
- 'context_name' => 'Context-Name',
- 'usr_send_script2' => 'USR-Send-Script2',
- 'ms_arap_pw_change_reason' => 'MS-ARAP-PW-Change-Reason',
- 'tunnel_session_auth_cty' => 'Tunnel_Session_Auth_Ctx',
- 'acct_session_id' => 'Acct-Session-Id',
- 'annex_port' => 'Annex-Port',
- 'quintum_h323_call_origin' => 'Quintum-h323-call-origin',
- 'erx_cli_initial_access_l' => 'ERX-Cli-Initial-Access-Level',
- 'x_ascend_shared_profile_' => 'X-Ascend-Shared-Profile-Enable',
- 'tunnel_cmd_timeouu' => 'Tunnel_Cmd_Timeout',
- 'initial_modulation_type' => 'Initial-Modulation-Type',
- 'ascend_h323_gatekeeper' => 'Ascend-H323-Gatekeeper',
- 'x_ascend_fcp_parameter' => 'X-Ascend-FCP-Parameter',
- 'multi_link_flag' => 'Multi-Link-Flag',
- 'tunnel_type' => 'Tunnel-Type',
- 'erx_output_gigapkts' => 'ERX-Output-Gigapkts',
- 'ascend_idle_limit' => 'Ascend-Idle-Limit',
- 'ns_user_group' => 'NS-User-Group',
- 'password_retry' => 'Password-Retry',
- 'h323_remote_address' => 'h323-remote-address',
- 'erx_atm_service_category' => 'ERX-Atm-Service-Category',
- 'acct_input_packets' => 'Acct-Input-Packets',
- 'h323_disconnect_time' => 'h323-disconnect-time',
- 'usr_syslog_tap' => 'USR-Syslog-Tap',
- 'telebit_accounting_info' => 'Telebit-Accounting-Info',
- 'ascend_billing_number' => 'Ascend-Billing-Number',
- 'ascend_tunnel_vrouter_na' => 'Ascend-Tunnel-VRouter-Name',
- 'ms_mppe_encryption_type' => 'MS-MPPE-Encryption-Type',
- 'quintum_h323_credit_amou' => 'Quintum-h323-credit-amount',
- 'acc_ace_token' => 'Acc-Ace-Token',
- 'ascend_assign_ip_pool' => 'Ascend-Assign-IP-Pool',
- 'annex_end_modulation' => 'Annex-End-Modulation',
- 'usr_routing_protocol' => 'USR-Routing-Protocol',
- 'cvx_assign_ip_pool' => 'CVX-Assign-IP-Pool',
- 'usr_rad_location_type' => 'USR-Rad-Location-Type',
- 'usr_rmmie_pwrlvl_noise_l' => 'USR-RMMIE-PwrLvl-Noise-Lvl',
- 'usr_characters_sent' => 'USR-Characters-Sent',
- 'usr_mp_edo_hiper' => 'USR-MP-EDO-HIPER',
- 'ascend_x25_nui_password_' => 'Ascend-X25-Nui-Password-Prompt',
- 'annex_host_restrict' => 'Annex-Host-Restrict',
- 'user_service_type' => 'User-Service-Type',
- 'acct_multi_session_id' => 'Acct-Multi-Session-Id',
- 'ms_chap_cpw_2' => 'MS-CHAP-CPW-2',
- 'x_ascend_secondary_home_' => 'X-Ascend-Secondary-Home-Agent',
- 'x_ascend_dialout_allowed' => 'X-Ascend-Dialout-Allowed',
- 'ascend_connect_progress' => 'Ascend-Connect-Progress',
- 'x_ascend_ara_pw' => 'X-Ascend-Ara-PW',
- 'cisco_fax_modem_time' => 'Cisco-Fax-Modem-Time',
- 'sql_group' => 'Sql-Group',
- 'annex_multicast_rate_lim' => 'Annex-Multicast-Rate-Limit',
- 'cvpn3000_user_auth_servg' => 'CVPN3000-User-Auth-Server-Secret',
- 'ns_mta_md5_password' => 'NS-MTA-MD5-Password',
- 'annex_addr_resolution_pr' => 'Annex-Addr-Resolution-Protocol',
- 'callback_number' => 'Callback-Number',
- 'cvx_multilink_match_info' => 'CVX-Multilink-Match-Info',
- 'tunnel_max_tunnelt' => 'Tunnel_Max_Tunnels',
- 'tunnel_local_namf' => 'Tunnel_Local_Name',
- 'quintum_h323_conf_id' => 'Quintum-h323-conf-id',
- 'acct_output_packets_64' => 'Acct-Output-Packets-64',
- 'annex_signal_to_noise_ra' => 'Annex-Signal-to-Noise-Ratio',
- 'acct_output_packets_65' => 'Acct_Output_Packets_64',
- 'x_ascend_user_acct_key' => 'X-Ascend-User-Acct-Key',
- 'erx_dial_out_number' => 'ERX-Dial-Out-Number',
- 'ascend_modem_portno' => 'Ascend-Modem-PortNo',
- 'ascend_assign_ip_server' => 'Ascend-Assign-IP-Server',
- 'ascend_fcp_parameter' => 'Ascend-FCP-Parameter',
- 'usr_chassis_temp_thresho' => 'USR-Chassis-Temp-Threshold',
- 'usr_mpip_tunnel_originat' => 'USR-MPIP-Tunnel-Originator',
- 'tunnel_rate_limit_bursu' => 'Tunnel_Rate_Limit_Burst',
- 'client_ip_address' => 'Client-IP-Address',
- 'le_nat_tcp_session_timeo' => 'LE-NAT-TCP-Session-Timeout',
- 'quintum_h323_redirect_ip' => 'Quintum-h323-redirect-ip-address',
- 'ms_acct_eap_type' => 'MS-Acct-EAP-Type',
- 'usr_rmmie_x2_status' => 'USR-RMMIE-x2-Status',
- 'x_ascend_user_acct_type' => 'X-Ascend-User-Acct-Type',
- 'shiva_customer_id' => 'Shiva-Customer-Id',
- 'pvc_encapsulation_typf' => 'PVC_Encapsulation_Type',
- 'st_acct_vc_connection_id' => 'ST-Acct-VC-Connection-Id',
- 'lac_real_port' => 'LAC-Real-Port',
- 'h323_connect_time' => 'h323-connect-time',
- 'usr_vpn_gw_location_id' => 'USR-VPN-GW-Location-Id',
- 'old_password' => 'Old-Password',
- 'x_ascend_if_netmask' => 'X-Ascend-IF-Netmask',
- 'add_suffix' => 'Add-Suffix',
- 'lac_port_typf' => 'LAC_Port_Type',
- 'acc_ip_pool_name' => 'Acc-Ip-Pool-Name',
- 'usr_terminal_type' => 'USR-Terminal-Type',
- 'usr_spoofing' => 'USR-Spoofing',
- 'erx_tunnel_password' => 'ERX-Tunnel-Password',
- 'ascend_inter_arrival_jit' => 'Ascend-Inter-Arrival-Jitter',
- 'ascend_call_block_durati' => 'Ascend-Call-Block-Duration',
- 'itk_channel_binding' => 'ITK-Channel-Binding',
- 'usr_server_time' => 'USR-Server-Time',
- 'ascend_assign_ip_client' => 'Ascend-Assign-IP-Client',
- 'erx_pppoe_max_sessions' => 'ERX-Pppoe-Max-Sessions',
- 'cvx_multilink_group_numb' => 'CVX-Multilink-Group-Number',
- 'x_ascend_client_assign_d' => 'X-Ascend-Client-Assign-DNS',
- 'erx_pppoe_url' => 'ERX-Pppoe-Url',
- 'police_ratf' => 'Police_Rate',
- 'ascend_data_svc' => 'Ascend-Data-Svc',
- 'annex_authen_servers' => 'Annex-Authen-Servers',
- 'nomadix_bw_up' => 'Nomadix-Bw-Up',
- 'cvx_modem_data_compressi' => 'CVX-Modem-Data-Compression',
- 'shiva_link_speed' => 'Shiva-Link-Speed',
- 'usr_reply_script6' => 'USR-Reply-Script6',
- 'usr_expansion_algorithm' => 'USR-Expansion-Algorithm',
- 'cabletron_protocol_calla' => 'Cabletron-Protocol-Callable',
- 'cisco_data_rate' => 'Cisco-Data-Rate',
- 'usr_primary_dns_server' => 'USR-Primary_DNS_Server',
- 'juniper_deny_configurati' => 'Juniper-Deny-Configuration',
- 'ascend_target_util' => 'Ascend-Target-Util',
- 'digest_method' => 'Digest-Method',
- 'altiga_ipsec_split_tunne' => 'Altiga-IPSec-Split-Tunnel-List-G',
- 'erx_alternate_cli_access' => 'ERX-Alternate-Cli-Access-Level',
- 'x_ascend_event_type' => 'X-Ascend-Event-Type',
- 'usr_q931_call_reference_' => 'USR-Q931-Call-Reference-Value',
- 'usr_mp_mrru' => 'USR-MP-MRRU',
- 'cvx_ipsvc_mask' => 'CVX-IPSVC-Mask',
- 'bind_bypass_context' => 'Bind-Bypass-Context',
- 'usr_rmmie_last_update_ev' => 'USR-RMMIE-Last-Update-Event',
- 'no_such_attribute' => 'No-Such-Attribute',
- 'acct_mcast_out_packets' => 'Acct-Mcast-Out-Packets',
- 'tunnel_medium_type' => 'Tunnel-Medium-Type',
- 'quintum_h323_remote_addr' => 'Quintum-h323-remote-address',
- 'acc_callback_delay' => 'Acc-Callback-Delay',
- 'acct_input_octets_64' => 'Acct-Input-Octets-64',
- 'ascend_base_channel_coun' => 'Ascend-Base-Channel-Count',
- 'ascend_atm_connect_vci' => 'Ascend-ATM-Connect-Vci',
- 'erx_primary_dns' => 'ERX-Primary-Dns',
- 'altiga_ipsec_over_nat_g' => 'Altiga-IPSec-Over-NAT-G',
- 'cvx_multicast_rate_limit' => 'CVX-Multicast-Rate-Limit',
- 'ascend_xmit_rate' => 'Ascend-Xmit-Rate',
- 'ms_new_arap_password' => 'MS-New-ARAP-Password',
- 'usr_call_error_code' => 'USR-Call-Error-Code',
- 'acct_output_octets' => 'Acct-Output-Octets',
- 'ascend_client_primary_wi' => 'Ascend-Client-Primary-WINS',
- 'cvpn3000_primary_wins' => 'CVPN3000-Primary-WINS',
- 'bintec_ipextrttable' => 'BinTec-ipExtRtTable',
- 'cisco_fax_mdn_flag' => 'Cisco-Fax-Mdn-Flag',
- 'ascend_destination_nas_p' => 'Ascend-Destination-Nas-Port',
- 'ascend_num_in_multilink' => 'Ascend-Num-In-Multilink',
- 'digest_attributes' => 'Digest-Attributes',
- 'cvpn3000_ipsec_tunnel_ty' => 'CVPN3000-IPSec-Tunnel-Type',
- 'x_ascend_number_sessions' => 'X-Ascend-Number-Sessions',
- 'usr_ip_rip_output_filter' => 'USR-IP-RIP-Output-Filter',
- 'tunnel_police_bursu' => 'Tunnel_Police_Burst',
- 'redcreek_tunneled_wins_s' => 'RedCreek-Tunneled-WINS-Server1',
- 'usr_blocks_sent' => 'USR-Blocks-Sent',
- 'erx_cli_allow_all_vr_acc' => 'ERX-Cli-Allow-All-VR-Access',
- 'tunnel_police_ratf' => 'Tunnel_Police_Rate',
- 'usr_ids0_call_type' => 'USR-IDS0-Call-Type',
- 'acc_ccp_option' => 'Acc-Ccp-Option',
- 'ascend_client_gateway' => 'Ascend-Client-Gateway',
- 'cvx_maximum_channels' => 'CVX-Maximum-Channels',
- 'bg_aging_timf' => 'BG_Aging_Time',
- 'annex_secondary_dns_serv' => 'Annex-Secondary-DNS-Server',
- 'le_ipsec_passive_profile' => 'LE-IPSec-Passive-Profile',
- 'usr_chassis_call_span' => 'USR-Chassis-Call-Span',
- 'aat_client_primary_wins_' => 'AAT-Client-Primary-WINS-NBNS',
- 'h323_currency' => 'h323-currency',
- 'password' => 'Password',
- 'le_nat_log_options' => 'LE-NAT-Log-Options',
- 'usr_fallback_limit' => 'USR-Fallback-Limit',
- 'x_ascend_ppp_address' => 'X-Ascend-PPP-Address',
- 'suffix' => 'Suffix',
- 'usr_multicast_receive' => 'USR-Multicast-Receive',
- 'client_dns_sec' => 'Client-DNS-Sec',
- 'annex_product_name' => 'Annex-Product-Name',
- 'cisco_pw_lifetime' => 'Cisco-PW-Lifetime',
- 'x_ascend_fr_dce_n393' => 'X-Ascend-FR-DCE-N393',
- 'x_ascend_ts_idle_limit' => 'X-Ascend-TS-Idle-Limit',
- 'mcast_send' => 'Mcast-Send',
- 'x_ascend_primary_home_ag' => 'X-Ascend-Primary-Home-Agent',
- 'tunnel_max_sessiont' => 'Tunnel_Max_Sessions',
- 'pppoe_motm' => 'PPPOE-MOTM',
- 'usr_pw_usr_ifilter_ipx' => 'USR-PW_USR_IFilter_IPX',
- 'ms_ras_version' => 'MS-RAS-Version',
- 'ascend_source_ip_check' => 'Ascend-Source-IP-Check',
- 'bintec_ospfiftable' => 'BinTec-ospfIfTable',
- 'acc_ml_call_threshold' => 'Acc-ML-Call-Threshold',
- 'x_ascend_modem_slotno' => 'X-Ascend-Modem-SlotNo',
- 'ascend_menu_item' => 'Ascend-Menu-Item',
- 'callback_id' => 'Callback-Id',
- 'framed_ipx_network' => 'Framed-IPX-Network',
- 'altiga_pptp_encryption_g' => 'Altiga-PPTP-Encryption-G',
- 'ascend_x25_reverse_charg' => 'Ascend-X25-Reverse-Charging',
- 'ascend_user_acct_key' => 'Ascend-User-Acct-Key',
- 'x_ascend_pw_lifetime' => 'X-Ascend-PW-Lifetime',
- 'user_name_is_star' => 'User-Name-Is-Star',
- 'nomadix_url_redirection' => 'Nomadix-URL-Redirection',
- 'framed_pool' => 'Framed-Pool',
- 'x_ascend_authen_alias' => 'X-Ascend-Authen-Alias',
- 'cisco_fax_dsn_address' => 'Cisco-Fax-Dsn-Address',
- 'ms_primary_dns_server' => 'MS-Primary-DNS-Server',
- 'acc_dialout_auth_usernam' => 'Acc-Dialout-Auth-Username',
- 'realm' => 'Realm',
- 'arap_features' => 'ARAP-Features',
- 'bind_auth_protocom' => 'Bind_Auth_Protocol',
- 'acc_connect_tx_speed' => 'Acc-Connect-Tx-Speed',
- 'usr_chassis_temperature' => 'USR-Chassis-Temperature',
- 'altiga_ipsec_mode_config' => 'Altiga-IPSec-Mode-Config-G',
- 'ascend_home_agent_ip_add' => 'Ascend-Home-Agent-IP-Addr',
- 'x_ascend_xmit_rate' => 'X-Ascend-Xmit-Rate',
- 'cvpn3000_secondary_dns' => 'CVPN3000-Secondary-DNS',
- 'x_ascend_send_passwd' => 'X-Ascend-Send-Passwd',
- 'bind_int_contexu' => 'Bind_Int_Context',
- 'cisco_fax_account_id_ori' => 'Cisco-Fax-Account-Id-Origin',
- 'le_modem_info' => 'LE-Modem-Info',
- 'ascend_ipx_peer_mode' => 'Ascend-IPX-Peer-Mode',
- 'juniper_local_user_name' => 'Juniper-Local-User-Name',
- 'tunnel_rate_limit_rate' => 'Tunnel-Rate-Limit-Rate',
- 'quintum_h323_credit_time' => 'Quintum-h323-credit-time',
- 'acc_modem_modulation_typ' => 'Acc-Modem-Modulation-Type',
- 'x_ascend_seconds_of_hist' => 'X-Ascend-Seconds-Of-History',
- 'ascend_dhcp_pool_number' => 'Ascend-DHCP-Pool-Number',
- 'redcreek_tunneled_ip_net' => 'RedCreek-Tunneled-IP-Netmask',
- 'x_ascend_callback' => 'X-Ascend-Callback',
- 'usr_iwf_ip_address' => 'USR-IWF-IP-Address',
- 'aat_input_octets_diff' => 'AAT-Input-Octets-Diff',
- 'nas_port_id' => 'NAS-Port-Id',
- 'le_advice_of_charge' => 'LE-Advice-of-Charge',
- 'x_ascend_dhcp_pool_numbe' => 'X-Ascend-DHCP-Pool-Number',
- 'ascend_add_seconds' => 'Ascend-Add-Seconds',
- 'annex_transmit_speed' => 'Annex-Transmit-Speed',
- 'usr_port_tap' => 'USR-Port-Tap',
- 'usr_at_call_input_filter' => 'USR-AT-Call-Input-Filter',
- 'framed_ipv6_pool' => 'Framed-IPv6-Pool',
- 'ascend_qos_downstream' => 'Ascend-QOS-Downstream',
- 'lac_port' => 'LAC-Port',
- 'tunnel_assignment_id' => 'Tunnel-Assignment-Id',
- 'acct_mcast_out_octett' => 'Acct_Mcast_Out_Octets',
- 'ascend_bi_directional_au' => 'Ascend-Bi-Directional-Auth',
- 'fall_through' => 'Fall-Through',
- 'cvpn3000_ipsec_ip_compre' => 'CVPN3000-IPSec-IP-Compression',
- 'cisco_disconnect_cause' => 'Cisco-Disconnect-Cause',
- 'usr_rad_multicast_routiq' => 'USR-Rad-Multicast-Routing-Bound',
- 'altiga_tunneling_protoco' => 'Altiga-Tunneling-Protocols-G/U',
- 'itk_tunnel_prot' => 'ITK-Tunnel-Prot',
- 'client_dns_sed' => 'Client_DNS_Sec',
- 'framed_ip_netmask' => 'Framed-IP-Netmask',
- 'usr_call_reference_numbe' => 'USR-Call-Reference-Number',
- 'ascend_egress_enabled' => 'Ascend-Egress-Enabled',
- 'ascend_dsl_rate_mode' => 'Ascend-Dsl-Rate-Mode',
- 'usr_pw_usr_ofilter_sap' => 'USR-PW_USR_OFilter_SAP',
- 'bintec_iproutetable' => 'BinTec-ipRouteTable',
- 'acct_terminate_cause' => 'Acct-Terminate-Cause',
- 'x_ascend_fr_dte_n393' => 'X-Ascend-FR-DTE-N393',
- 'ascend_ppp_address' => 'Ascend-PPP-Address',
- 'erx_maximum_bps' => 'ERX-Maximum-BPS',
- 'caller_id' => 'Caller-ID',
- 'bintec_ipfiltertable' => 'BinTec-ipFilterTable',
- 'x_ascend_base_channel_co' => 'X-Ascend-Base-Channel-Count',
- 'bind_int_interface_name' => 'Bind-Int-Interface-Name',
- 'usr_modem_group' => 'USR-Modem-Group',
- 'cisco_maximum_channels' => 'Cisco-Maximum-Channels',
- 'erx_ppp_username' => 'ERX-PPP-Username',
- 'ascend_link_compression' => 'Ascend-Link-Compression',
- 'annex_retransmitted_pack' => 'Annex-Retransmitted-Packets',
- 'usr_retrains_granted' => 'USR-Retrains-Granted',
- 'ascend_dropped_packets' => 'Ascend-Dropped-Packets',
- 'erx_bearer_type' => 'ERX-Bearer-Type',
- 'usr_pw_usr_ofilter_ip' => 'USR-PW_USR_OFilter_IP',
- 'quintum_nas_port' => 'Quintum-NAS-Port',
- 'x_ascend_pre_output_pack' => 'X-Ascend-Pre-Output-Packets',
- 'usr_cdma_call_reference_' => 'USR-CDMA-Call-Reference-Number',
- 'tunnel_function' => 'Tunnel-Function',
- 'annex_tunnel_authen_mode' => 'Annex-Tunnel-Authen-Mode',
- 'usr_mp_edo' => 'USR-MP-EDO',
- 'le_nat_outmap' => 'LE-NAT-Outmap',
- 'cvpn3000_primary_dns' => 'CVPN3000-Primary-DNS',
- 'usr_modulation_type' => 'USR-Modulation-Type',
- 'ascend_calling_id_screen' => 'Ascend-Calling-Id-Screening',
- 'ascend_maximum_time' => 'Ascend-Maximum-Time',
- 'user_password' => 'User-Password',
- 'annex_callback_portlist' => 'Annex-Callback-Portlist',
- 'cvpn3000_ipsec_split_tun' => 'CVPN3000-IPSec-Split-Tunnel-List',
- 'annex_pre_output_packets' => 'Annex-Pre-Output-Packets',
- 'usr_at_call_output_filte' => 'USR-AT-Call-Output-Filter',
- 'x_ascend_client_primary_' => 'X-Ascend-Client-Primary-DNS',
- 'tunnel_server_endpoint' => 'Tunnel-Server-Endpoint',
- 'x_ascend_remove_seconds' => 'X-Ascend-Remove-Seconds',
- 'cvpn3000_user_auth_serve' => 'CVPN3000-User-Auth-Server-Name',
- 'arap_password' => 'ARAP-Password',
- 'x_ascend_assign_ip_serve' => 'X-Ascend-Assign-IP-Server',
- 'cisco_fax_pages' => 'Cisco-Fax-Pages',
- 'ms_chap_mppe_keys' => 'MS-CHAP-MPPE-Keys',
- 'ascend_source_auth' => 'Ascend-Source-Auth',
- 'group' => 'Group',
- 'usr_send_script6' => 'USR-Send-Script6',
- 'le_nat_inmap' => 'LE-NAT-Inmap',
- 'chap_password' => 'CHAP-Password',
- 'annex_receive_speed' => 'Annex-Receive-Speed',
- 'usr_mobileip_home_agent_' => 'USR-MobileIP-Home-Agent-Address',
- 'bind_l2tp_flow_control' => 'Bind-L2TP-Flow-Control',
- 'smb_account_ctrl' => 'SMB-Account-CTRL',
- 'ascend_ip_pool_chaining' => 'Ascend-IP-Pool-Chaining',
- 'le_admin_group' => 'LE-Admin-Group',
- 'tunnel_connection_id' => 'Tunnel-Connection-Id',
- 'tunnel_windox' => 'Tunnel_Window',
- 'nas_identifier' => 'NAS-Identifier',
- 'dhcp_max_leaset' => 'DHCP_Max_Leases',
- 'digest_nonce_count' => 'Digest-Nonce-Count',
- 'nas_real_port' => 'NAS-Real-Port',
- 'ms_old_arap_password' => 'MS-Old-ARAP-Password',
- 'usr_pw_index' => 'USR-PW_Index',
- 'erx_primary_wins' => 'ERX-Primary-Wins',
- 'ascend_appletalk_peer_mo' => 'Ascend-Appletalk-Peer-Mode',
- 'le_ipsec_log_options' => 'LE-IPSec-Log-Options',
- 'x_ascend_maximum_channel' => 'X-Ascend-Maximum-Channels',
- 'cvx_ipsvc_aznlvl' => 'CVX-IPSVC-AZNLVL',
- 'x_ascend_client_secondar' => 'X-Ascend-Client-Secondary-DNS',
- 'annex_re_chap_timeout' => 'Annex-Re-CHAP-Timeout',
- 'aat_ip_pool_definition' => 'AAT-IP-Pool-Definition',
- 'client_dns_pri' => 'Client-DNS-Pri',
- 'cisco_service_info' => 'Cisco-Service-Info',
- 'usr_primary_nbns_server' => 'USR-Primary_NBNS_Server',
- 'aat_atm_direct' => 'AAT-ATM-Direct',
- 'bind_ses_contexu' => 'Bind_Ses_Context',
- 'sip_translated_request_u' => 'Sip-Translated-Request-URI',
- 'acc_acct_on_off_reason' => 'Acc-Acct-On-Off-Reason',
- 'le_multicast_client' => 'LE-Multicast-Client',
- 'bind_sub_passwore' => 'Bind_Sub_Password',
- 'cvpn3000_cisco_ip_phone_' => 'CVPN3000-Cisco-IP-Phone-Bypass',
- 'ascend_send_passwd' => 'Ascend-Send-Passwd',
- 'tunnel_remote_namf' => 'Tunnel_Remote_Name',
- 'cvx_disconnect_cause' => 'CVX-Disconnect-Cause',
- 'itk_auth_serv_prot' => 'ITK-Auth-Serv-Prot',
- 'tunnel_context' => 'Tunnel-Context',
- 'digest_uri' => 'Digest-URI',
- 'usr_channel_decrement' => 'USR-Channel-Decrement',
- 'acc_nbns_server_sec' => 'Acc-Nbns-Server-Sec',
- 'ms_chap_challenge' => 'MS-CHAP-Challenge',
- 'cisco_assign_ip_pool' => 'Cisco-Assign-IP-Pool',
- 'ascend_cbcp_mode' => 'Ascend-CBCP-Mode',
- 'ascend_x25_rpoa' => 'Ascend-X25-Rpoa',
- 'usr_dtr_false_timeout' => 'USR-DTR-False-Timeout',
- 'acct_dyn_ac_enu' => 'Acct_Dyn_Ac_Ent',
- 'usr_physical_state' => 'USR-Physical-State',
- 'x_ascend_ppp_vj_slot_com' => 'X-Ascend-PPP-VJ-Slot-Comp',
- 'x_ascend_link_compressio' => 'X-Ascend-Link-Compression',
- 'ascend_fr_t391' => 'Ascend-FR-T391',
- 'bind_dot1q_port' => 'Bind-Dot1q-Port',
- 'ns_secondary_dns' => 'NS-Secondary-DNS',
- 'altiga_ipsec_tunnel_type' => 'Altiga-IPSec-Tunnel-Type-G',
- 'lac_port_type' => 'LAC-Port-Type',
- 'bg_aging_time' => 'BG-Aging-Time',
- 'erx_atm_scr' => 'ERX-Atm-SCR',
- 'x_ascend_pre_input_octet' => 'X-Ascend-Pre-Input-Octets',
- 'cisco_fax_connect_speed' => 'Cisco-Fax-Connect-Speed',
- 'x_ascend_menu_item' => 'X-Ascend-Menu-Item',
- 'quintum_h323_voice_quali' => 'Quintum-h323-voice-quality',
- 'ascend_x25_pad_banner' => 'Ascend-X25-Pad-Banner',
- 'module_failure_message' => 'Module-Failure-Message',
- 'h323_gw_id' => 'h323-gw-id',
- 'h323_preferred_lang' => 'h323-preferred-lang',
- 'usr_min_compression_size' => 'USR-Min-Compression-Size',
- 'usr_compression_type' => 'USR-Compression-Type',
- 'bintec_ipxstaticroutetab' => 'BinTec-ipxStaticRouteTable',
- 'ascend_dialout_allowed' => 'Ascend-Dialout-Allowed',
- 'annex_local_username' => 'Annex-Local-Username',
- 'cisco_pre_input_packets' => 'Cisco-Pre-Input-Packets',
- 'shiva_function' => 'Shiva-Function',
- 'ascend_send_secret' => 'Ascend-Send-Secret',
- 'usr_number_of_blers' => 'USR-Number-of-Blers',
- 'usr_dte_data_idle_timout' => 'USR-DTE-Data-Idle-Timout',
- 'usr_card_type' => 'USR-Card-Type',
- 'x_ascend_connect_progres' => 'X-Ascend-Connect-Progress',
- 'x_ascend_group' => 'X-Ascend-Group',
- 'ascend_token_idle' => 'Ascend-Token-Idle',
- 'erx_qos_profile_interfac' => 'ERX-Qos-Profile-Interface-Type',
- 'ascend_private_route_tab' => 'Ascend-Private-Route-Table-ID',
- 'nt_password' => 'NT-Password',
- 'acct_mcast_in_packets' => 'Acct-Mcast-In-Packets',
- 'x_ascend_multicast_clien' => 'X-Ascend-Multicast-Client',
- 'usr_supports_tags' => 'USR-Supports-Tags',
- 'cvpn3000_authd_user_idle' => 'CVPN3000-Authd-User-Idle-Timeout',
- 'ascend_number_sessions' => 'Ascend-Number-Sessions',
- 'x_ascend_add_seconds' => 'X-Ascend-Add-Seconds',
- 'usr_number_of_upshifts' => 'USR-Number-of-Upshifts',
- 'proxy_to_realm' => 'Proxy-To-Realm',
- 'aat_client_secondary_win' => 'AAT-Client-Secondary-WINS-NBNS',
- 'aat_ip_tos_precedence' => 'AAT-IP-TOS-Precedence',
- 'acc_callback_num_valid' => 'Acc-Callback-Num-Valid',
- 'nokia_ggsn_ip_address' => 'Nokia-GGSN-IP-Address',
- 'acc_access_community' => 'Acc-Access-Community',
- 'ascend_multicast_rate_li' => 'Ascend-Multicast-Rate-Limit',
- 'usr_default_dte_data_rat' => 'USR-Default-DTE-Data-Rate',
- 'usr_rmmie_pwrlvl_nearech' => 'USR-RMMIE-PwrLvl-NearEcho-Canc',
- 'usr_send_name' => 'USR-Send-Name',
- 'usr_chassis_slot' => 'USR-Chassis-Slot',
- 'login_ip_host' => 'Login-IP-Host',
- 'ascend_netware_timeout' => 'Ascend-Netware-timeout',
- 'bind_sub_user_at_context' => 'Bind-Sub-User-At-Context',
- 'vendor_specific' => 'Vendor-Specific',
- 'ascend_fr_direct_dlci' => 'Ascend-FR-Direct-DLCI',
- 'ascend_qos_upstream' => 'Ascend-QOS-Upstream',
- 'aat_user_mac_address' => 'AAT-User-MAC-Address',
- 'source_validation' => 'Source-Validation',
- 'x_ascend_token_expiry' => 'X-Ascend-Token-Expiry',
- 'altiga_ipsec_user_group_' => 'Altiga-IPSec-User-Group-Lock-G',
- 'ascend_dec_channel_count' => 'Ascend-Dec-Channel-Count',
- 'assigned_ip_addrest' => 'Assigned_IP_Address',
- 'usr_local_framed_ip_addr' => 'USR-Local-Framed-IP-Addr',
- 'usr_service_option' => 'USR-Service-Option',
- 'usr_transmit_acc_map' => 'USR-Transmit-Acc-Map',
- 'ascend_fr_direct' => 'Ascend-FR-Direct',
- 'usr_final_rx_link_data_r' => 'USR-Final-Rx-Link-Data-Rate',
- 'x_ascend_expect_callback' => 'X-Ascend-Expect-Callback',
- 'x_ascend_disconnect_caus' => 'X-Ascend-Disconnect-Cause',
- 'acc_ml_damping_factor' => 'Acc-ML-Damping-Factor',
- 'framed_netmask' => 'Framed-Netmask',
- 'usr_connect_speed' => 'USR-Connect-Speed',
- 'x_ascend_home_agent_ip_a' => 'X-Ascend-Home-Agent-IP-Addr',
- 'usr_disconnect_cause_ind' => 'USR-Disconnect-Cause-Indicator',
- 'bg_span_dis' => 'BG-Span-Dis',
- 'cisco_multilink_id' => 'Cisco-Multilink-ID',
- 'tunnel_max_tunnels' => 'Tunnel-Max-Tunnels',
- 'ascend_dsl_downstream_li' => 'Ascend-Dsl-Downstream-Limit',
- 'ascend_multilink_id' => 'Ascend-Multilink-ID',
- 'altiga_ipsec_default_dom' => 'Altiga-IPSec-Default-Domain-G',
- 'ascend_dhcp_reply' => 'Ascend-DHCP-Reply',
- 'login_ipv6_host' => 'Login-IPv6-Host',
- 'ascend_x25_cug' => 'Ascend-X25-Cug',
- 'shiva_network_protocols' => 'Shiva-Network-Protocols',
- 'cvpn3000_ipsec_mode_conf' => 'CVPN3000-IPSec-Mode-Config',
- 'extreme_netlogin_vlan' => 'Extreme-Netlogin-Vlan',
- 'ascend_ara_pw' => 'Ascend-Ara-PW',
- 'tunnel_l2f_second_passwo' => 'Tunnel-L2F-Second-Password',
- 'altiga_sep_card_assignme' => 'Altiga-SEP-Card-Assignment-G/U',
- 'ip_host_addr' => 'Ip-Host-Addr',
- 'le_ip_gateway' => 'LE-IP-Gateway',
- 'usr_mobile_numbytes_txed' => 'USR-Mobile-NumBytes-Txed',
- 'altiga_ipsec_allow_passw' => 'Altiga-IPSec-Allow-Passwd-Store-G/U',
- 'itk_users_default_entry' => 'ITK-Users-Default-Entry',
- 'quintum_h323_redirect_nu' => 'Quintum-h323-redirect-number',
- 'x_ascend_fr_t392' => 'X-Ascend-FR-T392',
- 'acc_igmp_version' => 'Acc-Igmp-Version',
- 'cisco_pre_output_packets' => 'Cisco-Pre-Output-Packets',
- 'tunnel_group' => 'Tunnel-Group',
- 'x_ascend_home_agent_udp_' => 'X-Ascend-Home-Agent-UDP-Port',
- 'cvpn3000_tunneling_proto' => 'CVPN3000-Tunneling-Protocols',
- 'usr_igmp_maximum_respons' => 'USR-IGMP-Maximum-Response-Time',
- 'bind_sub_password' => 'Bind-Sub-Password',
- 'eap_message' => 'EAP-Message',
- 'exec_program' => 'Exec-Program',
- 'cvpn3000_reqrd_client_fx' => 'CVPN3000-Reqrd-Client-Fw-Product-Code',
- 'bg_path_cost' => 'BG-Path-Cost',
- 'usr_modem_training_time' => 'USR-Modem-Training-Time',
- 'auth_type' => 'Auth-Type',
- 'itk_acct_serv_prot' => 'ITK-Acct-Serv-Prot',
- 'x_ascend_ipx_route' => 'X-Ascend-IPX-Route',
- 'altiga_primary_dns_g' => 'Altiga-Primary-DNS-G',
- 'ascend_cbcp_enable' => 'Ascend-CBCP-Enable',
- 'ms_mppe_encryption_polic' => 'MS-MPPE-Encryption-Policy',
- 'annex_unauthenticated_ti' => 'Annex-Unauthenticated-Time',
- 'annex_begin_receive_line' => 'Annex-Begin-Receive-Line-Level',
- 'ascend_atm_direct_profil' => 'Ascend-ATM-Direct-Profile',
- 'redcreek_tunneled_dns_se' => 'RedCreek-Tunneled-DNS-Server',
- 'ascend_redirect_number' => 'Ascend-Redirect-Number',
- 'h323_credit_time' => 'h323-credit-time',
- 'cvx_idle_limit' => 'CVX-Idle-Limit',
- 'ascend_appletalk_route' => 'Ascend-Appletalk-Route',
- 'aat_ip_tos' => 'AAT-IP-TOS',
- 'cvx_ppp_address' => 'CVX-PPP-Address',
- 'aat_data_filter' => 'AAT-Data-Filter',
- 'cvx_primary_dns' => 'CVX-Primary-DNS',
- 'shiva_link_protocol' => 'Shiva-Link-Protocol',
- 'x_ascend_fr_circuit_name' => 'X-Ascend-FR-Circuit-Name',
- 'usr_appletalk' => 'USR-Appletalk',
- 'client_id' => 'Client-Id',
- 'tunnel_algorithn' => 'Tunnel_Algorithm',
- 'aat_assign_ip_pool' => 'AAT-Assign-IP-Pool',
- 'quintum_h323_incoming_co' => 'Quintum-h323-incoming-conf-id',
- 'aat_atm_vpi' => 'AAT-ATM-VPI',
- 'annex_output_filter' => 'Annex-Output-Filter',
- 'pvc_circuit_padding' => 'PVC-Circuit-Padding',
- 'usr_ipx_call_output_filt' => 'USR-IPX-Call-Output-Filter',
- 'usr_rmmie_planned_discon' => 'USR-RMMIE-Planned-Disconnect',
- 'session_error_msh' => 'Session_Error_Msg',
- 'usr_rad_multicast_routin' => 'USR-Rad-Multicast-Routing-Ttl',
- 'h323_time_and_day' => 'h323-time-and-day',
- 'cvpn3000_ipsec_backup_se' => 'CVPN3000-IPSec-Backup-Servers',
- 'termination_action' => 'Termination-Action',
- 'cvpn3000_ipsec_client_fx' => 'CVPN3000-IPSec-Client-Fw-Filter-Opt',
- 'aat_client_primary_dnt' => 'AAT-Client-Primary-DNS',
- 'acct_tunnel_packets_lost' => 'Acct-Tunnel-Packets-Lost',
- 'x_ascend_modem_portno' => 'X-Ascend-Modem-PortNo',
- 'framed_filter_id' => 'Framed-Filter-Id',
- 'usr_ccp_algorithm' => 'USR-CCP-Algorithm',
- 'quintum_h323_preferred_l' => 'Quintum-h323-preferred-lang',
- 'ascend_fr_link_status_dl' => 'Ascend-FR-Link-Status-DLCI',
- 'ascend_token_expiry' => 'Ascend-Token-Expiry',
- 'itk_auth_req_type' => 'ITK-Auth-Req-Type',
- 'acc_modem_error_protocol' => 'Acc-Modem-Error-Protocol',
- 'acc_request_type' => 'Acc-Request-Type',
- 'usr_last_number_dialed_i' => 'USR-Last-Number-Dialed-In-DNIS',
- 'x_ascend_ipx_peer_mode' => 'X-Ascend-IPX-Peer-Mode',
- 'ascend_ppp_vj_slot_comp' => 'Ascend-PPP-VJ-Slot-Comp',
- 'cisco_presession_time' => 'Cisco-PreSession-Time',
- 'usr_chat_script_name' => 'USR-Chat-Script-Name',
- 'tunnel_session_auti' => 'Tunnel_Session_Auth',
- 'ascend_fr_circuit_name' => 'Ascend-FR-Circuit-Name',
- 'ascend_expect_callback' => 'Ascend-Expect-Callback',
- 'framed_mtu' => 'Framed-MTU',
- 'usr_pw_vpn_name' => 'USR-PW_VPN_Name',
- 'nomadix_ip_upsell' => 'Nomadix-IP-Upsell',
- 'ascend_nas_port_format' => 'Ascend-NAS-Port-Format',
- 'usr_dtr_true_timeout' => 'USR-DTR-True-Timeout',
- 'shasta_vpn_name' => 'Shasta-VPN-Name',
- 'connect_rate' => 'Connect-Rate',
- 'ascend_third_prompt' => 'Ascend-Third-Prompt',
- 'cabletron_protocol_enabl' => 'Cabletron-Protocol-Enable',
- 'annex_pre_input_octets' => 'Annex-Pre-Input-Octets',
- 'cvx_modem_error_correcti' => 'CVX-Modem-Error-Correction',
- 'cvx_ss7_session_id_type' => 'CVX-SS7-Session-ID-Type',
- 'called_station_id' => 'Called-Station-Id',
- 'itk_ddi' => 'ITK-DDI',
- 'usr_pw_cutoff' => 'USR-PW_Cutoff',
- 'ascend_data_rate' => 'Ascend-Data-Rate',
- 'acct_input_packets_65' => 'Acct_Input_Packets_64',
- 'x_ascend_ts_idle_mode' => 'X-Ascend-TS-Idle-Mode',
- 'ascend_x25_pad_prompt' => 'Ascend-X25-Pad-Prompt',
- 'x_ascend_dhcp_reply' => 'X-Ascend-DHCP-Reply',
- 'acc_nbns_server_pri' => 'Acc-Nbns-Server-Pri',
- 'post_auth_type' => 'Post-Auth-Type',
- 'ascend_call_filter' => 'Ascend-Call-Filter',
- 'acc_tunnel_secret' => 'Acc-Tunnel-Secret',
- 'colubris_avpair' => 'Colubris-AVPair',
- 'bind_int_context' => 'Bind-Int-Context',
- 'annex_logical_channel_nu' => 'Annex-Logical-Channel-Number',
- 'erx_virtual_router_name' => 'ERX-Virtual-Router-Name',
- 'wispr_redirection_url' => 'WISPr-Redirection-URL',
- 'bintec_ipextiftable' => 'BinTec-ipExtIfTable',
- 'crypt_password' => 'Crypt-Password',
- 'challenge_state' => 'Challenge-State',
- 'x_ascend_pre_input_packe' => 'X-Ascend-Pre-Input-Packets',
- 'altiga_ipsec_l2l_keepali' => 'Altiga-IPSec-L2L-Keepalives-G',
- 'x_ascend_dhcp_maximum_le' => 'X-Ascend-DHCP-Maximum-Leases',
- 'acc_dialout_auth_passwor' => 'Acc-Dialout-Auth-Password',
- 'itk_ip_pool' => 'ITK-IP-Pool',
- 'pvc_profile_namf' => 'PVC_Profile_Name',
- 'x_ascend_user_acct_host' => 'X-Ascend-User-Acct-Host',
- 'strip_user_name' => 'Strip-User-Name',
- 'itk_ppp_client_server_mo' => 'ITK-PPP-Client-Server-Mode',
- 'usr_mbi_ct_bchannel_used' => 'USR-Mbi_Ct_BChannel_Used',
- 'x_ascend_route_ip' => 'X-Ascend-Route-IP',
- 'ascend_seconds_of_histor' => 'Ascend-Seconds-Of-History',
- 'cvx_data_rate' => 'CVX-Data-Rate',
- 'ascend_x25_profile_name' => 'Ascend-X25-Profile-Name',
- 'itk_ftp_auth_ip' => 'ITK-Ftp-Auth-IP',
- 'cisco_control_info' => 'Cisco-Control-Info',
- 'cvpn3000_secondary_wins' => 'CVPN3000-Secondary-WINS',
- 'usr_call_type' => 'USR-Call-Type',
- 'x_ascend_user_acct_base' => 'X-Ascend-User-Acct-Base',
- 'acct_mcast_in_packett' => 'Acct_Mcast_In_Packets',
- 'ns_vsys_name' => 'NS-VSYS-Name',
- 'acct_output_gigawords' => 'Acct-Output-Gigawords',
- 'bind_typf' => 'Bind_Type',
- 'bintec_ipqostable' => 'BinTec-ipQoSTable',
- 'bintec_ipxstaticservtabl' => 'BinTec-ipxStaticServTable',
- 'cvpn3000_l2tp_mppc_compr' => 'CVPN3000-L2TP-MPPC-Compression',
- 'login_lat_port' => 'Login-LAT-Port',
- 'usr_call_arrival_in_gmt' => 'USR-Call-Arrival-in-GMT',
- 'acct_mcast_in_octets' => 'Acct-Mcast-In-Octets',
- 'erx_sa_validate' => 'ERX-Sa-Validate',
- 'ascend_service_type' => 'Ascend-Service-Type',
- 'usr_pw_vpn_gateway' => 'USR-PW_VPN_Gateway',
- 'acc_ip_compression' => 'Acc-Ip-Compression',
- 'ascend_fr_dce_n392' => 'Ascend-FR-DCE-N392',
- 'bintec_ipxcirctable' => 'BinTec-ipxCircTable',
- 'lac_real_port_type' => 'LAC-Real-Port-Type',
- 'ascend_client_primary_dn' => 'Ascend-Client-Primary-DNS',
- 'acct_session_start_time' => 'Acct-Session-Start-Time',
- 'ascend_if_netmask' => 'Ascend-IF-Netmask',
- 'ms_chap_nt_enc_pw' => 'MS-CHAP-NT-Enc-PW',
- 'ms_mppe_encryption_types' => 'MS-MPPE-Encryption-Types',
- 'cisco_fax_process_abort_' => 'Cisco-Fax-Process-Abort-Flag',
- 'mcast_maxgroups' => 'Mcast-MaxGroups',
- 'annex_end_receive_line_l' => 'Annex-End-Receive-Line-Level',
- 'usr_ipx_call_input_filte' => 'USR-IPX-Call-Input-Filter',
- 'usr_back_channel_data_ra' => 'USR-Back-Channel-Data-Rate',
- 'ascend_cache_time' => 'Ascend-Cache-Time',
- 'x_ascend_data_svc' => 'X-Ascend-Data-Svc',
- 'usr_re_chap_timeout' => 'USR-Re-Chap-Timeout',
- 'bintec_bibodialtable' => 'BinTec-biboDialTable',
- 'annex_connect_progress' => 'Annex-Connect-Progress',
- 'x_ascend_ppp_vj_1172' => 'X-Ascend-PPP-VJ-1172',
- 'usr_igmp_routing' => 'USR-IGMP-Routing',
- 'x_ascend_ip_pool_definit' => 'X-Ascend-IP-Pool-Definition',
- 'h323_prompt_id' => 'h323-prompt-id',
- 'foundry_command_string' => 'Foundry-Command-String',
- 'le_terminate_detail' => 'LE-Terminate-Detail',
- 'cvpn3000_pptp_encryption' => 'CVPN3000-PPTP-Encryption',
- 'quintum_h323_disconnect_' => 'Quintum-h323-disconnect-time',
- 'acc_ml_clear_threshold' => 'Acc-ML-Clear-Threshold',
- 'x_ascend_ip_direct' => 'X-Ascend-IP-Direct',
- 'usr_ip_call_input_filter' => 'USR-IP-Call-Input-Filter',
- 'x_ascend_data_rate' => 'X-Ascend-Data-Rate',
- 'nas_port' => 'NAS-Port',
- 'ascend_client_secondary_' => 'Ascend-Client-Secondary-WINS',
- 'ascend_auth_type' => 'Ascend-Auth-Type',
- 'x_ascend_preempt_limit' => 'X-Ascend-Preempt-Limit',
- 'cvx_xmit_rate' => 'CVX-Xmit-Rate',
- 'annex_transmitted_packet' => 'Annex-Transmitted-Packets',
- 'h323_credit_amount' => 'h323-credit-amount',
- 'usr_reply_script1' => 'USR-Reply-Script1',
- 'current_time' => 'Current-Time',
- 'cisco_xmit_rate' => 'Cisco-Xmit-Rate',
- 'x_ascend_session_svr_key' => 'X-Ascend-Session-Svr-Key',
- 'ascend_authen_alias' => 'Ascend-Authen-Alias',
- 'erx_redirect_vr_name' => 'ERX-Redirect-VR-Name',
- 'module_success_message' => 'Module-Success-Message',
- 'acc_dialout_auth_mode' => 'Acc-Dialout-Auth-Mode',
- 'bind_auth_contexu' => 'Bind_Auth_Context',
- 'x_ascend_minimum_channel' => 'X-Ascend-Minimum-Channels',
- 'usr_event_date_time' => 'USR-Event-Date-Time',
- 'x_ascend_ipx_node_addr' => 'X-Ascend-IPX-Node-Addr',
- 'cvpn3000_ipsec_over_udp' => 'CVPN3000-IPSec-Over-UDP',
- 'x_ascend_user_acct_time' => 'X-Ascend-User-Acct-Time',
- 'cisco_email_server_ack_f' => 'Cisco-Email-Server-Ack-Flag',
- 'telebit_activate_command' => 'Telebit-Activate-Command',
- 'acc_output_errors' => 'Acc-Output-Errors',
- 'juniper_allow_configurat' => 'Juniper-Allow-Configuration',
- 'bind_l2tp_tunnel_name' => 'Bind-L2TP-Tunnel-Name',
- 'x_ascend_pri_number_type' => 'X-Ascend-PRI-Number-Type',
- 'bintec_biboppptable' => 'BinTec-biboPPPTable',
- 'le_ipsec_outsource_profi' => 'LE-IPSec-Outsource-Profile',
- 'usr_at_zip_input_filter' => 'USR-AT-Zip-Input-Filter',
- 'replicate_to_realm' => 'Replicate-To-Realm',
- 'annex_mrru' => 'Annex-MRRU',
- 'event_timestamp' => 'Event-Timestamp',
- 'nokia_sgsn_ip_address' => 'Nokia-SGSN-IP-Address',
- 'ascend_pre_input_packets' => 'Ascend-Pre-Input-Packets',
- 'cvpn5000_client_assigned' => 'CVPN5000-Client-Assigned-IP',
- 'tunnel_dnit' => 'Tunnel_DNIS',
- 'h323_call_origin' => 'h323-call-origin',
- 'x_ascend_fr_type' => 'X-Ascend-FR-Type',
- 'itk_provider_id' => 'ITK-Provider-Id',
- 'cvx_ppp_log_mask' => 'CVX-PPP-Log-Mask',
- 'x_ascend_token_idle' => 'X-Ascend-Token-Idle',
- 'usr_rmmie_pwrlvl_xmit_lv' => 'USR-RMMIE-PwrLvl-Xmit-Lvl',
- 'usr_igmp_query_interval' => 'USR-IGMP-Query-Interval',
- 'quintum_h323_billing_mod' => 'Quintum-h323-billing-model',
- 'ascend_atm_vci' => 'Ascend-ATM-Vci',
- 'usr_port_tap_output' => 'USR-Port-Tap-Output',
- 'session' => 'Session',
- 'itk_welcome_message' => 'ITK-Welcome-Message',
- 'cvpn3000_ike_keep_alives' => 'CVPN3000-IKE-Keep-Alives',
- 'ascend_uu_info' => 'Ascend-UU-Info',
- 'usr_et_bridge_call_outpu' => 'USR-ET-Bridge-Call-Output-Filte',
- 'usr_secondary_dns_server' => 'USR-Secondary_DNS_Server',
- 'ms_mppe_recv_key' => 'MS-MPPE-Recv-Key',
- 'bintec_ripcirctable' => 'BinTec-ripCircTable',
- 'acc_dial_port_index' => 'Acc-Dial-Port-Index',
- 'cisco_nas_port' => 'Cisco-NAS-Port',
- 'itk_username' => 'ITK-Username',
- 'usr_send_script1' => 'USR-Send-Script1',
- 'cvpn3000_ipsec_ike_peer_' => 'CVPN3000-IPSec-IKE-Peer-ID-Check',
- 'ascend_dsl_upstream_limi' => 'Ascend-Dsl-Upstream-Limit',
- 'x_ascend_dec_channel_cou' => 'X-Ascend-Dec-Channel-Count',
- 'usr_tunnel_security' => 'USR-Tunnel-Security',
- 'arap_security' => 'ARAP-Security',
- 'tunnel_preference' => 'Tunnel-Preference',
- 'cisco_port_used' => 'Cisco-Port-Used',
- 'usr_reply_script4' => 'USR-Reply-Script4',
- 'cvpn5000_client_real_ip' => 'CVPN5000-Client-Real-IP',
- 'usr_rmmie_status' => 'USR-RMMIE-Status',
- 'usr_send_script4' => 'USR-Send-Script4',
- 'quintum_h323_connect_tim' => 'Quintum-h323-connect-time',
- 'annex_syslog_tap' => 'Annex-Syslog-Tap',
- 'redcreek_tunneled_hostna' => 'RedCreek-Tunneled-HostName',
- 'acc_clearing_location' => 'Acc-Clearing-Location',
- 'ascend_access_intercept_' => 'Ascend-Access-Intercept-LEA',
- 'annex_disconnect_reason' => 'Annex-Disconnect-Reason',
- 'usr_at_input_filter' => 'USR-AT-Input-Filter',
- 'usr_auth_mode' => 'USR-Auth-Mode',
- 'usr_expected_voltage' => 'USR-Expected-Voltage',
- 'shiva_session_id' => 'Shiva-Session-Id',
- 'annex_maximum_call_durat' => 'Annex-Maximum-Call-Duration',
- 'usr_block_error_count_li' => 'USR-Block-Error-Count-Limit',
- 'ascend_owner_ip_addr' => 'Ascend-Owner-IP-Addr',
- 'bind_tun_contexu' => 'Bind_Tun_Context',
- 'usr_pw_usr_ofilter_ipx' => 'USR-PW_USR_OFilter_IPX',
- 'framed_routing' => 'Framed-Routing',
- 'annex_primary_nbns_serve' => 'Annex-Primary-NBNS-Server',
- 'usr_interface_index' => 'USR-Interface-Index',
- 'pam_auth' => 'Pam-Auth',
- 'usr_end_time' => 'USR-End-Time',
- 'rate_limit_bursu' => 'Rate_Limit_Burst',
- 'nomadix_expiration' => 'Nomadix-Expiration',
- 'x_ascend_transit_number' => 'X-Ascend-Transit-Number',
- 'itk_usergroup' => 'ITK-Usergroup',
- 'x_ascend_assign_ip_pool' => 'X-Ascend-Assign-IP-Pool',
- 'annex_secondary_nbns_ser' => 'Annex-Secondary-NBNS-Server',
- 'bind_dot1q_vlan_tag_id' => 'Bind-Dot1q-Vlan-Tag-Id',
- 'ms_secondary_nbns_server' => 'MS-Secondary-NBNS-Server',
- 'tunnel_retransmit' => 'Tunnel-Retransmit',
- 'acct_tunnel_connection' => 'Acct-Tunnel-Connection',
- 'x_ascend_backup' => 'X-Ascend-Backup',
- 'xedia_ppp_echo_interval' => 'Xedia-PPP-Echo-Interval',
- 'usr_bearer_capabilities' => 'USR-Bearer-Capabilities',
- 'shiva_acct_serv_switch' => 'Shiva-Acct-Serv-Switch',
- 'acct_authentic' => 'Acct-Authentic',
- 'le_nat_other_session_tim' => 'LE-NAT-Other-Session-Timeout',
- 'cvpn3000_ipsec_banner2' => 'CVPN3000-IPSec-Banner2',
- 'x_ascend_force_56' => 'X-Ascend-Force-56',
- 'framed_appletalk_network' => 'Framed-AppleTalk-Network',
- 'reply_message' => 'Reply-Message',
- 'class' => 'Class',
- 'h323_conf_id' => 'h323-conf-id',
- 'quintum_h323_disconnecta' => 'Quintum-h323-disconnect-cause',
- 'itk_filter_rule' => 'ITK-Filter-Rule',
- 'wispr_bandwidth_max_up' => 'WISPr-Bandwidth-Max-Up',
- 'usr_appletalk_network_ra' => 'USR-Appletalk-Network-Range',
- 'ascend_cbcp_delay' => 'Ascend-CBCP-Delay',
- 'usr_dte_ring_no_answer_l' => 'USR-DTE-Ring-No-Answer-Limit',
- 'pre_acct_type' => 'Pre-Acct-Type',
- 'usr_local_ip_address' => 'USR-Local-IP-Address',
- 'ascend_dropped_octets' => 'Ascend-Dropped-Octets',
- 'ascend_h323_dialed_time' => 'Ascend-H323-Dialed-Time',
- 'cisco_email_server_addre' => 'Cisco-Email-Server-Address',
- 'ascend_x25_x121_address' => 'Ascend-X25-X121-Address',
- 'cvx_multicast_client' => 'CVX-Multicast-Client',
- 'wispr_bandwidth_min_up' => 'WISPr-Bandwidth-Min-Up',
- 'usr_at_output_filter' => 'USR-AT-Output-Filter',
- 'annex_local_ip_address' => 'Annex-Local-IP-Address',
- 'cisco_ip_pool_definition' => 'Cisco-IP-Pool-Definition',
- 'cisco_gateway_id' => 'Cisco-Gateway-Id',
- 'itk_password_prompt' => 'ITK-Password-Prompt',
- 'annex_domain_name' => 'Annex-Domain-Name',
- 'foundry_command_exceptio' => 'Foundry-Command-Exception-Flag',
- 'ascend_preempt_limit' => 'Ascend-Preempt-Limit',
- 'erx_minimum_bps' => 'ERX-Minimum-BPS',
- 'aat_mcast_client' => 'AAT-MCast-Client',
- 'ascend_atm_fault_managem' => 'Ascend-ATM-Fault-Management',
- 'ascend_event_type' => 'Ascend-Event-Type',
- 'exec_program_wait' => 'Exec-Program-Wait',
- 'framed_interface_id' => 'Framed-Interface-Id',
-
- #NETC.NET.AU (RADIATOR?)
- 'authentication_type' => 'Authentication-Type',
-
-);
-
-1;
diff --git a/FS/FS/radius_usergroup.pm b/FS/FS/radius_usergroup.pm
deleted file mode 100644
index 9bba057..0000000
--- a/FS/FS/radius_usergroup.pm
+++ /dev/null
@@ -1,131 +0,0 @@
-package FS::radius_usergroup;
-
-use strict;
-use vars qw( @ISA );
-use FS::Record qw( qsearch qsearchs );
-use FS::svc_acct;
-
-@ISA = qw(FS::Record);
-
-=head1 NAME
-
-FS::radius_usergroup - Object methods for radius_usergroup records
-
-=head1 SYNOPSIS
-
- use FS::radius_usergroup;
-
- $record = new FS::radius_usergroup \%hash;
- $record = new FS::radius_usergroup { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
-=head1 DESCRIPTION
-
-An FS::radius_usergroup object links an account (see L<FS::svc_acct>) with a
-RADIUS group. FS::radius_usergroup inherits from FS::Record. The following
-fields are currently supported:
-
-=over 4
-
-=item usergroupnum - primary key
-
-=item svcnum - Account (see L<FS::svc_acct>).
-
-=item groupname - group name
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new record. To add the record 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 { 'radius_usergroup'; }
-
-=item insert
-
-Adds this record to the database. If there is an error, returns the error,
-otherwise returns false.
-
-=cut
-
-#inherited from FS::Record
-
-=item delete
-
-Delete this record from the database.
-
-=cut
-
-#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
-
-#inherited from FS::Record
-
-=item check
-
-Checks all fields to make sure this is a valid record. If there is
-an error, returns the error, otherwise returns false. Called by the insert
-and replace methods.
-
-=cut
-
-sub check {
- my $self = shift;
-
- $self->ut_numbern('usergroupnum')
- || $self->ut_number('svcnum')
- || $self->ut_foreign_key('svcnum','svc_acct','svcnum')
- || $self->ut_text('groupname')
- || $self->SUPER::check
- ;
-}
-
-=item svc_acct
-
-Returns the account associated with this record (see L<FS::svc_acct>).
-
-=cut
-
-sub svc_acct {
- my $self = shift;
- qsearchs('svc_acct', { svcnum => $self->svcnum } );
-}
-
-=back
-
-=head1 BUGS
-
-Don't let 'em get you down.
-
-=head1 SEE ALSO
-
-L<svc_acct>, L<FS::Record>, schema.html from the base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/router.pm b/FS/FS/router.pm
deleted file mode 100755
index 2554ce8..0000000
--- a/FS/FS/router.pm
+++ /dev/null
@@ -1,144 +0,0 @@
-package FS::router;
-
-use strict;
-use vars qw( @ISA );
-use FS::Record qw( qsearchs qsearch );
-use FS::addr_block;
-
-@ISA = qw( FS::Record );
-
-=head1 NAME
-
-FS::router - Object methods for router records
-
-=head1 SYNOPSIS
-
- use FS::router;
-
- $record = new FS::router \%hash;
- $record = new FS::router { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
-=head1 DESCRIPTION
-
-An FS::router record describes a broadband router, such as a DSLAM or a wireless
- access point. FS::router inherits from FS::Record. The following
-fields are currently supported:
-
-=over 4
-
-=item routernum - primary key
-
-=item routername - descriptive name for the router
-
-=item svcnum - svcnum of the owning FS::svc_broadband, if appropriate
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Create a new record. To add the record to the database, see "insert".
-
-=cut
-
-sub table { 'router'; }
-
-=item insert
-
-Adds this record to the database. If there is an error, returns the error,
-otherwise returns false.
-
-=item delete
-
-Deletes this record from the database. If there is an error, returns the
-error, otherwise returns false.
-
-=item replace OLD_RECORD
-
-Replaces OLD_RECORD with this one in the database. If there is an error,
-returns the error, otherwise returns false.
-
-=item check
-
-Checks all fields to make sure this is a valid record. If there is an error,
-returns the error, otherwise returns false. Called by the insert and replace
-methods.
-
-=cut
-
-sub check {
- my $self = shift;
-
- my $error =
- $self->ut_numbern('routernum')
- || $self->ut_text('routername');
- return $error if $error;
-
- $self->SUPER::check;
-}
-
-=item addr_block
-
-Returns a list of FS::addr_block objects (address blocks) associated
-with this object.
-
-=cut
-
-sub addr_block {
- my $self = shift;
- return qsearch('addr_block', { routernum => $self->routernum });
-}
-
-=item part_svc_router
-
-Returns a list of FS::part_svc_router objects associated with this
-object. This is unlikely to be useful for any purpose other than retrieving
-the associated FS::part_svc objects. See below.
-
-=cut
-
-sub part_svc_router {
- my $self = shift;
- return qsearch('part_svc_router', { routernum => $self->routernum });
-}
-
-=item part_svc
-
-Returns a list of FS::part_svc objects associated with this object.
-
-=cut
-
-sub part_svc {
- my $self = shift;
- return map { qsearchs('part_svc', { svcpart => $_->svcpart }) }
- $self->part_svc_router;
-}
-
-=back
-
-=head1 VERSION
-
-$Id:
-
-=head1 BUGS
-
-=head1 SEE ALSO
-
-FS::svc_broadband, FS::router, FS::addr_block, FS::part_svc,
-schema.html from the base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/session.pm b/FS/FS/session.pm
deleted file mode 100644
index 2ad594c..0000000
--- a/FS/FS/session.pm
+++ /dev/null
@@ -1,269 +0,0 @@
-package FS::session;
-
-use strict;
-use vars qw( @ISA $conf $start $stop );
-use FS::UID qw( dbh );
-use FS::Record qw( qsearchs );
-use FS::svc_acct;
-use FS::port;
-use FS::nas;
-
-@ISA = qw(FS::Record);
-
-$FS::UID::callback{'FS::session'} = sub {
- $conf = new FS::Conf;
- $start = $conf->exists('session-start') ? $conf->config('session-start') : '';
- $stop = $conf->exists('session-stop') ? $conf->config('session-stop') : '';
-};
-
-=head1 NAME
-
-FS::session - Object methods for session records
-
-=head1 SYNOPSIS
-
- use FS::session;
-
- $record = new FS::session \%hash;
- $record = new FS::session {
- 'portnum' => 1,
- 'svcnum' => 2,
- 'login' => $timestamp,
- 'logout' => $timestamp,
- };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
- $error = $record->nas_heartbeat($timestamp);
-
-=head1 DESCRIPTION
-
-An FS::session object represents an user login session. FS::session inherits
-from FS::Record. The following fields are currently supported:
-
-=over 4
-
-=item sessionnum - primary key
-
-=item portnum - NAS port for this session - see L<FS::port>
-
-=item svcnum - User for this session - see L<FS::svc_acct>
-
-=item login - timestamp indicating the beginning of this user session.
-
-=item logout - timestamp indicating the end of this user session. May be null,
- which indicates a currently open session.
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new session. To add the session 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 { 'session'; }
-
-=item insert
-
-Adds this record to the database. If there is an error, returns the error,
-otherwise returns false. If the `login' field is empty, it is replaced with
-the current time.
-
-=cut
-
-sub insert {
- my $self = shift;
- my $error;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- $error = $self->check;
- return $error if $error;
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- if ( qsearchs('session', { 'portnum' => $self->portnum, 'logout' => '' } ) ) {
- $dbh->rollback if $oldAutoCommit;
- return "a session on that port is already open!";
- }
-
- $self->setfield('login', time()) unless $self->getfield('login');
-
- $error = $self->SUPER::insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- $self->nas_heartbeat($self->getfield('login'));
-
- #session-starting callback
- #redundant with heartbeat, yuck
- my $port = qsearchs('port',{'portnum'=>$self->portnum});
- my $nas = qsearchs('nas',{'nasnum'=>$port->nasnum});
- #kcuy
- my( $ip, $nasip, $nasfqdn ) = ( $port->ip, $nas->nasip, $nas->nasfqdn );
- system( eval qq("$start") ) if $start;
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
- '';
-
-}
-
-=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. If the `logout' field is empty,
-it is replaced with the current time.
-
-=cut
-
-sub replace {
- my($self, $old) = @_;
- my $error;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- $error = $self->check;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- $self->setfield('logout', time()) unless $self->getfield('logout');
-
- $error = $self->SUPER::replace($old);
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- $self->nas_heartbeat($self->getfield('logout'));
-
- #session-ending callback
- #redundant with heartbeat, yuck
- my $port = qsearchs('port',{'portnum'=>$self->portnum});
- my $nas = qsearchs('nas',{'nasnum'=>$port->nasnum});
- #kcuy
- my( $ip, $nasip, $nasfqdn ) = ( $port->ip, $nas->nasip, $nas->nasfqdn );
- system( eval qq("$stop") ) if $stop;
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
-
- '';
-}
-
-=item check
-
-Checks all fields to make sure this is a valid session. 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;
- my $error =
- $self->ut_numbern('sessionnum')
- || $self->ut_number('portnum')
- || $self->ut_number('svcnum')
- || $self->ut_numbern('login')
- || $self->ut_numbern('logout')
- ;
- return $error if $error;
- return "Unknown svcnum"
- unless qsearchs('svc_acct', { 'svcnum' => $self->svcnum } );
- $self->SUPER::check;
-}
-
-=item nas_heartbeat
-
-Heartbeats the nas associated with this session (see L<FS::nas>).
-
-=cut
-
-sub nas_heartbeat {
- my $self = shift;
- my $port = qsearchs('port',{'portnum'=>$self->portnum});
- my $nas = qsearchs('nas',{'nasnum'=>$port->nasnum});
- $nas->heartbeat(shift);
-}
-
-=item svc_acct
-
-Returns the svc_acct record associated with this session (see L<FS::svc_acct>).
-
-=cut
-
-sub svc_acct {
- my $self = shift;
- qsearchs('svc_acct', { 'svcnum' => $self->svcnum } );
-}
-
-=back
-
-=head1 VERSION
-
-$Id: session.pm,v 1.8 2003-08-05 00:20:46 khoff Exp $
-
-=head1 BUGS
-
-Maybe you shouldn't be able to insert a session if there's currently an open
-session on that port. Or maybe the open session on that port should be flagged
-as problematic? autoclosed? *sigh*
-
-Hmm, sessions refer to current svc_acct records... probably need to constrain
-deletions to svc_acct records such that no svc_acct records are deleted which
-have a session (even if long-closed).
-
-=head1 SEE ALSO
-
-L<FS::Record>, schema.html from the base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/svc_Common.pm b/FS/FS/svc_Common.pm
deleted file mode 100644
index a223266..0000000
--- a/FS/FS/svc_Common.pm
+++ /dev/null
@@ -1,515 +0,0 @@
-package FS::svc_Common;
-
-use strict;
-use vars qw( @ISA $noexport_hack $DEBUG );
-use FS::Record qw( qsearch qsearchs fields dbh );
-use FS::cust_svc;
-use FS::part_svc;
-use FS::queue;
-
-@ISA = qw( FS::Record );
-
-$DEBUG = 0;
-#$DEBUG = 1;
-
-=head1 NAME
-
-FS::svc_Common - Object method for all svc_ records
-
-=head1 SYNOPSIS
-
-use FS::svc_Common;
-
-@ISA = qw( FS::svc_Common );
-
-=head1 DESCRIPTION
-
-FS::svc_Common is intended as a base class for table-specific classes to
-inherit from, i.e. FS::svc_acct. FS::svc_Common inherits from FS::Record.
-
-=head1 METHODS
-
-=over 4
-
-=cut
-
-sub virtual_fields {
-
- # This restricts the fields based on part_svc_column and the svcpart of
- # the service. There are four possible cases:
- # 1. svcpart passed as part of the svc_x hash.
- # 2. svcpart fetched via cust_svc based on svcnum.
- # 3. No svcnum or svcpart. In this case, return ALL the fields with
- # dbtable eq $self->table.
- # 4. Called via "fields('svc_acct')" or something similar. In this case
- # there is no $self object.
-
- my $self = shift;
- my $svcpart;
- my @vfields = $self->SUPER::virtual_fields;
-
- return @vfields unless (ref $self); # Case 4
-
- if ($self->svcpart) { # Case 1
- $svcpart = $self->svcpart;
- } elsif ( $self->svcnum
- && qsearchs('cust_svc',{'svcnum'=>$self->svcnum} )
- ) { #Case 2
- $svcpart = $self->cust_svc->svcpart;
- } else { # Case 3
- $svcpart = '';
- }
-
- if ($svcpart) { #Cases 1 and 2
- my %flags = map { $_->columnname, $_->columnflag } (
- qsearch ('part_svc_column', { svcpart => $svcpart } )
- );
- return grep { not ($flags{$_} eq 'X') } @vfields;
- } else { # Case 3
- return @vfields;
- }
- return ();
-}
-
-=item check
-
-Checks the validity of fields in this record.
-
-At present, this does nothing but call FS::Record::check (which, in turn,
-does nothing but run virtual field checks).
-
-=cut
-
-sub check {
- my $self = shift;
- $self->SUPER::check;
-}
-
-=item insert [ , OPTION => VALUE ... ]
-
-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.
-
-Currently available options are: I<jobnums>, I<child_objects> and
-I<depend_jobnum>.
-
-If I<jobnum> is set to an array reference, the jobnums of any export jobs will
-be added to the referenced array.
-
-If I<child_objects> is set to an array reference of FS::tablename objects (for
-example, FS::acct_snarf objects), they will have their svcnum fieldsset and
-will be inserted after this record, but before any exports are run.
-
-If I<depend_jobnum> is set (to a scalar jobnum or an array reference of
-jobnums), all provisioning jobs will have a dependancy on the supplied
-jobnum(s) (they will not run until the specific job(s) complete(s)).
-
-=cut
-
-sub insert {
- my $self = shift;
- my %options = @_;
- warn "FS::svc_Common::insert called with options ".
- join(', ', map { "$_: $options{$_}" } keys %options ). "\n"
- if $DEBUG;
-
- my @jobnums = ();
- local $FS::queue::jobnums = \@jobnums;
- warn "FS::svc_Common::insert: set \$FS::queue::jobnums to $FS::queue::jobnums"
- if $DEBUG;
- my $objects = $options{'child_objects'} || [];
- my $depend_jobnums = $options{'depend_jobnum'} || [];
- $depend_jobnums = [ $depend_jobnums ] unless ref($depend_jobnums);
- my $error;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- $error = $self->check;
- return $error if $error;
-
- my $svcnum = $self->svcnum;
- my $cust_svc = $svcnum ? qsearchs('cust_svc',{'svcnum'=>$self->svcnum}) : '';
- #unless ( $svcnum ) {
- if ( !$svcnum or !$cust_svc ) {
- $cust_svc = new FS::cust_svc ( {
- #hua?# 'svcnum' => $svcnum,
- 'svcnum' => $self->svcnum,
- 'pkgnum' => $self->pkgnum,
- 'svcpart' => $self->svcpart,
- } );
- $error = $cust_svc->insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- $svcnum = $self->svcnum($cust_svc->svcnum);
- } else {
- #$cust_svc = qsearchs('cust_svc',{'svcnum'=>$self->svcnum});
- unless ( $cust_svc ) {
- $dbh->rollback if $oldAutoCommit;
- return "no cust_svc record found for svcnum ". $self->svcnum;
- }
- $self->pkgnum($cust_svc->pkgnum);
- $self->svcpart($cust_svc->svcpart);
- }
-
- $error = $self->SUPER::insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- foreach my $object ( @$objects ) {
- $object->svcnum($self->svcnum);
- $error = $object->insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
-
- #new-style exports!
- unless ( $noexport_hack ) {
-
- warn "FS::svc_Common::insert: \$FS::queue::jobnums is $FS::queue::jobnums"
- if $DEBUG;
-
- foreach my $part_export ( $self->cust_svc->part_svc->part_export ) {
- my $error = $part_export->export_insert($self);
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "exporting to ". $part_export->exporttype.
- " (transaction rolled back): $error";
- }
- }
-
- foreach my $depend_jobnum ( @$depend_jobnums ) {
- warn "inserting dependancies on supplied job $depend_jobnum\n"
- if $DEBUG;
- foreach my $jobnum ( @jobnums ) {
- my $queue = qsearchs('queue', { 'jobnum' => $jobnum } );
- warn "inserting dependancy for job $jobnum on $depend_jobnum\n"
- if $DEBUG;
- my $error = $queue->depend_insert($depend_jobnum);
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "error queuing job dependancy: $error";
- }
- }
- }
-
- }
-
- if ( exists $options{'jobnums'} ) {
- push @{ $options{'jobnums'} }, @jobnums;
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
-
- '';
-}
-
-=item delete
-
-Deletes this account from the database. If there is an error, returns the
-error, otherwise returns false.
-
-The corresponding FS::cust_svc record will be deleted as well.
-
-=cut
-
-sub delete {
- my $self = shift;
- my $error;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $svcnum = $self->svcnum;
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- $error = $self->SUPER::delete;
- return $error if $error;
-
- #new-style exports!
- unless ( $noexport_hack ) {
- foreach my $part_export ( $self->cust_svc->part_svc->part_export ) {
- my $error = $part_export->export_delete($self);
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "exporting to ". $part_export->exporttype.
- " (transaction rolled back): $error";
- }
- }
- }
-
- return $error if $error;
-
- my $cust_svc = $self->cust_svc;
- $error = $cust_svc->delete;
- return $error if $error;
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
-
- '';
-}
-
-=item replace OLD_RECORD
-
-Replaces OLD_RECORD with this one. If there is an error, returns the error,
-otherwise returns false.
-
-=cut
-
-sub replace {
- my ($new, $old) = (shift, shift);
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- my $error = $new->SUPER::replace($old);
- if ($error) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- #new-style exports!
- unless ( $noexport_hack ) {
- foreach my $part_export ( $new->cust_svc->part_svc->part_export ) {
- my $error = $part_export->export_replace($new,$old);
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "error exporting to ". $part_export->exporttype.
- " (transaction rolled back): $error";
- }
- }
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
- '';
-}
-
-
-=item setfixed
-
-Sets any fixed fields for this service (see L<FS::part_svc>). If there is an
-error, returns the error, otherwise returns the FS::part_svc object (use ref()
-to test the return). Usually called by the check method.
-
-=cut
-
-sub setfixed {
- my $self = shift;
- $self->setx('F');
-}
-
-=item setdefault
-
-Sets all fields to their defaults (see L<FS::part_svc>), overriding their
-current values. If there is an error, returns the error, otherwise returns
-the FS::part_svc object (use ref() to test the return).
-
-=cut
-
-sub setdefault {
- my $self = shift;
- $self->setx('D');
-}
-
-sub setx {
- my $self = shift;
- my $x = shift;
-
- my $error;
-
- $error =
- $self->ut_numbern('svcnum')
- ;
- return $error if $error;
-
- #get part_svc
- my $svcpart;
- if ( $self->svcnum && qsearchs('cust_svc', {'svcnum'=>$self->svcnum}) ) {
- my $cust_svc = $self->cust_svc;
- return "Unknown svcnum" unless $cust_svc;
- $svcpart = $cust_svc->svcpart;
- } else {
- $svcpart = $self->getfield('svcpart');
- }
- my $part_svc = qsearchs( 'part_svc', { 'svcpart' => $svcpart } );
- return "Unkonwn svcpart" unless $part_svc;
-
- #set default/fixed/whatever fields from part_svc
- my $table = $self->table;
- foreach my $field ( grep { $_ ne 'svcnum' } $self->fields ) {
- my $part_svc_column = $part_svc->part_svc_column($field);
- if ( $part_svc_column->columnflag eq $x ) {
- $self->setfield( $field, $part_svc_column->columnvalue );
- }
- }
-
- $part_svc;
-
-}
-
-=item cust_svc
-
-Returns the cust_svc record associated with this svc_ record, as a FS::cust_svc
-object (see L<FS::cust_svc>).
-
-=cut
-
-sub cust_svc {
- my $self = shift;
- qsearchs('cust_svc', { 'svcnum' => $self->svcnum } );
-}
-
-=item suspend
-
-Runs export_suspend callbacks.
-
-=cut
-
-sub suspend {
- my $self = shift;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- #new-style exports!
- unless ( $noexport_hack ) {
- foreach my $part_export ( $self->cust_svc->part_svc->part_export ) {
- my $error = $part_export->export_suspend($self);
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "error exporting to ". $part_export->exporttype.
- " (transaction rolled back): $error";
- }
- }
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
- '';
-
-}
-
-=item unsuspend
-
-Runs export_unsuspend callbacks.
-
-=cut
-
-sub unsuspend {
- my $self = shift;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- #new-style exports!
- unless ( $noexport_hack ) {
- foreach my $part_export ( $self->cust_svc->part_svc->part_export ) {
- my $error = $part_export->export_unsuspend($self);
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "error exporting to ". $part_export->exporttype.
- " (transaction rolled back): $error";
- }
- }
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
- '';
-
-}
-
-=item cancel
-
-Stub - returns false (no error) so derived classes don't need to define these
-methods. Called by the cancel method of FS::cust_pkg (see L<FS::cust_pkg>).
-
-=cut
-
-sub cancel { ''; }
-
-=item clone_suspended
-
-Constructor used by FS::part_export::_export_suspend fallback. Stub returning
-same object for svc_ classes which don't implement a suspension fallback
-(everything except svc_acct at the moment). Document better.
-
-=cut
-
-sub clone_suspended {
- shift;
-}
-
-=item clone_kludge_unsuspend
-
-Constructor used by FS::part_export::_export_unsuspend fallback. Stub returning
-same object for svc_ classes which don't implement a suspension fallback
-(everything except svc_acct at the moment). Document better.
-
-=cut
-
-sub clone_kludge_unsuspend {
- shift;
-}
-
-=back
-
-=head1 BUGS
-
-The setfixed method return value.
-
-=head1 SEE ALSO
-
-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/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm
deleted file mode 100644
index 100af6c..0000000
--- a/FS/FS/svc_acct.pm
+++ /dev/null
@@ -1,1372 +0,0 @@
-package FS::svc_acct;
-
-use strict;
-use vars qw( @ISA $DEBUG $me $conf
- $dir_prefix @shells $usernamemin
- $usernamemax $passwordmin $passwordmax
- $username_ampersand $username_letter $username_letterfirst
- $username_noperiod $username_nounderscore $username_nodash
- $username_uppercase
- $welcome_template $welcome_from $welcome_subject $welcome_mimetype
- $smtpmachine
- $radius_password $radius_ip
- $dirhash
- @saltset @pw_set );
-use Carp;
-use Fcntl qw(:flock);
-use Crypt::PasswdMD5;
-use FS::UID qw( datasrc );
-use FS::Conf;
-use FS::Record qw( qsearch qsearchs fields dbh dbdef );
-use FS::svc_Common;
-use FS::cust_svc;
-use FS::part_svc;
-use FS::svc_acct_pop;
-use FS::cust_main_invoice;
-use FS::svc_domain;
-use FS::raddb;
-use FS::queue;
-use FS::radius_usergroup;
-use FS::export_svc;
-use FS::part_export;
-use FS::Msgcat qw(gettext);
-
-@ISA = qw( FS::svc_Common );
-
-$DEBUG = 0;
-#$DEBUG = 1;
-$me = '[FS::svc_acct]';
-
-#ask FS::UID to run this stuff for us later
-$FS::UID::callback{'FS::svc_acct'} = sub {
- $conf = new FS::Conf;
- $dir_prefix = $conf->config('home');
- @shells = $conf->config('shells');
- $usernamemin = $conf->config('usernamemin') || 2;
- $usernamemax = $conf->config('usernamemax');
- $passwordmin = $conf->config('passwordmin') || 6;
- $passwordmax = $conf->config('passwordmax') || 8;
- $username_letter = $conf->exists('username-letter');
- $username_letterfirst = $conf->exists('username-letterfirst');
- $username_noperiod = $conf->exists('username-noperiod');
- $username_nounderscore = $conf->exists('username-nounderscore');
- $username_nodash = $conf->exists('username-nodash');
- $username_uppercase = $conf->exists('username-uppercase');
- $username_ampersand = $conf->exists('username-ampersand');
- $dirhash = $conf->config('dirhash') || 0;
- if ( $conf->exists('welcome_email') ) {
- $welcome_template = new Text::Template (
- TYPE => 'ARRAY',
- SOURCE => [ map "$_\n", $conf->config('welcome_email') ]
- ) or warn "can't create welcome email template: $Text::Template::ERROR";
- $welcome_from = $conf->config('welcome_email-from'); # || 'your-isp-is-dum'
- $welcome_subject = $conf->config('welcome_email-subject') || 'Welcome';
- $welcome_mimetype = $conf->config('welcome_email-mimetype') || 'text/plain';
- } else {
- $welcome_template = '';
- $welcome_from = '';
- $welcome_subject = '';
- $welcome_mimetype = '';
- }
- $smtpmachine = $conf->config('smtpmachine');
- $radius_password = $conf->config('radius-password') || 'Password';
- $radius_ip = $conf->config('radius-ip') || 'Framed-IP-Address';
-};
-
-@saltset = ( 'a'..'z' , 'A'..'Z' , '0'..'9' , '.' , '/' );
-@pw_set = ( 'a'..'z', 'A'..'Z', '0'..'9', '(', ')', '#', '!', '.', ',' );
-
-sub _cache {
- my $self = shift;
- my ( $hashref, $cache ) = @_;
- if ( $hashref->{'svc_acct_svcnum'} ) {
- $self->{'_domsvc'} = FS::svc_domain->new( {
- 'svcnum' => $hashref->{'domsvc'},
- 'domain' => $hashref->{'svc_acct_domain'},
- 'catchall' => $hashref->{'svc_acct_catchall'},
- } );
- }
-}
-
-=head1 NAME
-
-FS::svc_acct - Object methods for svc_acct records
-
-=head1 SYNOPSIS
-
- use FS::svc_acct;
-
- $record = new FS::svc_acct \%hash;
- $record = new FS::svc_acct { '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;
-
- %hash = $record->radius;
-
- %hash = $record->radius_reply;
-
- %hash = $record->radius_check;
-
- $domain = $record->domain;
-
- $svc_domain = $record->svc_domain;
-
- $email = $record->email;
-
- $seconds_since = $record->seconds_since($timestamp);
-
-=head1 DESCRIPTION
-
-An FS::svc_acct object represents an account. FS::svc_acct inherits from
-FS::svc_Common. The following fields are currently supported:
-
-=over 4
-
-=item svcnum - primary key (assigned automatcially for new accounts)
-
-=item username
-
-=item _password - generated if blank
-
-=item sec_phrase - security phrase
-
-=item popnum - Point of presence (see L<FS::svc_acct_pop>)
-
-=item uid
-
-=item gid
-
-=item finger - GECOS
-
-=item dir - set automatically if blank (and uid is not)
-
-=item shell
-
-=item quota - (unimplementd)
-
-=item slipip - IP address
-
-=item seconds -
-
-=item domsvc - svcnum from svc_domain
-
-=item radius_I<Radius_Attribute> - I<Radius-Attribute>
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new account. To add the account to the database, see L<"insert">.
-
-=cut
-
-sub table { 'svc_acct'; }
-
-=item insert [ , OPTION => VALUE ... ]
-
-Adds this account 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.
-
-The additional field I<usergroup> can optionally be defined; if so it should
-contain an arrayref of group names. See L<FS::radius_usergroup>. (used in
-sqlradius export only)
-
-The additional field I<child_objects> can optionally be defined; if so it
-should contain an arrayref of FS::tablename objects. They will have their
-svcnum fields set and will be inserted after this record, but before any
-exports are run.
-
-Currently available options are: I<depend_jobnum>
-
-If I<depend_jobnum> is set (to a scalar jobnum or an array reference of
-jobnums), all provisioning jobs will have a dependancy on the supplied
-jobnum(s) (they will not run until the specific job(s) complete(s)).
-
-(TODOC: L<FS::queue> and L<freeside-queued>)
-
-(TODOC: new exports!)
-
-=cut
-
-sub insert {
- my $self = shift;
- my %options = @_;
- my $error;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- $error = $self->check;
- return $error if $error;
-
- #no, duplicate checking just got a whole lot more complicated
- #(perhaps keep this check with a config option to turn on?)
-
- #return gettext('username_in_use'). ": ". $self->username
- # if qsearchs( 'svc_acct', { 'username' => $self->username,
- # 'domsvc' => $self->domsvc,
- # } );
-
- if ( $self->svcnum && qsearchs('cust_svc',{'svcnum'=>$self->svcnum}) ) {
- my $cust_svc = qsearchs('cust_svc',{'svcnum'=>$self->svcnum});
- unless ( $cust_svc ) {
- $dbh->rollback if $oldAutoCommit;
- return "no cust_svc record found for svcnum ". $self->svcnum;
- }
- $self->pkgnum($cust_svc->pkgnum);
- $self->svcpart($cust_svc->svcpart);
- }
-
- #new duplicate username checking
-
- my $part_svc = qsearchs('part_svc', { 'svcpart' => $self->svcpart } );
- unless ( $part_svc ) {
- $dbh->rollback if $oldAutoCommit;
- return 'unknown svcpart '. $self->svcpart;
- }
-
- my @dup_user = qsearch( 'svc_acct', { 'username' => $self->username } );
- my @dup_userdomain = qsearch( 'svc_acct', { 'username' => $self->username,
- 'domsvc' => $self->domsvc } );
- my @dup_uid;
- if ( $part_svc->part_svc_column('uid')->columnflag ne 'F'
- && $self->username !~ /^(toor|(hyla)?fax)$/ ) {
- @dup_uid = qsearch( 'svc_acct', { 'uid' => $self->uid } );
- } else {
- @dup_uid = ();
- }
-
- if ( @dup_user || @dup_userdomain || @dup_uid ) {
- my $exports = FS::part_export::export_info('svc_acct');
- my %conflict_user_svcpart;
- my %conflict_userdomain_svcpart = ( $self->svcpart => 'SELF', );
-
- foreach my $part_export ( $part_svc->part_export ) {
-
- #this will catch to the same exact export
- my @svcparts = map { $_->svcpart }
- qsearch('export_svc', { 'exportnum' => $part_export->exportnum });
-
- #this will catch to exports w/same exporthost+type ???
- #my @other_part_export = qsearch('part_export', {
- # 'machine' => $part_export->machine,
- # 'exporttype' => $part_export->exporttype,
- #} );
- #foreach my $other_part_export ( @other_part_export ) {
- # push @svcparts, map { $_->svcpart }
- # qsearch('export_svc', { 'exportnum' => $part_export->exportnum });
- #}
-
- #my $nodomain = $exports->{$part_export->exporttype}{'nodomain'};
- #silly kludge to avoid uninitialized value errors
- my $nodomain = exists( $exports->{$part_export->exporttype}{'nodomain'} )
- ? $exports->{$part_export->exporttype}{'nodomain'}
- : '';
- if ( $nodomain =~ /^Y/i ) {
- $conflict_user_svcpart{$_} = $part_export->exportnum
- foreach @svcparts;
- } else {
- $conflict_userdomain_svcpart{$_} = $part_export->exportnum
- foreach @svcparts;
- }
- }
-
- foreach my $dup_user ( @dup_user ) {
- my $dup_svcpart = $dup_user->cust_svc->svcpart;
- if ( exists($conflict_user_svcpart{$dup_svcpart}) ) {
- $dbh->rollback if $oldAutoCommit;
- return "duplicate username: conflicts with svcnum ". $dup_user->svcnum.
- " via exportnum ". $conflict_user_svcpart{$dup_svcpart};
- }
- }
-
- foreach my $dup_userdomain ( @dup_userdomain ) {
- my $dup_svcpart = $dup_userdomain->cust_svc->svcpart;
- if ( exists($conflict_userdomain_svcpart{$dup_svcpart}) ) {
- $dbh->rollback if $oldAutoCommit;
- return "duplicate username\@domain: conflicts with svcnum ".
- $dup_userdomain->svcnum. " via exportnum ".
- $conflict_userdomain_svcpart{$dup_svcpart};
- }
- }
-
- foreach my $dup_uid ( @dup_uid ) {
- my $dup_svcpart = $dup_uid->cust_svc->svcpart;
- if ( exists($conflict_user_svcpart{$dup_svcpart})
- || exists($conflict_userdomain_svcpart{$dup_svcpart}) ) {
- $dbh->rollback if $oldAutoCommit;
- return "duplicate uid: conflicts with svcnum". $dup_uid->svcnum.
- "via exportnum ". $conflict_user_svcpart{$dup_svcpart}
- || $conflict_userdomain_svcpart{$dup_svcpart};
- }
- }
-
- }
-
- #see? i told you it was more complicated
-
- my @jobnums;
- $error = $self->SUPER::insert(
- 'jobnums' => \@jobnums,
- 'child_objects' => $self->child_objects,
- %options,
- );
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- if ( $self->usergroup ) {
- foreach my $groupname ( @{$self->usergroup} ) {
- my $radius_usergroup = new FS::radius_usergroup ( {
- svcnum => $self->svcnum,
- groupname => $groupname,
- } );
- my $error = $radius_usergroup->insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
- }
-
- #false laziness with sub replace (and cust_main)
- my $queue = new FS::queue {
- 'svcnum' => $self->svcnum,
- 'job' => 'FS::svc_acct::append_fuzzyfiles'
- };
- $error = $queue->insert($self->username);
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "queueing job (transaction rolled back): $error";
- }
-
- my $cust_pkg = $self->cust_svc->cust_pkg;
-
- if ( $cust_pkg ) {
- my $cust_main = $cust_pkg->cust_main;
-
- if ( $conf->exists('emailinvoiceauto') ) {
- my @invoicing_list = $cust_main->invoicing_list;
- push @invoicing_list, $self->email;
- $cust_main->invoicing_list(\@invoicing_list);
- }
-
- #welcome email
- my $to = '';
- if ( $welcome_template && $cust_pkg ) {
- my $to = join(', ', grep { $_ ne 'POST' } $cust_main->invoicing_list );
- if ( $to ) {
- my $wqueue = new FS::queue {
- 'svcnum' => $self->svcnum,
- 'job' => 'FS::svc_acct::send_email'
- };
- my $error = $wqueue->insert(
- 'to' => $to,
- 'from' => $welcome_from,
- 'subject' => $welcome_subject,
- 'mimetype' => $welcome_mimetype,
- 'body' => $welcome_template->fill_in( HASH => {
- 'custnum' => $self->custnum,
- 'username' => $self->username,
- 'password' => $self->_password,
- 'first' => $cust_main->first,
- 'last' => $cust_main->getfield('last'),
- 'pkg' => $cust_pkg->part_pkg->pkg,
- } ),
- );
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "error queuing welcome email: $error";
- }
-
- if ( $options{'depend_jobnum'} ) {
- warn "$me depend_jobnum found; adding to welcome email dependancies"
- if $DEBUG;
- if ( ref($options{'depend_jobnum'}) ) {
- warn "$me adding jobs ". join(', ', @{$options{'depend_jobnum'}} ).
- "to welcome email dependancies"
- if $DEBUG;
- push @jobnums, @{ $options{'depend_jobnum'} };
- } else {
- warn "$me adding job $options{'depend_jobnum'} ".
- "to welcome email dependancies"
- if $DEBUG;
- push @jobnums, $options{'depend_jobnum'};
- }
- }
-
- foreach my $jobnum ( @jobnums ) {
- my $error = $wqueue->depend_insert($jobnum);
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "error queuing welcome email job dependancy: $error";
- }
- }
-
- }
-
- }
-
- } # if ( $cust_pkg )
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
- ''; #no error
-}
-
-=item delete
-
-Deletes this account from the database. If there is an error, returns the
-error, otherwise returns false.
-
-The corresponding FS::cust_svc record will be deleted as well.
-
-(TODOC: new exports!)
-
-=cut
-
-sub delete {
- my $self = shift;
-
- return "can't delete system account" if $self->_check_system;
-
- return "Can't delete an account which is a (svc_forward) source!"
- if qsearch( 'svc_forward', { 'srcsvc' => $self->svcnum } );
-
- return "Can't delete an account which is a (svc_forward) destination!"
- if qsearch( 'svc_forward', { 'dstsvc' => $self->svcnum } );
-
- return "Can't delete an account with (svc_www) web service!"
- if qsearch( 'svc_www', { 'usersvc' => $self->usersvc } );
-
- # what about records in session ? (they should refer to history table)
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- foreach my $cust_main_invoice (
- qsearch( 'cust_main_invoice', { 'dest' => $self->svcnum } )
- ) {
- unless ( defined($cust_main_invoice) ) {
- warn "WARNING: something's wrong with qsearch";
- next;
- }
- my %hash = $cust_main_invoice->hash;
- $hash{'dest'} = $self->email;
- my $new = new FS::cust_main_invoice \%hash;
- my $error = $new->replace($cust_main_invoice);
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
-
- foreach my $svc_domain (
- qsearch( 'svc_domain', { 'catchall' => $self->svcnum } )
- ) {
- my %hash = new FS::svc_domain->hash;
- $hash{'catchall'} = '';
- my $new = new FS::svc_domain \%hash;
- my $error = $new->replace($svc_domain);
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
-
- foreach my $radius_usergroup (
- qsearch('radius_usergroup', { 'svcnum' => $self->svcnum } )
- ) {
- my $error = $radius_usergroup->delete;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
-
- my $error = $self->SUPER::delete;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
- '';
-}
-
-=item replace OLD_RECORD
-
-Replaces OLD_RECORD with this one in the database. If there is an error,
-returns the error, otherwise returns false.
-
-The additional field I<usergroup> can optionally be defined; if so it should
-contain an arrayref of group names. See L<FS::radius_usergroup>. (used in
-sqlradius export only)
-
-=cut
-
-sub replace {
- my ( $new, $old ) = ( shift, shift );
- my $error;
- warn "$me replacing $old with $new\n" if $DEBUG;
-
- return "can't modify system account" if $old->_check_system;
-
- return "Username in use"
- if $old->username ne $new->username &&
- qsearchs( 'svc_acct', { 'username' => $new->username,
- 'domsvc' => $new->domsvc,
- } );
- {
- #no warnings 'numeric'; #alas, a 5.006-ism
- local($^W) = 0;
- return "Can't change uid!" if $old->uid != $new->uid;
- }
-
- #change homdir when we change username
- $new->setfield('dir', '') if $old->username ne $new->username;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- # redundant, but so $new->usergroup gets set
- $error = $new->check;
- return $error if $error;
-
- $old->usergroup( [ $old->radius_groups ] );
- warn "old groups: ". join(' ',@{$old->usergroup}). "\n" if $DEBUG;
- warn "new groups: ". join(' ',@{$new->usergroup}). "\n" if $DEBUG;
- if ( $new->usergroup ) {
- #(sorta) false laziness with FS::part_export::sqlradius::_export_replace
- my @newgroups = @{$new->usergroup};
- foreach my $oldgroup ( @{$old->usergroup} ) {
- if ( grep { $oldgroup eq $_ } @newgroups ) {
- @newgroups = grep { $oldgroup ne $_ } @newgroups;
- next;
- }
- my $radius_usergroup = qsearchs('radius_usergroup', {
- svcnum => $old->svcnum,
- groupname => $oldgroup,
- } );
- my $error = $radius_usergroup->delete;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "error deleting radius_usergroup $oldgroup: $error";
- }
- }
-
- foreach my $newgroup ( @newgroups ) {
- my $radius_usergroup = new FS::radius_usergroup ( {
- svcnum => $new->svcnum,
- groupname => $newgroup,
- } );
- my $error = $radius_usergroup->insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "error adding radius_usergroup $newgroup: $error";
- }
- }
-
- }
-
- $error = $new->SUPER::replace($old);
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error if $error;
- }
-
- if ( $new->username ne $old->username ) {
- #false laziness with sub insert (and cust_main)
- my $queue = new FS::queue {
- 'svcnum' => $new->svcnum,
- 'job' => 'FS::svc_acct::append_fuzzyfiles'
- };
- $error = $queue->insert($new->username);
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "queueing job (transaction rolled back): $error";
- }
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
- ''; #no error
-}
-
-=item suspend
-
-Suspends this account by calling export-specific suspend hooks. If there is
-an error, returns the error, otherwise returns false.
-
-Called by the suspend method of FS::cust_pkg (see L<FS::cust_pkg>).
-
-=cut
-
-sub suspend {
- my $self = shift;
- return "can't suspend system account" if $self->_check_system;
- $self->SUPER::suspend;
-}
-
-=item unsuspend
-
-Unsuspends this account by by calling export-specific suspend hooks. If there
-is an error, returns the error, otherwise returns false.
-
-Called by the unsuspend method of FS::cust_pkg (see L<FS::cust_pkg>).
-
-=cut
-
-sub unsuspend {
- my $self = shift;
- my %hash = $self->hash;
- if ( $hash{_password} =~ /^\*SUSPENDED\* (.*)$/ ) {
- $hash{_password} = $1;
- my $new = new FS::svc_acct ( \%hash );
- my $error = $new->replace($self);
- return $error if $error;
- }
-
- $self->SUPER::unsuspend;
-}
-
-=item cancel
-
-Called by the cancel method of FS::cust_pkg (see L<FS::cust_pkg>).
-
-If the B<auto_unset_catchall> configuration option is set, this method will
-automatically remove any references to the canceled service in the catchall
-field of svc_domain. This allows packages that contain both a svc_domain and
-its catchall svc_acct to be canceled in one step.
-
-=cut
-
-sub cancel {
- # Only one thing to do at this level
- my $self = shift;
- foreach my $svc_domain (
- qsearch( 'svc_domain', { catchall => $self->svcnum } ) ) {
- if($conf->exists('auto_unset_catchall')) {
- my %hash = $svc_domain->hash;
- $hash{catchall} = '';
- my $new = new FS::svc_domain ( \%hash );
- my $error = $new->replace($svc_domain);
- return $error if $error;
- } else {
- return "cannot unprovision svc_acct #".$self->svcnum.
- " while assigned as catchall for svc_domain #".$svc_domain->svcnum;
- }
- }
-
- $self->SUPER::cancel;
-}
-
-
-=item check
-
-Checks all fields to make sure this is a valid service. If there is an error,
-returns the error, otherwise returns false. Called by the insert and replace
-methods.
-
-Sets any fixed values; see L<FS::part_svc>.
-
-=cut
-
-sub check {
- my $self = shift;
-
- my($recref) = $self->hashref;
-
- my $x = $self->setfixed;
- return $x unless ref($x);
- my $part_svc = $x;
-
- if ( $part_svc->part_svc_column('usergroup')->columnflag eq "F" ) {
- $self->usergroup(
- [ split(',', $part_svc->part_svc_column('usergroup')->columnvalue) ] );
- }
-
- my $error = $self->ut_numbern('svcnum')
- #|| $self->ut_number('domsvc')
- || $self->ut_foreign_key('domsvc', 'svc_domain', 'svcnum' )
- || $self->ut_textn('sec_phrase')
- ;
- return $error if $error;
-
- my $ulen = $usernamemax || $self->dbdef_table->column('username')->length;
- if ( $username_uppercase ) {
- $recref->{username} =~ /^([a-z0-9_\-\.\&]{$usernamemin,$ulen})$/i
- or return gettext('illegal_username'). " ($usernamemin-$ulen): ". $recref->{username};
- $recref->{username} = $1;
- } else {
- $recref->{username} =~ /^([a-z0-9_\-\.\&]{$usernamemin,$ulen})$/
- or return gettext('illegal_username'). " ($usernamemin-$ulen): ". $recref->{username};
- $recref->{username} = $1;
- }
-
- if ( $username_letterfirst ) {
- $recref->{username} =~ /^[a-z]/ or return gettext('illegal_username');
- } elsif ( $username_letter ) {
- $recref->{username} =~ /[a-z]/ or return gettext('illegal_username');
- }
- if ( $username_noperiod ) {
- $recref->{username} =~ /\./ and return gettext('illegal_username');
- }
- if ( $username_nounderscore ) {
- $recref->{username} =~ /_/ and return gettext('illegal_username');
- }
- if ( $username_nodash ) {
- $recref->{username} =~ /\-/ and return gettext('illegal_username');
- }
- unless ( $username_ampersand ) {
- $recref->{username} =~ /\&/ and return gettext('illegal_username');
- }
-
- $recref->{popnum} =~ /^(\d*)$/ or return "Illegal popnum: ".$recref->{popnum};
- $recref->{popnum} = $1;
- return "Unknown popnum" unless
- ! $recref->{popnum} ||
- qsearchs('svc_acct_pop',{'popnum'=> $recref->{popnum} } );
-
- unless ( $part_svc->part_svc_column('uid')->columnflag eq 'F' ) {
-
- $recref->{uid} =~ /^(\d*)$/ or return "Illegal uid";
- $recref->{uid} = $1 eq '' ? $self->unique('uid') : $1;
-
- $recref->{gid} =~ /^(\d*)$/ or return "Illegal gid";
- $recref->{gid} = $1 eq '' ? $recref->{uid} : $1;
- #not all systems use gid=uid
- #you can set a fixed gid in part_svc
-
- return "Only root can have uid 0"
- if $recref->{uid} == 0
- && $recref->{username} ne 'root'
- && $recref->{username} ne 'toor';
-
-
- $recref->{dir} =~ /^([\/\w\-\.\&]*)$/
- or return "Illegal directory: ". $recref->{dir};
- $recref->{dir} = $1;
- return "Illegal directory"
- if $recref->{dir} =~ /(^|\/)\.+(\/|$)/; #no .. component
- return "Illegal directory"
- if $recref->{dir} =~ /\&/ && ! $username_ampersand;
- unless ( $recref->{dir} ) {
- $recref->{dir} = $dir_prefix . '/';
- if ( $dirhash > 0 ) {
- for my $h ( 1 .. $dirhash ) {
- $recref->{dir} .= substr($recref->{username}, $h-1, 1). '/';
- }
- } elsif ( $dirhash < 0 ) {
- for my $h ( reverse $dirhash .. -1 ) {
- $recref->{dir} .= substr($recref->{username}, $h, 1). '/';
- }
- }
- $recref->{dir} .= $recref->{username};
- ;
- }
-
- unless ( $recref->{username} eq 'sync' ) {
- if ( grep $_ eq $recref->{shell}, @shells ) {
- $recref->{shell} = (grep $_ eq $recref->{shell}, @shells)[0];
- } else {
- return "Illegal shell \`". $self->shell. "\'; ".
- $conf->dir. "/shells contains: @shells";
- }
- } else {
- $recref->{shell} = '/bin/sync';
- }
-
- } else {
- $recref->{gid} ne '' ?
- return "Can't have gid without uid" : ( $recref->{gid}='' );
- $recref->{dir} ne '' ?
- return "Can't have directory without uid" : ( $recref->{dir}='' );
- $recref->{shell} ne '' ?
- return "Can't have shell without uid" : ( $recref->{shell}='' );
- }
-
- # $error = $self->ut_textn('finger');
- # return $error if $error;
- $self->getfield('finger') =~
- /^([\w \t\!\@\#\$\%\&\(\)\-\+\;\'\"\,\.\?\/\*\<\>]*)$/
- or return "Illegal finger: ". $self->getfield('finger');
- $self->setfield('finger', $1);
-
- $recref->{quota} =~ /^(\w*)$/ or return "Illegal quota";
- $recref->{quota} = $1;
-
- unless ( $part_svc->part_svc_column('slipip')->columnflag eq 'F' ) {
- if ( $recref->{slipip} eq '' ) {
- $recref->{slipip} = '';
- } elsif ( $recref->{slipip} eq '0e0' ) {
- $recref->{slipip} = '0e0';
- } else {
- $recref->{slipip} =~ /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/
- or return "Illegal slipip: ". $self->slipip;
- $recref->{slipip} = $1;
- }
-
- }
-
- #arbitrary RADIUS stuff; allow ut_textn for now
- foreach ( grep /^radius_/, fields('svc_acct') ) {
- $self->ut_textn($_);
- }
-
- #generate a password if it is blank
- $recref->{_password} = join('',map($pw_set[ int(rand $#pw_set) ], (0..7) ) )
- unless ( $recref->{_password} );
-
- #if ( $recref->{_password} =~ /^((\*SUSPENDED\* )?)([^\t\n]{4,16})$/ ) {
- if ( $recref->{_password} =~ /^((\*SUSPENDED\* )?)([^\t\n]{$passwordmin,$passwordmax})$/ ) {
- $recref->{_password} = $1.$3;
- #uncomment this to encrypt password immediately upon entry, or run
- #bin/crypt_pw in cron to give new users a window during which their
- #password is available to techs, for faxing, etc. (also be aware of
- #radius issues!)
- #$recref->{password} = $1.
- # crypt($3,$saltset[int(rand(64))].$saltset[int(rand(64))]
- #;
- } elsif ( $recref->{_password} =~ /^((\*SUSPENDED\* )?)([\w\.\/\$\;\+]{13,60})$/ ) {
- $recref->{_password} = $1.$3;
- } elsif ( $recref->{_password} eq '*' ) {
- $recref->{_password} = '*';
- } elsif ( $recref->{_password} eq '!' ) {
- $recref->{_password} = '!';
- } elsif ( $recref->{_password} eq '!!' ) {
- $recref->{_password} = '!!';
- } else {
- #return "Illegal password";
- return gettext('illegal_password'). " $passwordmin-$passwordmax ".
- FS::Msgcat::_gettext('illegal_password_characters').
- ": ". $recref->{_password};
- }
-
- $self->SUPER::check;
-}
-
-=item _check_system
-
-=cut
-
-sub _check_system {
- my $self = shift;
- scalar( grep { $self->username eq $_ || $self->email eq $_ }
- $conf->config('system_usernames')
- );
-}
-
-=item radius
-
-Depriciated, use radius_reply instead.
-
-=cut
-
-sub radius {
- carp "FS::svc_acct::radius depriciated, use radius_reply";
- $_[0]->radius_reply;
-}
-
-=item radius_reply
-
-Returns key/value pairs, suitable for assigning to a hash, for any RADIUS
-reply attributes of this record.
-
-Note that this is now the preferred method for reading RADIUS attributes -
-accessing the columns directly is discouraged, as the column names are
-expected to change in the future.
-
-=cut
-
-sub radius_reply {
- my $self = shift;
- my %reply =
- map {
- /^(radius_(.*))$/;
- my($column, $attrib) = ($1, $2);
- #$attrib =~ s/_/\-/g;
- ( $FS::raddb::attrib{lc($attrib)}, $self->getfield($column) );
- } grep { /^radius_/ && $self->getfield($_) } fields( $self->table );
- if ( $self->slipip && $self->slipip ne '0e0' ) {
- $reply{$radius_ip} = $self->slipip;
- }
- %reply;
-}
-
-=item radius_check
-
-Returns key/value pairs, suitable for assigning to a hash, for any RADIUS
-check attributes of this record.
-
-Note that this is now the preferred method for reading RADIUS attributes -
-accessing the columns directly is discouraged, as the column names are
-expected to change in the future.
-
-=cut
-
-sub radius_check {
- my $self = shift;
- my $password = $self->_password;
- my $pw_attrib = length($password) <= 12 ? $radius_password : 'Crypt-Password';
- ( $pw_attrib => $password,
- map {
- /^(rc_(.*))$/;
- my($column, $attrib) = ($1, $2);
- #$attrib =~ s/_/\-/g;
- ( $FS::raddb::attrib{lc($attrib)}, $self->getfield($column) );
- } grep { /^rc_/ && $self->getfield($_) } fields( $self->table )
- );
-}
-
-=item domain
-
-Returns the domain associated with this account.
-
-=cut
-
-sub domain {
- my $self = shift;
- die "svc_acct.domsvc is null for svcnum ". $self->svcnum unless $self->domsvc;
- my $svc_domain = $self->svc_domain
- or die "no svc_domain.svcnum for svc_acct.domsvc ". $self->domsvc;
- $svc_domain->domain;
-}
-
-=item svc_domain
-
-Returns the FS::svc_domain record for this account's domain (see
-L<FS::svc_domain>).
-
-=cut
-
-sub svc_domain {
- my $self = shift;
- $self->{'_domsvc'}
- ? $self->{'_domsvc'}
- : qsearchs( 'svc_domain', { 'svcnum' => $self->domsvc } );
-}
-
-=item cust_svc
-
-Returns the FS::cust_svc record for this account (see L<FS::cust_svc>).
-
-=cut
-
-sub cust_svc {
- my $self = shift;
- qsearchs( 'cust_svc', { 'svcnum' => $self->svcnum } );
-}
-
-=item email
-
-Returns an email address associated with the account.
-
-=cut
-
-sub email {
- my $self = shift;
- $self->username. '@'. $self->domain;
-}
-
-=item acct_snarf
-
-Returns an array of FS::acct_snarf records associated with the account.
-If the acct_snarf table does not exist or there are no associated records,
-an empty list is returned
-
-=cut
-
-sub acct_snarf {
- my $self = shift;
- return () unless dbdef->table('acct_snarf');
- eval "use FS::acct_snarf;";
- die $@ if $@;
- qsearch('acct_snarf', { 'svcnum' => $self->svcnum } );
-}
-
-=item seconds_since TIMESTAMP
-
-Returns the number of seconds this account has been online since TIMESTAMP,
-according to the session monitor (see L<FS::Session>).
-
-TIMESTAMP is specified as a UNIX timestamp; see L<perlfunc/"time">. Also see
-L<Time::Local> and L<Date::Parse> for conversion functions.
-
-=cut
-
-#note: POD here, implementation in FS::cust_svc
-sub seconds_since {
- my $self = shift;
- $self->cust_svc->seconds_since(@_);
-}
-
-=item seconds_since_sqlradacct TIMESTAMP_START TIMESTAMP_END
-
-Returns the numbers of seconds this account has been online between
-TIMESTAMP_START (inclusive) and TIMESTAMP_END (exclusive), according to an
-external SQL radacct table, specified via sqlradius export. Sessions which
-started in the specified range but are still open are counted from session
-start to the end of the range (unless they are over 1 day old, in which case
-they are presumed missing their stop record and not counted). Also, sessions
-which end in the range but started earlier are counted from the start of the
-range to session end. Finally, sessions which start before the range but end
-after are counted for the entire range.
-
-TIMESTAMP_START and TIMESTAMP_END are specified as UNIX timestamps; see
-L<perlfunc/"time">. Also see L<Time::Local> and L<Date::Parse> for conversion
-functions.
-
-=cut
-
-#note: POD here, implementation in FS::cust_svc
-sub seconds_since_sqlradacct {
- my $self = shift;
- $self->cust_svc->seconds_since_sqlradacct(@_);
-}
-
-=item attribute_since_sqlradacct TIMESTAMP_START TIMESTAMP_END ATTRIBUTE
-
-Returns the sum of the given attribute for all accounts (see L<FS::svc_acct>)
-in this package for sessions ending between TIMESTAMP_START (inclusive) and
-TIMESTAMP_END (exclusive).
-
-TIMESTAMP_START and TIMESTAMP_END are specified as UNIX timestamps; see
-L<perlfunc/"time">. Also see L<Time::Local> and L<Date::Parse> for conversion
-functions.
-
-=cut
-
-#note: POD here, implementation in FS::cust_svc
-sub attribute_since_sqlradacct {
- my $self = shift;
- $self->cust_svc->attribute_since_sqlradacct(@_);
-}
-
-=item get_session_history_sqlradacct TIMESTAMP_START TIMESTAMP_END
-
-Returns an array of hash references of this customers login history for the
-given time range. (document this better)
-
-=cut
-
-sub get_session_history_sqlradacct {
- my $self = shift;
- $self->cust_svc->get_session_history_sqlradacct(@_);
-}
-
-=item radius_groups
-
-Returns all RADIUS groups for this account (see L<FS::radius_usergroup>).
-
-=cut
-
-sub radius_groups {
- my $self = shift;
- if ( $self->usergroup ) {
- #when provisioning records, export callback runs in svc_Common.pm before
- #radius_usergroup records can be inserted...
- @{$self->usergroup};
- } else {
- map { $_->groupname }
- qsearch('radius_usergroup', { 'svcnum' => $self->svcnum } );
- }
-}
-
-=item clone_suspended
-
-Constructor used by FS::part_export::_export_suspend fallback. Document
-better.
-
-=cut
-
-sub clone_suspended {
- my $self = shift;
- my %hash = $self->hash;
- $hash{_password} = join('',map($pw_set[ int(rand $#pw_set) ], (0..7) ) );
- new FS::svc_acct \%hash;
-}
-
-=item clone_kludge_unsuspend
-
-Constructor used by FS::part_export::_export_unsuspend fallback. Document
-better.
-
-=cut
-
-sub clone_kludge_unsuspend {
- my $self = shift;
- my %hash = $self->hash;
- $hash{_password} = '';
- new FS::svc_acct \%hash;
-}
-
-=item check_password
-
-Checks the supplied password against the (possibly encrypted) password in the
-database. Returns true for a sucessful authentication, false for no match.
-
-Currently supported encryptions are: classic DES crypt() and MD5
-
-=cut
-
-sub check_password {
- my($self, $check_password) = @_;
-
- #remove old-style SUSPENDED kludge, they should be allowed to login to
- #self-service and pay up
- ( my $password = $self->_password ) =~ s/^\*SUSPENDED\* //;
-
- #eventually should check a "password-encoding" field
- if ( $password =~ /^(\*|!!?)$/ ) { #no self-service login
- return 0;
- } elsif ( length($password) < 13 ) { #plaintext
- $check_password eq $password;
- } elsif ( length($password) == 13 ) { #traditional DES crypt
- crypt($check_password, $password) eq $password;
- } elsif ( $password =~ /^\$1\$/ ) { #MD5 crypt
- unix_md5_crypt($check_password, $password) eq $password;
- } elsif ( $password =~ /^\$2a?\$/ ) { #Blowfish
- warn "Can't check password: Blowfish encryption not yet supported, svcnum".
- $self->svcnum. "\n";
- 0;
- } else {
- warn "Can't check password: Unrecognized encryption for svcnum ".
- $self->svcnum. "\n";
- 0;
- }
-
-}
-
-=back
-
-=head1 SUBROUTINES
-
-=over 4
-
-=item send_email
-
-This is the FS::svc_acct job-queue-able version. It still uses
-FS::Misc::send_email under-the-hood.
-
-=cut
-
-sub send_email {
- my %opt = @_;
-
- eval "use FS::Misc qw(send_email)";
- die $@ if $@;
-
- $opt{mimetype} ||= 'text/plain';
- $opt{mimetype} .= '; charset="iso-8859-1"' unless $opt{mimetype} =~ /charset/;
-
- my $error = send_email(
- 'from' => $opt{from},
- 'to' => $opt{to},
- 'subject' => $opt{subject},
- 'content-type' => $opt{mimetype},
- 'body' => [ map "$_\n", split("\n", $opt{body}) ],
- );
- die $error if $error;
-}
-
-=item check_and_rebuild_fuzzyfiles
-
-=cut
-
-sub check_and_rebuild_fuzzyfiles {
- my $dir = $FS::UID::conf_dir. "cache.". $FS::UID::datasrc;
- -e "$dir/svc_acct.username"
- or &rebuild_fuzzyfiles;
-}
-
-=item rebuild_fuzzyfiles
-
-=cut
-
-sub rebuild_fuzzyfiles {
-
- use Fcntl qw(:flock);
-
- my $dir = $FS::UID::conf_dir. "cache.". $FS::UID::datasrc;
-
- #username
-
- open(USERNAMELOCK,">>$dir/svc_acct.username")
- or die "can't open $dir/svc_acct.username: $!";
- flock(USERNAMELOCK,LOCK_EX)
- or die "can't lock $dir/svc_acct.username: $!";
-
- my @all_username = map $_->getfield('username'), qsearch('svc_acct', {});
-
- open (USERNAMECACHE,">$dir/svc_acct.username.tmp")
- or die "can't open $dir/svc_acct.username.tmp: $!";
- print USERNAMECACHE join("\n", @all_username), "\n";
- close USERNAMECACHE or die "can't close $dir/svc_acct.username.tmp: $!";
-
- rename "$dir/svc_acct.username.tmp", "$dir/svc_acct.username";
- close USERNAMELOCK;
-
-}
-
-=item all_username
-
-=cut
-
-sub all_username {
- my $dir = $FS::UID::conf_dir. "cache.". $FS::UID::datasrc;
- open(USERNAMECACHE,"<$dir/svc_acct.username")
- or die "can't open $dir/svc_acct.username: $!";
- my @array = map { chomp; $_; } <USERNAMECACHE>;
- close USERNAMECACHE;
- \@array;
-}
-
-=item append_fuzzyfiles USERNAME
-
-=cut
-
-sub append_fuzzyfiles {
- my $username = shift;
-
- &check_and_rebuild_fuzzyfiles;
-
- use Fcntl qw(:flock);
-
- my $dir = $FS::UID::conf_dir. "cache.". $FS::UID::datasrc;
-
- open(USERNAME,">>$dir/svc_acct.username")
- or die "can't open $dir/svc_acct.username: $!";
- flock(USERNAME,LOCK_EX)
- or die "can't lock $dir/svc_acct.username: $!";
-
- print USERNAME "$username\n";
-
- flock(USERNAME,LOCK_UN)
- or die "can't unlock $dir/svc_acct.username: $!";
- close USERNAME;
-
- 1;
-}
-
-
-
-=item radius_usergroup_selector GROUPS_ARRAYREF [ SELECTNAME ]
-
-=cut
-
-sub radius_usergroup_selector {
- my $sel_groups = shift;
- my %sel_groups = map { $_=>1 } @$sel_groups;
-
- my $selectname = shift || 'radius_usergroup';
-
- my $dbh = dbh;
- my $sth = $dbh->prepare(
- 'SELECT DISTINCT(groupname) FROM radius_usergroup ORDER BY groupname'
- ) or die $dbh->errstr;
- $sth->execute() or die $sth->errstr;
- my @all_groups = map { $_->[0] } @{$sth->fetchall_arrayref};
-
- my $html = <<END;
- <SCRIPT>
- function ${selectname}_doadd(object) {
- var myvalue = object.${selectname}_add.value;
- var optionName = new Option(myvalue,myvalue,false,true);
- var length = object.$selectname.length;
- object.$selectname.options[length] = optionName;
- object.${selectname}_add.value = "";
- }
- </SCRIPT>
- <SELECT MULTIPLE NAME="$selectname">
-END
-
- foreach my $group ( @all_groups ) {
- $html .= '<OPTION';
- if ( $sel_groups{$group} ) {
- $html .= ' SELECTED';
- $sel_groups{$group} = 0;
- }
- $html .= ">$group</OPTION>\n";
- }
- foreach my $group ( grep { $sel_groups{$_} } keys %sel_groups ) {
- $html .= "<OPTION SELECTED>$group</OPTION>\n";
- };
- $html .= '</SELECT>';
-
- $html .= qq!<BR><INPUT TYPE="text" NAME="${selectname}_add">!.
- qq!<INPUT TYPE="button" VALUE="Add new group" onClick="${selectname}_doadd(this.form)">!;
-
- $html;
-}
-
-=back
-
-=head1 BUGS
-
-The $recref stuff in sub check should be cleaned up.
-
-The suspend, unsuspend and cancel methods update the database, but not the
-current object. This is probably a bug as it's unexpected and
-counterintuitive.
-
-radius_usergroup_selector? putting web ui components in here? they should
-probably live somewhere else...
-
-insertion of RADIUS group stuff in insert could be done with child_objects now
-(would probably clean up export of them too)
-
-=head1 SEE ALSO
-
-L<FS::svc_Common>, edit/part_svc.cgi from an installed web interface,
-export.html from the base documentation, L<FS::Record>, L<FS::Conf>,
-L<FS::cust_svc>, L<FS::part_svc>, L<FS::cust_pkg>, L<FS::queue>,
-L<freeside-queued>), L<FS::svc_acct_pop>,
-schema.html from the base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/svc_acct_pop.pm b/FS/FS/svc_acct_pop.pm
deleted file mode 100644
index f98f91a..0000000
--- a/FS/FS/svc_acct_pop.pm
+++ /dev/null
@@ -1,210 +0,0 @@
-package FS::svc_acct_pop;
-
-use strict;
-use vars qw( @ISA @EXPORT_OK @svc_acct_pop %svc_acct_pop );
-use FS::Record qw( qsearch qsearchs );
-
-@ISA = qw( FS::Record Exporter );
-@EXPORT_OK = qw( popselector );
-
-=head1 NAME
-
-FS::svc_acct_pop - Object methods for svc_acct_pop records
-
-=head1 SYNOPSIS
-
- use FS::svc_acct_pop;
-
- $record = new FS::svc_acct_pop \%hash;
- $record = new FS::svc_acct_pop { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
- $html = FS::svc_acct_pop::popselector( $popnum, $state );
-
-=head1 DESCRIPTION
-
-An FS::svc_acct object represents an point of presence. FS::svc_acct_pop
-inherits from FS::Record. The following fields are currently supported:
-
-=over 4
-
-=item popnum - primary key (assigned automatically for new accounts)
-
-=item city
-
-=item state
-
-=item ac - area code
-
-=item exch - exchange
-
-=item loc - rest of number
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new point of presence (if only it were that easy!). To add the
-point of presence to the database, see L<"insert">.
-
-=cut
-
-sub table { 'svc_acct_pop'; }
-
-=item insert
-
-Adds this point of presence to the database. If there is an error, returns the
-error, otherwise returns false.
-
-=item delete
-
-Removes this point of presence from the database.
-
-=item replace OLD_RECORD
-
-Replaces OLD_RECORD with this one in the database. If there is an error,
-returns the error, otherwise returns false.
-
-=item check
-
-Checks all fields to make sure this is a valid point of presence. If there is
-an error, returns the error, otherwise returns false. Called by the insert
-and replace methods.
-
-=cut
-
-sub check {
- my $self = shift;
-
- $self->ut_numbern('popnum')
- or $self->ut_text('city')
- or $self->ut_text('state')
- or $self->ut_number('ac')
- or $self->ut_number('exch')
- or $self->ut_numbern('loc')
- or $self->SUPER::check
- ;
-
-}
-
-=item text
-
-Returns:
-
-"$city, $state ($ac)/$exch"
-
-=cut
-
-sub text {
- my $self = shift;
- $self->city. ', '. $self->state.
- ' ('. $self->ac. ')/'. $self->exch. '-'. $self->loc;
-}
-
-=back
-
-=head1 SUBROUTINES
-
-=over 4
-
-=item popselector [ POPNUM [ STATE ] ]
-
-=cut
-
-#horrible false laziness with signup.cgi (pull special-case for 0 & 1
-# pop code out from signup.cgi??)
-sub popselector {
- my( $popnum, $state ) = @_;
-
- unless ( @svc_acct_pop ) { #cache pop list
- @svc_acct_pop = qsearch('svc_acct_pop', {} );
- %svc_acct_pop = ();
- push @{$svc_acct_pop{$_->state}}, $_ foreach @svc_acct_pop;
- }
-
- my $text = <<END;
- <SCRIPT>
- function opt(what,href,text) {
- var optionName = new Option(text, href, false, false)
- var length = what.length;
- what.options[length] = optionName;
- }
-
- function popstate_changed(what) {
- state = what.options[what.selectedIndex].text;
- what.form.popnum.options.length = 0
- what.form.popnum.options[0] = new Option("", "", false, true);
-END
-
- foreach my $popstate ( sort { $a cmp $b } keys %svc_acct_pop ) {
- $text .= "\nif ( state == \"$popstate\" ) {\n";
-
- foreach my $pop ( @{$svc_acct_pop{$popstate}}) {
- my $o_popnum = $pop->popnum;
- my $poptext = $pop->text;
- $text .= "opt(what.form.popnum, \"$o_popnum\", \"$poptext\");\n"
- }
- $text .= "}\n";
- }
-
- $text .= "}\n</SCRIPT>\n";
-
- $text .=
- qq!<SELECT NAME="popstate" SIZE=1 onChange="popstate_changed(this)">!.
- qq!<OPTION> !;
- $text .= "<OPTION>$_" foreach sort { $a cmp $b } keys %svc_acct_pop;
- $text .= '</SELECT>'; #callback? return 3 html pieces? #'</TD><TD>';
-
- $text .= qq!<SELECT NAME="popnum" SIZE=1><OPTION> !;
- my @initial_select;
- if ( scalar(@svc_acct_pop) > 100 ) {
- @initial_select = qsearchs( 'svc_acct_pop', { 'popnum' => $popnum } );
- } else {
- @initial_select = @svc_acct_pop;
- }
- foreach my $pop ( @initial_select ) {
- $text .= qq!<OPTION VALUE="!. $pop->popnum. '"'.
- ( ( $popnum && $pop->popnum == $popnum ) ? ' SELECTED' : '' ). ">".
- $pop->text;
- }
- $text .= '</SELECT>';
-
- $text;
-
-}
-
-=back
-
-=head1 VERSION
-
-$Id: svc_acct_pop.pm,v 1.10 2003-08-05 00:20:47 khoff Exp $
-
-=head1 BUGS
-
-It should be renamed to part_pop.
-
-popselector? putting web ui components in here? they should probably live
-somewhere else...
-
-popselector: pull special-case for 0 & 1 pop code out from signup.cgi
-
-=head1 SEE ALSO
-
-L<FS::Record>, L<FS::svc_acct>, L<FS::part_pop_local>, schema.html from the
-base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/svc_broadband.pm b/FS/FS/svc_broadband.pm
deleted file mode 100755
index aaac891..0000000
--- a/FS/FS/svc_broadband.pm
+++ /dev/null
@@ -1,243 +0,0 @@
-package FS::svc_broadband;
-
-use strict;
-use vars qw(@ISA $conf);
-use FS::Record qw( qsearchs qsearch dbh );
-use FS::svc_Common;
-use FS::cust_svc;
-use FS::addr_block;
-use NetAddr::IP;
-
-@ISA = qw( FS::svc_Common );
-
-$FS::UID::callback{'FS::svc_broadband'} = sub {
- $conf = new FS::Conf;
-};
-
-=head1 NAME
-
-FS::svc_broadband - Object methods for svc_broadband records
-
-=head1 SYNOPSIS
-
- use FS::svc_broadband;
-
- $record = new FS::svc_broadband \%hash;
- $record = new FS::svc_broadband { '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::svc_broadband object represents a 'broadband' Internet connection, such
-as a DSL, cable modem, or fixed wireless link. These services are assumed to
-have the following properties:
-
-FS::svc_broadband inherits from FS::svc_Common. The following fields are
-currently supported:
-
-=over 4
-
-=item svcnum - primary key
-
-=item blocknum - see FS::addr_block
-
-=item
-speed_up - maximum upload speed, in bits per second. If set to zero, upload
-speed will be unlimited. Exports that do traffic shaping should handle this
-correctly, and not blindly set the upload speed to zero and kill the customer's
-connection.
-
-=item
-speed_down - maximum download speed, as above
-
-=item ip_addr - the customer's IP address. If the customer needs more than one
-IP address, set this to the address of the customer's router. As a result, the
-customer's router will have the same address for both its internal and external
-interfaces thus saving address space. This has been found to work on most NAT
-routers available.
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new svc_broadband. To add the record to the database, see
-"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 { 'svc_broadband'; }
-
-=item insert [ , OPTION => VALUE ... ]
-
-Adds this record to the database. If there is an error, returns the error,
-otherwise returns false.
-
-The additional fields pkgnum and svcpart (see FS::cust_svc) should be
-defined. An FS::cust_svc record will be created and inserted.
-
-Currently available options are: I<depend_jobnum>
-
-If I<depend_jobnum> is set (to a scalar jobnum or an array reference of
-jobnums), all provisioning jobs will have a dependancy on the supplied
-jobnum(s) (they will not run until the specific job(s) complete(s)).
-
-=cut
-
-# Standard FS::svc_Common::insert
-
-=item delete
-
-Delete this record from the database.
-
-=cut
-
-# Standard FS::svc_Common::delete
-
-=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
-
-# Standard FS::svc_Common::replace
-
-=item suspend
-
-Called by the suspend method of FS::cust_pkg (see FS::cust_pkg).
-
-=item unsuspend
-
-Called by the unsuspend method of FS::cust_pkg (see FS::cust_pkg).
-
-=item cancel
-
-Called by the cancel method of FS::cust_pkg (see FS::cust_pkg).
-
-=item check
-
-Checks all fields to make sure this is a valid broadband service. If there is
-an error, returns the error, otherwise returns false. Called by the insert
-and replace methods.
-
-=cut
-
-sub check {
- my $self = shift;
- my $x = $self->setfixed;
-
- return $x unless ref($x);
-
- my $error =
- $self->ut_numbern('svcnum')
- || $self->ut_foreign_key('blocknum', 'addr_block', 'blocknum')
- || $self->ut_number('speed_up')
- || $self->ut_number('speed_down')
- || $self->ut_ipn('ip_addr')
- ;
- return $error if $error;
-
- if($self->speed_up < 0) { return 'speed_up must be positive'; }
- if($self->speed_down < 0) { return 'speed_down must be positive'; }
-
- if (not($self->ip_addr) or $self->ip_addr eq '0.0.0.0') {
- my $next_addr = $self->addr_block->next_free_addr;
- if ($next_addr) {
- $self->ip_addr($next_addr->addr);
- } else {
- return "No free addresses in addr_block (blocknum: ".$self->blocknum.")";
- }
- }
-
- # This should catch errors in the ip_addr. If it doesn't,
- # they'll almost certainly not map into the block anyway.
- my $self_addr = $self->NetAddr; #netmask is /32
- return ('Cannot parse address: ' . $self->ip_addr) unless $self_addr;
-
- my $block_addr = $self->addr_block->NetAddr;
- unless ($block_addr->contains($self_addr)) {
- return 'blocknum '.$self->blocknum.' does not contain address '.$self->ip_addr;
- }
-
- my $router = $self->addr_block->router
- or return 'Cannot assign address from unallocated block:'.$self->addr_block->blocknum;
- if(grep { $_->routernum == $router->routernum} $self->allowed_routers) {
- } # do nothing
- else {
- return 'Router '.$router->routernum.' cannot provide svcpart '.$self->svcpart;
- }
-
- $self->SUPER::check;
-}
-
-=item NetAddr
-
-Returns a NetAddr::IP object containing the IP address of this service. The netmask
-is /32.
-
-=cut
-
-sub NetAddr {
- my $self = shift;
- return new NetAddr::IP ($self->ip_addr);
-}
-
-=item addr_block
-
-Returns the FS::addr_block record (i.e. the address block) for this broadband service.
-
-=cut
-
-sub addr_block {
- my $self = shift;
-
- return qsearchs('addr_block', { blocknum => $self->blocknum });
-}
-
-=back
-
-=item allowed_routers
-
-Returns a list of allowed FS::router objects.
-
-=cut
-
-sub allowed_routers {
- my $self = shift;
-
- return map { $_->router } qsearch('part_svc_router', { svcpart => $self->svcpart });
-}
-
-=head1 BUGS
-
-The business with sb_field has been 'fixed', in a manner of speaking.
-
-=head1 SEE ALSO
-
-FS::svc_Common, FS::Record, FS::addr_block,
-FS::part_svc, schema.html from the base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/svc_domain.pm b/FS/FS/svc_domain.pm
deleted file mode 100644
index 4dd6342..0000000
--- a/FS/FS/svc_domain.pm
+++ /dev/null
@@ -1,443 +0,0 @@
-package FS::svc_domain;
-
-use strict;
-use vars qw( @ISA $whois_hack $conf
- @defaultrecords $soadefaultttl $soaemail $soaexpire $soamachine
- $soarefresh $soaretry
-);
-use Carp;
-use Date::Format;
-use Net::Whois 1.0;
-use FS::Record qw(fields qsearch qsearchs dbh);
-use FS::Conf;
-use FS::svc_Common;
-use FS::cust_svc;
-use FS::svc_acct;
-use FS::cust_pkg;
-use FS::cust_main;
-use FS::domain_record;
-use FS::queue;
-
-@ISA = qw( FS::svc_Common );
-
-#ask FS::UID to run this stuff for us later
-$FS::UID::callback{'FS::domain'} = sub {
- $conf = new FS::Conf;
-
- @defaultrecords = $conf->config('defaultrecords');
- $soadefaultttl = $conf->config('soadefaultttl');
- $soaemail = $conf->config('soaemail');
- $soaexpire = $conf->config('soaexpire');
- $soamachine = $conf->config('soamachine');
- $soarefresh = $conf->config('soarefresh');
- $soaretry = $conf->config('soaretry');
-
-};
-
-=head1 NAME
-
-FS::svc_domain - Object methods for svc_domain records
-
-=head1 SYNOPSIS
-
- use FS::svc_domain;
-
- $record = new FS::svc_domain \%hash;
- $record = new FS::svc_domain { '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::svc_domain object represents a domain. FS::svc_domain inherits from
-FS::svc_Common. The following fields are currently supported:
-
-=over 4
-
-=item svcnum - primary key (assigned automatically for new accounts)
-
-=item domain
-
-=item catchall - optional svcnum of an svc_acct record, designating an email catchall account.
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new domain. To add the domain to the database, see L<"insert">.
-
-=cut
-
-sub table { 'svc_domain'; }
-
-=item insert [ , OPTION => VALUE ... ]
-
-Adds this domain to the database. If there is an error, returns the error,
-otherwise returns false.
-
-The additional fields I<pkgnum> and I<svcpart> (see L<FS::cust_svc>) should be
-defined. An FS::cust_svc record will be created and inserted.
-
-The additional field I<action> should be set to I<N> for new domains or I<M>
-for transfers.
-
-A registration or transfer email will be submitted unless
-$FS::svc_domain::whois_hack is true.
-
-The additional field I<email> can be used to manually set the admin contact
-email address on this email. Otherwise, the svc_acct records for this package
-(see L<FS::cust_pkg>) are searched. If there is exactly one svc_acct record
-in the same package, it is automatically used. Otherwise an error is returned.
-
-If any I<soamachine> configuration file exists, an SOA record is added to
-the domain_record table (see <FS::domain_record>).
-
-If any records are defined in the I<defaultrecords> configuration file,
-appropriate records are added to the domain_record table (see
-L<FS::domain_record>).
-
-Currently available options are: I<depend_jobnum>
-
-If I<depend_jobnum> is set (to a scalar jobnum or an array reference of
-jobnums), all provisioning jobs will have a dependancy on the supplied
-jobnum(s) (they will not run until the specific job(s) complete(s)).
-
-=cut
-
-sub insert {
- my $self = shift;
- my $error;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- $error = $self->check;
- return $error if $error;
-
- return "Domain in use (here)"
- if qsearchs( 'svc_domain', { 'domain' => $self->domain } );
-
- my $whois = $self->whois;
- if ( $self->action eq "N" && ! $whois_hack && $whois ) {
- $dbh->rollback if $oldAutoCommit;
- return "Domain in use (see whois)";
- }
- if ( $self->action eq "M" && ! $whois ) {
- $dbh->rollback if $oldAutoCommit;
- return "Domain not found (see whois)";
- }
-
- $error = $self->SUPER::insert(@_);
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- $self->submit_internic unless $whois_hack;
-
- if ( $soamachine ) {
- my $soa = new FS::domain_record {
- 'svcnum' => $self->svcnum,
- 'reczone' => '@',
- 'recaf' => 'IN',
- 'rectype' => 'SOA',
- 'recdata' => "$soamachine $soaemail ( ". time2str("%Y%m%d", time). "00 ".
- "$soarefresh $soaretry $soaexpire $soadefaultttl )"
- };
- $error = $soa->insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "couldn't insert SOA record for new domain: $error";
- }
-
- foreach my $record ( @defaultrecords ) {
- my($zone,$af,$type,$data) = split(/\s+/,$record,4);
- my $domain_record = new FS::domain_record {
- 'svcnum' => $self->svcnum,
- 'reczone' => $zone,
- 'recaf' => $af,
- 'rectype' => $type,
- 'recdata' => $data,
- };
- my $error = $domain_record->insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "couldn't insert record for new domain: $error";
- }
- }
-
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
-
- ''; #no error
-}
-
-=item delete
-
-Deletes this domain from the database. If there is an error, returns the
-error, otherwise returns false.
-
-The corresponding FS::cust_svc record will be deleted as well.
-
-=cut
-
-sub delete {
- my $self = shift;
-
- return "Can't delete a domain which has accounts!"
- if qsearch( 'svc_acct', { 'domsvc' => $self->svcnum } );
-
- #return "Can't delete a domain with (domain_record) zone entries!"
- # if qsearch('domain_record', { 'svcnum' => $self->svcnum } );
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- foreach my $domain_record ( reverse $self->domain_record ) {
- my $error = $domain_record->delete;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- }
-
- my $error = $self->SUPER::delete;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
-}
-
-=item replace OLD_RECORD
-
-Replaces 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 );
-
- return "Can't change domain - reorder."
- if $old->getfield('domain') ne $new->getfield('domain');
-
- # Better to do it here than to force the caller to remember that svc_domain is weird.
- $new->setfield(action => 'M');
- my $error = $new->SUPER::replace($old);
- return $error if $error;
-}
-
-=item suspend
-
-Just returns false (no error) for now.
-
-Called by the suspend method of FS::cust_pkg (see L<FS::cust_pkg>).
-
-=item unsuspend
-
-Just returns false (no error) for now.
-
-Called by the unsuspend method of FS::cust_pkg (see L<FS::cust_pkg>).
-
-=item cancel
-
-Just returns false (no error) for now.
-
-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 domain. If there is an error,
-returns the error, otherwise returns false. Called by the insert and replace
-methods.
-
-Sets any fixed values; see L<FS::part_svc>.
-
-=cut
-
-sub check {
- my $self = shift;
-
- my $x = $self->setfixed;
- return $x unless ref($x);
- #my $part_svc = $x;
-
- my $error = $self->ut_numbern('svcnum')
- || $self->ut_numbern('catchall')
- ;
- return $error if $error;
-
- #hmm
- my $pkgnum;
- if ( $self->svcnum ) {
- my $cust_svc = qsearchs( 'cust_svc', { 'svcnum' => $self->svcnum } );
- $pkgnum = $cust_svc->pkgnum;
- } else {
- $pkgnum = $self->pkgnum;
- }
-
- my($recref) = $self->hashref;
-
- unless ( $whois_hack ) {
- unless ( $self->email ) { #find out an email address
- my @svc_acct;
- foreach ( qsearch( 'cust_svc', { 'pkgnum' => $pkgnum } ) ) {
- my $svc_acct = qsearchs( 'svc_acct', { 'svcnum' => $_->svcnum } );
- push @svc_acct, $svc_acct if $svc_acct;
- }
-
- if ( scalar(@svc_acct) == 0 ) {
- return "Must order an account in package ". $pkgnum. " first";
- } elsif ( scalar(@svc_acct) > 1 ) {
- return "More than one account in package ". $pkgnum. ": specify admin contact email";
- } else {
- $self->email($svc_acct[0]->email );
- }
- }
- }
-
- #if ( $recref->{domain} =~ /^([\w\-\.]{1,22})\.(com|net|org|edu)$/ ) {
- if ( $recref->{domain} =~ /^([\w\-]{1,63})\.(com|net|org|edu)$/ ) {
- $recref->{domain} = "$1.$2";
- # hmmmmmmmm.
- } elsif ( $whois_hack && $recref->{domain} =~ /^([\w\-\.]+)$/ ) {
- $recref->{domain} = $1;
- } else {
- return "Illegal domain ". $recref->{domain}.
- " (or unknown registry - try \$whois_hack)";
- }
-
- $recref->{action} =~ /^(M|N)$/ or return "Illegal action";
- $recref->{action} = $1;
-
- if ( $recref->{catchall} ne '' ) {
- my $svc_acct = qsearchs( 'svc_acct', { 'svcnum' => $recref->{catchall} } );
- return "Unknown catchall" unless $svc_acct;
- }
-
- $self->ut_textn('purpose')
- or $self->SUPER::check;
-
-}
-
-=item domain_record
-
-=cut
-
-sub domain_record {
- my $self = shift;
-
- my %order = (
- SOA => 1,
- NS => 2,
- MX => 3,
- CNAME => 4,
- A => 5,
- );
-
- sort { $order{$a->rectype} <=> $order{$b->rectype} }
- qsearch('domain_record', { svcnum => $self->svcnum } );
-
-}
-
-sub catchall_svc_acct {
- my $self = shift;
- if ( $self->catchall ) {
- qsearchs( 'svc_acct', { 'svcnum' => $self->catchall } );
- } else {
- '';
- }
-}
-
-=item whois
-
-Returns the Net::Whois::Domain object (see L<Net::Whois>) for this domain, or
-undef if the domain is not found in whois.
-
-(If $FS::svc_domain::whois_hack is true, returns that in all cases instead.)
-
-=cut
-
-sub whois {
- $whois_hack or new Net::Whois::Domain $_[0]->domain;
-}
-
-=item _whois
-
-Depriciated.
-
-=cut
-
-sub _whois {
- die "_whois depriciated";
-}
-
-=item submit_internic
-
-Submits a registration email for this domain.
-
-=cut
-
-sub submit_internic {
- #my $self = shift;
- carp "submit_internic depreciated";
-}
-
-=back
-
-=head1 BUGS
-
-Delete doesn't send a registration template.
-
-All registries should be supported.
-
-Should change action to a real field.
-
-The $recref stuff in sub check should be cleaned up.
-
-=head1 SEE ALSO
-
-L<FS::svc_Common>, L<FS::Record>, L<FS::Conf>, L<FS::cust_svc>,
-L<FS::part_svc>, L<FS::cust_pkg>, L<Net::Whois>, schema.html from the base
-documentation, config.html from the base documentation.
-
-=cut
-
-1;
-
-
diff --git a/FS/FS/svc_external.pm b/FS/FS/svc_external.pm
deleted file mode 100644
index b97e12b..0000000
--- a/FS/FS/svc_external.pm
+++ /dev/null
@@ -1,180 +0,0 @@
-package FS::svc_external;
-
-use strict;
-use vars qw(@ISA); # $conf
-use FS::UID;
-#use FS::Record qw( qsearch qsearchs dbh);
-use FS::svc_Common;
-
-@ISA = qw( FS::svc_Common );
-
-#FS::UID::install_callback( sub {
-# $conf = new FS::Conf;
-#};
-
-=head1 NAME
-
-FS::svc_external - Object methods for svc_external records
-
-=head1 SYNOPSIS
-
- use FS::svc_external;
-
- $record = new FS::svc_external \%hash;
- $record = new FS::svc_external { '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::svc_external object represents a externally tracked service.
-FS::svc_external inherits from FS::svc_Common. The following fields are
-currently supported:
-
-=over 4
-
-=item svcnum - primary key
-
-=item id - unique number of external record
-
-=item title - for invoice line items
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new external service. To add the external service 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 { 'svc_external'; }
-
-=item insert [ , OPTION => VALUE ... ]
-
-Adds this external service 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.
-
-Currently available options are: I<depend_jobnum>
-
-If I<depend_jobnum> is set (to a scalar jobnum or an array reference of
-jobnums), all provisioning jobs will have a dependancy on the supplied
-jobnum(s) (they will not run until the specific job(s) complete(s)).
-
-=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 external service. 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;
-
- my $error =
- $self->ut_numbern('svcnum')
- || $self->ut_number('id')
- || $self->ut_textn('title')
- ;
-
- $self->SUPER::check;
-}
-
-=back
-
-=head1 BUGS
-
-=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/FS/FS/svc_forward.pm b/FS/FS/svc_forward.pm
deleted file mode 100644
index b8d55fe..0000000
--- a/FS/FS/svc_forward.pm
+++ /dev/null
@@ -1,306 +0,0 @@
-package FS::svc_forward;
-
-use strict;
-use vars qw( @ISA );
-use FS::Conf;
-use FS::Record qw( fields qsearch qsearchs dbh );
-use FS::svc_Common;
-use FS::cust_svc;
-use FS::svc_acct;
-use FS::svc_domain;
-
-@ISA = qw( FS::svc_Common );
-
-=head1 NAME
-
-FS::svc_forward - Object methods for svc_forward records
-
-=head1 SYNOPSIS
-
- use FS::svc_forward;
-
- $record = new FS::svc_forward \%hash;
- $record = new FS::svc_forward { '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::svc_forward object represents a mail forwarding alias. FS::svc_forward
-inherits from FS::Record. The following fields are currently supported:
-
-=over 4
-
-=item svcnum - primary key (assigned automatcially for new accounts)
-
-=item srcsvc - svcnum of the source of the forward (see L<FS::svc_acct>)
-
-=item src - literal source (username or full email address)
-
-=item dstsvc - svcnum of the destination of the forward (see L<FS::svc_acct>)
-
-=item dst - literal destination (username or full email address)
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new mail forwarding alias. To add the mail forwarding alias to the
-database, see L<"insert">.
-
-=cut
-
-sub table { 'svc_forward'; }
-
-=item insert [ , OPTION => VALUE ... ]
-
-Adds this mail forwarding alias 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.
-
-Currently available options are: I<depend_jobnum>
-
-If I<depend_jobnum> is set (to a scalar jobnum or an array reference of
-jobnums), all provisioning jobs will have a dependancy on the supplied
-jobnum(s) (they will not run until the specific job(s) complete(s)).
-
-=cut
-
-sub insert {
- my $self = shift;
- my $error;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- $error = $self->check;
- return $error if $error;
-
- $error = $self->SUPER::insert(@_);
- if ($error) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
- ''; #no error
-
-}
-
-=item delete
-
-Deletes this mail forwarding alias from the database. If there is an error,
-returns the error, otherwise returns false.
-
-The corresponding FS::cust_svc record will be deleted as well.
-
-=cut
-
-sub delete {
- my $self = shift;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::Autocommit = 0;
- my $dbh = dbh;
-
- my $error = $self->SUPER::delete;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
- '';
-}
-
-
-=item replace OLD_RECORD
-
-Replaces 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 );
-
- if ( $new->srcsvc != $old->srcsvc
- && ( $new->dstsvc != $old->dstsvc
- || ! $new->dstsvc && $new->dst ne $old->dst
- )
- ) {
- return "Can't change both source and destination of a mail forward!"
- }
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- my $error = $new->SUPER::replace($old);
- if ($error) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
- '';
-}
-
-=item suspend
-
-Just returns false (no error) for now.
-
-Called by the suspend method of FS::cust_pkg (see L<FS::cust_pkg>).
-
-=item unsuspend
-
-Just returns false (no error) for now.
-
-Called by the unsuspend method of FS::cust_pkg (see L<FS::cust_pkg>).
-
-=item cancel
-
-Just returns false (no error) for now.
-
-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 mail forwarding alias. If there
-is an error, returns the error, otherwise returns false. Called by the insert
-and replace methods.
-
-Sets any fixed values; see L<FS::part_svc>.
-
-=cut
-
-sub check {
- my $self = shift;
-
- my $x = $self->setfixed;
- return $x unless ref($x);
- #my $part_svc = $x;
-
- my $error = $self->ut_numbern('svcnum')
- || $self->ut_numbern('srcsvc')
- || $self->ut_numbern('dstsvc')
- ;
- return $error if $error;
-
- return "Both srcsvc and src were defined; only one can be specified"
- if $self->srcsvc && $self->src;
-
- return "one of srcsvc or src is required"
- unless $self->srcsvc || $self->src;
-
- return "Unknown srcsvc: ". $self->srcsvc
- unless ! $self->srcsvc || $self->srcsvc_acct;
-
- return "Both dstsvc and dst were defined; only one can be specified"
- if $self->dstsvc && $self->dst;
-
- return "one of dstsvc or dst is required"
- unless $self->dstsvc || $self->dst;
-
- return "Unknown dstsvc: ". $self->dstsvc
- unless ! $self->dstsvc || $self->dstsvc_acct;
- #return "Unknown dstsvc"
- # unless qsearchs('svc_acct', { 'svcnum' => $self->dstsvc } )
- # || ! $self->dstsvc;
-
- if ( $self->src ) {
- $self->src =~ /^([\w\.\-\&]*)(\@([\w\-]+\.)+\w+)?$/
- or return "Illegal src: ". $self->dst;
- $self->src("$1$2");
- } else {
- $self->src('');
- }
-
- if ( $self->dst ) {
- $self->dst =~ /^([\w\.\-\&]*)(\@([\w\-]+\.)+\w+)?$/
- or return "Illegal dst: ". $self->dst;
- $self->dst("$1$2");
- } else {
- $self->dst('');
- }
-
- $self->SUPER::check;
-}
-
-=item srcsvc_acct
-
-Returns the FS::svc_acct object referenced by the srcsvc column, or false for
-literally specified forwards.
-
-=cut
-
-sub srcsvc_acct {
- my $self = shift;
- qsearchs('svc_acct', { 'svcnum' => $self->srcsvc } );
-}
-
-=item dstsvc_acct
-
-Returns the FS::svc_acct object referenced by the srcsvc column, or false for
-literally specified forwards.
-
-=cut
-
-sub dstsvc_acct {
- my $self = shift;
- qsearchs('svc_acct', { 'svcnum' => $self->dstsvc } );
-}
-
-=back
-
-=head1 BUGS
-
-=head1 SEE ALSO
-
-L<FS::Record>, L<FS::Conf>, L<FS::cust_svc>, L<FS::part_svc>, L<FS::cust_pkg>,
-L<FS::svc_acct>, L<FS::svc_domain>, schema.html from the base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/svc_www.pm b/FS/FS/svc_www.pm
deleted file mode 100644
index 6c276a1..0000000
--- a/FS/FS/svc_www.pm
+++ /dev/null
@@ -1,284 +0,0 @@
-package FS::svc_www;
-
-use strict;
-use vars qw(@ISA $conf $apacheip);
-#use FS::Record qw( qsearch qsearchs );
-use FS::Record qw( qsearchs dbh );
-use FS::svc_Common;
-use FS::cust_svc;
-use FS::domain_record;
-use FS::svc_acct;
-use FS::svc_domain;
-
-@ISA = qw( FS::svc_Common );
-
-#ask FS::UID to run this stuff for us later
-$FS::UID::callback{'FS::svc_www'} = sub {
- $conf = new FS::Conf;
- $apacheip = $conf->config('apacheip');
-};
-
-=head1 NAME
-
-FS::svc_www - Object methods for svc_www records
-
-=head1 SYNOPSIS
-
- use FS::svc_www;
-
- $record = new FS::svc_www \%hash;
- $record = new FS::svc_www { '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::svc_www object represents an web virtual host. FS::svc_www inherits
-from FS::svc_Common. The following fields are currently supported:
-
-=over 4
-
-=item svcnum - primary key
-
-=item recnum - DNS `A' record corresponding to this web virtual host. (see L<FS::domain_record>)
-
-=item usersvc - account (see L<FS::svc_acct>) corresponding to this web virtual host.
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new web virtual host. To add the record 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 { 'svc_www'; }
-
-=item insert [ , OPTION => VALUE ... ]
-
-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.
-
-Currently available options are: I<depend_jobnum>
-
-If I<depend_jobnum> is set (to a scalar jobnum or an array reference of
-jobnums), all provisioning jobs will have a dependancy on the supplied
-jobnum(s) (they will not run until the specific job(s) complete(s)).
-
-
-=cut
-
-sub insert {
- my $self = shift;
-
- my $error = $self->check;
- return $error if $error;
-
- local $SIG{HUP} = 'IGNORE';
- local $SIG{INT} = 'IGNORE';
- local $SIG{QUIT} = 'IGNORE';
- local $SIG{TERM} = 'IGNORE';
- local $SIG{TSTP} = 'IGNORE';
- local $SIG{PIPE} = 'IGNORE';
-
- my $oldAutoCommit = $FS::UID::AutoCommit;
- local $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- #if ( $self->recnum =~ /^([\w\-]+|\@)\.(([\w\.\-]+\.)+\w+)$/ ) {
- if ( $self->recnum =~ /^([\w\-]+|\@)\.(\d+)$/ ) {
- my( $reczone, $domain_svcnum ) = ( $1, $2 );
- unless ( $apacheip ) {
- $dbh->rollback if $oldAutoCommit;
- return "Configuration option apacheip not set; can't autocreate A record";
- #"for $reczone". $svc_domain->domain;
- }
- my $domain_record = new FS::domain_record {
- 'svcnum' => $domain_svcnum,
- 'reczone' => $reczone,
- 'recaf' => 'IN',
- 'rectype' => 'A',
- 'recdata' => $apacheip,
- };
- $error = $domain_record->insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
- $self->recnum($domain_record->recnum);
- }
-
- $error = $self->SUPER::insert(@_);
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- }
-
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
- '';
-}
-
-=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 web virtual host. 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;
-
- my $error =
- $self->ut_numbern('svcnum')
-# || $self->ut_number('recnum')
- || $self->ut_number('usersvc')
- ;
- return $error if $error;
-
- if ( $self->recnum =~ /^(\d+)$/ ) {
-
- $self->recnum($1);
- return "Unknown recnum: ". $self->recnum
- unless qsearchs('domain_record', { 'recnum' => $self->recnum } );
-
- } elsif ( $self->recnum =~ /^([\w\-]+|\@)\.(([\w\.\-]+\.)+\w+)$/ ) {
-
- my( $reczone, $domain ) = ( $1, $2 );
-
- my $svc_domain = qsearchs( 'svc_domain', { 'domain' => $domain } )
- or return "unknown domain $domain (recnum $1.$2)";
-
- my $domain_record = qsearchs( 'domain_record', {
- 'reczone' => $reczone,
- 'svcnum' => $svc_domain->svcnum,
- });
-
- if ( $domain_record ) {
- $self->recnum($domain_record->recnum);
- } else {
- #insert will create it
- #$self->recnum("$reczone.$domain");
- $self->recnum("$reczone.". $svc_domain->svcnum);
- }
-
- } else {
- return "Illegal recnum: ". $self->recnum;
- }
-
- return "Unknown usersvc (svc_acct.svcnum): ". $self->usersvc
- unless qsearchs('svc_acct', { 'svcnum' => $self->usersvc } );
-
- $self->SUPER::check;
-
-}
-
-=item domain_record
-
-Returns the FS::domain_record record for this web virtual host's zone (see
-L<FS::domain_record>).
-
-=cut
-
-sub domain_record {
- my $self = shift;
- qsearchs('domain_record', { 'recnum' => $self->recnum } );
-}
-
-=item svc_acct
-
-Returns the FS::svc_acct record for this web virtual host's owner (see
-L<FS::svc_acct>).
-
-=cut
-
-sub svc_acct {
- my $self = shift;
- qsearchs('svc_acct', { 'svcnum' => $self->usersvc } );
-}
-
-=back
-
-=head1 BUGS
-
-=head1 SEE ALSO
-
-L<FS::svc_Common>, L<FS::Record>, L<FS::domain_record>, L<FS::cust_svc>,
-L<FS::part_svc>, L<FS::cust_pkg>, schema.html from the base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/FS/type_pkgs.pm b/FS/FS/type_pkgs.pm
deleted file mode 100644
index 5b3b11c..0000000
--- a/FS/FS/type_pkgs.pm
+++ /dev/null
@@ -1,126 +0,0 @@
-package FS::type_pkgs;
-
-use strict;
-use vars qw( @ISA );
-use FS::Record qw( qsearchs );
-use FS::agent_type;
-use FS::part_pkg;
-
-@ISA = qw( FS::Record );
-
-=head1 NAME
-
-FS::type_pkgs - Object methods for type_pkgs records
-
-=head1 SYNOPSIS
-
- use FS::type_pkgs;
-
- $record = new FS::type_pkgs \%hash;
- $record = new FS::type_pkgs { 'column' => 'value' };
-
- $error = $record->insert;
-
- $error = $new_record->replace($old_record);
-
- $error = $record->delete;
-
- $error = $record->check;
-
-=head1 DESCRIPTION
-
-An FS::type_pkgs record links an agent type (see L<FS::agent_type>) to a
-billing item definition (see L<FS::part_pkg>). FS::type_pkgs inherits from
-FS::Record. The following fields are currently supported:
-
-=over 4
-
-=item typenum - Agent type, see L<FS::agent_type>
-
-=item pkgpart - Billing item definition, see L<FS::part_pkg>
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Create a new record. To add the record to the database, see L<"insert">.
-
-=cut
-
-sub table { 'type_pkgs'; }
-
-=item insert
-
-Adds this record to the database. If there is an error, returns the error,
-otherwise returns false.
-
-=item delete
-
-Deletes this record from the database. If there is an error, returns the
-error, otherwise returns false.
-
-=item replace OLD_RECORD
-
-Replaces OLD_RECORD with this one in the database. If there is an error,
-returns the error, otherwise returns false.
-
-=item check
-
-Checks all fields to make sure this is a valid record. If there is an error,
-returns the error, otherwise returns false. Called by the insert and replace
-methods.
-
-=cut
-
-sub check {
- my $self = shift;
-
- my $error =
- $self->ut_number('typenum')
- || $self->ut_number('pkgpart')
- ;
- return $error if $error;
-
- return "Unknown typenum"
- unless qsearchs( 'agent_type', { 'typenum' => $self->typenum } );
-
- return "Unknown pkgpart"
- unless qsearchs( 'part_pkg', { 'pkgpart' => $self->pkgpart } );
-
- $self->SUPER::check;
-}
-
-=item part_pkg
-
-Returns the FS::part_pkg object associated with this record.
-
-=cut
-
-sub part_pkg {
- my $self = shift;
- qsearchs( 'part_pkg', { 'pkgpart' => $self->pkgpart } );
-}
-
-=cut
-
-=back
-
-=head1 VERSION
-
-$Id: type_pkgs.pm,v 1.3 2003-08-05 00:20:48 khoff Exp $
-
-=head1 BUGS
-
-=head1 SEE ALSO
-
-L<FS::Record>, L<FS::agent_type>, L<FS::part_pkgs>, schema.html from the base
-documentation.
-
-=cut
-
-1;
-
diff --git a/FS/MANIFEST b/FS/MANIFEST
deleted file mode 100644
index 10a64d0..0000000
--- a/FS/MANIFEST
+++ /dev/null
@@ -1,210 +0,0 @@
-Changes
-MANIFEST
-MANIFEST.SKIP
-Makefile.PL
-README
-bin/freeside-addoutsource
-bin/freeside-addoutsourceuser
-bin/freeside-adduser
-bin/freeside-apply-credits
-bin/freeside-bill
-bin/freeside-cc-receipts-report
-bin/freeside-count-active-customers
-bin/freeside-credit-report
-bin/freeside-daily
-bin/freeside-deloutsource
-bin/freeside-deloutsourceuser
-bin/freeside-deluser
-bin/freeside-email
-bin/freeside-expiration-alerter
-bin/freeside-queued
-bin/freeside-radgroup
-bin/freeside-reexport
-bin/freeside-selfservice-server
-bin/freeside-setinvoice
-bin/freeside-setup
-bin/freeside-sqlradius-radacctd
-bin/freeside-sqlradius-reset
-bin/freeside-sqlradius-seconds
-bin/freeside-tax-report
-FS.pm
-FS/CGI.pm
-FS/InitHandler.pm
-FS/ClientAPI.pm
-FS/ClientAPI/passwd.pm
-FS/ClientAPI/MyAccount.pm
-FS/Conf.pm
-FS/ConfItem.pm
-FS/Misc.pm
-FS/Record.pm
-FS/Report.pm
-FS/Report/Table.pm
-FS/Report/Table/Monthly.pm
-FS/SearchCache.pm
-FS/UI/Base.pm
-FS/UI/CGI.pm
-FS/UI/Gtk.pm
-FS/UI/agent.pm
-FS/UID.pm
-FS/Msgcat.pm
-FS/acct_snarf.pm
-FS/agent.pm
-FS/agent_type.pm
-FS/cust_bill.pm
-FS/cust_bill_pkg.pm
-FS/cust_bill_pkg_detail.pm
-FS/cust_credit.pm
-FS/cust_credit_bill.pm
-FS/cust_main.pm
-FS/cust_main_county.pm
-FS/cust_main_invoice.pm
-FS/cust_pay.pm
-FS/cust_bill_event.pm
-FS/cust_bill_pay.pm
-FS/cust_pay_batch.pm
-FS/cust_pkg.pm
-FS/cust_refund.pm
-FS/cust_credit_refund.pm
-FS/cust_svc.pm
-FS/part_bill_event.pm
-FS/export_svc.pm
-FS/part_export.pm
-FS/part_export_option.pm
-FS/part_export/apache.pm
-FS/part_export/bind.pm
-FS/part_export/bind_slave.pm
-FS/part_export/bsdshell.pm
-FS/part_export/communigate_pro.pm
-FS/part_export/communigate_pro_singledomain.pm
-FS/part_export/cp.pm
-FS/part_export/cyrus.pm
-FS/part_export/domain_shellcommands.pm
-FS/part_export/forward_shellcommands.pm
-FS/part_export/http.pm
-FS/part_export/infostreet.pm
-FS/part_export/ldap.pm
-FS/part_export/null.pm
-FS/part_export/shellcommands.pm
-FS/part_export/shellcommands_withdomain.pm
-FS/part_export/sqlmail.pm
-FS/part_export/sqlradius.pm
-FS/part_export/sysvshell.pm
-FS/part_export/textradius.pm
-FS/part_export/vpopmail.pm
-FS/part_export/www_shellcommands.pm
-FS/part_pkg.pm
-FS/part_pop_local.pm
-FS/part_referral.pm
-FS/part_svc.pm
-FS/part_svc_column.pm
-FS/part_svc_router.pm
-FS/part_virtual_field.pm
-FS/pkg_svc.pm
-FS/svc_Common.pm
-FS/svc_acct.pm
-FS/svc_acct_pop.pm
-FS/svc_broadband.pm
-FS/svc_domain.pm
-FS/svc_external.pm
-FS/router.pm
-FS/type_pkgs.pm
-FS/nas.pm
-FS/port.pm
-FS/session.pm
-FS/domain_record.pm
-FS/prepay_credit.pm
-FS/svc_www.pm
-FS/svc_forward.pm
-FS/raddb.pm
-FS/radius_usergroup.pm
-FS/queue.pm
-FS/queue_arg.pm
-FS/queue_depend.pm
-FS/msgcat.pm
-FS/cust_tax_exempt.pm
-t/agent.t
-t/agent_type.t
-t/CGI.t
-t/InitHandler.t
-t/ClientAPI.t
-t/Conf.t
-t/ConfItem.t
-t/Misc.t
-t/Record.t
-t/Report.t
-t/Report-Table.t
-t/Report-Table-Monthly.t
-t/UID.t
-t/Msgcat.t
-t/SearchCache.t
-t/cust_bill.t
-t/cust_bill_event.t
-t/cust_bill_pay.t
-t/cust_bill_pkg.t
-t/cust_bill_pkg_detail.t
-t/cust_credit.t
-t/cust_credit_bill.t
-t/cust_credit_refund.t
-t/cust_main.t
-t/cust_main_county.t
-t/cust_main_invoice.t
-t/cust_pay.t
-t/cust_pay_batch.t
-t/cust_pkg.t
-t/cust_refund.t
-t/cust_svc.t
-t/cust_tax_exempt.t
-t/domain_record.t
-t/nas.t
-t/part_bill_event.t
-t/export_svc.t
-t/part_export.t
-t/part_export_option.t
-t/part_export-bind.t
-t/part_export-bind_slave.t
-t/part_export-bsdshell.t
-t/part_export-communigate_pro.t
-t/part_export-communigate_pro_singledomain.t
-t/part_export-cp.t
-t/part_export-cyrus.t
-t/part_export-domain_shellcommands.t
-t/part_export-forward_shellcommands.t
-t/part_export-http.t
-t/part_export-infostreet.t
-t/part_export-ldap.t
-t/part_export-null.t
-t/part_export-passwdfile.t
-t/part_export-postfix.t
-t/part_export-router.t
-t/part_export-shellcommands.t
-t/part_export-shellcommands_withdomain.t
-t/part_export-sqlmail.t
-t/part_export-sqlradius.t
-t/part_export-sysvshell.t
-t/part_export-textradius.t
-t/part_export-vpopmail.t
-t/part_export-www_shellcommands.t
-t/part_pkg.t
-t/part_pop_local.t
-t/part_referral.t
-t/part_svc.t
-t/part_svc_column.t
-t/pkg_svc.t
-t/port.t
-t/prepay_credit.t
-t/radius_usergroup.t
-t/session.t
-t/svc_acct.t
-t/svc_acct_pop.t
-t/svc_broadband.t
-t/svc_Common.t
-t/svc_domain.t
-t/svc_external.t
-t/svc_forward.t
-t/svc_www.t
-t/type_pkgs.t
-t/queue.t
-t/queue_arg.t
-t/queue_depend.t
-t/msgcat.t
-t/raddb.t
diff --git a/FS/MANIFEST.SKIP b/FS/MANIFEST.SKIP
deleted file mode 100644
index ae335e7..0000000
--- a/FS/MANIFEST.SKIP
+++ /dev/null
@@ -1 +0,0 @@
-CVS/
diff --git a/FS/Makefile.PL b/FS/Makefile.PL
deleted file mode 100644
index 1647f8e..0000000
--- a/FS/Makefile.PL
+++ /dev/null
@@ -1,10 +0,0 @@
-use ExtUtils::MakeMaker;
-# See lib/ExtUtils/MakeMaker.pm for details of how to influence
-# the contents of the Makefile that is written.
-WriteMakefile(
- 'NAME' => 'FS',
- 'VERSION_FROM' => 'FS.pm', # finds $VERSION
- 'EXE_FILES' => [ glob 'bin/*' ],
- 'INSTALLSCRIPT' => '/usr/local/bin',
- 'INSTALLSITEBIN' => '/usr/local/bin',
-);
diff --git a/FS/README b/FS/README
deleted file mode 100644
index d4c35ac..0000000
--- a/FS/README
+++ /dev/null
@@ -1,6 +0,0 @@
-This is the Perl module section of Freeside.
-
-perl Makefile.PL
-make
-make test
-make install
diff --git a/FS/bin/freeside-addoutsource b/FS/bin/freeside-addoutsource
deleted file mode 100644
index 5cec17f..0000000
--- a/FS/bin/freeside-addoutsource
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/sh
-
-domain=$1
-
-createdb $domain && \
-\
-mkdir /usr/local/etc/freeside/conf.DBI:Pg:host=localhost\;dbname=$domain && \
-\
-chown freeside /usr/local/etc/freeside/conf.DBI:Pg:host=localhost\;dbname=$domain && \
-\
-cp /home/ivan/freeside/conf/[a-z]* /usr/local/etc/freeside/conf.DBI:Pg:host=localhost\;dbname=$domain && \
-\
-touch /usr/local/etc/freeside/conf.DBI:Pg:host=localhost\;dbname=$domain/secrets && \
-\
-chown freeside /usr/local/etc/freeside/conf.DBI:Pg:host=localhost\;dbname=$domain/secrets && \
-\
-chmod 600 /usr/local/etc/freeside/conf.DBI:Pg:host=localhost\;dbname=$domain/secrets && \
-\
-echo -e "DBI:Pg:host=localhost;dbname=$domain\nfreeside\n" >/usr/local/etc/freeside/conf.DBI:Pg:host=localhost\;dbname=$domain/secrets && \
-\
-mkdir /usr/local/etc/freeside/counters.DBI:Pg:host=localhost\;dbname=$domain && \
-mkdir /usr/local/etc/freeside/cache.DBI:Pg:host=localhost\;dbname=$domain && \
-mkdir /usr/local/etc/freeside/export.DBI:Pg:host=localhost\;dbname=$domain
-
diff --git a/FS/bin/freeside-addoutsourceuser b/FS/bin/freeside-addoutsourceuser
deleted file mode 100644
index abb515b..0000000
--- a/FS/bin/freeside-addoutsourceuser
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-
-username=$1
-domain=$2
-password=$3
-
-freeside-adduser -h /usr/local/etc/freeside/htpasswd \
- -s conf.DBI:Pg:host=localhost\;dbname=$domain/secrets \
- -b \
- $username $password 2>/dev/null
-
-[ -e /usr/local/etc/freeside/dbdef.DBI:Pg:host=localhost\;dbname=$domain ] \
- || ( freeside-setup -s $username 2>/dev/null; \
- /home/ivan/freeside/bin/populate-msgcat $username 2>/dev/null )
-
diff --git a/FS/bin/freeside-adduser b/FS/bin/freeside-adduser
deleted file mode 100644
index c3ee05b..0000000
--- a/FS/bin/freeside-adduser
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/usr/bin/perl -w
-#
-# $Id: freeside-adduser,v 1.8 2002-09-27 05:36:29 ivan Exp $
-
-use strict;
-use vars qw($opt_h $opt_b $opt_c $opt_s);
-use Fcntl qw(:flock);
-use Getopt::Std;
-
-my $FREESIDE_CONF = "/usr/local/etc/freeside";
-
-getopts("bch:s:");
-die &usage if $opt_c && ! $opt_h;
-my $user = shift or die &usage;
-
-if ( $opt_h ) {
- my @args = ( 'htpasswd' );
- push @args, '-b' if $opt_b;
- push @args, '-c' if $opt_c;
- push @args, $opt_h, $user;
- push @args, shift if $opt_b;
- system(@args) == 0 or die "htpasswd failed: $?";
-}
-
-my $secretfile = $opt_s || 'secrets';
-
-open(MAPSECRETS,">>$FREESIDE_CONF/mapsecrets")
- and flock(MAPSECRETS,LOCK_EX)
- or die "can't open $FREESIDE_CONF/mapsecrets: $!";
-print MAPSECRETS "$user $secretfile\n";
-close MAPSECRETS or die "can't close $FREESIDE_CONF/mapsecrets: $!";
-
-sub usage {
- die "Usage:\n\n freeside-adduser [ -h htpasswd_file [ -c ] [ -b ] ] [ -s secretfile ] username"
-}
-
-=head1 NAME
-
-freeside-adduser - Command line interface to add (freeside) users.
-
-=head1 SYNOPSIS
-
- freeside-adduser [ -h htpasswd_file [ -c ] ] [ -s secretfile ] username
-
-=head1 DESCRIPTION
-
-Adds a user to the Freeside billing system. This is for adding users (internal
-sales/tech folks) to the web interface, not for adding customer accounts.
-
- -h: Also call htpasswd for this user with the given filename
-
- -c: Passed to htpasswd(1)
-
- -s: Specify an alternate secret file
-
- -b: same as htpasswd(1), probably insecure, not recommended
-
-=head1 SEE ALSO
-
-L<htpasswd>(1), base Freeside documentation
-
-=cut
-
diff --git a/FS/bin/freeside-apply-credits b/FS/bin/freeside-apply-credits
deleted file mode 100755
index ea6a7bd..0000000
--- a/FS/bin/freeside-apply-credits
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/bin/perl -Tw
-
-use strict;
-use vars qw( $user $cust_main @customers );
-use FS::UID qw(adminsuidsetup);
-use FS::Record qw(qsearch);
-use FS::cust_main;
-
-$user = shift or die &usage;
-&adminsuidsetup( $user );
-
-my @customers = qsearch('cust_main', {} );
-die "No customers" unless (scalar(@customers) > 0);
-
-foreach $cust_main (@customers) {
- print "Applying credits for customer #". $cust_main->custnum;
- $cust_main->apply_credits;
-}
-
-
-
diff --git a/FS/bin/freeside-bill b/FS/bin/freeside-bill
deleted file mode 100755
index 49ad4a7..0000000
--- a/FS/bin/freeside-bill
+++ /dev/null
@@ -1,128 +0,0 @@
-#!/usr/bin/perl -w
-# don't take any world-facing input
-#!/usr/bin/perl -Tw
-
-use strict;
-use Fcntl qw(:flock);
-use Date::Parse;
-use Getopt::Std;
-use FS::UID qw(adminsuidsetup);
-use FS::Record qw(qsearch qsearchs);
-use FS::cust_main;
-
-&untaint_argv; #what it sounds like (eww)
-use vars qw($opt_a $opt_c $opt_d $opt_p);
-getopts("acd:p");
-my $user = shift or die &usage;
-
-adminsuidsetup $user;
-
-my %bill_only = map { $_ => 1 } (
- @ARGV ? @ARGV : ( map $_->custnum, qsearch('cust_main', {} ) )
-);
-
-#we're at now now (and later).
-my($time)= $opt_d ? str2time($opt_d) : $^T;
-
-# find packages w/ bill < time && cancel != '', and create corresponding
-# customer objects
-
-my($cust_main,%saw);
-foreach $cust_main (
- map {
- unless ( exists $saw{ $_->custnum } && defined $saw{ $_->custnum} ) {
- $saw{ $_->custnum } = 0; # to avoid 'use of uninitialized value' errors
- }
- if (
- ( $opt_a || ( ( $_->getfield('bill') || 0 ) <= $time ) )
- && $bill_only{ $_->custnum }
- && !$saw{ $_->custnum }++
- ) {
- qsearchs('cust_main',{'custnum'=> $_->custnum } );
- } else {
- ();
- }
- } ( qsearch('cust_pkg', { 'cancel' => '' }),
- qsearch('cust_pkg', { 'cancel' => 0 }),
- )
-) {
-
- # and bill them
-
- print "Billing customer #" . $cust_main->getfield('custnum') . "\n";
-
- my($error);
-
- $error=$cust_main->bill('time'=>$time);
- warn "Error billing, customer #" . $cust_main->getfield('custnum') .
- ":" . $error if $error;
-
- if ($opt_p) {
- $cust_main->apply_payments;
- $cust_main->apply_credits;
- }
-
- if ($opt_c) {
- $error=$cust_main->collect( 'invoice_time' => $time);
- warn "Error collecting from customer #" . $cust_main->custnum. ":$error"
- if $error;
-
- #sleep 1;
- }
-
-}
-
-# subroutines
-
-sub untaint_argv {
- foreach $_ ( $[ .. $#ARGV ) { #untaint @ARGV
- #$ARGV[$_] =~ /^([\w\-\/]*)$/ || die "Illegal arguement \"$ARGV[$_]\"";
- # Date::Parse
- $ARGV[$_] =~ /^(.*)$/ || die "Illegal arguement \"$ARGV[$_]\"";
- $ARGV[$_]=$1;
- }
-}
-
-sub usage {
- die "Usage:\n\n freeside-bill [ -c [ -p ] ] [ -d 'date' ] user [ custnum custnum ... ]\n";
-}
-
-=head1 NAME
-
-freeside-bill - Command line (crontab, script) interface to customer billing.
-
-=head1 SYNOPSIS
-
- freeside-bill [ -c [ -p ] [ -a ] ] [ -d 'date' ] user [ custnum custnum ... ]
-
-=head1 DESCRIPTION
-
-This script is deprecated in 1.4.0. You should use freeside-daily instead.
-
-Bills customers. Searches for customers who are due for billing and calls
-the bill and collect methods of a cust_main object. See L<FS::cust_main>.
-
- -c: Turn on collecting (you probably want this).
-
- -p: Apply unapplied payments and credits before collecting (you probably want
- this too)
-
- -a: Call collect even if there isn't a new invoice (probably a bad idea for
- daily use)
-
- -d: Pretend it's 'date'. Date is in any format Date::Parse is happy with,
- but be careful.
-
-user: From the mapsecrets file - see config.html from the base documentation
-
-custnum: if one or more customer numbers are specified, only bills those
-customers. Otherwise, bills all customers.
-
-=head1 BUGS
-
-=head1 SEE ALSO
-
-L<freeside-daily>, L<FS::cust_main>, config.html from the base documentation
-
-=cut
-
diff --git a/FS/bin/freeside-cc-receipts-report b/FS/bin/freeside-cc-receipts-report
deleted file mode 100755
index 136851a..0000000
--- a/FS/bin/freeside-cc-receipts-report
+++ /dev/null
@@ -1,270 +0,0 @@
-#!/usr/bin/perl -Tw
-
-
-use strict;
-use Date::Parse;
-use Time::Local;
-use Getopt::Std;
-use Text::Template;
-use Net::SMTP;
-use Mail::Header;
-use Mail::Internet;
-use FS::Conf;
-use FS::UID qw(adminsuidsetup);
-use FS::Record qw(qsearch qsearchs);
-use FS::cust_pay;
-use FS::cust_pay_batch;
-
-
-&untaint_argv; #what it sounds like (eww)
-use vars qw($opt_v $opt_p $opt_m $opt_e $opt_t $opt_s $opt_f $report_lines $report_template @buf $header);
-getopts("vpmef:s:"); #switches
-
-#we're at now now (and later).
-my($_finishdate)= $opt_f ? str2time($main::opt_f) : $^T;
-my($_startdate)= $opt_s ? str2time($main::opt_s) : $^T;
-
-# Get the current month
-my ($ssec,$smin,$shour,$smday,$smon,$syear) =
- (localtime($_startdate) )[0,1,2,3,4,5];
-$smon++;
-$syear += 1900;
-
-# Get the current month
-my ($fsec,$fmin,$fhour,$fmday,$fmon,$fyear) =
- (localtime($_finishdate) )[0,1,2,3,4,5];
-$fmon++;
-$fyear += 1900;
-
-# Login to the database
-my $user = shift or die &usage;
-adminsuidsetup $user;
-
-# Get the needed configuration files
-my $conf = new FS::Conf;
-my $lpr = $conf->config('lpr');
-my $email = $conf->config('email');
-my $smtpmachine = $conf->config('smtpmachine');
-my $mail_sender = $conf->exists('invoice_from') ? $conf->config('invoice_from') :
- 'postmaster';
-my @report_template = $conf->config('report_template')
- or die "cannot load config file report_template";
-$report_lines = 0;
-foreach ( grep /report_lines\(\d+\)/, @report_template ) { #kludgy :/
- /report_lines\((\d+)\)/;
- $report_lines += $1;
-}
-die "no report_lines() functions in template?" unless $report_lines;
-$report_template = new Text::Template (
- TYPE => 'ARRAY',
- SOURCE => [ map "$_\n", @report_template ],
-) or die "can't create new Text::Template object: $Text::Template::ERROR";
-
-
-my(@cust_pays)=qsearch('cust_pay',{});
-if (scalar(@cust_pays) == 0)
-{
- exit 1;
-}
-
-# Open print and email pipes
-# $lpr and opt_p for printing
-# $email and opt_m for email
-
-if ($lpr && $main::opt_p)
-{
- open(LPR, "|$lpr");
-}
-
-if ($email && $main::opt_m)
-{
- $ENV{MAILADDRESS} = $mail_sender;
- $header = new Mail::Header ( [
- "From: Account Processor",
- "To: $email",
- "Sender: $mail_sender",
- "Reply-To: $mail_sender",
- "Subject: Credit Card Receipts",
- ] );
-}
-
-my $uninvoiced = 0;
-my $total = 0;
-my $taxed = 0;
-my $untaxed = 0;
-my $total_tax = 0;
-
-# Now I can start looping
-foreach my $cust_pay (@cust_pays)
-{
- my $_date = $cust_pay->getfield('_date');
- my $invnum = $cust_pay->getfield('invnum');
- my $paid = $cust_pay->getfield('paid');
- my $payby = $cust_pay->getfield('payby');
-
-
- if ($_date >= $_startdate && $_date <= $_finishdate && $payby =~ 'CARD') {
- $total += $paid;
-
- $uninvoiced += $cust_pay->unapplied;
- my @cust_bill_pays = $cust_pay->cust_bill_pay;
- foreach my $cust_bill_pay (@cust_bill_pays) {
- my $invoice_amt =0;
- my $invoice_tax =0;
- my(@cust_bill_pkgs)= $cust_bill_pay->cust_bill->cust_bill_pkg;
- foreach my $cust_bill_pkg (@cust_bill_pkgs) {
-
- my $recur = $cust_bill_pkg->getfield('recur');
- my $setup = $cust_bill_pkg->getfield('setup');
- my $pkgnum = $cust_bill_pkg->getfield('pkgnum');
-
- if ($pkgnum == 0) {
- $invoice_tax += $recur;
- $invoice_tax += $setup;
- } else {
- $invoice_amt += $recur;
- $invoice_amt += $setup;
- }
-
- }
-
- if ($invoice_tax > 0) {
- if ($invoice_amt != $paid) {
- # attempt to prorate partially paid invoices
- $total_tax += $paid / ($invoice_amt + $invoice_tax) * $invoice_tax;
- $taxed += $paid / ($invoice_amt + $invoice_tax) * $invoice_amt;
- } else {
- $total_tax += $invoice_tax;
- $taxed += $invoice_amt;
- }
- } else {
- $untaxed += $paid;
- }
-
- }
-
- }
-
-}
-
-push @buf, sprintf(qq{\n%25s%14.2f\n}, "Uninvoiced", $uninvoiced);
-push @buf, sprintf(qq{%25s%14.2f\n}, "Untaxed", $untaxed);
-push @buf, sprintf(qq{%25s%14.2f\n}, "Taxed", $taxed);
-push @buf, sprintf(qq{%25s%14.2f\n}, "Tax", $total_tax);
-push @buf, sprintf(qq{\n%39s\n%39.2f\n}, "=========", $total);
-
-sub FS::cc_receipts_report::_template::report_lines {
- my $lines = shift;
- map {
- scalar(@buf) ? shift @buf : '' ;
- }
- ( 1 .. $lines );
-}
-
-$FS::cc_receipts_report::_template::title = qq~CREDIT CARD RECEIPTS for period $smon/$smday/$syear through $fmon/$fmday/$fyear~;
-$FS::cc_receipts_report::_template::title = $opt_t if $opt_t;
-$FS::cc_receipts_report::_template::page = 1;
-$FS::cc_receipts_report::_template::date = $^T;
-$FS::cc_receipts_report::_template::date = $^T;
-$FS::cc_receipts_report::_template::fdate = $_finishdate;
-$FS::cc_receipts_report::_template::fdate = $_finishdate;
-$FS::cc_receipts_report::_template::sdate = $_startdate;
-$FS::cc_receipts_report::_template::sdate = $_startdate;
-$FS::cc_receipts_report::_template::total_pages =
- int( scalar(@buf) / $report_lines);
-$FS::cc_receipts_report::_template::total_pages++ if scalar(@buf) % $report_lines;
-
-my @report;
-while (@buf) {
- push @report, split("\n",
- $report_template->fill_in( PACKAGE => 'FS::cc_receipts_report::_template' )
- );
- $FS::cc_receipts_report::_template::page++;
-}
-
-if ($opt_v) {
- print map "$_\n", @report;
-}
-if($lpr && $opt_p)
-{
- print LPR map "$_\n", @report;
- print LPR "\f" if $opt_e;
- close LPR || die "Could not close printer: $lpr\n";
-}
-if($email && $opt_m)
-{
- my $message = new Mail::Internet (
- 'Header' => $header,
- 'Body' => [ (@report) ],
- );
- $!=0;
- $message->smtpsend( Host => "$smtpmachine" )
- or die "can't send report to $email via $smtpmachine: $!";
-}
-
-
-# subroutines
-sub untaint_argv {
- foreach $_ ( $[ .. $#ARGV ) { #untaint @ARGV
- $ARGV[$_] =~ /^([\w\-\/ :\.]*)$/ || die "Illegal argument \"$ARGV[$_]\"";
- $ARGV[$_]=$1;
- }
-}
-
-sub usage {
- die "Usage:\n\n freeside-cc-receipts-report [-v] [-p] [-e] user\n";
-}
-
-=head1 NAME
-
-freeside-cc-receipts-report - Prints or emails total credit card receipts in a given period.
-
-=head1 SYNOPSIS
-
- freeside-cc-receipts-report [-v] [-p] [-m] [-e] [-t "title"] [-s date] [-f date] user
-
-=head1 DESCRIPTION
-
-Prints or emails sales taxes invoiced in a given period.
-
--v: Verbose - Prints records to STDOUT.
-
--p: Print to printer lpr as found in the conf directory.
-
--m: Email output to user found in the Conf email file.
-
--e: Print a final form feed to the printer.
-
--t: supply a title for the top of each page.
-
--s: starting date for inclusion
-
--f: final date for inclusion
-
-user: From the mapsecrets file - see config.html from the base documentation
-
-=head1 VERSION
-
-$Id: freeside-cc-receipts-report,v 1.5 2002-09-09 22:57:34 ivan Exp $
-
-=head1 BUGS
-
-Yes..... Use at your own risk. No guarantees or warrantees of any
-kind apply to this program. Parts of this program are hacked from
-other GNU licensed software created mainly by Ivan Kohler.
-
-This is released under the GNU Public License. See www.gnu.org
-for more information regarding this license.
-
-=head1 SEE ALSO
-
-L<FS::cust_main>, config.html from the base documentation
-
-=head1 AUTHOR
-
-Jeff Finucane <jeff@cmh.net>
-
-based on print-batch by Joel Griffiths <griff@aver-computer.com>
-
-=cut
-
diff --git a/FS/bin/freeside-count-active-customers b/FS/bin/freeside-count-active-customers
deleted file mode 100755
index 759085a..0000000
--- a/FS/bin/freeside-count-active-customers
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/sh
-
-domain=$1
-
-echo "\t
-select count(*) from cust_main where
- 0 < ( SELECT COUNT(*) FROM cust_pkg
- WHERE cust_pkg.custnum = cust_main.custnum
- AND ( cust_pkg.cancel IS NULL
- OR cust_pkg.cancel = 0
- )
- )
- OR 0 = ( SELECT COUNT(*) FROM cust_pkg
- WHERE cust_pkg.custnum = cust_main.custnum
- );
-" | psql -U freeside -q $domain | head -1
-
diff --git a/FS/bin/freeside-credit-report b/FS/bin/freeside-credit-report
deleted file mode 100755
index 410dabe..0000000
--- a/FS/bin/freeside-credit-report
+++ /dev/null
@@ -1,224 +0,0 @@
-#!/usr/bin/perl -Tw
-
-
-use strict;
-use Date::Parse;
-use Time::Local;
-use Getopt::Std;
-use Text::Template;
-use Net::SMTP;
-use Mail::Header;
-use Mail::Internet;
-use FS::Conf;
-use FS::UID qw(adminsuidsetup);
-use FS::Record qw(qsearch);
-use FS::cust_credit;
-
-
-&untaint_argv; #what it sounds like (eww)
-use vars qw($opt_v $opt_p $opt_m $opt_e $opt_t $opt_s $opt_f $report_lines $report_template @buf $header);
-getopts("vpmef:s:"); #switches
-
-#we're at now now (and later).
-my($_finishdate)= $opt_f ? str2time($main::opt_f) : $^T;
-my($_startdate)= $opt_s ? str2time($main::opt_s) : $^T;
-
-# Get the current month
-my ($ssec,$smin,$shour,$smday,$smon,$syear) =
- (localtime($_startdate) )[0,1,2,3,4,5];
-$smon++;
-$syear += 1900;
-
-# Get the current month
-my ($fsec,$fmin,$fhour,$fmday,$fmon,$fyear) =
- (localtime($_finishdate) )[0,1,2,3,4,5];
-$fmon++;
-$fyear += 1900;
-
-# Login to the database
-my $user = shift or die &usage;
-adminsuidsetup $user;
-
-# Get the needed configuration files
-my $conf = new FS::Conf;
-my $lpr = $conf->config('lpr');
-my $email = $conf->config('email');
-my $smtpmachine = $conf->config('smtpmachine');
-my $mail_sender = $conf->exists('invoice_from') ? $conf->config('invoice_from') :
- 'postmaster';
-my @report_template = $conf->config('report_template')
- or die "cannot load config file report_template";
-$report_lines = 0;
-foreach ( grep /report_lines\(\d+\)/, @report_template ) { #kludgy :/
- /report_lines\((\d+)\)/;
- $report_lines += $1;
-}
-die "no report_lines() functions in template?" unless $report_lines;
-$report_template = new Text::Template (
- TYPE => 'ARRAY',
- SOURCE => [ map "$_\n", @report_template ],
-) or die "can't create new Text::Template object: $Text::Template::ERROR";
-
-
-my(@cust_credits)=qsearch('cust_credit',{});
-if (scalar(@cust_credits) == 0)
-{
- exit 1;
-}
-
-# Open print and email pipes
-# $lpr and opt_p for printing
-# $email and opt_m for email
-
-if ($lpr && $main::opt_p)
-{
- open(LPR, "|$lpr");
-}
-
-if ($email && $main::opt_m)
-{
- $ENV{MAILADDRESS} = $mail_sender;
- $header = new Mail::Header ( [
- "From: Account Processor",
- "To: $email",
- "Sender: $mail_sender",
- "Reply-To: $mail_sender",
- "Subject: In House Credits",
- ] );
-}
-
-my $uninvoiced = 0;
-my $total = 0;
-my $taxed = 0;
-my $untaxed = 0;
-my $total_tax = 0;
-
-# Now I can start looping
-foreach my $cust_credit (@cust_credits)
-{
- my $_date = $cust_credit->getfield('_date');
- my $amount = $cust_credit->getfield('amount');
-
- if ($_date >= $_startdate && $_date <= $_finishdate) {
- $total += $amount;
- }
-}
-
-push @buf, sprintf(qq{\n%25s%14.2f\n}, "Credits Offered", $total);
-push @buf, sprintf(qq{\n%39s\n%39.2f\n}, "=========", $total);
-
-sub FS::credit_report::_template::report_lines {
- my $lines = shift;
- map {
- scalar(@buf) ? shift @buf : '' ;
- }
- ( 1 .. $lines );
-}
-
-$FS::credit_report::_template::title = qq~IN HOUSE CREDITS for $smon/$smday/$syear through $fmon/$fmday/$fyear~;
-$FS::credit_report::_template::title = $opt_t if $opt_t;
-$FS::credit_report::_template::page = 1;
-$FS::credit_report::_template::date = $^T;
-$FS::credit_report::_template::date = $^T;
-$FS::credit_report::_template::fdate = $_finishdate;
-$FS::credit_report::_template::fdate = $_finishdate;
-$FS::credit_report::_template::sdate = $_startdate;
-$FS::credit_report::_template::sdate = $_startdate;
-$FS::credit_report::_template::total_pages =
- int( scalar(@buf) / $report_lines);
-$FS::credit_report::_template::total_pages++ if scalar(@buf) % $report_lines;
-
-my @report;
-while (@buf) {
- push @report, split("\n",
- $report_template->fill_in( PACKAGE => 'FS::credit_report::_template' )
- );
- $FS::credit_report::_template::page++;
-}
-
-if ($opt_v) {
- print map "$_\n", @report;
-}
-if($lpr && $opt_p)
-{
- print LPR map "$_\n", @report;
- print LPR "\f" if $opt_e;
- close LPR || die "Could not close printer: $lpr\n";
-}
-if($email && $opt_m)
-{
- my $message = new Mail::Internet (
- 'Header' => $header,
- 'Body' => [ (@report) ],
- );
- $!=0;
- $message->smtpsend( Host => "$smtpmachine" )
- or die "can't send report to $email via $smtpmachine: $!";
-}
-
-
-# subroutines
-sub untaint_argv {
- foreach $_ ( $[ .. $#ARGV ) { #untaint @ARGV
- $ARGV[$_] =~ /^([\w\-\/ :\.]*)$/ || die "Illegal argument \"$ARGV[$_]\"";
- $ARGV[$_]=$1;
- }
-}
-
-sub usage {
- die "Usage:\n\n freeside-credit-report [-v] [-p] [-e] user\n";
-}
-
-=head1 NAME
-
-freeside-credit-report - Prints or emails total credit memos in a given period.
-
-=head1 SYNOPSIS
-
- freeside-credit-report [-v] [-p] [-m] [-e] [-t "title"] [-s date] [-f date] user
-
-=head1 DESCRIPTION
-
-Prints or emails total credit memos in a given period.
-
--v: Verbose - Prints records to STDOUT.
-
--p: Print to printer lpr as found in the conf directory.
-
--m: Email output to user found in the Conf email file.
-
--e: Print a final form feed to the printer.
-
--t: supply a title for the top of each page.
-
--s: starting date for inclusion
-
--f: final date for inclusion
-
-user: From the mapsecrets file - see config.html from the base documentation
-
-=head1 VERSION
-
-$Id: freeside-credit-report,v 1.5 2002-09-09 22:57:34 ivan Exp $
-
-=head1 BUGS
-
-Yes..... Use at your own risk. No guarantees or warrantees of any
-kind apply to this program. Parts of this program are hacked from
-other GNU licensed software created mainly by Ivan Kohler.
-
-This is released under the GNU Public License. See www.gnu.org
-for more information regarding this license.
-
-=head1 SEE ALSO
-
-L<FS::cust_main>, config.html from the base documentation
-
-=head1 AUTHOR
-
-Jeff Finucane <jeff@cmh.net>
-
-based on print-batch by Joel Griffiths <griff@aver-computer.com>
-
-=cut
-
diff --git a/FS/bin/freeside-daily b/FS/bin/freeside-daily
deleted file mode 100755
index 00de298..0000000
--- a/FS/bin/freeside-daily
+++ /dev/null
@@ -1,141 +0,0 @@
-#!/usr/bin/perl -w
-
-use strict;
-use Fcntl qw(:flock);
-use Date::Parse;
-use Getopt::Std;
-use FS::UID qw(adminsuidsetup driver_name dbh datasrc);
-use FS::Record qw(qsearch qsearchs);
-use FS::Conf;
-use FS::cust_main;
-
-&untaint_argv; #what it sounds like (eww)
-use vars qw($opt_d $opt_v $opt_p $opt_s $opt_y);
-getopts("p:d:vsy:");
-my $user = shift or die &usage;
-
-adminsuidsetup $user;
-
-$FS::cust_main::DEBUG = 1 if $opt_v;
-
-my %search;
-$search{'payby'} = $opt_p if $opt_p;
-
-my @cust_main = @ARGV
- ? map { qsearchs('cust_main', { custnum => $_, %search } ) } @ARGV
- : qsearch('cust_main', \%search )
-;
-
-#we're at now now (and later).
-my($time)= $opt_d ? str2time($opt_d) : $^T;
-$time += $opt_y * 86400 if $opt_y;
-
-my($cust_main,%saw);
-foreach $cust_main ( @cust_main ) {
-
- # $^T not $time because -d is for pre-printing invoices
- foreach my $cust_pkg (
- grep { $_->expire && $_->expire <= $^T } $cust_main->ncancelled_pkgs
- ) {
- my $error = $cust_pkg->cancel;
- warn "Error cancelling expired pkg ". $cust_pkg->pkgnum. " for custnum ".
- $cust_main->custnum. ": $error"
- if $error;
- }
-
- my $error = $cust_main->bill( 'time' => $time,
- 'resetup' => $opt_s, );
- warn "Error billing, custnum ". $cust_main->custnum. ": $error" if $error;
-
- $cust_main->apply_payments;
- $cust_main->apply_credits;
-
- $error = $cust_main->collect( 'invoice_time' => $time );
- warn "Error collecting, custnum". $cust_main->custnum. ": $error" if $error;
-
-}
-
-if ( driver_name eq 'Pg' ) {
- dbh->{AutoCommit} = 1; #so we can vacuum
- foreach my $statement ( 'vacuum', 'vacuum analyze' ) {
- my $sth = dbh->prepare($statement) or die dbh->errstr;
- $sth->execute or die $sth->errstr;
- }
-}
-
-#local hack
-my $conf = new FS::Conf;
-my $dest = $conf->config('dump-scpdest');
-if ( $dest ) {
- datasrc =~ /dbname=([\w\.]+)$/ or die "unparsable datasrc ". datasrc;
- my $database = $1;
- eval "use Net::SCP qw(scp);";
- if ( driver_name eq 'Pg' ) {
- system("pg_dump $database >/var/tmp/$database.sql")
- } else {
- die "database dumps not yet supported for ". driver_name;
- }
- scp("/var/tmp/$database.sql", $dest);
- unlink "/var/tmp/$database.sql" or die $!;
-}
-
-# subroutines
-
-sub untaint_argv {
- foreach $_ ( $[ .. $#ARGV ) { #untaint @ARGV
- #$ARGV[$_] =~ /^([\w\-\/]*)$/ || die "Illegal arguement \"$ARGV[$_]\"";
- # Date::Parse
- $ARGV[$_] =~ /^(.*)$/ || die "Illegal arguement \"$ARGV[$_]\"";
- $ARGV[$_]=$1;
- }
-}
-
-sub usage {
- die "Usage:\n\n freeside-daily [ -d 'date' ] user [ custnum custnum ... ]\n";
-}
-
-=head1 NAME
-
-freeside-daily - Run daily billing and invoice collection events.
-
-=head1 SYNOPSIS
-
- freeside-daily [ -d 'date' ] [ -y days ] [ -p 'payby' ] [ -s ] [ -v ] user [ custnum custnum ... ]
-
-=head1 DESCRIPTION
-
-Bills customers and runs invoice collection events. Should be run from
-crontab daily.
-
-This script replaces freeside-bill from 1.3.1.
-
-Bills customers. Searches for customers who are due for billing and calls
-the bill and collect methods of a cust_main object. See L<FS::cust_main>.
-
- -d: Pretend it's 'date'. Date is in any format Date::Parse is happy with,
- but be careful.
-
- -y: In addition to -d, which specifies an absolute date, the -y switch
- specifies an offset, in days. For example, "-y 15" would increment the
- "pretend date" 15 days from whatever was specified by the -d switch
- (or now, if no -d switch was given).
-
- -p: Only process customers with the specified payby (I<CARD>, I<DCRD>, I<CHEK>, I<DCHK>, I<BILL>, I<COMP>, I<LECB>)
-
- -s: re-charge setup fees
-
- -v: enable debugging
-
-user: From the mapsecrets file - see config.html from the base documentation
-
-custnum: if one or more customer numbers are specified, only bills those
-customers. Otherwise, bills all customers.
-
-=head1 BUGS
-
-=head1 SEE ALSO
-
-L<FS::cust_main>, config.html from the base documentation
-
-=cut
-
diff --git a/FS/bin/freeside-deloutsource b/FS/bin/freeside-deloutsource
deleted file mode 100644
index 5618535..0000000
--- a/FS/bin/freeside-deloutsource
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/sh
-
-domain=$1
-
-dropdb $domain && \
-rm -rf /usr/local/etc/freeside/conf.DBI:Pg:host=localhost\;dbname=$domain && \
-rm -rf /usr/local/etc/freeside/counters.DBI:Pg:host=localhost\;dbname=$domain && \
-rm -rf /usr/local/etc/freeside/cache.DBI:Pg:host=localhost\;dbname=$domain && \
-rm -rf /usr/local/etc/freeside/export.DBI:Pg:host=localhost\;dbname=$domain && \
-rm /usr/local/etc/freeside/dbdef.DBI:Pg:host=localhost\;dbname=$domain
-
diff --git a/FS/bin/freeside-deloutsourceuser b/FS/bin/freeside-deloutsourceuser
deleted file mode 100644
index 96871e5..0000000
--- a/FS/bin/freeside-deloutsourceuser
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/sh
-
-username=$1
-
-freeside-deluser -h /usr/local/etc/freeside/htpasswd $username 2>/dev/null
-
diff --git a/FS/bin/freeside-deluser b/FS/bin/freeside-deluser
deleted file mode 100644
index 57d6ce1..0000000
--- a/FS/bin/freeside-deluser
+++ /dev/null
@@ -1,64 +0,0 @@
-#!/usr/bin/perl -w
-
-use strict;
-use vars qw($opt_h);
-use Fcntl qw(:flock);
-use Getopt::Std;
-
-my $FREESIDE_CONF = "/usr/local/etc/freeside";
-
-getopts("h:");
-my $user = shift or die &usage;
-
-if ( $opt_h ) {
- open(HTPASSWD,"<$opt_h")
- and flock(HTPASSWD,LOCK_EX)
- or die "can't open $opt_h: $!";
- open(HTPASSWD_TMP,">$opt_h.tmp") or die "can't open $opt_h.tmp: $!";
- while (<HTPASSWD>) {
- print HTPASSWD_TMP $_ unless /^$user:/;
- }
- close HTPASSWD_TMP;
- rename "$opt_h.tmp", "$opt_h" or die $!;
- flock(HTPASSWD,LOCK_UN);
- close HTPASSWD;
-}
-
-open(MAPSECRETS,"<$FREESIDE_CONF/mapsecrets")
- and flock(MAPSECRETS,LOCK_EX)
- or die "can't open $FREESIDE_CONF/mapsecrets: $!";
-open(MAPSECRETS_TMP,">>$FREESIDE_CONF/mapsecrets.tmp")
- or die "can't open $FREESIDE_CONF/mapsecrets.tmp: $!";
-while (<MAPSECRETS>) {
- print MAPSECRETS_TMP $_ unless /^$user\s/;
-}
-close MAPSECRETS_TMP;
-rename "$FREESIDE_CONF/mapsecrets.tmp", "$FREESIDE_CONF/mapsecrets" or die $!;
-flock(MAPSECRETS,LOCK_UN);
-close MAPSECRETS;
-
-sub usage {
- die "Usage:\n\n freeside-deluser [ -h htpasswd_file ] username"
-}
-
-=head1 NAME
-
-freeside-deluser - Command line interface to add (freeside) users.
-
-=head1 SYNOPSIS
-
- freeside-deluser [ -h htpasswd_file ] username
-
-=head1 DESCRIPTION
-
-Adds a user to the Freeside billing system. This is for adding users (internal
-sales/tech folks) to the web interface, not for adding customer accounts.
-
- -h: Also delete from the given htpasswd filename
-
-=head1 SEE ALSO
-
-L<freeside-adduser>, L<htpasswd>(1), base Freeside documentation
-
-=cut
-
diff --git a/FS/bin/freeside-email b/FS/bin/freeside-email
deleted file mode 100755
index 400dc2a..0000000
--- a/FS/bin/freeside-email
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/usr/bin/perl -Tw
-
-use strict;
-use FS::UID qw(adminsuidsetup);
-use FS::Conf;
-use FS::Record qw(qsearch);
-use FS::svc_acct;
-
-&untaint_argv; #what it sounds like (eww)
-my $user = shift or die &usage;
-
-adminsuidsetup $user;
-
-my $conf = new FS::Conf;
-
-my @svc_acct = qsearch('svc_acct', {});
-my @emails = map $_->email, @svc_acct;
-
-print join("\n", @emails), "\n";
-
-# subroutines
-
-sub untaint_argv {
- foreach $_ ( $[ .. $#ARGV ) { #untaint @ARGV
- #$ARGV[$_] =~ /^([\w\-\/]*)$/ || die "Illegal arguement \"$ARGV[$_]\"";
- # Date::Parse
- $ARGV[$_] =~ /^(.*)$/ || die "Illegal arguement \"$ARGV[$_]\"";
- $ARGV[$_]=$1;
- }
-}
-
-sub usage {
- die "Usage:\n\n freeside-email user\n";
-}
-
-=head1 NAME
-
-freeside-email - Prints email addresses of all users on STDOUT
-
-=head1 SYNOPSIS
-
- freeside-email user
-
-=head1 DESCRIPTION
-
-Prints the email addresses of all customers on STDOUT, separated by newlines.
-
-user: From the mapsecrets file - see config.html from the base documentation
-
-=head1 VERSION
-
-$Id: freeside-email,v 1.2 2002-09-18 22:50:44 ivan Exp $
-
-=head1 BUGS
-
-=head1 SEE ALSO
-
-=cut
-
diff --git a/FS/bin/freeside-expiration-alerter b/FS/bin/freeside-expiration-alerter
deleted file mode 100755
index 691fd3a..0000000
--- a/FS/bin/freeside-expiration-alerter
+++ /dev/null
@@ -1,226 +0,0 @@
-#!/usr/bin/perl -Tw
-
-use strict;
-use Date::Format;
-use Time::Local;
-use Text::Template;
-use Getopt::Std;
-use Net::SMTP;
-use Mail::Header;
-use Mail::Internet;
-use FS::Conf;
-use FS::UID qw(adminsuidsetup);
-use FS::Record qw(qsearch);
-use FS::cust_main;
-
-use vars qw($smtpmachine @body);
-
-#hush, perl!
-$FS::alerter::_template::first = "";
-$FS::alerter::_template::last = "";
-$FS::alerter::_template::company = "";
-$FS::alerter::_template::payby = "";
-$FS::alerter::_template::expdate = "";
-
-# Set the mail program and other variables
-my $mail_sender = "billing\@mydomain.tld"; # or invoice_from if available
-my $failure_recipient = "postmaster"; # or invoice_from if available
-my $warning_time = 30 * 24 * 60 * 60;
-my $urgent_time = 15 * 24 * 60 * 60;
-my $panic_time = 5 * 24 * 60 * 60;
-my $window_time = 24 * 60 * 60;
-
-&untaint_argv; #what it sounds like (eww)
-
-#we're at now now (and later).
-my($_date)= $^T;
-
-# Get the current month
-my ($sec,$min,$hour,$mday,$mon,$year) =
- (localtime($_date) )[0,1,2,3,4,5];
-$mon++;
-
-# Login to the database
-my $user = shift or die &usage;
-adminsuidsetup $user;
-
-# Get the needed configuration files
-my $conf = new FS::Conf;
-$smtpmachine = $conf->config('smtpmachine');
-$mail_sender = $conf->config('invoice_from')
- if $conf->exists('invoice_from');
-$failure_recipient = $conf->config('invoice_from')
- if $conf->exists('invoice_from');
-
-
-my(@customers)=qsearch('cust_main',{});
-if (scalar(@customers) == 0)
-{
- exit 1;
-}
-
-# Prepare for sending email
-
-$ENV{MAILADDRESS} = $mail_sender;
-my $header = new Mail::Header ( [
- "From: Account Processor",
- "To: $failure_recipient",
- "Sender: $mail_sender",
- "Reply-To: $mail_sender",
- "Subject: Unnotified Billing Arrangement Expirations",
-] );
-
-my @alerter_template = $conf->config('alerter_template')
- or die "cannot load config file alerter_template";
-
-my $alerter = new Text::Template (TYPE => 'ARRAY', SOURCE => [ map "$_\n", @alerter_template ])
- or die "can't create new Text::Template object: Text::Template::ERROR";
-$alerter->compile() or die "can't compile template: Text::Template::ERROR";
-
-# Now I can start looping
-foreach my $customer (@customers)
-{
- my $paydate = $customer->getfield('paydate');
- next if $paydate =~ /^\s*$/; #skip empty expiration dates
-
- my $custnum = $customer->getfield('custnum');
- my $first = $customer->getfield('first');
- my $last = $customer->getfield('last');
- my $company = $customer->getfield('company');
- my $payby = $customer->getfield('payby');
- my $payinfo = $customer->getfield('payinfo');
- my $daytime = $customer->getfield('daytime');
- my $night = $customer->getfield('night');
-
- my ($payyear,$paymonth,$payday) = split (/-/,$paydate);
-
- my $expire_time = timelocal(0,0,0,$payday,--$paymonth,$payyear);
-
- #credit cards expire at the end of the month/year of their exp date
- if ($payby eq 'CARD' || $payby eq 'DCRD') {
- ($paymonth < 11) ? $paymonth++ : ($paymonth=0, $payyear++);
- $expire_time = timelocal(0,0,0,$payday,$paymonth,$payyear);
- $expire_time--;
- }
-
- if (($expire_time < $_date + $warning_time &&
- $expire_time > $_date + $warning_time - $window_time) ||
- ($expire_time < $_date + $urgent_time &&
- $expire_time > $_date + $urgent_time - $window_time) ||
- ($expire_time < $_date + $panic_time &&
- $expire_time > $_date + $panic_time - $window_time)) {
-
-
-
- my @packages = $customer->ncancelled_pkgs;
- if (scalar(@packages) != 0) {
- my @invoicing_list = $customer->invoicing_list;
- if ( grep { $_ ne 'POST' } @invoicing_list ) {
- my $header = new Mail::Header ( [
- "From: $mail_sender",
- "To: ". join(', ', grep { $_ ne 'POST' } @invoicing_list ),
- "Sender: $mail_sender",
- "Reply-To: $mail_sender",
- "Date: ". time2str("%a, %d %b %Y %X %z", time),
- "Subject: Billing Arrangement Expiration",
- ] );
- $FS::alerter::_template::first = $first;
- $FS::alerter::_template::last = $last;
- $FS::alerter::_template::company = $company;
- if ($payby eq 'CARD' || $payby eq 'DCRD') {
- $FS::alerter::_template::payby = "credit card (" .
- substr($payinfo, 0, 2) . "xxxxxxxxxx" .
- substr($payinfo, -4) . ")";
- }elsif ($payby eq 'COMP') {
- $FS::alerter::_template::payby = "complimentary account";
- }else{
- $FS::alerter::_template::payby = "current method";
- }
- $FS::alerter::_template::expdate = $expire_time;
-
- my $message = new Mail::Internet (
- 'Header' => $header,
- 'Body' => [ $alerter->fill_in( PACKAGE => 'FS::alerter::_template' ) ],
- );
- $!=0;
- $message->smtpsend( Host => $smtpmachine )
- or $message->smtpsend( Host => $smtpmachine, Debug => 1 )
- or die "Can't send expiration email: $!";
-
- } elsif ( ! @invoicing_list || grep { $_ eq 'POST' } @invoicing_list ) {
- push @body, sprintf(qq{%5d %-32.32s %4s %10s %12s %12s},
- $custnum,
- $first . " " . $last . " " . $company,
- $payby,
- $paydate,
- $daytime,
- $night);
- }
- }
- }
-}
-
-# Now I need to send EMAIL
-if (scalar(@body)) {
- my $message = new Mail::Internet (
- 'Header' => $header,
- 'Body' => [ (@body) ],
- );
- $!=0;
- $message->smtpsend( Host => $smtpmachine )
- or $message->smtpsend( Host => $smtpmachine, Debug => 1 )
- or die "can't send alerter failure email to $failure_recipient".
- " via server $smtpmachine with SMTP: $!";
-}
-
-# subroutines
-sub untaint_argv {
- foreach $_ ( $[ .. $#ARGV ) { #untaint @ARGV
- $ARGV[$_] =~ /^([\w\-\/]*)$/ || die "Illegal argument \"$ARGV[$_]\"";
- $ARGV[$_]=$1;
- }
-}
-
-sub usage {
- die "Usage:\n\n freeside-expiration-alerter user\n";
-}
-
-=head1 NAME
-
-freeside-expiration-alerter - Emails notifications of credit card expirations.
-
-=head1 SYNOPSIS
-
- freeside-expiration-alerter user
-
-=head1 DESCRIPTION
-
-Emails customers notice that their credit card or other billing arrangement
-is about to expire. Usually run as a cron job.
-
-user: From the mapsecrets file - see config.html from the base documentation
-
-=head1 VERSION
-
-$Id: freeside-expiration-alerter,v 1.5 2003-04-21 20:53:57 ivan Exp $
-
-=head1 BUGS
-
-Yes..... Use at your own risk. No guarantees or warrantees of any
-kind apply to this program. Parts of this program are hacked from
-other GNU licensed software created mainly by Ivan Kohler.
-
-This is released under the GNU Public License. See www.gnu.org
-for more information regarding this license.
-
-=head1 SEE ALSO
-
-L<FS::cust_main>, config.html from the base documentation
-
-=head1 AUTHOR
-
-Jeff Finucane <jeff@cmh.net>
-
-=cut
-
-
diff --git a/FS/bin/freeside-queued b/FS/bin/freeside-queued
deleted file mode 100644
index 6ea27c0..0000000
--- a/FS/bin/freeside-queued
+++ /dev/null
@@ -1,267 +0,0 @@
-#!/usr/bin/perl -w
-
-use strict;
-use vars qw( $log_file $sigterm $sigint $kids $max_kids %kids );
-use subs qw( _die _logmsg );
-use Fcntl qw(:flock);
-use POSIX qw(:sys_wait_h setsid);
-use Date::Format;
-use IO::File;
-use FS::UID qw(adminsuidsetup forksuidsetup driver_name dbh);
-use FS::Record qw(qsearch qsearchs);
-use FS::queue;
-use FS::queue_depend;
-
-# no autoloading just yet
-use FS::cust_main;
-use FS::svc_acct;
-use Net::SSH 0.07;
-use FS::part_export;
-
-$max_kids = '10'; #guess it should be a config file...
-$kids = 0;
-
-my $user = shift or die &usage;
-
-#my $pid_file = "/var/run/freeside-queued.$user.pid";
-my $pid_file = "/var/run/freeside-queued.pid";
-
-&daemonize1;
-
-#sub REAPER { my $pid = wait; $SIG{CHLD} = \&REAPER; $kids--; }
-#$SIG{CHLD} = \&REAPER;
-
-$sigterm = 0;
-$sigint = 0;
-$SIG{INT} = sub { warn "SIGINT received; shutting down\n"; $sigint++; };
-$SIG{TERM} = sub { warn "SIGTERM received; shutting down\n"; $sigterm++; };
-
-my $freeside_gid = scalar(getgrnam('freeside'))
- or die "can't setgid to freeside group\n";
-$) = $freeside_gid;
-$( = $freeside_gid;
-#if freebsd can't setuid(), presumably it can't setgid() either. grr fleabsd
-($(,$)) = ($),$();
-$) = $freeside_gid;
-
-$> = $FS::UID::freeside_uid;
-$< = $FS::UID::freeside_uid;
-#freebsd is sofa king broken, won't setuid()
-($<,$>) = ($>,$<);
-$> = $FS::UID::freeside_uid;
-
-$ENV{HOME} = (getpwuid($>))[7]; #for ssh
-adminsuidsetup $user;
-
-$log_file = "/usr/local/etc/freeside/queuelog.". $FS::UID::datasrc;
-
-&daemonize2;
-
-$SIG{__DIE__} = \&_die;
-$SIG{__WARN__} = \&_logmsg;
-
-warn "freeside-queued starting\n";
-
-my $warnkids=0;
-while (1) {
-
- &reap_kids;
- #prevent runaway forking
- if ( $kids >= $max_kids ) {
- warn "WARNING: maximum $kids children reached\n" unless $warnkids++;
- &reap_kids;
- sleep 1; #waiting for signals is cheap
- next;
- }
- $warnkids=0;
-
- my $nodepend = driver_name eq 'mysql'
- ? ''
- : 'AND 0 = ( SELECT COUNT(*) FROM queue_depend'.
- ' WHERE queue_depend.jobnum = queue.jobnum ) ';
-
- #my($job, $ljob);
- #{
- # my $oldAutoCommit = $FS::UID::AutoCommit;
- # local $FS::UID::AutoCommit = 0;
- $FS::UID::AutoCommit = 0;
- my $dbh = dbh;
-
- my $job = qsearchs(
- 'queue',
- { 'status' => 'new' },
- '',
- driver_name eq 'mysql'
- ? "$nodepend ORDER BY jobnum LIMIT 1 FOR UPDATE"
- : "$nodepend ORDER BY jobnum FOR UPDATE LIMIT 1"
- ) or do {
- $dbh->commit or die $dbh->errstr; #if $oldAutoCommit;
- sleep 5; #connecting to db is expensive
- next;
- };
-
- if ( driver_name eq 'mysql'
- && qsearch('queue_depend', { 'jobnum' => $job->jobnum } ) ) {
- $dbh->commit or die $dbh->errstr; #if $oldAutoCommit;
- sleep 5; #would be better if mysql could do everything in query above
- next;
- }
-
- my %hash = $job->hash;
- $hash{'status'} = 'locked';
- my $ljob = new FS::queue ( \%hash );
- my $error = $ljob->replace($job);
- die $error if $error;
-
- $dbh->commit or die $dbh->errstr; #if $oldAutoCommit;
-
- $FS::UID::AutoCommit = 1;
- #}
-
- my @args = $ljob->args;
-
- defined( my $pid = fork ) or do {
- warn "WARNING: can't fork: $!\n";
- my %hash = $job->hash;
- $hash{'status'} = 'failed';
- $hash{'statustext'} = "[freeside-queued] can't fork: $!";
- my $ljob = new FS::queue ( \%hash );
- my $error = $ljob->replace($job);
- die $error if $error;
- next; #don't increment the kid counter
- };
-
- if ( $pid ) {
- $kids++;
- $kids{$pid} = 1;
- } else { #kid time
-
- #get new db handle
- $FS::UID::dbh->{InactiveDestroy} = 1;
-
- forksuidsetup($user);
-
- #auto-use export classes...
- if ( $ljob->job =~ /(FS::part_export::\w+)::/ ) {
- my $class = $1;
- eval "use $class;";
- if ( $@ ) {
- warn "job use $class failed";
- my %hash = $ljob->hash;
- $hash{'status'} = 'failed';
- $hash{'statustext'} = $@;
- my $fjob = new FS::queue( \%hash );
- my $error = $fjob->replace($ljob);
- die $error if $error;
- exit; #end-of-kid
- };
- }
-
- my $eval = "&". $ljob->job. '(@args);';
- warn "running $eval";
- eval $eval; #throw away return value? suppose so
- if ( $@ ) {
- warn "job $eval failed";
- my %hash = $ljob->hash;
- $hash{'status'} = 'failed';
- $hash{'statustext'} = $@;
- my $fjob = new FS::queue( \%hash );
- my $error = $fjob->replace($ljob);
- die $error if $error;
- } else {
- $ljob->delete;
- }
-
- exit;
- #end-of-kid
- }
-
-} continue {
- if ( $sigterm ) {
- warn "received TERM signal; exiting\n";
- exit;
- }
- if ( $sigint ) {
- warn "received INT signal; exiting\n";
- exit;
- }
-}
-
-sub usage {
- die "Usage:\n\n freeside-queued user\n";
-}
-
-sub _die {
- my $msg = shift;
- unlink $pid_file if -e $pid_file;
- _logmsg($msg);
-}
-
-sub _logmsg {
- chomp( my $msg = shift );
- my $log = new IO::File ">>$log_file";
- flock($log, LOCK_EX);
- seek($log, 0, 2);
- print $log "[". time2str("%a %b %e %T %Y",time). "] [$$] $msg\n";
- flock($log, LOCK_UN);
- close $log;
-}
-
-sub daemonize1 {
-
- chdir "/" or die "Can't chdir to /: $!";
- open STDIN, '/dev/null' or die "Can't read /dev/null: $!";
- defined(my $pid = fork) or die "Can't fork: $!";
- if ( $pid ) {
- print "freeside-queued started with pid $pid\n"; #logging to $log_file\n";
- exit unless $pid_file;
- my $pidfh = new IO::File ">$pid_file" or exit;
- print $pidfh "$pid\n";
- exit;
- }
- #open STDOUT, '>/dev/null'
- # or die "Can't write to /dev/null: $!";
- #setsid or die "Can't start a new session: $!";
- #open STDERR, '>&STDOUT' or die "Can't dup stdout: $!";
-
-}
-
-sub daemonize2 {
- open STDOUT, '>/dev/null'
- or die "Can't write to /dev/null: $!";
- setsid or die "Can't start a new session: $!";
- open STDERR, '>&STDOUT' or die "Can't dup stdout: $!";
-}
-
-sub reap_kids {
- foreach my $pid ( keys %kids ) {
- my $kid = waitpid($pid, WNOHANG);
- if ( $kid > 0 ) {
- $kids--;
- delete $kids{$kid};
- }
- }
-}
-
-=head1 NAME
-
-freeside-queued - Job queue daemon
-
-=head1 SYNOPSIS
-
- freeside-queued user
-
-=head1 DESCRIPTION
-
-Job queue daemon. Should be running at all times.
-
-user: from the mapsecrets file - see config.html from the base documentation
-
-=head1 VERSION
-
-=head1 BUGS
-
-=head1 SEE ALSO
-
-=cut
-
diff --git a/FS/bin/freeside-radgroup b/FS/bin/freeside-radgroup
deleted file mode 100644
index ed85626..0000000
--- a/FS/bin/freeside-radgroup
+++ /dev/null
@@ -1,76 +0,0 @@
-#!/usr/bin/perl -w
-
-use strict;
-use FS::UID qw(adminsuidsetup);
-use FS::Record qw(qsearch);
-use FS::cust_svc;
-use FS::svc_acct;
-
-&untaint_argv; #what it sounds like (eww)
-
-my($user, $action, $groupname, $svcpart) = @ARGV;
-
-adminsuidsetup $user;
-
-my @svc_acct = map { $_->svc_x } qsearch('cust_svc', { svcpart => $svcpart } );
-
-if ( lc($action) eq 'add' ) {
- foreach my $svc_acct ( @svc_acct ) {
- my @groups = $svc_acct->radius_groups;
- next if grep { $_ eq $groupname } @groups;
- push @groups, $groupname;
- my %hash = $svc_acct->hash;
- $hash{usergroup} = \@groups;
- my $new = new FS::svc_acct \%hash;
- my $error = $new->replace($svc_acct);
- die $error if $error;
- }
-} else {
- die &usage;
-}
-
-# subroutines
-
-sub untaint_argv {
- foreach $_ ( $[ .. $#ARGV ) { #untaint @ARGV
- $ARGV[$_] =~ /^(.*)$/ || die "Illegal arguement \"$ARGV[$_]\"";
- $ARGV[$_]=$1;
- }
-}
-
-sub usage {
- die "Usage:\n\n freeside-radgroup user action groupname svcpart\n";
-}
-
-=head1 NAME
-
-freeside-radgroup - Command line utility to manipulate radius groups
-
-=head1 SYNOPSIS
-
- freeside-addgroup user action groupname svcpart
-
-=head1 DESCRIPTION
-
- B<user> is a freeside user as added with freeside-adduser.
-
- B<command> is the action to take. Available actions are: I<add>
-
- B<groupname> is the group to add (or remove, etc.)
-
- B<svcpart> specifies which accounts will be updated.
-
-=head1 EXAMPLES
-
-freeside-radgroup freesideuser add groupname 3
-
-Adds I<groupname> to all accounts with service definition 3.
-
-=head1 BUGS
-
-=head1 SEE ALSO
-
-L<freeside-adduser>, L<FS::svc_acct>, L<FS::part_svc>
-
-=cut
-
diff --git a/FS/bin/freeside-reexport b/FS/bin/freeside-reexport
deleted file mode 100644
index b5c50a4..0000000
--- a/FS/bin/freeside-reexport
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/usr/bin/perl -Tw
-
-use strict;
-use FS::UID qw(adminsuidsetup);
-use FS::Record qw(qsearch qsearchs);
-use FS::part_export;
-use FS::svc_acct;
-use FS::cust_svc;
-
-my $user = shift or die &usage;
-adminsuidsetup $user;
-
-my $export_x = shift or die &usage;
-my @part_export;
-if ( $export_x =~ /^(\d+)$/ ) {
- @part_export = qsearchs('part_export', { exportnum=>$1 } )
- or die "exportnum $export_x not found\n";
-} else {
- @part_export = qsearch('part_export', { exporttype=>$export_x } )
- or die "no exports of type $export_x found\n";
-}
-
-my $svc_something = shift or die &usage;
-my $svc_x;
-if ( $svc_something =~ /^(\d+)$/ ) {
- my $cust_svc = qsearchs('cust_svc', { svcnum=>$1 } )
- or die "svcnum $svc_something not found\n";
- $svc_x = $cust_svc->svc_x;
-} else {
- $svc_x = qsearchs('svc_acct', { username=>$svc_something } )
- or die "username $svc_something not found\n";
-}
-
-foreach my $part_export ( @part_export ) {
- my $error = $part_export->export_insert($svc_x);
- die $error if $error;
-}
-
-
-sub usage {
- die "Usage:\n\n freeside-reexport user exportnum|exporttype svcnum|username\n";
-}
-
-=head1 NAME
-
-freeside-reexport - Command line tool to re-trigger export jobs for existing services
-
-=head1 SYNOPSIS
-
- freeside-reexport user exportnum|exporttype svcnum|username
-
-=head1 DESCRIPTION
-
- Re-queues the export job for the specified exportnum or exporttype(s) and
- specified service (selected by svcnum or username).
-
-=head1 SEE ALSO
-
-L<freeside-sqlradius-reset>, L<FS::part_export>
-
-=cut
-
diff --git a/FS/bin/freeside-selfservice-server b/FS/bin/freeside-selfservice-server
deleted file mode 100644
index 864c2d4..0000000
--- a/FS/bin/freeside-selfservice-server
+++ /dev/null
@@ -1,266 +0,0 @@
-#!/usr/bin/perl -w
-#
-# freeside-selfservice-server
-
-# alas, much false laziness with freeside-queued and fs_signup_server. at
-# least it is slated to replace fs_{signup,passwd,mailadmin}_server
-# should probably generalize the version in here, or better yet use
-# Proc::Daemon or somesuch
-
-use strict;
-use vars qw( $Debug %kids $kids $max_kids $shutdown $log_file $ssh_pid );
-use subs qw( lock_write unlock_write );
-use Fcntl qw(:flock);
-use POSIX qw(:sys_wait_h setsid);
-use IO::Handle;
-use IO::Select;
-use IO::File;
-use Storable 2.09 qw(nstore_fd fd_retrieve);
-use Net::SSH qw(sshopen2);
-use FS::UID qw(adminsuidsetup forksuidsetup);
-use FS::ClientAPI;
-
-use FS::Conf;
-use FS::cust_bill;
-use FS::cust_pkg;
-
-$Debug = 1; # >= 2 will log packet contents, including potentially compromising
- # information
-
-$shutdown = 0;
-$max_kids = '10'; #?
-$kids = 0;
-
-my $user = shift or die &usage;
-my $machine = shift or die &usage;
-my $tag = scalar(@ARGV) ? shift : '';
-
-# $FS::UID::datasrc not posible
-my $pid_file = "/var/run/freeside-selfservice-server.$user.$machine.pid";
-
-my $lock_file = "/usr/local/etc/freeside/selfservice.$machine.writelock";
-open(LOCKFILE,">$lock_file") or die "can't open $lock_file: $!";
-
-&init($user);
-
-my $conf = new FS::Conf;
-
-my $clientd = "/usr/local/sbin/freeside-selfservice-clientd"; #better name?
-
-my $warnkids=0;
-while (1) {
- my($writer,$reader,$error) = (new IO::Handle, new IO::Handle, new IO::Handle);
- warn "connecting to $machine\n" if $Debug;
-
- $ssh_pid = sshopen2($machine,$reader,$writer,$clientd,$tag);
-
-# nstore_fd(\*writer, {'hi'=>'there'});
-
- warn "entering main loop\n" if $Debug;
- my $undisp = 0;
- my $s = IO::Select->new( $reader );
- while (1) {
-
- &reap_kids;
-
- warn "waiting for packet from client\n" if $Debug && !$undisp;
- $undisp = 1;
- my @handles = $s->can_read(5);
- unless ( @handles ) {
- &shutdown if $shutdown;
- next;
- }
-
- $undisp = 0;
-
- warn "receiving packet from client\n" if $Debug;
-
- my $packet = eval { fd_retrieve($reader); };
- if ( $@ ) {
- warn "Storable error receiving packet from client".
- " (assuming lost connection): $@\n"
- if $Debug;
- if ( $ssh_pid ) {
- warn "sending TERM signal to ssh process $ssh_pid\n" if $Debug;
- kill 'TERM', $ssh_pid;
- $ssh_pid = 0;
- }
- last;
- }
- warn "packet received\n".
- join('', map { " $_=>$packet->{$_}\n" } keys %$packet )
- if $Debug > 1;
-
- #prevent runaway forking
- my $warnkids = 0;
- while ( $kids >= $max_kids ) {
- warn "WARNING: maximum $kids children reached\n" unless $warnkids++;
- &reap_kids;
- sleep 1;
- }
-
- warn "forking child\n" if $Debug;
- defined( my $pid = fork ) or die "can't fork: $!";
- if ( $pid ) {
- $kids++;
- $kids{$pid} = 1;
- warn "child $pid spawned\n" if $Debug;
- } else { #kid time
-
- #get new db handle
- $FS::UID::dbh->{InactiveDestroy} = 1;
- forksuidsetup($user);
-
- my $type = $packet->{_packet};
- warn "calling $type handler\n" if $Debug;
- my $rv = eval { FS::ClientAPI->dispatch($type, $packet); };
- if ( $@ ) {
- warn my $error = "WARNING: error dispatching $type: $@";
- $rv = { _error => $error };
- }
- $rv->{_token} = $packet->{_token}; #identifier
-
- warn "sending response\n" if $Debug;
- lock_write;
- nstore_fd($rv, $writer) or die "FATAL: can't send response: $!";
- $writer->flush or die "FATAL: can't flush: $!";
- unlock_write;
-
- warn "child exiting\n" if $Debug;
- exit; #end-of-kid
- }
-
- }
-
- warn "connection lost, reconnecting\n" if $Debug;
- sleep 3;
-
-}
-
-###
-# utility subroutines
-###
-
-sub reap_kids {
- #warn "reaping kids\n";
- foreach my $pid ( keys %kids ) {
- my $kid = waitpid($pid, WNOHANG);
- if ( $kid > 0 ) {
- $kids--;
- delete $kids{$kid};
- }
- }
- #warn "done reaping\n";
-}
-
-sub init {
- my $user = shift;
-
- chdir "/" or die "Can't chdir to /: $!";
- open STDIN, '/dev/null' or die "Can't read /dev/null: $!";
- defined(my $pid = fork) or die "Can't fork: $!";
- if ( $pid ) {
- print "freeside-selfservice-server to $machine started with pid $pid\n"; #logging to $log_file
- exit unless $pid_file;
- my $pidfh = new IO::File ">$pid_file" or exit;
- print $pidfh "$pid\n";
- exit;
- }
-
-# sub REAPER { my $pid = wait; $SIG{CHLD} = \&REAPER; $kids--; }
-# #sub REAPER { my $pid = wait; $kids--; $SIG{CHLD} = \&REAPER; }
-# $SIG{CHLD} = \&REAPER;
-
- $shutdown = 0;
- $SIG{HUP} = sub { warn "SIGHUP received; shutting down\n"; $shutdown++; };
- $SIG{INT} = sub { warn "SIGINT received; shutting down\n"; $shutdown++; };
- $SIG{TERM} = sub { warn "SIGTERM received; shutting down\n"; $shutdown++; };
- $SIG{QUIT} = sub { warn "SIGQUIT received; shutting down\n"; $shutdown++; };
- $SIG{PIPE} = sub { warn "SIGPIPE received; shutting down\n"; $shutdown++; };
-
- #false laziness w/freeside-queued
- my $freeside_gid = scalar(getgrnam('freeside'))
- or die "can't setgid to freeside group\n";
- $) = $freeside_gid;
- $( = $freeside_gid;
- #if freebsd can't setuid(), presumably it can't setgid() either. grr fleabsd
- ($(,$)) = ($),$();
- $) = $freeside_gid;
-
- $> = $FS::UID::freeside_uid;
- $< = $FS::UID::freeside_uid;
- #freebsd is sofa king broken, won't setuid()
- ($<,$>) = ($>,$<);
- $> = $FS::UID::freeside_uid;
- #eslaf
-
- $ENV{HOME} = (getpwuid($>))[7]; #for ssh
- adminsuidsetup $user;
-
- #$log_file = "/usr/local/etc/freeside/selfservice.". $FS::UID::datasrc; #MACHINE NAME
- $log_file = "/usr/local/etc/freeside/selfservice.$machine.log";
-
- open STDOUT, '>/dev/null'
- or die "Can't write to /dev/null: $!";
- setsid or die "Can't start a new session: $!";
- open STDERR, '>&STDOUT' or die "Can't dup stdout: $!";
-
- $SIG{__DIE__} = \&_die;
- $SIG{__WARN__} = \&_logmsg;
-
- warn "freeside-selfservice-server starting\n";
-
-}
-
-sub shutdown {
- my $wait = 12; #wait up to 1 minute
- while ( $kids > 0 && $wait-- ) {
- warn "waiting for $kids children to terminate";
- sleep 5;
- }
- warn "abandoning $kids children" if $kids;
- kill 'TERM', $ssh_pid if $ssh_pid;
- die "exiting";
-}
-
-sub _die {
- my $msg = shift;
- unlink $pid_file if -e $pid_file;
- _logmsg($msg);
-}
-
-sub _logmsg {
- chomp( my $msg = shift );
- _do_logmsg( "[server] [". scalar(localtime). "] [$$] $msg\n" );
-}
-
-sub _do_logmsg {
- chomp( my $msg = shift );
- my $log = new IO::File ">>$log_file";
- flock($log, LOCK_EX);
- seek($log, 0, 2);
- print $log "$msg\n";
- flock($log, LOCK_UN);
- close $log;
-}
-
-sub lock_write {
- #broken on freebsd?
- #flock($writer, LOCK_EX) or die "FATAL: can't lock write stream: $!";
-
- flock(LOCKFILE, LOCK_EX) or die "FATAL: can't lock $lock_file: $!";
-
-}
-
-sub unlock_write {
- #broken on freebsd?
- #flock($writer, LOCK_UN) or die "WARNING: can't release write lock: $!";
-
- flock(LOCKFILE, LOCK_UN) or die "FATAL: can't unlock $lock_file: $!";
-
-}
-
-sub usage {
- die "Usage:\n\n freeside-selfservice-server user machine\n";
-}
-
diff --git a/FS/bin/freeside-setinvoice b/FS/bin/freeside-setinvoice
deleted file mode 100644
index 708e2fa..0000000
--- a/FS/bin/freeside-setinvoice
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-use FS::UID qw(adminsuidsetup);
-use FS::Conf;
-use FS::Record qw(qsearch qsearchs);
-use FS::cust_main;
-use FS::svc_acct;
-
-&untaint_argv; #what it sounds like (eww)
-my $user = shift or die &usage;
-
-adminsuidsetup $user;
-
-foreach my $cust_main (
- grep { ! scalar($_->invoicing_list) }
- qsearch( 'cust_main', {} )
-) {
- my @dest;
- my @cust_pkg = $cust_main->ncancelled_pkgs;
- foreach my $cust_pkg ( @cust_pkg ) {
- foreach my $cust_svc ( $cust_pkg->cust_svc ) {
- my $svc_acct = qsearchs( 'svc_acct', { 'svcnum' => $cust_svc->svcnum } );
- push @dest, $svc_acct->svcnum if $svc_acct;
- }
- }
- push @dest, 'POST' unless @dest;
- $cust_main->invoicing_list(\@dest);
-}
-
-sub untaint_argv {
- foreach $_ ( $[ .. $#ARGV ) { #untaint @ARGV
- $ARGV[$_] =~ /^(.*)$/ || die "Illegal arguement \"$ARGV[$_]\"";
- $ARGV[$_]=$1;
- }
-}
-
-sub usage {
- die "Usage:\n\n freeside-setinvoice user\n";
-}
-
-
diff --git a/FS/bin/freeside-setup b/FS/bin/freeside-setup
deleted file mode 100755
index 522c0a1..0000000
--- a/FS/bin/freeside-setup
+++ /dev/null
@@ -1,1123 +0,0 @@
-#!/usr/bin/perl -Tw
-
-#to delay loading dbdef until we're ready
-BEGIN { $FS::Record::setup_hack = 1; }
-
-use strict;
-use vars qw($opt_s);
-use Getopt::Std;
-use Locale::Country;
-use Locale::SubCountry;
-use DBI;
-use DBIx::DBSchema 0.21;
-use DBIx::DBSchema::Table;
-use DBIx::DBSchema::Column;
-use DBIx::DBSchema::ColGroup::Unique;
-use DBIx::DBSchema::ColGroup::Index;
-use FS::UID qw(adminsuidsetup datasrc checkeuid getsecrets);
-use FS::Record;
-use FS::cust_main_county;
-use FS::raddb;
-use FS::part_bill_event;
-
-die "Not running uid freeside!" unless checkeuid();
-
-my %attrib2db =
- map { lc($FS::raddb::attrib{$_}) => $_ } keys %FS::raddb::attrib;
-
-getopts("s");
-my $user = shift or die &usage;
-getsecrets($user);
-
-#needs to match FS::Record
-my($dbdef_file) = "/usr/local/etc/freeside/dbdef.". datasrc;
-
-###
-
-#print "\nEnter the maximum username length: ";
-#my($username_len)=&getvalue;
-my $username_len = 32; #usernamemax config file
-
-#print "\n\n", <<END, ":";
-#Freeside tracks the RADIUS User-Name, check attribute Password and
-#reply attribute Framed-IP-Address for each user. You can specify additional
-#check and reply attributes (or you can add them later with the
-#fs-radius-add-check and fs-radius-add-reply programs).
-#
-#First enter any additional RADIUS check attributes you need to track for each
-#user, separated by whitespace.
-#END
-#my @check_attributes = map { $attrib2db{lc($_)} or die "unknown attribute $_"; }
-# split(" ",&getvalue);
-#
-#print "\n\n", <<END, ":";
-#Now enter any additional reply attributes you need to track for each user,
-#separated by whitespace.
-#END
-#my @attributes = map { $attrib2db{lc($_)} or die "unknown attribute $_"; }
-# split(" ",&getvalue);
-#
-#print "\n\n", <<END, ":";
-#Do you wish to enable the tracking of a second, separate shipping/service
-#address?
-#END
-#my $ship = &_yesno;
-#
-#sub getvalue {
-# my($x)=scalar(<STDIN>);
-# chop $x;
-# $x;
-#}
-#
-#sub _yesno {
-# print " [y/N]:";
-# my $x = scalar(<STDIN>);
-# $x =~ /^y/i;
-#}
-
-my @check_attributes = (); #add later
-my @attributes = (); #add later
-my $ship = $opt_s;
-
-###
-
-my($char_d) = 80; #default maxlength for text fields
-
-#my(@date_type) = ( 'timestamp', '', '' );
-my(@date_type) = ( 'int', 'NULL', '' );
-my(@perl_type) = ( 'text', 'NULL', '' );
-my @money_type = ( 'decimal', '', '10,2' );
-
-###
-# create a dbdef object from the old data structure
-###
-
-my(%tables)=&tables_hash_hack;
-
-#turn it into objects
-my($dbdef) = new DBIx::DBSchema ( map {
- my(@columns);
- while (@{$tables{$_}{'columns'}}) {
- my($name,$type,$null,$length)=splice @{$tables{$_}{'columns'}}, 0, 4;
- push @columns, new DBIx::DBSchema::Column ( $name,$type,$null,$length );
- }
- DBIx::DBSchema::Table->new(
- $_,
- $tables{$_}{'primary_key'},
- DBIx::DBSchema::ColGroup::Unique->new($tables{$_}{'unique'}),
- DBIx::DBSchema::ColGroup::Index->new($tables{$_}{'index'}),
- @columns,
- );
-} (keys %tables) );
-
-my $cust_main = $dbdef->table('cust_main');
-unless ($ship) { #remove ship_ from cust_main
- $cust_main->delcolumn($_) foreach ( grep /^ship_/, $cust_main->columns );
-} else { #add indices
- push @{$cust_main->index->lol_ref},
- map { [ "ship_$_" ] } qw( last company daytime night fax );
-}
-
-#add radius attributes to svc_acct
-
-my($svc_acct)=$dbdef->table('svc_acct');
-
-my($attribute);
-foreach $attribute (@attributes) {
- $svc_acct->addcolumn ( new DBIx::DBSchema::Column (
- 'radius_'. $attribute,
- 'varchar',
- 'NULL',
- $char_d,
- ));
-}
-
-foreach $attribute (@check_attributes) {
- $svc_acct->addcolumn( new DBIx::DBSchema::Column (
- 'rc_'. $attribute,
- 'varchar',
- 'NULL',
- $char_d,
- ));
-}
-
-#create history tables (false laziness w/create-history-tables)
-foreach my $table ( grep { ! /^h_/ } $dbdef->tables ) {
- my $tableobj = $dbdef->table($table)
- or die "unknown table $table";
-
- die "unique->lol_ref undefined for $table"
- unless defined $tableobj->unique->lol_ref;
- die "index->lol_ref undefined for $table"
- unless defined $tableobj->index->lol_ref;
-
- my $h_tableobj = DBIx::DBSchema::Table->new( {
- name => "h_$table",
- primary_key => 'historynum',
- unique => DBIx::DBSchema::ColGroup::Unique->new( [] ),
- 'index' => DBIx::DBSchema::ColGroup::Index->new( [
- @{$tableobj->unique->lol_ref},
- @{$tableobj->index->lol_ref}
- ] ),
- columns => [
- DBIx::DBSchema::Column->new( {
- 'name' => 'historynum',
- 'type' => 'serial',
- 'null' => 'NOT NULL',
- 'length' => '',
- 'default' => '',
- 'local' => '',
- } ),
- DBIx::DBSchema::Column->new( {
- 'name' => 'history_date',
- 'type' => 'int',
- 'null' => 'NULL',
- 'length' => '',
- 'default' => '',
- 'local' => '',
- } ),
- DBIx::DBSchema::Column->new( {
- 'name' => 'history_user',
- 'type' => 'varchar',
- 'null' => 'NOT NULL',
- 'length' => '80',
- 'default' => '',
- 'local' => '',
- } ),
- DBIx::DBSchema::Column->new( {
- 'name' => 'history_action',
- 'type' => 'varchar',
- 'null' => 'NOT NULL',
- 'length' => '80',
- 'default' => '',
- 'local' => '',
- } ),
- map {
- my $column = $tableobj->column($_);
-
- #clone so as to not disturb the original
- $column = DBIx::DBSchema::Column->new( {
- map { $_ => $column->$_() }
- qw( name type null length default local )
- } );
-
- $column->type('int')
- if $column->type eq 'serial';
- #$column->default('')
- # if $column->default =~ /^nextval\(/i;
- #( my $local = $column->local ) =~ s/AUTO_INCREMENT//i;
- #$column->local($local);
- $column;
- } $tableobj->columns
- ],
- } );
- $dbdef->addtable($h_tableobj);
-}
-
-#important
-$dbdef->save($dbdef_file);
-&FS::Record::reload_dbdef($dbdef_file);
-
-###
-# create 'em
-###
-
-my($dbh)=adminsuidsetup $user;
-
-#create tables
-$|=1;
-
-foreach my $statement ( $dbdef->sql($dbh) ) {
- $dbh->do( $statement )
- or die "CREATE error: ". $dbh->errstr. "\ndoing statement: $statement";
-}
-
-#cust_main_county
-foreach my $country ( sort map uc($_), all_country_codes ) {
-
- my $subcountry = eval { new Locale::SubCountry($country) };
- my @states = $subcountry ? $subcountry->all_codes : undef;
-
- if ( !scalar(@states) || ( scalar(@states) == 1 && !defined($states[0]) ) ) {
-
- my $cust_main_county = new FS::cust_main_county({
- 'tax' => 0,
- 'country' => $country,
- });
- my $error = $cust_main_county->insert;
- die $error if $error;
-
- } else {
-
- if ( $states[0] =~ /^(\d+|\w)$/ ) {
- @states = map $subcountry->full_name($_), @states
- }
-
- foreach my $state ( @states ) {
-
- my $cust_main_county = new FS::cust_main_county({
- 'state' => $state,
- 'tax' => 0,
- 'country' => $country,
- });
- my $error = $cust_main_county->insert;
- die $error if $error;
-
- }
-
- }
-}
-
-#billing events
-foreach my $aref (
- [ 'COMP', 'Comp invoice', '$cust_bill->comp();', 30, 'comp' ],
- [ 'CARD', 'Batch card', '$cust_bill->batch_card();', 40, 'batch-card' ],
- [ 'BILL', 'Send invoice', '$cust_bill->send();', 50, 'send' ],
- [ 'DCRD', 'Send invoice', '$cust_bill->send();', 50, 'send' ],
- [ 'DCHK', 'Send invoice', '$cust_bill->send();', 50, 'send' ],
-) {
-
- my $part_bill_event = new FS::part_bill_event({
- 'payby' => $aref->[0],
- 'event' => $aref->[1],
- 'eventcode' => $aref->[2],
- 'seconds' => 0,
- 'weight' => $aref->[3],
- 'plan' => $aref->[4],
- });
- my($error);
- $error=$part_bill_event->insert;
- die $error if $error;
-
-}
-
-$dbh->commit or die $dbh->errstr;
-$dbh->disconnect or die $dbh->errstr;
-
-#print "Freeside database initialized sucessfully\n";
-
-sub usage {
- die "Usage:\n freeside-setup [ -s ] user\n";
-}
-
-###
-# Now it becomes an object. much better.
-###
-sub tables_hash_hack {
-
- #note that s/(date|change)/_$1/; to avoid keyword conflict.
- #put a kludge in FS::Record to catch this or? (pry need some date-handling
- #stuff anyway also)
-
- my(%tables)=( #yech.}
-
- 'agent' => {
- 'columns' => [
- 'agentnum', 'serial', '', '',
- 'agent', 'varchar', '', $char_d,
- 'typenum', 'int', '', '',
- 'freq', 'int', 'NULL', '',
- 'prog', @perl_type,
- 'disabled', 'char', 'NULL', 1,
- 'username', 'varchar', 'NULL', $char_d,
- '_password','varchar', 'NULL', $char_d,
- ],
- 'primary_key' => 'agentnum',
- 'unique' => [],
- 'index' => [ ['typenum'], ['disabled'] ],
- },
-
- 'agent_type' => {
- 'columns' => [
- 'typenum', 'serial', '', '',
- 'atype', 'varchar', '', $char_d,
- ],
- 'primary_key' => 'typenum',
- 'unique' => [],
- 'index' => [],
- },
-
- 'type_pkgs' => {
- 'columns' => [
- 'typenum', 'int', '', '',
- 'pkgpart', 'int', '', '',
- ],
- 'primary_key' => '',
- 'unique' => [ ['typenum', 'pkgpart'] ],
- 'index' => [ ['typenum'] ],
- },
-
- 'cust_bill' => {
- 'columns' => [
- 'invnum', 'serial', '', '',
- 'custnum', 'int', '', '',
- '_date', @date_type,
- 'charged', @money_type,
- 'printed', 'int', '', '',
- 'closed', 'char', 'NULL', 1,
- ],
- 'primary_key' => 'invnum',
- 'unique' => [],
- 'index' => [ ['custnum'], ['_date'] ],
- },
-
- 'cust_bill_event' => {
- 'columns' => [
- 'eventnum', 'serial', '', '',
- 'invnum', 'int', '', '',
- 'eventpart', 'int', '', '',
- '_date', @date_type,
- 'status', 'varchar', '', $char_d,
- 'statustext', 'text', 'NULL', '',
- ],
- 'primary_key' => 'eventnum',
- #no... there are retries now #'unique' => [ [ 'eventpart', 'invnum' ] ],
- 'unique' => [],
- 'index' => [ ['invnum'], ['status'] ],
- },
-
- 'part_bill_event' => {
- 'columns' => [
- 'eventpart', 'serial', '', '',
- 'payby', 'char', '', 4,
- 'event', 'varchar', '', $char_d,
- 'eventcode', @perl_type,
- 'seconds', 'int', 'NULL', '',
- 'weight', 'int', '', '',
- 'plan', 'varchar', 'NULL', $char_d,
- 'plandata', 'text', 'NULL', '',
- 'disabled', 'char', 'NULL', 1,
- ],
- 'primary_key' => 'eventpart',
- 'unique' => [],
- 'index' => [ ['payby'], ['disabled'], ],
- },
-
- 'cust_bill_pkg' => {
- 'columns' => [
- 'pkgnum', 'int', '', '',
- 'invnum', 'int', '', '',
- 'setup', @money_type,
- 'recur', @money_type,
- 'sdate', @date_type,
- 'edate', @date_type,
- 'itemdesc', 'varchar', 'NULL', $char_d,
- ],
- 'primary_key' => '',
- 'unique' => [],
- 'index' => [ ['invnum'] ],
- },
-
- 'cust_bill_pkg_detail' => {
- 'columns' => [
- 'detailnum', 'serial', '', '',
- 'pkgnum', 'int', '', '',
- 'invnum', 'int', '', '',
- 'detail', 'varchar', '', $char_d,
- ],
- 'primary_key' => 'detailnum',
- 'unique' => [],
- 'index' => [ [ 'pkgnum', 'invnum' ] ],
- },
-
- 'cust_credit' => {
- 'columns' => [
- 'crednum', 'serial', '', '',
- 'custnum', 'int', '', '',
- '_date', @date_type,
- 'amount', @money_type,
- 'otaker', 'varchar', '', 32,
- 'reason', 'text', 'NULL', '',
- 'closed', 'char', 'NULL', 1,
- ],
- 'primary_key' => 'crednum',
- 'unique' => [],
- 'index' => [ ['custnum'] ],
- },
-
- 'cust_credit_bill' => {
- 'columns' => [
- 'creditbillnum', 'serial', '', '',
- 'crednum', 'int', '', '',
- 'invnum', 'int', '', '',
- '_date', @date_type,
- 'amount', @money_type,
- ],
- 'primary_key' => 'creditbillnum',
- 'unique' => [],
- 'index' => [ ['crednum'], ['invnum'] ],
- },
-
- 'cust_main' => {
- 'columns' => [
- 'custnum', 'serial', '', '',
- 'agentnum', 'int', '', '',
-# 'titlenum', 'int', 'NULL', '',
- 'last', 'varchar', '', $char_d,
-# 'middle', 'varchar', 'NULL', $char_d,
- 'first', 'varchar', '', $char_d,
- 'ss', 'varchar', 'NULL', 11,
- 'company', 'varchar', 'NULL', $char_d,
- 'address1', 'varchar', '', $char_d,
- 'address2', 'varchar', 'NULL', $char_d,
- 'city', 'varchar', '', $char_d,
- 'county', 'varchar', 'NULL', $char_d,
- 'state', 'varchar', 'NULL', $char_d,
- 'zip', 'varchar', '', 10,
- 'country', 'char', '', 2,
- 'daytime', 'varchar', 'NULL', 20,
- 'night', 'varchar', 'NULL', 20,
- 'fax', 'varchar', 'NULL', 12,
- 'ship_last', 'varchar', 'NULL', $char_d,
-# 'ship_middle', 'varchar', 'NULL', $char_d,
- 'ship_first', 'varchar', 'NULL', $char_d,
- 'ship_company', 'varchar', 'NULL', $char_d,
- 'ship_address1', 'varchar', 'NULL', $char_d,
- 'ship_address2', 'varchar', 'NULL', $char_d,
- 'ship_city', 'varchar', 'NULL', $char_d,
- 'ship_county', 'varchar', 'NULL', $char_d,
- 'ship_state', 'varchar', 'NULL', $char_d,
- 'ship_zip', 'varchar', 'NULL', 10,
- 'ship_country', 'char', 'NULL', 2,
- 'ship_daytime', 'varchar', 'NULL', 20,
- 'ship_night', 'varchar', 'NULL', 20,
- 'ship_fax', 'varchar', 'NULL', 12,
- 'payby', 'char', '', 4,
- 'payinfo', 'varchar', 'NULL', $char_d,
- 'paycvv', 'varchar', 'NULL', 4,
- #'paydate', @date_type,
- 'paydate', 'varchar', 'NULL', 10,
- 'payname', 'varchar', 'NULL', $char_d,
- 'tax', 'char', 'NULL', 1,
- 'otaker', 'varchar', '', 32,
- 'refnum', 'int', '', '',
- 'referral_custnum', 'int', 'NULL', '',
- 'comments', 'text', 'NULL', '',
- ],
- 'primary_key' => 'custnum',
- 'unique' => [],
- #'index' => [ ['last'], ['company'] ],
- 'index' => [ ['last'], [ 'company' ], [ 'referral_custnum' ],
- [ 'daytime' ], [ 'night' ], [ 'fax' ],
- ],
- },
-
- 'cust_main_invoice' => {
- 'columns' => [
- 'destnum', 'serial', '', '',
- 'custnum', 'int', '', '',
- 'dest', 'varchar', '', $char_d,
- ],
- 'primary_key' => 'destnum',
- 'unique' => [],
- 'index' => [ ['custnum'], ],
- },
-
- 'cust_main_county' => { #county+state+country are checked off the
- #cust_main_county for validation and to provide
- # a tax rate.
- 'columns' => [
- 'taxnum', 'serial', '', '',
- 'state', 'varchar', 'NULL', $char_d,
- 'county', 'varchar', 'NULL', $char_d,
- 'country', 'char', '', 2,
- 'taxclass', 'varchar', 'NULL', $char_d,
- 'exempt_amount', @money_type,
- 'tax', 'real', '', '', #tax %
- 'taxname', 'varchar', 'NULL', $char_d,
- 'setuptax', 'char', 'NULL', 1, # Y = setup tax exempt
- 'recurtax', 'char', 'NULL', 1, # Y = recur tax exempt
- ],
- 'primary_key' => 'taxnum',
- 'unique' => [],
- # 'unique' => [ ['taxnum'], ['state', 'county'] ],
- 'index' => [],
- },
-
- 'cust_pay' => {
- 'columns' => [
- 'paynum', 'serial', '', '',
- #now cust_bill_pay #'invnum', 'int', '', '',
- 'custnum', 'int', '', '',
- 'paid', @money_type,
- '_date', @date_type,
- 'payby', 'char', '', 4, # CARD/BILL/COMP, should be index into
- # payment type table.
- 'payinfo', 'varchar', 'NULL', $char_d, #see cust_main above
- 'paybatch', 'varchar', 'NULL', $char_d, #for auditing purposes.
- 'closed', 'char', 'NULL', 1,
- ],
- 'primary_key' => 'paynum',
- 'unique' => [],
- 'index' => [ [ 'custnum' ], [ 'paybatch' ], [ 'payby' ], [ '_date' ] ],
- },
-
- 'cust_bill_pay' => {
- 'columns' => [
- 'billpaynum', 'serial', '', '',
- 'invnum', 'int', '', '',
- 'paynum', 'int', '', '',
- 'amount', @money_type,
- '_date', @date_type
- ],
- 'primary_key' => 'billpaynum',
- 'unique' => [],
- 'index' => [ [ 'paynum' ], [ 'invnum' ] ],
- },
-
- 'cust_pay_batch' => { #what's this used for again? list of customers
- #in current CARD batch? (necessarily CARD?)
- 'columns' => [
- 'paybatchnum', 'serial', '', '',
- 'invnum', 'int', '', '',
- 'custnum', 'int', '', '',
- 'last', 'varchar', '', $char_d,
- 'first', 'varchar', '', $char_d,
- 'address1', 'varchar', '', $char_d,
- 'address2', 'varchar', 'NULL', $char_d,
- 'city', 'varchar', '', $char_d,
- 'state', 'varchar', 'NULL', $char_d,
- 'zip', 'varchar', '', 10,
- 'country', 'char', '', 2,
-# 'trancode', 'int', '', '',
- 'cardnum', 'varchar', '', 16,
- #'exp', @date_type,
- 'exp', 'varchar', '', 11,
- 'payname', 'varchar', 'NULL', $char_d,
- 'amount', @money_type,
- ],
- 'primary_key' => 'paybatchnum',
- 'unique' => [],
- 'index' => [ ['invnum'], ['custnum'] ],
- },
-
- 'cust_pkg' => {
- 'columns' => [
- 'pkgnum', 'serial', '', '',
- 'custnum', 'int', '', '',
- 'pkgpart', 'int', '', '',
- 'otaker', 'varchar', '', 32,
- 'setup', @date_type,
- 'bill', @date_type,
- 'last_bill', @date_type,
- 'susp', @date_type,
- 'cancel', @date_type,
- 'expire', @date_type,
- 'manual_flag', 'char', 'NULL', 1,
- ],
- 'primary_key' => 'pkgnum',
- 'unique' => [],
- 'index' => [ ['custnum'] ],
- },
-
- 'cust_refund' => {
- 'columns' => [
- 'refundnum', 'serial', '', '',
- #now cust_credit_refund #'crednum', 'int', '', '',
- 'custnum', 'int', '', '',
- '_date', @date_type,
- 'refund', @money_type,
- 'otaker', 'varchar', '', 32,
- 'reason', 'varchar', '', $char_d,
- 'payby', 'char', '', 4, # CARD/BILL/COMP, should be index
- # into payment type table.
- 'payinfo', 'varchar', 'NULL', $char_d, #see cust_main above
- 'paybatch', 'varchar', 'NULL', $char_d,
- 'closed', 'char', 'NULL', 1,
- ],
- 'primary_key' => 'refundnum',
- 'unique' => [],
- 'index' => [],
- },
-
- 'cust_credit_refund' => {
- 'columns' => [
- 'creditrefundnum', 'serial', '', '',
- 'crednum', 'int', '', '',
- 'refundnum', 'int', '', '',
- 'amount', @money_type,
- '_date', @date_type
- ],
- 'primary_key' => 'creditrefundnum',
- 'unique' => [],
- 'index' => [ [ 'crednum', 'refundnum' ] ],
- },
-
-
- 'cust_svc' => {
- 'columns' => [
- 'svcnum', 'serial', '', '',
- 'pkgnum', 'int', 'NULL', '',
- 'svcpart', 'int', '', '',
- ],
- 'primary_key' => 'svcnum',
- 'unique' => [],
- 'index' => [ ['svcnum'], ['pkgnum'], ['svcpart'] ],
- },
-
- 'part_pkg' => {
- 'columns' => [
- 'pkgpart', 'serial', '', '',
- 'pkg', 'varchar', '', $char_d,
- 'comment', 'varchar', '', $char_d,
- 'setup', @perl_type,
- 'freq', 'varchar', '', $char_d, #billing frequency
- 'recur', @perl_type,
- 'setuptax', 'char', 'NULL', 1,
- 'recurtax', 'char', 'NULL', 1,
- 'plan', 'varchar', 'NULL', $char_d,
- 'plandata', 'text', 'NULL', '',
- 'disabled', 'char', 'NULL', 1,
- 'taxclass', 'varchar', 'NULL', $char_d,
- ],
- 'primary_key' => 'pkgpart',
- 'unique' => [],
- 'index' => [ [ 'disabled' ], ],
- },
-
-# 'part_title' => {
-# 'columns' => [
-# 'titlenum', 'int', '', '',
-# 'title', 'varchar', '', $char_d,
-# ],
-# 'primary_key' => 'titlenum',
-# 'unique' => [ [] ],
-# 'index' => [ [] ],
-# },
-
- 'pkg_svc' => {
- 'columns' => [
- 'pkgpart', 'int', '', '',
- 'svcpart', 'int', '', '',
- 'quantity', 'int', '', '',
- 'primary_svc','char', 'NULL', 1,
- ],
- 'primary_key' => '',
- 'unique' => [ ['pkgpart', 'svcpart'] ],
- 'index' => [ ['pkgpart'] ],
- },
-
- 'part_referral' => {
- 'columns' => [
- 'refnum', 'serial', '', '',
- 'referral', 'varchar', '', $char_d,
- 'disabled', 'char', 'NULL', 1,
- ],
- 'primary_key' => 'refnum',
- 'unique' => [],
- 'index' => [ ['disabled'] ],
- },
-
- 'part_svc' => {
- 'columns' => [
- 'svcpart', 'serial', '', '',
- 'svc', 'varchar', '', $char_d,
- 'svcdb', 'varchar', '', $char_d,
- 'disabled', 'char', 'NULL', 1,
- ],
- 'primary_key' => 'svcpart',
- 'unique' => [],
- 'index' => [ [ 'disabled' ] ],
- },
-
- 'part_svc_column' => {
- 'columns' => [
- 'columnnum', 'serial', '', '',
- 'svcpart', 'int', '', '',
- 'columnname', 'varchar', '', 64,
- 'columnvalue', 'varchar', 'NULL', $char_d,
- 'columnflag', 'char', 'NULL', 1,
- ],
- 'primary_key' => 'columnnum',
- 'unique' => [ [ 'svcpart', 'columnname' ] ],
- 'index' => [ [ 'svcpart' ] ],
- },
-
- #(this should be renamed to part_pop)
- 'svc_acct_pop' => {
- 'columns' => [
- 'popnum', 'serial', '', '',
- 'city', 'varchar', '', $char_d,
- 'state', 'varchar', '', $char_d,
- 'ac', 'char', '', 3,
- 'exch', 'char', '', 3,
- 'loc', 'char', 'NULL', 4, #NULL for legacy purposes
- ],
- 'primary_key' => 'popnum',
- 'unique' => [],
- 'index' => [ [ 'state' ] ],
- },
-
- 'part_pop_local' => {
- 'columns' => [
- 'localnum', 'serial', '', '',
- 'popnum', 'int', '', '',
- 'city', 'varchar', 'NULL', $char_d,
- 'state', 'char', 'NULL', 2,
- 'npa', 'char', '', 3,
- 'nxx', 'char', '', 3,
- ],
- 'primary_key' => 'localnum',
- 'unique' => [],
- 'index' => [ [ 'npa', 'nxx' ], [ 'popnum' ] ],
- },
-
- 'svc_acct' => {
- 'columns' => [
- 'svcnum', 'int', '', '',
- 'username', 'varchar', '', $username_len, #unique (& remove dup code)
- '_password', 'varchar', '', 72, #13 for encryped pw's plus ' *SUSPENDED* (md5 passwords can be 34, blowfish 60)
- 'sec_phrase', 'varchar', 'NULL', $char_d,
- 'popnum', 'int', 'NULL', '',
- 'uid', 'int', 'NULL', '',
- 'gid', 'int', 'NULL', '',
- 'finger', 'varchar', 'NULL', $char_d,
- 'dir', 'varchar', 'NULL', $char_d,
- 'shell', 'varchar', 'NULL', $char_d,
- 'quota', 'varchar', 'NULL', $char_d,
- 'slipip', 'varchar', 'NULL', 15, #four TINYINTs, bah.
- 'seconds', 'int', 'NULL', '', #uhhhh
- 'domsvc', 'int', '', '',
- ],
- 'primary_key' => 'svcnum',
- #'unique' => [ [ 'username', 'domsvc' ] ],
- 'unique' => [],
- 'index' => [ ['username'], ['domsvc'] ],
- },
-
- #'svc_charge' => {
- # 'columns' => [
- # 'svcnum', 'int', '', '',
- # 'amount', @money_type,
- # ],
- # 'primary_key' => 'svcnum',
- # 'unique' => [ [] ],
- # 'index' => [ [] ],
- #},
-
- 'svc_domain' => {
- 'columns' => [
- 'svcnum', 'int', '', '',
- 'domain', 'varchar', '', $char_d,
- 'catchall', 'int', 'NULL', '',
- ],
- 'primary_key' => 'svcnum',
- 'unique' => [ ['domain'] ],
- 'index' => [],
- },
-
- 'domain_record' => {
- 'columns' => [
- 'recnum', 'serial', '', '',
- 'svcnum', 'int', '', '',
- #'reczone', 'varchar', '', $char_d,
- 'reczone', 'varchar', '', 255,
- 'recaf', 'char', '', 2,
- 'rectype', 'varchar', '', 5,
- #'recdata', 'varchar', '', $char_d,
- 'recdata', 'varchar', '', 255,
- ],
- 'primary_key' => 'recnum',
- 'unique' => [],
- 'index' => [ ['svcnum'] ],
- },
-
- 'svc_forward' => {
- 'columns' => [
- 'svcnum', 'int', '', '',
- 'srcsvc', 'int', 'NULL', '',
- 'src', 'varchar', 'NULL', 255,
- 'dstsvc', 'int', 'NULL', '',
- 'dst', 'varchar', 'NULL', 255,
- ],
- 'primary_key' => 'svcnum',
- 'unique' => [],
- 'index' => [ ['srcsvc'], ['dstsvc'] ],
- },
-
- 'svc_www' => {
- 'columns' => [
- 'svcnum', 'int', '', '',
- 'recnum', 'int', '', '',
- 'usersvc', 'int', '', '',
- ],
- 'primary_key' => 'svcnum',
- 'unique' => [],
- 'index' => [],
- },
-
- #'svc_wo' => {
- # 'columns' => [
- # 'svcnum', 'int', '', '',
- # 'svcnum', 'int', '', '',
- # 'svcnum', 'int', '', '',
- # 'worker', 'varchar', '', $char_d,
- # '_date', @date_type,
- # ],
- # 'primary_key' => 'svcnum',
- # 'unique' => [ [] ],
- # 'index' => [ [] ],
- #},
-
- 'prepay_credit' => {
- 'columns' => [
- 'prepaynum', 'serial', '', '',
- 'identifier', 'varchar', '', $char_d,
- 'amount', @money_type,
- 'seconds', 'int', 'NULL', '',
- ],
- 'primary_key' => 'prepaynum',
- 'unique' => [ ['identifier'] ],
- 'index' => [],
- },
-
- 'port' => {
- 'columns' => [
- 'portnum', 'serial', '', '',
- 'ip', 'varchar', 'NULL', 15,
- 'nasport', 'int', 'NULL', '',
- 'nasnum', 'int', '', '',
- ],
- 'primary_key' => 'portnum',
- 'unique' => [],
- 'index' => [],
- },
-
- 'nas' => {
- 'columns' => [
- 'nasnum', 'serial', '', '',
- 'nas', 'varchar', '', $char_d,
- 'nasip', 'varchar', '', 15,
- 'nasfqdn', 'varchar', '', $char_d,
- 'last', 'int', '', '',
- ],
- 'primary_key' => 'nasnum',
- 'unique' => [ [ 'nas' ], [ 'nasip' ] ],
- 'index' => [ [ 'last' ] ],
- },
-
- 'session' => {
- 'columns' => [
- 'sessionnum', 'serial', '', '',
- 'portnum', 'int', '', '',
- 'svcnum', 'int', '', '',
- 'login', @date_type,
- 'logout', @date_type,
- ],
- 'primary_key' => 'sessionnum',
- 'unique' => [],
- 'index' => [ [ 'portnum' ] ],
- },
-
- 'queue' => {
- 'columns' => [
- 'jobnum', 'serial', '', '',
- 'job', 'text', '', '',
- '_date', 'int', '', '',
- 'status', 'varchar', '', $char_d,
- 'statustext', 'text', 'NULL', '',
- 'svcnum', 'int', 'NULL', '',
- ],
- 'primary_key' => 'jobnum',
- 'unique' => [],
- 'index' => [ [ 'svcnum' ], [ 'status' ] ],
- },
-
- 'queue_arg' => {
- 'columns' => [
- 'argnum', 'serial', '', '',
- 'jobnum', 'int', '', '',
- 'arg', 'text', 'NULL', '',
- ],
- 'primary_key' => 'argnum',
- 'unique' => [],
- 'index' => [ [ 'jobnum' ] ],
- },
-
- 'queue_depend' => {
- 'columns' => [
- 'dependnum', 'serial', '', '',
- 'jobnum', 'int', '', '',
- 'depend_jobnum', 'int', '', '',
- ],
- 'primary_key' => 'dependnum',
- 'unique' => [],
- 'index' => [ [ 'jobnum' ], [ 'depend_jobnum' ] ],
- },
-
- 'export_svc' => {
- 'columns' => [
- 'exportsvcnum' => 'serial', '', '',
- 'exportnum' => 'int', '', '',
- 'svcpart' => 'int', '', '',
- ],
- 'primary_key' => 'exportsvcnum',
- 'unique' => [ [ 'exportnum', 'svcpart' ] ],
- 'index' => [ [ 'exportnum' ], [ 'svcpart' ] ],
- },
-
- 'part_export' => {
- 'columns' => [
- 'exportnum', 'serial', '', '',
- #'svcpart', 'int', '', '',
- 'machine', 'varchar', '', $char_d,
- 'exporttype', 'varchar', '', $char_d,
- 'nodomain', 'char', 'NULL', 1,
- ],
- 'primary_key' => 'exportnum',
- 'unique' => [],
- 'index' => [ [ 'machine' ], [ 'exporttype' ] ],
- },
-
- 'part_export_option' => {
- 'columns' => [
- 'optionnum', 'serial', '', '',
- 'exportnum', 'int', '', '',
- 'optionname', 'varchar', '', $char_d,
- 'optionvalue', 'text', 'NULL', '',
- ],
- 'primary_key' => 'optionnum',
- 'unique' => [],
- 'index' => [ [ 'exportnum' ], [ 'optionname' ] ],
- },
-
- 'radius_usergroup' => {
- 'columns' => [
- 'usergroupnum', 'serial', '', '',
- 'svcnum', 'int', '', '',
- 'groupname', 'varchar', '', $char_d,
- ],
- 'primary_key' => 'usergroupnum',
- 'unique' => [],
- 'index' => [ [ 'svcnum' ], [ 'groupname' ] ],
- },
-
- 'msgcat' => {
- 'columns' => [
- 'msgnum', 'serial', '', '',
- 'msgcode', 'varchar', '', $char_d,
- 'locale', 'varchar', '', 16,
- 'msg', 'text', '', '',
- ],
- 'primary_key' => 'msgnum',
- 'unique' => [ [ 'msgcode', 'locale' ] ],
- 'index' => [],
- },
-
- 'cust_tax_exempt' => {
- 'columns' => [
- 'exemptnum', 'serial', '', '',
- 'custnum', 'int', '', '',
- 'taxnum', 'int', '', '',
- 'year', 'int', '', '',
- 'month', 'int', '', '',
- 'amount', @money_type,
- ],
- 'primary_key' => 'exemptnum',
- 'unique' => [ [ 'custnum', 'taxnum', 'year', 'month' ] ],
- 'index' => [],
- },
-
- 'router' => {
- 'columns' => [
- 'routernum', 'serial', '', '',
- 'routername', 'varchar', '', $char_d,
- 'svcnum', 'int', 'NULL', '',
- ],
- 'primary_key' => 'routernum',
- 'unique' => [],
- 'index' => [],
- },
-
- 'part_svc_router' => {
- 'columns' => [
- 'svcpart', 'int', '', '',
- 'routernum', 'int', '', '',
- ],
- 'primary_key' => '',
- 'unique' => [],
- 'index' => [],
- },
-
- 'addr_block' => {
- 'columns' => [
- 'blocknum', 'serial', '', '',
- 'routernum', 'int', '', '',
- 'ip_gateway', 'varchar', '', 15,
- 'ip_netmask', 'int', '', '',
- ],
- 'primary_key' => 'blocknum',
- 'unique' => [ [ 'blocknum', 'routernum' ] ],
- 'index' => [],
- },
-
- 'svc_broadband' => {
- 'columns' => [
- 'svcnum', 'int', '', '',
- 'blocknum', 'int', '', '',
- 'speed_up', 'int', '', '',
- 'speed_down', 'int', '', '',
- 'ip_addr', 'varchar', '', 15,
- ],
- 'primary_key' => 'svcnum',
- 'unique' => [],
- 'index' => [],
- },
-
- 'part_virtual_field' => {
- 'columns' => [
- 'vfieldpart', 'int', '', '',
- 'dbtable', 'varchar', '', 32,
- 'name', 'varchar', '', 32,
- 'check_block', 'text', 'NULL', '',
- 'length', 'int', 'NULL', '',
- 'list_source', 'text', 'NULL', '',
- 'label', 'varchar', 'NULL', 80,
- ],
- 'primary_key' => 'vfieldpart',
- 'unique' => [],
- 'index' => [],
- },
-
- 'virtual_field' => {
- 'columns' => [
- 'recnum', 'int', '', '',
- 'vfieldpart', 'int', '', '',
- 'value', 'varchar', '', 128,
- ],
- 'primary_key' => '',
- 'unique' => [ [ 'vfieldpart', 'recnum' ] ],
- 'index' => [],
- },
-
- 'acct_snarf' => {
- 'columns' => [
- 'snarfnum', 'int', '', '',
- 'svcnum', 'int', '', '',
- 'machine', 'varchar', '', 255,
- 'protocol', 'varchar', '', $char_d,
- 'username', 'varchar', '', $char_d,
- '_password', 'varchar', '', $char_d,
- ],
- 'primary_key' => 'snarfnum',
- 'unique' => [],
- 'index' => [ [ 'svcnum' ] ],
- },
-
- 'svc_external' => {
- 'columns' => [
- 'svcnum', 'int', '', '',
- 'id', 'int', '', '',
- 'title', 'varchar', 'NULL', $char_d,
- ],
- 'primary_key' => 'svcnum',
- 'unique' => [],
- 'index' => [],
- },
-
- );
-
- %tables;
-
-}
-
diff --git a/FS/bin/freeside-sqlradius-radacctd b/FS/bin/freeside-sqlradius-radacctd
deleted file mode 100644
index 4e8d57c..0000000
--- a/FS/bin/freeside-sqlradius-radacctd
+++ /dev/null
@@ -1,180 +0,0 @@
-#!/usr/bin/perl -Tw
-
-use strict;
-use vars qw( $log_file $sigterm $sigint );
-use subs qw( _die _logmsg );
-use Fcntl qw(:flock);
-use POSIX qw(setsid);
-use Date::Format;
-use IO::File;
-use FS::UID qw(adminsuidsetup);
-#use FS::Record qw(qsearch qsearchs);
-#use FS::part_export;
-#use FS::svc_acct;
-#use FS::cust_svc;
-
-#lots of false laziness w/freeside-queued
-
-my $user = shift or die &usage;
-
-#my $pid_file = "/var/run/freeside-sqlradius-radacctd.$user.pid";
-my $pid_file = "/var/run/freeside-sqlradius-radacctd.pid";
-
-&daemonize1;
-
-#sub REAPER { my $pid = wait; $SIG{CHLD} = \&REAPER; $kids--; }
-#$SIG{CHLD} = \&REAPER;
-
-$sigterm = 0;
-$sigint = 0;
-$SIG{INT} = sub { warn "SIGINT received; shutting down\n"; $sigint++; };
-$SIG{TERM} = sub { warn "SIGTERM received; shutting down\n"; $sigterm++; };
-
-my $freeside_gid = scalar(getgrnam('freeside'))
- or die "can't setgid to freeside group\n";
-$) = $freeside_gid;
-$( = $freeside_gid;
-#if freebsd can't setuid(), presumably it can't setgid() either. grr fleabsd
-($(,$)) = ($),$();
-$) = $freeside_gid;
-
-$> = $FS::UID::freeside_uid;
-$< = $FS::UID::freeside_uid;
-#freebsd is sofa king broken, won't setuid()
-($<,$>) = ($>,$<);
-$> = $FS::UID::freeside_uid;
-
-#$ENV{HOME} = (getpwuid($>))[7]; #for ssh
-adminsuidsetup $user;
-
-$log_file= "/usr/local/etc/freeside/sqlradius-radacctd-log.". $FS::UID::datasrc;
-
-&daemonize2;
-
-$SIG{__DIE__} = \&_die;
-$SIG{__WARN__} = \&_logmsg;
-
-warn "freeside-sqlradius-radacctd starting\n";
-
-#eslaf
-
-#my $machine = shift or die &usage; #would need to be up higher for real
-my @exports = qsearch('part_export', { 'exporttype' => 'sqlradius' } );
-
-while (1) {
-
- my %seen = ();
- foreach my $export ( @exports ) {
- next if $seen{$export->option('datasrc')}++;
- my $dbh = DBI->connect(
- map { $export->option($_) } qw( datasrc username password )
- ) or do {
- warn "can't connect to ". $export->option('datasrc'). ": ". $DBI::errstr;
- next;
- }
-
- # find old radacct position
- #$lastid = 0;
-
- # get new radacct records
- my $sth = $dbh->prepare('SELECT * FROM radacct WHERE radacctid > ?') or do {
- warn "can't select in radacct table from ". $export->option('datasrc').
- ": ". $dbh->errstr;
- next;
- };
-
- while ( my $radacct = $sth->fetchrow_arrayref({}) ) {
-
- my $session = new FS::session {
- portnum =>
- svcnum =>
- login =>
- #logout =>
- };
-
- }
-
- # look for updated radacct records & replace them
-
- }
-
- sleep 5;
-
-}
-
-#more false laziness w/freeside-queued
-
-sub usage {
- die "Usage:\n\n freeside-sqlradius-radacctd user\n";
-}
-
-sub _die {
- my $msg = shift;
- unlink $pid_file if -e $pid_file;
- _logmsg($msg);
-}
-
-sub _logmsg {
- chomp( my $msg = shift );
- my $log = new IO::File ">>$log_file";
- flock($log, LOCK_EX);
- seek($log, 0, 2);
- print $log "[". time2str("%a %b %e %T %Y",time). "] [$$] $msg\n";
- flock($log, LOCK_UN);
- close $log;
-}
-
-sub daemonize1 {
-
- chdir "/" or die "Can't chdir to /: $!";
- open STDIN, '/dev/null' or die "Can't read /dev/null: $!";
- defined(my $pid = fork) or die "Can't fork: $!";
- if ( $pid ) {
- print "freeside-sqlradius-radacctd started with pid $pid\n";
- #logging to $log_file\n";
- exit unless $pid_file;
- my $pidfh = new IO::File ">$pid_file" or exit;
- print $pidfh "$pid\n";
- exit;
- }
- #open STDOUT, '>/dev/null'
- # or die "Can't write to /dev/null: $!";
- #setsid or die "Can't start a new session: $!";
- #open STDERR, '>&STDOUT' or die "Can't dup stdout: $!";
-
-}
-
-sub daemonize2 {
- open STDOUT, '>/dev/null'
- or die "Can't write to /dev/null: $!";
- setsid or die "Can't start a new session: $!";
- open STDERR, '>&STDOUT' or die "Can't dup stdout: $!";
-}
-
-
-#eslaf
-
-=head1 NAME
-
-freeside-sqlradius-radacctd - Real-time radacct import daemon
-
-=head1 SYNOPSIS
-
- freeside-sqlradius-radacctd username
-
-=head1 DESCRIPTION
-
-Imports records from an SQL radacct table in real-time into the session
-monitor.
-
-This enables per-minute or per-hour charges as well as the
-"View active NAS ports" function.
-
-B<username> is a username added by freeside-adduser.
-
-=head1 SEE ALSO
-
-session.html from the base documentation.
-
-=cut
-
diff --git a/FS/bin/freeside-sqlradius-reset b/FS/bin/freeside-sqlradius-reset
deleted file mode 100755
index 74f90a5..0000000
--- a/FS/bin/freeside-sqlradius-reset
+++ /dev/null
@@ -1,76 +0,0 @@
-#!/usr/bin/perl -Tw
-
-use strict;
-use FS::UID qw(adminsuidsetup);
-use FS::Record qw(qsearch qsearchs);
-use FS::part_export;
-use FS::svc_acct;
-use FS::cust_svc;
-
-my $user = shift or die &usage;
-adminsuidsetup $user;
-
-#my $machine = shift or die &usage;
-
-my @exports = qsearch('part_export', { exporttype=>'sqlradius' } );
-push @exports, qsearch('part_export', { exporttype=>'sqlradius_withdomain' } );
-
-
-foreach my $export ( @exports ) {
- my $icradius_dbh = DBI->connect(
- map { $export->option($_) } qw( datasrc username password )
- ) or die $DBI::errstr;
- for my $table (qw( radcheck radreply usergroup )) {
- my $sth = $icradius_dbh->prepare("DELETE FROM $table");
- $sth->execute or die "Can't reset $table table: ". $sth->errstr;
- }
- $icradius_dbh->disconnect;
-}
-
-foreach my $export ( @exports ) {
-
- #my @svcparts = map { $_->svcpart } $export->export_svc;
-
- my @svc_acct =
- map { qsearchs('svc_acct', { 'svcnum' => $_->svcnum } ) }
- map { qsearch('cust_svc', { 'svcpart' => $_->svcpart } ) }
- grep { qsearch('cust_svc', { 'svcpart' => $_->svcpart } ) }
- $export->export_svc;
-
- foreach my $svc_acct ( @svc_acct ) {
-
- #false laziness with FS::svc_acct::insert (like it matters)
- my $error = $export->export_insert($svc_acct);
- die $error if $error;
-
- }
-}
-
-sub usage {
- #die "Usage:\n\n sqlradius_reset user machine\n";
- die "Usage:\n\n freeside-sqlradius-reset user\n";
-}
-
-=head1 NAME
-
-freeside-sqlradius-reset - Command line interface to reset and recreate RADIUS SQL tables
-
-=head1 SYNOPSIS
-
- freeside-sqlradius-reset username
-
-=head1 DESCRIPTION
-
-Deletes the radcheck, radreply and usergroup tables and repopulates them from
-the Freeside database, for all sqlradius exports.
-
-B<username> is a username added by freeside-adduser.
-
-=head1 SEE ALSO
-
-L<freeside-reexport>, L<FS::part_export>, L<FS::part_export::sqlradius>
-
-=cut
-
-
-
diff --git a/FS/bin/freeside-sqlradius-seconds b/FS/bin/freeside-sqlradius-seconds
deleted file mode 100644
index 1c978fa..0000000
--- a/FS/bin/freeside-sqlradius-seconds
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/usr/bin/perl -Tw
-
-use strict;
-use Date::Parse;
-use FS::UID qw(adminsuidsetup);
-use FS::Record qw(qsearchs);
-use FS::svc_acct;
-
-my $fs_user = shift or die &usage;
-adminsuidsetup( $fs_user );
-
-my $target_user = shift or die &usage;
-my $start = shift or die &usage;
-$start = str2time($start);
-my $stop = scalar(@ARGV) ? str2time(shift) : time;
-
-my $svc_acct = qsearchs( 'svc_acct', { 'username' => $target_user } );
-die "username $target_user not found\n" unless $svc_acct;
-
-print $svc_acct->seconds_since_sqlradacct( $start, $stop ). "\n";
-
-sub usage {
- die "Usage:\n\n freeside-sqlradius-seconds freeside_username target_username start_date stop_date\n";
-}
-
-
-=head1 NAME
-
-freeside-sqlradius-seconds - Real-time radacct import daemon
-
-=head1 SYNOPSIS
-
- freeside-sqlradius-seconds freeside_username target_username start_date [ stop_date ]
-
-=head1 DESCRIPTION
-
-Returns the number of seconds the specified username has been online between
-start_date (inclusive) and stop_date (exclusive).
-See L<FS::svc_acct/seconds_since_sqlradacct>
-
-B<freeside_username> is a username added by freeside-adduser.
-B<target_username> is the username of the user account to query.
-B<start_date> and B<stop_date> are in any format Date::Parse is happy with.
-B<stop_date> defaults to now if not specified.
-
-=head1 BUGS
-
-Selection of the account in question is rather simplistic in that
-B<target_username> doesn't necessarily identify a unique account (and wouldn't
-even if a domain was specified), and no sqlradius export is checked for.
-
-=head1 SEE ALSO
-
-L<FS::svc_acct/seconds_since_sqlradacct>
-
-=cut
-
-1;
diff --git a/FS/bin/freeside-tax-report b/FS/bin/freeside-tax-report
deleted file mode 100755
index 240f3ad..0000000
--- a/FS/bin/freeside-tax-report
+++ /dev/null
@@ -1,292 +0,0 @@
-#!/usr/bin/perl -Tw
-
-
-use strict;
-use Date::Parse;
-use Time::Local;
-use Getopt::Std;
-use Text::Template;
-use Net::SMTP;
-use Mail::Header;
-use Mail::Internet;
-use FS::Conf;
-use FS::UID qw(adminsuidsetup);
-use FS::Record qw(qsearch);
-use FS::cust_bill;
-use FS::cust_bill_pay;
-use FS::cust_pay;
-
-
-&untaint_argv; #what it sounds like (eww)
-use vars qw($opt_v $opt_p $opt_m $opt_e $opt_t $opt_s $opt_f $report_lines $report_template @buf $header);
-getopts("vpmef:s:"); #switches
-
-#we're at now now (and later).
-my($_finishdate)= $opt_f ? str2time($main::opt_f) : $^T;
-my($_startdate)= $opt_s ? str2time($main::opt_s) : $^T;
-
-# Get the current month
-my ($ssec,$smin,$shour,$smday,$smon,$syear) =
- (localtime($_startdate) )[0,1,2,3,4,5];
-$smon++;
-$syear += 1900;
-
-# Get the current month
-my ($fsec,$fmin,$fhour,$fmday,$fmon,$fyear) =
- (localtime($_finishdate) )[0,1,2,3,4,5];
-$fmon++;
-$fyear += 1900;
-
-# Login to the database
-my $user = shift or die &usage;
-adminsuidsetup $user;
-
-# Get the needed configuration files
-my $conf = new FS::Conf;
-my $lpr = $conf->config('lpr');
-my $email = $conf->config('email');
-my $smtpmachine = $conf->config('smtpmachine');
-my $mail_sender = $conf->exists('invoice_from') ? $conf->config('invoice_from') :
- 'postmaster';
-my @report_template = $conf->config('report_template')
- or die "cannot load config file report_template";
-$report_lines = 0;
-foreach ( grep /report_lines\(\d+\)/, @report_template ) { #kludgy :/
- /report_lines\((\d+)\)/;
- $report_lines += $1;
-}
-die "no report_lines() functions in template?" unless $report_lines;
-$report_template = new Text::Template (
- TYPE => 'ARRAY',
- SOURCE => [ map "$_\n", @report_template ],
-) or die "can't create new Text::Template object: $Text::Template::ERROR";
-
-
-my(@cust_bills)=qsearch('cust_bill',{});
-if (scalar(@cust_bills) == 0)
-{
- exit 1;
-}
-
-# Open print and email pipes
-# $lpr and opt_p for printing
-# $email and opt_m for email
-
-if ($lpr && $main::opt_p)
-{
- open(LPR, "|$lpr");
-}
-
-if ($email && $main::opt_m)
-{
- $ENV{MAILADDRESS} = $mail_sender;
- $header = new Mail::Header ( [
- "From: Account Processor",
- "To: $email",
- "Sender: $mail_sender",
- "Reply-To: $mail_sender",
- "Subject: Sales Taxes Invoiced",
- ] );
-}
-
-my $comped = 0;
-my $comped_tax = 0;
-my $other = 0;
-my $other_tax = 0;
-my $total = 0;
-my $taxed = 0;
-my $untaxed = 0;
-my $total_tax = 0;
-
-# Now I can start looping
-foreach my $cust_bill (@cust_bills)
-{
- my $_date = $cust_bill->getfield('_date');
- my $invnum = $cust_bill->getfield('invnum');
- my $charged = $cust_bill->getfield('charged');
-
- if ($_date >= $_startdate && $_date <= $_finishdate) {
- $total += $charged;
-
- # The following lines were used to produce rather verbose reports
- #my ($sec,$min,$hour,$mday,$mon,$year) =
- # (localtime($_date) )[0,1,2,3,4,5];
- #$mon++;
- #$year -= 100 if $year >= 100;
- #$year = "0" . $year if $year < 10;
-
- my $invoice_amt =0;
- my $invoice_tax =0;
- my $invoice_comped =0;
- my(@cust_bill_pkgs)= $cust_bill->cust_bill_pkg;
- foreach my $cust_bill_pkg (@cust_bill_pkgs) {
-
- my $recur = $cust_bill_pkg->getfield('recur');
- my $setup = $cust_bill_pkg->getfield('setup');
- my $pkgnum = $cust_bill_pkg->getfield('pkgnum');
-
- if ($pkgnum == 0) {
- # The following line was used to produce rather verbose reports
- # push @buf, ('', sprintf(qq{%10s%15s%14.2f}, "$mon/$mday/$year", "Tax $invnum", $recur+$setup));
- $invoice_tax += $recur;
- $invoice_tax += $setup;
- } else {
- # The following line was used to produce rather verbose reports
- # push @buf, ('', sprintf(qq{%10s%15s%14.2f}, "$mon/$mday/$year", "Inv $invnum", $recur+$setup));
- $invoice_amt += $recur;
- $invoice_amt += $setup;
- }
-
- }
-
- my(@cust_bill_pays)= $cust_bill->cust_bill_pay;
- foreach my $cust_bill_pay (@cust_bill_pays) {
- my $payby = $cust_bill_pay->cust_pay->payby;
- my $paid = $cust_bill_pay->getfield('amount');
- if ($payby =~ 'COMP') {
- $invoice_comped += $paid;
- }
- }
-
- if (abs($invoice_comped - ($invoice_amt + $invoice_tax)) < 0.0001){
- $comped += $invoice_amt;
- $comped_tax += $invoice_tax;
- } elsif ($invoice_comped > 0) {
- push @buf, sprintf(qq{\nInvoice %10d has inexpliciable complimentary payments of %14.9f\n}, $invnum, $invoice_comped);
- $other += $invoice_amt;
- $other_tax += $invoice_tax;
- } elsif ($invoice_tax > 0) {
- $total_tax += $invoice_tax;
- $taxed += $invoice_amt;
- } else {
- $untaxed += $invoice_amt;
- }
-
- }
-
-}
-
-push @buf, ('', sprintf(qq{%25s%14.2f}, "Complimentary", $comped));
-push @buf, sprintf(qq{%25s%14.2f}, "Complimentary Tax", $comped_tax);
-push @buf, sprintf(qq{%25s%14.2f}, "Other", $other);
-push @buf, sprintf(qq{%25s%14.2f}, "Other Tax", $other_tax);
-push @buf, sprintf(qq{%25s%14.2f}, "Untaxed", $untaxed);
-push @buf, sprintf(qq{%25s%14.2f}, "Taxed", $taxed);
-push @buf, sprintf(qq{%25s%14.2f}, "Tax", $total_tax);
-push @buf, ('', sprintf(qq{%39s}, "========="), sprintf(qq{%39.2f}, $total));
-
-sub FS::tax_report::_template::report_lines {
- my $lines = shift;
- map {
- scalar(@buf) ? shift @buf : '' ;
- }
- ( 1 .. $lines );
-}
-
-$FS::tax_report::_template::title = qq~SALES TAXES INVOICED for $smon/$smday/$syear through $fmon/$fmday/$fyear~;
-$FS::tax_report::_template::title = $opt_t if $opt_t;
-$FS::tax_report::_template::page = 1;
-$FS::tax_report::_template::date = $^T;
-$FS::tax_report::_template::date = $^T;
-$FS::tax_report::_template::fdate = $_finishdate;
-$FS::tax_report::_template::fdate = $_finishdate;
-$FS::tax_report::_template::sdate = $_startdate;
-$FS::tax_report::_template::sdate = $_startdate;
-$FS::tax_report::_template::total_pages =
- int( scalar(@buf) / $report_lines);
-$FS::tax_report::_template::total_pages++ if scalar(@buf) % $report_lines;
-
-my @report;
-while (@buf) {
- push @report, split("\n",
- $report_template->fill_in( PACKAGE => 'FS::tax_report::_template' )
- );
- $FS::tax_report::_template::page++;
-}
-
-if ($opt_v) {
- print map "$_\n", @report;
-}
-if($lpr && $opt_p)
-{
- print LPR map "$_\n", @report;
- print LPR "\f" if $opt_e;
- close LPR || die "Could not close printer: $lpr\n";
-}
-if($email && $opt_m)
-{
- my $message = new Mail::Internet (
- 'Header' => $header,
- 'Body' => [ (@report) ],
- );
- $!=0;
- $message->smtpsend( Host => "$smtpmachine" )
- or die "can't send report to $email via $smtpmachine: $!";
-}
-
-
-# subroutines
-sub untaint_argv {
- foreach $_ ( $[ .. $#ARGV ) { #untaint @ARGV
- $ARGV[$_] =~ /^([\w\-\/ :\.]*)$/ || die "Illegal argument \"$ARGV[$_]\"";
- $ARGV[$_]=$1;
- }
-}
-
-sub usage {
- die "Usage:\n\n freeside-tax-report [-v] [-p] [-e] user\n";
-}
-
-=head1 NAME
-
-freeside-tax-report - Prints or emails sales taxes invoiced in a given period.
-
-=head1 SYNOPSIS
-
- freeside-tax-report [-v] [-p] [-m] [-e] [-t "title"] [-s date] [-f date] user
-
-=head1 DESCRIPTION
-
-Prints or emails sales taxes invoiced in a given period.
-
--v: Verbose - Prints records to STDOUT.
-
--p: Print to printer lpr as found in the conf directory.
-
--m: Email output to user found in the Conf email file.
-
--e: Print a final form feed to the printer.
-
--t: supply a title for the top of each page.
-
--s: starting date for inclusion
-
--f: final date for inclusion
-
-user: From the mapsecrets file - see config.html from the base documentation
-
-=head1 VERSION
-
-$Id: freeside-tax-report,v 1.5 2002-09-09 22:57:34 ivan Exp $
-
-=head1 BUGS
-
-Yes..... Use at your own risk. No guarantees or warrantees of any
-kind apply to this program. Parts of this program are hacked from
-other GNU licensed software created mainly by Ivan Kohler.
-
-This is released under the GNU Public License. See www.gnu.org
-for more information regarding this license.
-
-=head1 SEE ALSO
-
-L<FS::cust_main>, config.html from the base documentation
-
-=head1 AUTHOR
-
-Jeff Finucane <jeff@cmh.net>
-
-based on print-batch by Joel Griffiths <griff@aver-computer.com>
-
-=cut
-
diff --git a/FS/t/CGI.t b/FS/t/CGI.t
deleted file mode 100644
index 1b4e238..0000000
--- a/FS/t/CGI.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::CGI;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/ClientAPI.t b/FS/t/ClientAPI.t
deleted file mode 100644
index 973d8da..0000000
--- a/FS/t/ClientAPI.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::ClientAPI;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/Conf.t b/FS/t/Conf.t
deleted file mode 100644
index a9f7653..0000000
--- a/FS/t/Conf.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::Conf;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/ConfItem.t b/FS/t/ConfItem.t
deleted file mode 100644
index c7932d7..0000000
--- a/FS/t/ConfItem.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::ConfItem;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/InitHandler.t b/FS/t/InitHandler.t
deleted file mode 100644
index 0ce60c8..0000000
--- a/FS/t/InitHandler.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::InitHandler;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/Misc.t b/FS/t/Misc.t
deleted file mode 100644
index cc7751a..0000000
--- a/FS/t/Misc.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::Misc;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/Msgcat.t b/FS/t/Msgcat.t
deleted file mode 100644
index 29e71b3..0000000
--- a/FS/t/Msgcat.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::Msgcat;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/Record.t b/FS/t/Record.t
deleted file mode 100644
index 00de1ed..0000000
--- a/FS/t/Record.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::Record;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/Report-Table-Monthly.t b/FS/t/Report-Table-Monthly.t
deleted file mode 100644
index 6ff365d..0000000
--- a/FS/t/Report-Table-Monthly.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::Report::Table::Monthly;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/Report-Table.t b/FS/t/Report-Table.t
deleted file mode 100644
index 866d498..0000000
--- a/FS/t/Report-Table.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::Report::Table;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/Report.t b/FS/t/Report.t
deleted file mode 100644
index 76d6ea4..0000000
--- a/FS/t/Report.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::Report;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/SearchCache.t b/FS/t/SearchCache.t
deleted file mode 100644
index 3c26f35..0000000
--- a/FS/t/SearchCache.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::SearchCache;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/UID.t b/FS/t/UID.t
deleted file mode 100644
index 9f7da4e..0000000
--- a/FS/t/UID.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::UID;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/acct_snarf.t b/FS/t/acct_snarf.t
deleted file mode 100644
index 642760f..0000000
--- a/FS/t/acct_snarf.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::acct_snarf;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/agent.t b/FS/t/agent.t
deleted file mode 100644
index 769cce2..0000000
--- a/FS/t/agent.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::agent;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/agent_type.t b/FS/t/agent_type.t
deleted file mode 100644
index 99c66a1..0000000
--- a/FS/t/agent_type.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::agent_type;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/cust_bill.t b/FS/t/cust_bill.t
deleted file mode 100644
index b43f08e..0000000
--- a/FS/t/cust_bill.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::cust_bill;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/cust_bill_event.t b/FS/t/cust_bill_event.t
deleted file mode 100644
index 0e2ca3e..0000000
--- a/FS/t/cust_bill_event.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::cust_bill_event;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/cust_bill_pay.t b/FS/t/cust_bill_pay.t
deleted file mode 100644
index 001eed0..0000000
--- a/FS/t/cust_bill_pay.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::cust_bill_pay;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/cust_bill_pkg.t b/FS/t/cust_bill_pkg.t
deleted file mode 100644
index 0e45bdb..0000000
--- a/FS/t/cust_bill_pkg.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::cust_bill_pkg;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/cust_bill_pkg_detail.t b/FS/t/cust_bill_pkg_detail.t
deleted file mode 100644
index ea6e3d1..0000000
--- a/FS/t/cust_bill_pkg_detail.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::cust_bill_pkg_detail;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/cust_credit.t b/FS/t/cust_credit.t
deleted file mode 100644
index cddf75c..0000000
--- a/FS/t/cust_credit.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::cust_credit;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/cust_credit_bill.t b/FS/t/cust_credit_bill.t
deleted file mode 100644
index 0ef54c3..0000000
--- a/FS/t/cust_credit_bill.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::cust_credit_bill;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/cust_credit_refund.t b/FS/t/cust_credit_refund.t
deleted file mode 100644
index 6b2b599..0000000
--- a/FS/t/cust_credit_refund.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::cust_credit_refund;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/cust_main.t b/FS/t/cust_main.t
deleted file mode 100644
index b0ffbdb..0000000
--- a/FS/t/cust_main.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::cust_main;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/cust_main_county.t b/FS/t/cust_main_county.t
deleted file mode 100644
index dd61199..0000000
--- a/FS/t/cust_main_county.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::cust_main_county;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/cust_main_invoice.t b/FS/t/cust_main_invoice.t
deleted file mode 100644
index 9661620..0000000
--- a/FS/t/cust_main_invoice.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::cust_main_invoice;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/cust_pay.t b/FS/t/cust_pay.t
deleted file mode 100644
index f6d0b75..0000000
--- a/FS/t/cust_pay.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::cust_pay;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/cust_pay_batch.t b/FS/t/cust_pay_batch.t
deleted file mode 100644
index 02b572c..0000000
--- a/FS/t/cust_pay_batch.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::cust_pay_batch;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/cust_pkg.t b/FS/t/cust_pkg.t
deleted file mode 100644
index c6a6860..0000000
--- a/FS/t/cust_pkg.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::cust_pkg;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/cust_refund.t b/FS/t/cust_refund.t
deleted file mode 100644
index 91583da..0000000
--- a/FS/t/cust_refund.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::cust_refund;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/cust_svc.t b/FS/t/cust_svc.t
deleted file mode 100644
index 267d731..0000000
--- a/FS/t/cust_svc.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::cust_svc;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/cust_tax_exempt.pm b/FS/t/cust_tax_exempt.pm
deleted file mode 100644
index 8af13e3..0000000
--- a/FS/t/cust_tax_exempt.pm
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::cust_tax_exempt;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/cust_tax_exempt.t b/FS/t/cust_tax_exempt.t
deleted file mode 100644
index 8af13e3..0000000
--- a/FS/t/cust_tax_exempt.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::cust_tax_exempt;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/domain_record.t b/FS/t/domain_record.t
deleted file mode 100644
index 794518c..0000000
--- a/FS/t/domain_record.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::domain_record;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/export_svc.t b/FS/t/export_svc.t
deleted file mode 100644
index 773c5de..0000000
--- a/FS/t/export_svc.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::export_svc;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/msgcat.t b/FS/t/msgcat.t
deleted file mode 100644
index c38c639..0000000
--- a/FS/t/msgcat.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::msgcat;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/nas.t b/FS/t/nas.t
deleted file mode 100644
index 6f8ae36..0000000
--- a/FS/t/nas.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::nas;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/part_bill_event.t b/FS/t/part_bill_event.t
deleted file mode 100644
index 5626a9f..0000000
--- a/FS/t/part_bill_event.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::part_bill_event;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/part_export-apache.t b/FS/t/part_export-apache.t
deleted file mode 100644
index b999508..0000000
--- a/FS/t/part_export-apache.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::part_export::apache;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/part_export-bind.t b/FS/t/part_export-bind.t
deleted file mode 100644
index d0c96be..0000000
--- a/FS/t/part_export-bind.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::part_export::bind;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/part_export-bind_slave.t b/FS/t/part_export-bind_slave.t
deleted file mode 100644
index c6a0386..0000000
--- a/FS/t/part_export-bind_slave.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::part_export::bind_slave;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/part_export-bsdshell.t b/FS/t/part_export-bsdshell.t
deleted file mode 100644
index eaf417a..0000000
--- a/FS/t/part_export-bsdshell.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::part_export::bsdshell;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/part_export-communigate_pro_singledomain.t b/FS/t/part_export-communigate_pro_singledomain.t
deleted file mode 100644
index 6f8a64e..0000000
--- a/FS/t/part_export-communigate_pro_singledomain.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::part_export::communigate_pro_singledomain;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/part_export-cp.t b/FS/t/part_export-cp.t
deleted file mode 100644
index bbefa6c..0000000
--- a/FS/t/part_export-cp.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::part_export::cp;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/part_export-cyrus.t b/FS/t/part_export-cyrus.t
deleted file mode 100644
index e0b3f35..0000000
--- a/FS/t/part_export-cyrus.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::part_export::cyrus;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/part_export-domain_shellcommands.t b/FS/t/part_export-domain_shellcommands.t
deleted file mode 100644
index a2a44fb..0000000
--- a/FS/t/part_export-domain_shellcommands.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::part_export::domain_shellcommands;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/part_export-forward_shellcommands.t b/FS/t/part_export-forward_shellcommands.t
deleted file mode 100644
index 78ca68d..0000000
--- a/FS/t/part_export-forward_shellcommands.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::part_export::forward_shellcommands;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/part_export-http.t b/FS/t/part_export-http.t
deleted file mode 100644
index ea41b93..0000000
--- a/FS/t/part_export-http.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::part_export::http;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/part_export-infostreet.t b/FS/t/part_export-infostreet.t
deleted file mode 100644
index 1b33418..0000000
--- a/FS/t/part_export-infostreet.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::part_export::infostreet;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/part_export-ldap.t b/FS/t/part_export-ldap.t
deleted file mode 100644
index 826c341..0000000
--- a/FS/t/part_export-ldap.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::part_export::ldap;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/part_export-null.t b/FS/t/part_export-null.t
deleted file mode 100644
index 055cdce..0000000
--- a/FS/t/part_export-null.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::part_export::null;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/part_export-passwdfile.t b/FS/t/part_export-passwdfile.t
deleted file mode 100644
index 0f18f30..0000000
--- a/FS/t/part_export-passwdfile.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::part_export::passwdfile;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/part_export-postfix.t b/FS/t/part_export-postfix.t
deleted file mode 100644
index 9518caa..0000000
--- a/FS/t/part_export-postfix.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::part_export::postfix;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/part_export-router.t b/FS/t/part_export-router.t
deleted file mode 100644
index 54e4b63..0000000
--- a/FS/t/part_export-router.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::part_export::router;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/part_export-shellcommands.t b/FS/t/part_export-shellcommands.t
deleted file mode 100644
index 7bb47d3..0000000
--- a/FS/t/part_export-shellcommands.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::part_export::shellcommands;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/part_export-shellcommands_withdomain.t b/FS/t/part_export-shellcommands_withdomain.t
deleted file mode 100644
index c0bd1bb..0000000
--- a/FS/t/part_export-shellcommands_withdomain.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::part_export::shellcommands_withdomain;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/part_export-sqlmail.t b/FS/t/part_export-sqlmail.t
deleted file mode 100644
index b048a75..0000000
--- a/FS/t/part_export-sqlmail.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::part_export::sqlmail;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/part_export-sqlradius.t b/FS/t/part_export-sqlradius.t
deleted file mode 100644
index 5fb23a5..0000000
--- a/FS/t/part_export-sqlradius.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::part_export::sqlradius;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/part_export-sqlradius_withdomain.t b/FS/t/part_export-sqlradius_withdomain.t
deleted file mode 100644
index 504bf67..0000000
--- a/FS/t/part_export-sqlradius_withdomain.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::part_export::sqlradius_withdomain;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/part_export-sysvshell.t b/FS/t/part_export-sysvshell.t
deleted file mode 100644
index 7fc24ac..0000000
--- a/FS/t/part_export-sysvshell.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::part_export::sysvshell;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/part_export-textradius.t b/FS/t/part_export-textradius.t
deleted file mode 100644
index d8a48a0..0000000
--- a/FS/t/part_export-textradius.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::part_export::textradius;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/part_export-vpopmail.t b/FS/t/part_export-vpopmail.t
deleted file mode 100644
index 2e37114..0000000
--- a/FS/t/part_export-vpopmail.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::part_export::vpopmail;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/part_export-www_shellcommands.t b/FS/t/part_export-www_shellcommands.t
deleted file mode 100644
index 2ea79cf..0000000
--- a/FS/t/part_export-www_shellcommands.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::part_export::www_shellcommands;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/part_export.t b/FS/t/part_export.t
deleted file mode 100644
index 26b3987..0000000
--- a/FS/t/part_export.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::part_export;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/part_export_option.t b/FS/t/part_export_option.t
deleted file mode 100644
index 13200c2..0000000
--- a/FS/t/part_export_option.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::part_export_option;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/part_pkg.t b/FS/t/part_pkg.t
deleted file mode 100644
index fd96073..0000000
--- a/FS/t/part_pkg.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::part_pkg;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/part_pop_local.t b/FS/t/part_pop_local.t
deleted file mode 100644
index 4e4ad17..0000000
--- a/FS/t/part_pop_local.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::part_pop_local;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/part_referral.t b/FS/t/part_referral.t
deleted file mode 100644
index d20b979..0000000
--- a/FS/t/part_referral.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::part_referral;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/part_svc.t b/FS/t/part_svc.t
deleted file mode 100644
index bdb2a7a..0000000
--- a/FS/t/part_svc.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::part_svc;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/part_svc_column.t b/FS/t/part_svc_column.t
deleted file mode 100644
index 467025c..0000000
--- a/FS/t/part_svc_column.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::part_svc_column;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/pkg_svc.t b/FS/t/pkg_svc.t
deleted file mode 100644
index 77d3429..0000000
--- a/FS/t/pkg_svc.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::pkg_svc;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/port.t b/FS/t/port.t
deleted file mode 100644
index 46377aa..0000000
--- a/FS/t/port.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::port;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/prepay_credit.t b/FS/t/prepay_credit.t
deleted file mode 100644
index e7626bd..0000000
--- a/FS/t/prepay_credit.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::prepay_credit;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/queue.t b/FS/t/queue.t
deleted file mode 100644
index 43e3373..0000000
--- a/FS/t/queue.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::queue;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/queue_arg.t b/FS/t/queue_arg.t
deleted file mode 100644
index cf3f91d..0000000
--- a/FS/t/queue_arg.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::queue_arg;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/queue_depend.t b/FS/t/queue_depend.t
deleted file mode 100644
index 8eaa2cd..0000000
--- a/FS/t/queue_depend.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::queue_depend;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/raddb.t b/FS/t/raddb.t
deleted file mode 100644
index ac28d07..0000000
--- a/FS/t/raddb.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::raddb;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/radius_usergroup.t b/FS/t/radius_usergroup.t
deleted file mode 100644
index 325742c..0000000
--- a/FS/t/radius_usergroup.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::radius_usergroup;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/session.t b/FS/t/session.t
deleted file mode 100644
index c4b714e..0000000
--- a/FS/t/session.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::session;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/svc_Common.t b/FS/t/svc_Common.t
deleted file mode 100644
index ed49e1e..0000000
--- a/FS/t/svc_Common.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::svc_Common;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/svc_acct.t b/FS/t/svc_acct.t
deleted file mode 100644
index 9ca78c9..0000000
--- a/FS/t/svc_acct.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::svc_acct;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/svc_acct_pop.t b/FS/t/svc_acct_pop.t
deleted file mode 100644
index e612c40..0000000
--- a/FS/t/svc_acct_pop.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::svc_acct_pop;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/svc_broadband.t b/FS/t/svc_broadband.t
deleted file mode 100644
index 02dc112..0000000
--- a/FS/t/svc_broadband.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::svc_broadband;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/svc_domain.t b/FS/t/svc_domain.t
deleted file mode 100644
index 4d91898..0000000
--- a/FS/t/svc_domain.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::svc_domain;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/svc_external.t b/FS/t/svc_external.t
deleted file mode 100644
index 20a6767..0000000
--- a/FS/t/svc_external.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::svc_external;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/svc_forward.t b/FS/t/svc_forward.t
deleted file mode 100644
index d653d34..0000000
--- a/FS/t/svc_forward.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::svc_forward;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/svc_www.t b/FS/t/svc_www.t
deleted file mode 100644
index eb4e83f..0000000
--- a/FS/t/svc_www.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::svc_www;
-$loaded=1;
-print "ok 1\n";
diff --git a/FS/t/type_pkgs.t b/FS/t/type_pkgs.t
deleted file mode 100644
index 9840180..0000000
--- a/FS/t/type_pkgs.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::type_pkgs;
-$loaded=1;
-print "ok 1\n";