diff options
Diffstat (limited to 'FS')
34 files changed, 256 insertions, 101 deletions
diff --git a/FS/FS/AccessRight.pm b/FS/FS/AccessRight.pm index ca96eb52f..4c99c7cb8 100644 --- a/FS/FS/AccessRight.pm +++ b/FS/FS/AccessRight.pm @@ -236,7 +236,7 @@ tie my %rights, 'Tie::IxHash', # customer voiding rights.. ### 'Customer payment void rights' => [ - { rightname=>'Credit card void', desc=>'Enable local-only voiding of echeck payments in addition to refunds against the payment gateway.' }, #aka. cc-void + { rightname=>'Credit card void', desc=>'Enable local-only voiding of credit card payments in addition to refunds against the payment gateway.' }, #aka. cc-void { rightname=>'Echeck void', desc=>'Enable local-only voiding of echeck payments in addition to refunds against the payment gateway.' }, #aka. echeck-void 'Void payments', { rightname=>'Unvoid payments', desc=>'Enable unvoiding of voided payments' }, #aka. unvoid diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm index db50d4250..2aeecc1b2 100644 --- a/FS/FS/ClientAPI/MyAccount.pm +++ b/FS/FS/ClientAPI/MyAccount.pm @@ -2801,13 +2801,16 @@ sub myaccount_passwd { } ) or return { 'error' => "Service not found" }; - if ( exists($p->{'old_password'}) ) { - return { 'error' => "Incorrect password." } - unless $svc_acct->check_password($p->{'old_password'}); - } + my $error = ''; + + my $conf = new FS::Conf; + $error = 'Password too short.' + if length($p->{'new_password'}) < ($conf->config('passwordmin') || 6); + $error = 'Password too long.' + if length($p->{'new_password'}) > ($conf->config('passwordmax') || 8); $svc_acct->set_password($p->{'new_password'}); - my $error = $svc_acct->replace(); + $error ||= $svc_acct->replace(); my($label, $value) = $svc_acct->cust_svc->label; diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index eed84fc52..0eed8ee5d 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -1724,6 +1724,21 @@ and customer address. Include units.', }, { + 'key' => 'sip_passwordmin', + 'section' => 'telephony', + 'description' => 'Minimum SIP password length (default 6)', + 'type' => 'text', + }, + + { + 'key' => 'sip_passwordmax', + 'section' => 'telephony', + 'description' => 'Maximum SIP password length (default 8) (don\'t set this over 12 if you need to import or export crypt() passwords)', + 'type' => 'text', + }, + + + { 'key' => 'password-noampersand', 'section' => 'password', 'description' => 'Disallow ampersands in passwords', @@ -2040,6 +2055,13 @@ and customer address. Include units.', }, { + 'key' => 'show_ship_company', + 'section' => 'UI', + 'description' => 'Turns on display/collection of a "service company name" field for customers.', + 'type' => 'checkbox', + }, + + { 'key' => 'show_ss', 'section' => 'UI', 'description' => 'Turns on display/collection of social security numbers in the web interface. Sometimes required by electronic check (ACH) processors.', @@ -4745,6 +4767,17 @@ and customer address. Include units.', }, { + 'key' => 'svc_phone-radius-password', + 'section' => 'telephony', + 'description' => 'Password when exporting svc_phone records to RADIUS', + 'type' => 'select', + 'select_hash' => [ + '' => 'Use default from svc_phone-radius-default_password config', + 'countrycode_phonenum' => 'Phone number (with country code)', + ], + }, + + { 'key' => 'svc_phone-radius-default_password', 'section' => 'telephony', 'description' => 'Default password when exporting svc_phone records to RADIUS', diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index 1a88c3acd..493734729 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -42,6 +42,7 @@ our $me = '[FS::Record]'; our $nowarn_identical = 0; our $nowarn_classload = 0; our $no_update_diff = 0; +our $no_history = 0; our $no_check_foreign = 1; #well, not inefficiently in perl by default anymore @@ -1250,7 +1251,7 @@ sub insert { } my $h_sth; - if ( defined dbdef->table('h_'. $table) ) { + if ( defined( dbdef->table('h_'. $table) ) && ! $no_history ) { my $h_statement = $self->_h_statement('insert'); warn "[debug]$me $h_statement\n" if $DEBUG > 2; $h_sth = dbh->prepare($h_statement) or do { @@ -3003,7 +3004,7 @@ You should generally not have to worry about calling this, as the system handles sub encrypt { my ($self, $value) = @_; - my $encrypted; + my $encrypted = $value; if ($conf->exists('encryption')) { if ($self->is_encrypted($value)) { diff --git a/FS/FS/Report/Table.pm b/FS/FS/Report/Table.pm index 1d60b6420..da4916176 100644 --- a/FS/FS/Report/Table.pm +++ b/FS/FS/Report/Table.pm @@ -757,7 +757,7 @@ sub with_cust_classnum { return 'cust_main.classnum in('. join(',',@$classnums) .')' if @$classnums; } - ''; + (); } diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index 8ba60200e..bc9d37aed 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -3,7 +3,7 @@ package FS::Schema; use vars qw(@ISA @EXPORT_OK $DEBUG $setup_hack %dbdef_cache); use subs qw(reload_dbdef); use Exporter; -use DBIx::DBSchema 0.43; #0.43 for foreign keys +use DBIx::DBSchema 0.44; #for foreign keys with MATCH / ON DELETE/UPDATE use DBIx::DBSchema::Table; use DBIx::DBSchema::Column; use DBIx::DBSchema::Index; @@ -1138,9 +1138,10 @@ sub tables_hashref { { columns => [ 'invnum' ], table => 'cust_bill_void', }, - { columns => [ 'pkgnum' ], - table => 'cust_pkg', - }, + #pkgnum 0 and -1 are used for special things + #{ columns => [ 'pkgnum' ], + # table => 'cust_pkg', + #}, { columns => [ 'pkgpart_override' ], table => 'part_pkg', references => [ 'pkgpart' ], @@ -2389,7 +2390,7 @@ sub tables_hashref { 'index' => [ [ 'billpaynum' ], [ 'billpkgnum' ], ], 'foreign_keys' => [ { columns => [ 'billpaynum' ], - table => 'cust_bill_pay_batch', + table => 'cust_bill_pay', }, { columns => [ 'billpkgnum' ], table => 'cust_bill_pkg', @@ -3953,6 +3954,7 @@ sub tables_hashref { 'foreign_keys' => [ { columns => [ 'jobnum' ], table => 'queue', + on_delete => 'CASCADE', }, ], }, @@ -3973,6 +3975,7 @@ sub tables_hashref { { columns => [ 'depend_jobnum' ], table => 'queue', references => [ 'jobnum' ], + on_delete => 'CASCADE', }, ], }, @@ -4903,7 +4906,7 @@ sub tables_hashref { #currently only u4: # terminating number (as opposed to dialed destination) - 'dst_term', 'varchar', '', $char_d, \"''", '', + 'dst_term', 'varchar', 'NULL', $char_d, '', '', #these don't seem to be logged by most of the SQL cdr_* modules #except tds under sql-illegal names, so; @@ -5843,7 +5846,7 @@ sub tables_hashref { 'statustext', 'varchar', 'NULL', $char_d, '', '', ], 'primary_key' => 'upgradenum', - 'unique' => [ [ 'upgradenum' ] ], + 'unique' => [], 'index' => [ [ 'upgrade' ] ], }, diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm index 840df7558..2314c02c1 100644 --- a/FS/FS/Template_Mixin.pm +++ b/FS/FS/Template_Mixin.pm @@ -581,11 +581,14 @@ sub print_generic { my $countrydefault = $conf->config('countrydefault') || 'US'; foreach ( qw( address1 address2 city state zip country fax) ){ my $method = 'ship_'.$_; - $invoice_data{"ship_$_"} = _latex_escape($cust_main->$method); + $invoice_data{"ship_$_"} = $escape_function->($cust_main->$method); } - foreach ( qw( contact company ) ) { #compatibility - $invoice_data{"ship_$_"} = _latex_escape($cust_main->$_); + if ( length($cust_main->ship_company) ) { + $invoice_data{'ship_company'} = $escape_function->($cust_main->ship_company); + } else { + $invoice_data{'ship_company'} = $escape_function->($cust_main->company); } + $invoice_data{'ship_contact'} = $escape_function->($cust_main->contact); $invoice_data{'ship_country'} = '' if ( $invoice_data{'ship_country'} eq $countrydefault ); diff --git a/FS/FS/UI/Web.pm b/FS/FS/UI/Web.pm index d7f998bdf..e31ff14a5 100644 --- a/FS/FS/UI/Web.pm +++ b/FS/FS/UI/Web.pm @@ -323,6 +323,14 @@ sub cust_header { @cust_header; } +sub cust_sort_fields { + cust_header(@_); + #inefficientish, but tiny lists and only run once per page + + map { $_ eq 'custnum' ? 'custnum' : '' } @cust_fields; + +} + =item cust_sql_fields [ CUST_FIELDS_VALUE ] Returns a list of fields for the SELECT portion of an SQL query. diff --git a/FS/FS/cdr.pm b/FS/FS/cdr.pm index b16cb8648..bf508dd8c 100644 --- a/FS/FS/cdr.pm +++ b/FS/FS/cdr.pm @@ -904,7 +904,7 @@ sub rate_prefix { #${$opt{region_group_included_min}} -= $minutes # if $region_group && $rate_detail->region_group; - if ( $included_min->{$regionnum}{$ratetimenum} > $minutes ) { + if ( $included_min->{$regionnum}{$ratetimenum} >= $minutes ) { $charge_sec = 0; $included_min->{$regionnum}{$ratetimenum} -= $minutes; } else { diff --git a/FS/FS/contact_phone.pm b/FS/FS/contact_phone.pm index 0eb216668..610753fc0 100644 --- a/FS/FS/contact_phone.pm +++ b/FS/FS/contact_phone.pm @@ -4,6 +4,7 @@ use base qw( FS::Record ); use strict; use FS::Record qw( qsearch qsearchs ); use FS::contact; +use FS::phone_type; =head1 NAME @@ -144,6 +145,16 @@ sub contact { qsearchs( 'contact', { 'contactnum' => $self->contactnum } ); } +sub phone_type { + my $self = shift; + qsearchs('phone_type', { 'phonetypenum' => $self->phonetypenum } ); +} + +sub typename { + my $self = shift; + $self->phone_type->typename; +} + =back =head1 BUGS diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index 4e34ef47b..d0e7048b7 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -1970,14 +1970,15 @@ sub print_csv { my $time = $opt{'time'} || time; + my $tracctnum = ''; #leaking out from billco-specific sections :/ if ( $format eq 'billco' ) { my $account_num = $self->conf->config('billco-account_num', $cust_main->agentnum); - my $tracctnum = $account_num eq 'display_custnum' - ? $cust_main->display_custnum - : $opt{'tracctnum'}; + $tracctnum = $account_num eq 'display_custnum' + ? $cust_main->display_custnum + : $opt{'tracctnum'}; my $taxtotal = 0; $taxtotal += $_->{'amount'} foreach $self->_items_tax; @@ -2232,7 +2233,7 @@ sub print_csv { $csv->combine( '', # 1 | N/A-Leave Empty CHAR 2 '', # 2 | N/A-Leave Empty CHAR 15 - $opt{'tracctnum'}, # 3 | Account Number CHAR 15 + $tracctnum, # 3 | Account Number CHAR 15 $self->invnum, # 4 | Invoice Number CHAR 15 $lineseq++, # 5 | Line Sequence (sort order) NUM 6 $item->{'description'}, # 6 | Transaction Detail CHAR 100 diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index d768f8406..5126fea6b 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -1662,7 +1662,7 @@ sub queue_fuzzyfiles_update { local $FS::UID::AutoCommit = 0; my $dbh = dbh; - foreach my $field ( 'first', 'last', 'company' ) { + foreach my $field ( 'first', 'last', 'company', 'ship_company' ) { my $queue = new FS::queue { 'job' => 'FS::cust_main::Search::append_fuzzyfiles_fuzzyfield' }; @@ -1724,6 +1724,7 @@ sub check { || $self->ut_snumbern('spouse_birthdate') || $self->ut_snumbern('anniversary_date') || $self->ut_textn('company') + || $self->ut_textn('ship_company') || $self->ut_anything('comments') || $self->ut_numbern('referral_custnum') || $self->ut_textn('stateid') @@ -1741,11 +1742,13 @@ sub check { || $self->ut_currencyn('currency') ; - my $company = $self->company; - $company =~ s/^\s+//; - $company =~ s/\s+$//; - $company =~ s/\s+/ /g; - $self->company($company); + foreach (qw(company ship_company)) { + my $company = $self->get($_); + $company =~ s/^\s+//; + $company =~ s/\s+$//; + $company =~ s/\s+/ /g; + $self->set($_, $company); + } #barf. need message catalogs. i18n. etc. $error .= "Please select an advertising source." diff --git a/FS/FS/cust_main/Search.pm b/FS/FS/cust_main/Search.pm index 16db71271..b1438619b 100644 --- a/FS/FS/cust_main/Search.pm +++ b/FS/FS/cust_main/Search.pm @@ -21,6 +21,7 @@ $me = '[FS::cust_main::Search]'; @fuzzyfields = ( 'cust_main.first', 'cust_main.last', 'cust_main.company', + 'cust_main.ship_company', # if you're using it 'cust_location.address1', 'contact.first', 'contact.last', ); @@ -321,6 +322,7 @@ sub smart_search { $sql .= " ( LOWER(cust_main.first) = $q_value OR LOWER(cust_main.last) = $q_value OR LOWER(cust_main.company) = $q_value + OR LOWER(cust_main.ship_company) = $q_value "; #address1 (yes, it's a kludge) @@ -356,27 +358,30 @@ sub smart_search { #substring - my @hashrefs = ( + my @company_hashrefs = ( { 'company' => { op=>'ILIKE', value=>"%$value%" }, }, + { 'ship_company' => { op=>'ILIKE', value=>"%$value%" }, }, ); + my @hashrefs = (); + if ( $first && $last ) { - push @hashrefs, + @hashrefs = ( { 'first' => { op=>'ILIKE', value=>"%$first%" }, 'last' => { op=>'ILIKE', value=>"%$last%" }, }, - ; + ); } else { - push @hashrefs, + @hashrefs = ( { 'first' => { op=>'ILIKE', value=>"%$value%" }, }, { 'last' => { op=>'ILIKE', value=>"%$value%" }, }, - ; + ); } - foreach my $hashref ( @hashrefs ) { + foreach my $hashref ( @company_hashrefs, @hashrefs ) { push @cust_main, qsearch( { 'table' => 'cust_main', @@ -402,8 +407,6 @@ sub smart_search { #contact substring - shift @hashrefs; #no company column in contact table - foreach my $hashref ( @hashrefs ) { push @cust_main, @@ -439,7 +442,7 @@ sub smart_search { %fuzopts ); } - foreach my $field ( 'first', 'last', 'company' ) { + foreach my $field ( 'first', 'last', 'company', 'ship_company' ) { push @cust_main, FS::cust_main::Search->fuzzy_search( { $field => $value }, %fuzopts @@ -1193,6 +1196,7 @@ sub append_fuzzyfiles { #foreach my $fuzzy (@fuzzyfields) { foreach my $fuzzy ( 'cust_main.first', 'cust_main.last', 'cust_main.company', 'cust_location.address1', + 'cust_main.ship_company', ) { append_fuzzyfiles_fuzzyfield($fuzzy, shift); diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm index 0669e1aa9..a7b91083f 100644 --- a/FS/FS/cust_pay.pm +++ b/FS/FS/cust_pay.pm @@ -36,6 +36,7 @@ FS::UID->install_callback( sub { } ); @encrypted_fields = ('payinfo'); +sub nohistory_fields { ('payinfo'); } =head1 NAME diff --git a/FS/FS/cust_pay_batch.pm b/FS/FS/cust_pay_batch.pm index b93d8166d..db53b19c9 100644 --- a/FS/FS/cust_pay_batch.pm +++ b/FS/FS/cust_pay_batch.pm @@ -16,6 +16,9 @@ use FS::cust_bill; # 3 is even more information including possibly sensitive data $DEBUG = 0; +#@encrypted_fields = ('payinfo'); +sub nohistory_fields { ('payinfo'); } + =head1 NAME FS::cust_pay_batch - Object methods for batch cards diff --git a/FS/FS/cust_pay_pending.pm b/FS/FS/cust_pay_pending.pm index 8c6ef69ae..572a2ade2 100644 --- a/FS/FS/cust_pay_pending.pm +++ b/FS/FS/cust_pay_pending.pm @@ -12,6 +12,7 @@ use FS::cust_pay; @ISA = qw( FS::payinfo_transaction_Mixin FS::cust_main_Mixin FS::Record ); @encrypted_fields = ('payinfo'); +sub nohistory_fields { ('payinfo'); } =head1 NAME diff --git a/FS/FS/cust_pay_void.pm b/FS/FS/cust_pay_void.pm index 92a96cb96..c42dc18e0 100644 --- a/FS/FS/cust_pay_void.pm +++ b/FS/FS/cust_pay_void.pm @@ -16,6 +16,8 @@ use FS::cust_pay; use FS::cust_pkg; @encrypted_fields = ('payinfo'); +sub nohistory_fields { ('payinfo'); } + $otaker_upgrade_kludge = 0; =head1 NAME diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm index 5abdbe2ee..8d12ab9c7 100644 --- a/FS/FS/cust_pkg.pm +++ b/FS/FS/cust_pkg.pm @@ -1859,7 +1859,7 @@ sub change { if ( $opt->{cust_main} ) { my $cust_main = $opt->{cust_main}; unless ( $cust_main->custnum ) { - my $error = $cust_main->insert; + my $error = $cust_main->insert( @{ $opt->{cust_main_insert_args}||[] } ); if ( $error ) { $dbh->rollback if $oldAutoCommit; return "inserting cust_main (transaction rolled back): $error"; @@ -3461,8 +3461,7 @@ sub attribute_since_sqlradacct { foreach my $cust_svc ( grep { my $part_svc = $_->part_svc; - $part_svc->svcdb eq 'svc_acct' - && scalar($part_svc->part_export_usage); + scalar($part_svc->part_export_usage); } $self->cust_svc ) { $sum += $cust_svc->attribute_since_sqlradacct($start, $end, $attrib); diff --git a/FS/FS/cust_refund.pm b/FS/FS/cust_refund.pm index 064992955..d29db5cfa 100644 --- a/FS/FS/cust_refund.pm +++ b/FS/FS/cust_refund.pm @@ -13,6 +13,7 @@ use FS::cust_pay_refund; use FS::cust_main; @encrypted_fields = ('payinfo'); +sub nohistory_fields { ('payinfo'); } =head1 NAME diff --git a/FS/FS/part_event/Action/letter.pm b/FS/FS/part_event/Action/letter.pm index 57b7b7783..835dec2b9 100644 --- a/FS/FS/part_event/Action/letter.pm +++ b/FS/FS/part_event/Action/letter.pm @@ -20,6 +20,7 @@ sub option_fields { 'type' => 'select-table', 'table' => 'msg_template', 'name_col' => 'msgname', + 'hashref' => { disabled => '' }, 'disable_empty' => 1, }, ); diff --git a/FS/FS/part_event/Action/notice.pm b/FS/FS/part_event/Action/notice.pm index 8e22c6844..7c8ed1682 100644 --- a/FS/FS/part_event/Action/notice.pm +++ b/FS/FS/part_event/Action/notice.pm @@ -19,6 +19,7 @@ sub option_fields { 'msgnum' => { 'label' => 'Template', 'type' => 'select-table', 'table' => 'msg_template', + 'hashref' => { disabled => '' }, 'name_col' => 'msgname', 'disable_empty' => 1, }, diff --git a/FS/FS/part_event/Action/notice_to.pm b/FS/FS/part_event/Action/notice_to.pm index 194aeb84f..d300e3385 100644 --- a/FS/FS/part_event/Action/notice_to.pm +++ b/FS/FS/part_event/Action/notice_to.pm @@ -24,6 +24,7 @@ sub option_fields { 'type' => 'select-table', 'table' => 'msg_template', 'name_col' => 'msgname', + 'hashref' => { disabled => '' }, 'disable_empty' => 1, }, ); diff --git a/FS/FS/part_event/Action/svc_acct_notice.pm b/FS/FS/part_event/Action/svc_acct_notice.pm index d71a1371a..97a4ad686 100644 --- a/FS/FS/part_event/Action/svc_acct_notice.pm +++ b/FS/FS/part_event/Action/svc_acct_notice.pm @@ -18,6 +18,7 @@ sub option_fields { 'type' => 'select-table', 'table' => 'msg_template', 'name_col' => 'msgname', + 'hashref' => { disabled => '' }, 'disable_empty' => 1, }, ); diff --git a/FS/FS/part_export/rt_ticket.pm b/FS/FS/part_export/rt_ticket.pm index 7ae6105a0..72e387c56 100644 --- a/FS/FS/part_export/rt_ticket.pm +++ b/FS/FS/part_export/rt_ticket.pm @@ -21,7 +21,7 @@ my %template_select = ( %templates = (0 => '', map { $_->msgnum, $_->msgname } qsearch({ table => 'msg_template', - hashref => {}, + hashref => { disabled => '' }, order_by => 'ORDER BY msgnum ASC' }) ); diff --git a/FS/FS/part_export/send_email.pm b/FS/FS/part_export/send_email.pm index 6ba131f18..1fcb828b7 100644 --- a/FS/FS/part_export/send_email.pm +++ b/FS/FS/part_export/send_email.pm @@ -21,7 +21,7 @@ my %template_select = ( %templates = (0 => '', map { $_->msgnum, $_->msgname } qsearch({ table => 'msg_template', - hashref => {}, + hashref => { disabled => 1 }, order_by => 'ORDER BY msgnum ASC' }) ); diff --git a/FS/FS/part_export/shellcommands.pm b/FS/FS/part_export/shellcommands.pm index ce1369510..f7e86514b 100644 --- a/FS/FS/part_export/shellcommands.pm +++ b/FS/FS/part_export/shellcommands.pm @@ -267,17 +267,19 @@ sub export_pkg_change { my @fields = qw( pkgnum pkgpart agent_pkgid ); #others? my @date_fields = qw( order_date start_date setup bill last_bill susp adjourn - resume cancel uncancel expore contract_end ); + resume cancel uncancel expire contract_end ); no strict 'vars'; { no strict 'refs'; foreach (@fields) { - ${"old_$_"} = $old_cust_pkg->getfield($_); + ${"old_$_"} = $old_cust_pkg ? $old_cust_pkg->getfield($_) : ''; ${"new_$_"} = $new_cust_pkg->getfield($_); } foreach (@date_fields) { - ${"old_$_"} = time2str('%Y-%m-%d', $old_cust_pkg->getfield($_)); + ${"old_$_"} = $old_cust_pkg + ? time2str('%Y-%m-%d', $old_cust_pkg->getfield($_)) + : ''; ${"new_$_"} = time2str('%Y-%m-%d', $new_cust_pkg->getfield($_)); } } diff --git a/FS/FS/part_pkg/bulk_Common.pm b/FS/FS/part_pkg/bulk_Common.pm index 26550df70..4e8850ee5 100644 --- a/FS/FS/part_pkg/bulk_Common.pm +++ b/FS/FS/part_pkg/bulk_Common.pm @@ -47,7 +47,7 @@ sub price_info { #some false laziness-ish w/agent.pm... not a lot sub calc_recur { - my($self, $cust_pkg, $sdate, $details ) = @_; + my($self, $cust_pkg, $sdate, $details, $param ) = @_; my $conf = new FS::Conf; my $money_char = $conf->config('money_char') || '$'; @@ -106,10 +106,13 @@ sub calc_recur { } } - sprintf('%.2f', $self->base_recur($cust_pkg, $sdate) + $total_svc_charge ); -} + my $charge = $self->base_recur($cust_pkg, $sdate) + $total_svc_charge; + + $param->{'override_charges'} = $total_svc_charge / $self->freq; + my $discount = $self->calc_discount($cust_pkg, $sdate, $details, $param); -sub can_discount { 0; } + sprintf('%.2f', $charge - $discount ); +} sub hide_svc_detail { 1; } diff --git a/FS/FS/queue.pm b/FS/FS/queue.pm index 3f8763da8..8ebadd417 100644 --- a/FS/FS/queue.pm +++ b/FS/FS/queue.pm @@ -193,20 +193,6 @@ deleted as well 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 $reportname = ''; if ( $self->status =~/^done/ ) { my $dropstring = rooturl(). '/misc/queued_report\?report='; @@ -216,20 +202,7 @@ sub delete { } 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; + return $error if $error; unlink $reportname if $reportname; diff --git a/FS/FS/svc_MAC_Mixin.pm b/FS/FS/svc_MAC_Mixin.pm new file mode 100644 index 000000000..737a8e83f --- /dev/null +++ b/FS/FS/svc_MAC_Mixin.pm @@ -0,0 +1,65 @@ +package FS::svc_MAC_Mixin; + +use strict; +#use FS::Record qw(qsearch); +#use FS::Conf; +# careful about importing anything here--it will end up in a LOT of +# namespaces + +#use vars qw(@subclasses $DEBUG $conf); + +#$DEBUG = 0; + +# any subclass that can have MAC addresses needs to be added here +#@subclasses = (qw(FS::svc_broadband FS::svc_cable)); + +#sub conf { +# $conf ||= FS::Conf->new; +#} + +=head1 NAME + +FS::MAC_Mixin - Mixin class for objects that have MAC addresses assigned. + +=head1 SYNOPSIS + +=head1 DESCRIPTION + +=head1 METHODS + +=head1 METHODS + +=over 4 + +=item mac_addr_pretty + +=cut + +sub mac_addr_pretty { + my $self = shift; + $self->mac_addr_formatted('U',':'); +} + +=item mac_addr_formatted CASE DELIMITER + +Format the MAC address (for use by exports). If CASE starts with "l" +(for "lowercase"), it's returned in lowercase. DELIMITER is inserted +between octets. + +=cut + +sub mac_addr_formatted { + my $self = shift; + my ($case, $delim) = @_; + my $addr = $self->mac_addr; + $addr = lc($addr) if $case =~ /^l/i; + join( $delim || '', $addr =~ /../g ); +} + +=back + +=head1 BUGS + +=cut + +1; diff --git a/FS/FS/svc_broadband.pm b/FS/FS/svc_broadband.pm index 6073902e8..b9c89cef7 100755 --- a/FS/FS/svc_broadband.pm +++ b/FS/FS/svc_broadband.pm @@ -3,6 +3,7 @@ use base qw( FS::svc_Radius_Mixin FS::svc_Tower_Mixin FS::svc_IP_Mixin + FS::svc_MAC_Mixin FS::svc_Common ); @@ -262,7 +263,7 @@ sub smart_search { =item label -Returns the IP address. +Returns the IP address, MAC address and description. =cut @@ -419,22 +420,6 @@ sub _check_duplicate { ''; } -=item mac_addr_formatted CASE DELIMITER - -Format the MAC address (for use by exports). If CASE starts with "l" -(for "lowercase"), it's returned in lowercase. DELIMITER is inserted -between octets. - -=cut - -sub mac_addr_formatted { - my $self = shift; - my ($case, $delim) = @_; - my $addr = $self->mac_addr; - $addr = lc($addr) if $case =~ /^l/i; - join( $delim || '', $addr =~ /../g ); -} - #class method sub _upgrade_data { my $class = shift; diff --git a/FS/FS/svc_cable.pm b/FS/FS/svc_cable.pm index 672a34d7b..5d281135b 100644 --- a/FS/FS/svc_cable.pm +++ b/FS/FS/svc_cable.pm @@ -1,5 +1,7 @@ package FS::svc_cable; -use base qw( FS::svc_Common ); #qw( FS::device_Common FS::svc_Common ); +use base qw( FS::svc_MAC_Mixin + FS::svc_Common + ); #FS::device_Common use strict; use Tie::IxHash; @@ -115,6 +117,22 @@ sub table_info { }; } +=item label + +Returns the MAC address and serial number. + +=cut + +sub label { + my $self = shift; + my @label = (); + push @label, 'MAC:'. $self->mac_addr_pretty + if $self->mac_addr; + push @label, 'Serial#'. $self->serialnum + if $self->serialnum; + return join(', ', @label); +} + =item insert Adds this record to the database. If there is an error, returns the error, diff --git a/FS/FS/svc_phone.pm b/FS/FS/svc_phone.pm index 77b013726..887f7bed3 100644 --- a/FS/FS/svc_phone.pm +++ b/FS/FS/svc_phone.pm @@ -2,9 +2,12 @@ package FS::svc_phone; use strict; use base qw( FS::svc_Domain_Mixin FS::location_Mixin FS::svc_Common ); -use vars qw( $DEBUG $me @pw_set $conf $phone_name_max ); +use vars qw( $DEBUG $me @pw_set $conf $phone_name_max + $passwordmin $passwordmax + ); use Data::Dumper; use Scalar::Util qw( blessed ); +use List::Util qw( min ); use FS::Conf; use FS::Record qw( qsearch qsearchs dbh ); use FS::PagedSearch qw( psearch ); @@ -26,6 +29,8 @@ $DEBUG = 0; FS::UID->install_callback( sub { $conf = new FS::Conf; $phone_name_max = $conf->config('svc_phone-phone_name-max_length'); + $passwordmin = $conf->config('sip_passwordmin') || 0; + $passwordmax = $conf->config('sip_passwordmax') || 80; } ); @@ -534,10 +539,17 @@ sub check { } } - unless ( length($self->sip_password) ) { # option for this? + if ( length($self->sip_password) ) { + + return "SIP password must be longer than $passwordmin characters" + if length($self->sip_password) < $passwordmin; + return "SIP password must be shorter than $passwordmax characters" + if length($self->sip_password) > $passwordmax; + + } else { # option for this? $self->sip_password( - join('', map $pw_set[ int(rand $#pw_set) ], (0..16) ) + join('', map $pw_set[ int(rand $#pw_set) ], (1..min($passwordmax,16)) ) ); } @@ -638,7 +650,13 @@ sub radius_check { my $conf = new FS::Conf; - $check{'User-Password'} = $conf->config('svc_phone-radius-default_password'); + my $password; + if ( $conf->config('svc_phone-radius-password') eq 'countrycode_phonenum' ) { + $password = $self->countrycode. $self->phonenum; + } else { + $password = $conf->config('svc_phone-radius-default_password'); + } + $check{'User-Password'} = $password; %check; } diff --git a/FS/bin/freeside-queued b/FS/bin/freeside-queued index 5eac06b24..f1a87cac9 100644 --- a/FS/bin/freeside-queued +++ b/FS/bin/freeside-queued @@ -12,6 +12,7 @@ use FS::Record qw(qsearch); use FS::queue; use FS::queue_depend; use FS::Log; +use FS::Cron::expire_user_pref qw( expire_user_pref ); # no autoloading for non-FS classes... use Net::SSH 0.07; @@ -66,6 +67,7 @@ while (1) { if ( $kids >= $max_kids ) { warn "WARNING: maximum $kids children reached\n" unless $warnkids++; &reap_kids; + expire_user_pref() unless $warnkids % 10; sleep 1; #waiting for signals is cheap next; } @@ -131,6 +133,7 @@ while (1) { undef $FS::UID::dbh; next; }; + expire_user_pref(); sleep $sleep_time; next; } diff --git a/FS/bin/freeside-upgrade b/FS/bin/freeside-upgrade index 7cacf105c..45d2709da 100755 --- a/FS/bin/freeside-upgrade +++ b/FS/bin/freeside-upgrade @@ -84,6 +84,13 @@ if ( dbdef->table('areacode') and } } +if ( dbdef->table('upgrade_journal') ) { + push @bugfix, "SELECT SETVAL( 'upgrade_journal_upgradenum_seq', + ( SELECT MAX(upgradenum) FROM upgrade_journal ) + ) + "; +} + if ( $DRY_RUN ) { print join(";\n", @bugfix ). ";\n"; |