Merge branch 'master' of git.freeside.biz:/home/git/freeside
authorIvan Kohler <ivan@freeside.biz>
Wed, 23 Apr 2014 07:14:10 +0000 (00:14 -0700)
committerIvan Kohler <ivan@freeside.biz>
Wed, 23 Apr 2014 07:14:10 +0000 (00:14 -0700)
1  2 
FS/FS/Schema.pm
FS/FS/agent.pm

diff --combined FS/FS/Schema.pm
@@@ -2232,7 -2232,7 +2232,7 @@@ sub tables_hashref 
  
          'pkgnum', 'int', 'NULL', '', '', '', #desired pkgnum for pkg-balances
          'status',       'varchar',     '', $char_d, '', '', 
-         'session_id',   'varchar', 'NULL', $char_d, '', '', #only need 32
+         'session_id',   'varchar', 'NULL', 1024, '', '', # SHA-512-hex
          'statustext',   'text',    'NULL',  '', '', '', 
          'gatewaynum',   'int',     'NULL',  '', '', '',
          #'cust_balance', @money_type,            '', '',
          'rssi',                    'int', 'NULL',        '', '', '',
          'suid',                    'int', 'NULL',        '', '', '',
          'shared_svcnum',           'int', 'NULL',        '', '', '',
 +        'serviceid',           'varchar', 'NULL',        64, '', '',#srvexport/reportfields
        ],
        'primary_key'  => 'svcnum',
        'unique'       => [ [ 'ip_addr' ], [ 'mac_addr' ] ],
diff --combined FS/FS/agent.pm
@@@ -44,49 -44,27 +44,49 @@@ from FS::Record.  The following fields 
  
  =over 4
  
 -=item agentnum - primary key (assigned automatically for new agents)
 +=item agentnum
  
 -=item agent - Text name of this agent
 +primary key (assigned automatically for new agents)
  
 -=item typenum - Agent type (see L<FS::agent_type>)
 +=item agent
  
 -=item ticketing_queueid - Ticketing Queue
 +Text name of this agent
  
 -=item invoice_template - Invoice template name
 +=item typenum
  
 -=item agent_custnum - Optional agent customer (see L<FS::cust_main>)
 +Agent type (see L<FS::agent_type>)
  
 -=item disabled - Disabled flag, empty or 'Y'
 +=item ticketing_queueid
  
 -=item prog - Deprecated (never used)
 +Ticketing Queue
  
 -=item freq - Deprecated (never used)
 +=item invoice_template
  
 -=item username - (Deprecated) Username for the Agent interface
 +Invoice template name
  
 -=item _password - (Deprecated) Password for the Agent interface
 +=item agent_custnum
 +
 +Optional agent customer (see L<FS::cust_main>)
 +
 +=item disabled
 +
 +Disabled flag, empty or 'Y'
 +
 +=item prog
 +
 +Deprecated (never used)
 +
 +=item freq
 +
 +Deprecated (never used)
 +
 +=item username
 +
 +(Deprecated) Username for the Agent interface
 +
 +=item _password
 +
 +(Deprecated) Password for the Agent interface
  
  =back
  
@@@ -147,7 -125,6 +147,7 @@@ sub check 
        || $self->ut_textn('prog')
        || $self->ut_textn('invoice_template')
        || $self->ut_foreign_keyn('agent_custnum', 'cust_main', 'custnum' )
 +      || $self->ut_numbern('ticketing_queueid')
    ;
    return $error if $error;
  
@@@ -232,7 -209,7 +232,7 @@@ field, or the empty string
  sub ticketing_queue {
    my $self = shift;
    FS::TicketSystem->queue($self->ticketing_queueid);
 -};
 +}
  
  =item payment_gateway [ OPTION => VALUE, ... ]
  
@@@ -271,8 -248,27 +271,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;