self-service Drupal module, RT#9380
[freeside.git] / FS / FS / ClientAPI / Signup.pm
index c376476..a4032f3 100644 (file)
@@ -1,7 +1,7 @@
 package FS::ClientAPI::Signup;
 
 use strict;
-use vars qw($DEBUG $me);
+use vars qw( $DEBUG $me );
 use Data::Dumper;
 use Tie::RefHash;
 use FS::Conf;
@@ -90,7 +90,7 @@ sub signup_info {
                             ],
 
       'agent' => [ map { my $agent = $_;
-                         map { $_ => $agent->get($_) } @agent_fields;
+                        +{ map { $_ => $agent->get($_) } @agent_fields }
                        }
                        qsearch('agent', { 'disabled' => '' } )
                  ],
@@ -111,6 +111,9 @@ sub signup_info {
 
       'payby' => [ $conf->config('signup_server-payby') ],
 
+      'payby_longname' => [ map { FS::payby->longname($_) } 
+                            $conf->config('signup_server-payby') ],
+
       'card_types' => card_types(),
 
       'paytypes' => [ @FS::cust_main::paytypes ],
@@ -338,6 +341,36 @@ sub signup_info {
         foreach qw( address1 city county state zip country );
     }
 
+    #some of the above could probably be cached, too
+
+    my $signup_info_cache_agent = $cache->get("signup_info_cache_agent$agentnum");
+
+    if ( $signup_info_cache_agent ) {
+
+      warn "$me loading cached signup info for agentnum $agentnum\n"
+        if $DEBUG > 1;
+
+    } else {
+
+      warn "$me populating signup info cache for agentnum $agentnum\n"
+        if $DEBUG > 1;
+
+      $signup_info_cache_agent = {
+        #( map { $_ => scalar( $conf->config($_, $agentnum) ) }
+        #  qw( company_name ) ),
+        ( map { $_ => scalar( $conf->config("selfservice-$_", $agentnum ) ) }
+          qw( body_bgcolor box_bgcolor) ),
+        ( map { $_ => join("\n", $conf->config("selfservice-$_", $agentnum ) ) }
+          qw( head body_header body_footer ) ),
+      };
+
+      $cache->set("signup_info_cache_agent$agentnum", $signup_info_cache_agent);
+
+    }
+
+    $signup_info->{$_} = $signup_info_cache_agent->{$_}
+      foreach keys %$signup_info_cache_agent;
+
   }
   # else {
   # delete $signup_info->{'part_pkg'};
@@ -619,14 +652,10 @@ sub new_customer {
     #     " new customer: $bill_error"
     #  if $bill_error;
 
-    if ($cust_main->_new_bop_required()) {
-      $bill_error = $cust_main->realtime_collect(
-         method        => FS::payby->payby2bop( $packet->{payby} ),
-         depend_jobnum => $placeholder->jobnum,
-      );
-    } else {
-      $bill_error = $cust_main->collect('realtime' => 1);
-    }
+    $bill_error = $cust_main->realtime_collect(
+       method        => FS::payby->payby2bop( $packet->{payby} ),
+       depend_jobnum => $placeholder->jobnum,
+    );
     #warn "[fs_signup_server] error collecting from new customer: $bill_error"
     #  if $bill_error;