X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fagent.pm;h=0bb7561da508652ec056c9feafe21a9c84a9add6;hp=d70ff18b4f7dd2224427b4432f1195b04acfe030;hb=13f21e01ac9faa50c07f64c20cbceae0ae50790c;hpb=fe4515eb37d76849dd08c62782d86bc7ba311dcd diff --git a/FS/FS/agent.pm b/FS/FS/agent.pm index d70ff18b4..0bb7561da 100644 --- a/FS/FS/agent.pm +++ b/FS/FS/agent.pm @@ -7,9 +7,8 @@ use Business::CreditCard 0.28; use FS::Record qw( dbh qsearch qsearchs ); use FS::cust_main; use FS::cust_pkg; -use FS::agent_type; -use FS::agent_currency; use FS::reg_code; +use FS::agent_payment_gateway; use FS::TicketSystem; use FS::Conf; @@ -157,13 +156,6 @@ sub check { Returns the FS::agent_type object (see L) for this agent. -=cut - -sub agent_type { - my $self = shift; - qsearchs( 'agent_type', { 'typenum' => $self->typenum } ); -} - =item agent_cust_main Returns the FS::cust_main object (see L), if any, for this @@ -181,13 +173,6 @@ sub agent_cust_main { Returns the FS::agent_currency objects (see L), if any, for this agent. -=cut - -sub agent_currency { - my $self = shift; - qsearch('agent_currency', { 'agentnum' => $self->agentnum } ); -} - =item agent_currency_hashref Returns a hash references of supported additional currencies for this agent. @@ -263,8 +248,27 @@ sub payment_gateway { # seeing the card number my $gatewaynum = $conf->config('selfservice-payment_gateway', $self->agentnum); - my $gateway = FS::payment_gateway->by_key($gatewaynum) - if $gatewaynum; + my $gateway; + $gateway = FS::payment_gateway->by_key($gatewaynum) if $gatewaynum; + return $gateway if $gateway; + + # a little less kludgey than the above, and allows PayPal to coexist + # with credit card gateways + my $is_paypal = { op => '!=', value => 'PayPal' }; + if ( uc($options{method}) eq 'PAYPAL' ) { + $is_paypal = 'PayPal'; + } + + $gateway = qsearchs({ + table => 'payment_gateway', + addl_from => ' JOIN agent_payment_gateway USING (gatewaynum) ', + hashref => { + gateway_namespace => 'Business::OnlineThirdPartyPayment', + gateway_module => $is_paypal, + disabled => '', + }, + extra_sql => ' AND agentnum = '.$self->agentnum, + }); if ( $gateway ) { return $gateway; @@ -434,6 +438,29 @@ sub cust_main_sql { ); } +=item num_ordered_cust_main + +Returns the number of ordered customers for this agent (customers with packages +ordered, but not yet billed). + +=cut + +sub num_ordered_cust_main { + shift->num_sql(FS::cust_main->ordered_sql); +} + +=item ordered_cust_main + +Returns the ordered customers for this agent (customers with packages ordered, +but not yet billed), as cust_main objects. + +=cut + +sub ordered_cust_main { + shift->cust_main_sql(FS::cust_main->ordered_sql); +} + + =item num_active_cust_main Returns the number of active customers for this agent (customers with active