X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2FClientAPI%2FMyAccount.pm;h=57d42982da9d948e01402fdbe75c35f3b6d931dd;hp=30ab96b49af7f87ed39826bd13321025d464e45c;hb=b22ecae7aaa96df5f0e70a5bea87ee42feaf7d30;hpb=8f1188e8550992bf3d9078e7a6042420eaf92bd5 diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm index 30ab96b49..57d42982d 100644 --- a/FS/FS/ClientAPI/MyAccount.pm +++ b/FS/FS/ClientAPI/MyAccount.pm @@ -184,6 +184,29 @@ sub skin_info { } +sub get_mac_address { + my $p = shift; + +## access radius exports acct tables to get mac + my @part_export = (); + @part_export = ( + qsearch( 'part_export', { 'exporttype' => 'sqlradius' } ), + qsearch( 'part_export', { 'exporttype' => 'sqlradius_withdomain' } ), + qsearch( 'part_export', { 'exporttype' => 'broadband_sqlradius' } ), + ); + + my @sessions; + foreach my $part_export (@part_export) { + push @sessions, ( @{ $part_export->usage_sessions( { + 'ip' => $p->{'ip'}, + } ) } ); + } + + my $mac = $sessions[0]->{'callingstationid'}; + + return { 'mac_address' => $mac, }; +} + sub login_info { my $p = shift; @@ -237,6 +260,16 @@ sub login { $svc_x = $svc_phone; + } elsif ( $p->{'domain'} eq 'ip_mac' ) { + + my $mac_address = $p->{'username'}; + $mac_address =~ s/\://g; + + my $svc_broadband = qsearchs( 'svc_broadband', { 'mac_addr' => $mac_address } ); + return { error => 'MAC address not found '.$p->{'username'} } + unless $svc_broadband; + $svc_x = $svc_broadband; + } elsif ( $p->{email} && (my $contact = FS::contact->by_selfservice_email($p->{email})) ) @@ -623,6 +656,8 @@ sub customer_info_short { for (@cust_main_editable_fields) { $return{$_} = $cust_main->get($_); } + $return{$_} = $cust_main->masked($_) for qw/ss stateid/; + #maybe a little more expensive, but it should be cached by now for (@location_editable_fields) { $return{$_} = $cust_main->bill_location->get($_) @@ -914,6 +949,7 @@ sub payment_info { $return{paybatch} = $return{payunique}; #back compat $return{credit_card_surcharge_percentage} = $conf->config('credit-card-surcharge-percentage', $cust_main->agentnum); + $return{credit_card_surcharge_flatfee} = $conf->config('credit-card-surcharge-flatfee', $cust_main->agentnum); return { 'error' => '', %return, @@ -1675,14 +1711,15 @@ sub insert_payby { #XXX payinfo1 + payinfo2 for CHEK? #or take the opportunity to use separate, more well- named fields? - # my $payinfo; - # $p->{'payinfo1'} =~ /^([\dx]+)$/ - # or return { 'error' => "illegal account number ". $p->{'payinfo1'} }; - # my $payinfo1 = $1; - # $p->{'payinfo2'} =~ /^([\dx\.]+)$/ # . turned on by echeck-country CA ? - # or return { 'error' => "illegal ABA/routing number ". $p->{'payinfo2'} }; - # my $payinfo2 = $1; - # $payinfo = $payinfo1. '@'. $payinfo2; + if ($p->{'payby'} eq 'CHEK') { + $p->{'payinfo1'} =~ /^([\dx]+)$/ + or return { 'error' => "illegal account number ". $p->{'payinfo1'} }; + my $payinfo1 = $1; + $p->{'payinfo2'} =~ /^([\dx\.]+)$/ # . turned on by echeck-country CA ? + or return { 'error' => "illegal ABA/routing number ". $p->{'payinfo2'} }; + my $payinfo2 = $1; + $p->{'payinfo'} = $payinfo1. '@'. $payinfo2; + } my $cust_payby = new FS::cust_payby { 'custnum' => $custnum, @@ -1706,26 +1743,50 @@ sub update_payby { my($context, $session, $custnum) = _custoragent_session_custnum($p); return { 'error' => $session } if $context eq 'error'; + if ($p->{'payby'} eq 'CHEK') { + $p->{'payinfo1'} =~ /^([\dx]+)$/ + or return { 'error' => "illegal account number ". $p->{'payinfo1'} }; + my $payinfo1 = $1; + $p->{'payinfo2'} =~ /^([\dx\.]+)$/ # . turned on by echeck-country CA ? + or return { 'error' => "illegal ABA/routing number ". $p->{'payinfo2'} }; + my $payinfo2 = $1; + $p->{'payinfo'} = $payinfo1. '@'. $payinfo2; + } + my $cust_payby = qsearchs('cust_payby', { 'custnum' => $custnum, 'custpaybynum' => $p->{'custpaybynum'}, }) or return { 'error' => 'unknown custpaybynum '. $p->{'custpaybynum'} }; + my $cust_main = qsearchs( 'cust_main', {custnum => $cust_payby->custnum} ) + or return { 'error' => 'unknown custnum '.$cust_payby->custnum }; + foreach my $field ( qw( weight payby payinfo paycvv paydate payname paystate paytype payip ) ) { next unless exists($p->{$field}); $cust_payby->set($field,$p->{$field}); } + $cust_payby->set( 'paymask' => $cust_payby->mask_payinfo ); - my $error = $cust_payby->replace; - if ( $error ) { - return { 'error' => $error }; - } else { - return { 'custpaybynum' => $cust_payby->custpaybynum }; + # Update column if given a value, and the given value wasn't + # the value generated by $cust_main->masked($column); + $cust_main->set( $_, $p->{$_} ) + for grep{ $p->{$_} !~ /^x/i; } + grep{ exists $p->{$_} } + qw/ss stateid/; + + # Perform updates within a transaction + local $FS::UID::AutoCommit = 0; + + if ( my $error = $cust_payby->replace || $cust_main->replace ) { + dbh->rollback; + return { error => $error }; } - + + dbh->commit; + return { custpaybynum => $cust_payby->custpaybynum }; } sub verify_payby { @@ -3571,6 +3632,11 @@ sub list_tickets { # unavoidable false laziness w/ httemplate/view/cust_main/tickets.html if ( $FS::TicketSystem::system && FS::TicketSystem->selfservice_priority ) { + + @tickets = grep { $_->{'_selfservice_priority'} + !~ /^\s*(closed?|resolved?|done)\s*/i } + @tickets; + my $conf = new FS::Conf; my $dir = $conf->exists('ticket_system-priority_reverse') ? -1 : 1; +{ tickets => [ @@ -3876,4 +3942,3 @@ sub _custoragent_session_custnum { } 1; -