add billco respooling, not re-FTPing, RT#3971
authorivan <ivan>
Fri, 12 Sep 2008 02:02:01 +0000 (02:02 +0000)
committerivan <ivan>
Fri, 12 Sep 2008 02:02:01 +0000 (02:02 +0000)
FS/FS/Conf.pm
FS/FS/cust_bill.pm
httemplate/misc/spool_invoices.cgi [new file with mode: 0644]
httemplate/search/cust_bill.html

index cf569a9..d244dce 100644 (file)
@@ -1865,6 +1865,21 @@ worry that config_items is freeside-specific and icky.
   },
 
   {
+    'key'         => 'cust_bill-spoolformat',
+    'section'     => 'billing',
+    'description' => 'Enable spooling of raw invoice data - format.',
+    'type'        => 'select',
+    'select_enum' => [ '', 'default', 'billco', ],
+  },
+
+  {
+    'key'         => 'cust_bill-spoolagent',
+    'section'     => 'billing',
+    'description' => 'Enable per-agent spooling of raw invoice data.',
+    'type'        => 'checkbox',
+  },
+
+  {
     'key'         => 'svc_acct-usage_suspend',
     'section'     => 'billing',
     'description' => 'Suspends the package an account belongs to when svc_acct.seconds or a bytecount is decremented to 0 or below (accounts with an empty seconds and up|down|totalbytes value are ignored).  Typically used in conjunction with prepaid packages and freeside-sqlradius-radacctd.',
@@ -2337,7 +2352,7 @@ worry that config_items is freeside-specific and icky.
   {
     'key'         => 'card_masking_method',
     'section'     => 'UI',
-    'description' => 'Digits to display when masking credit cards.  Note that the first six digits are necessary to canonically identify the credit card type (Visa/MC, Amex, Discover, Maestro, etc.) in all cases.  The first four digits can identify the most common credit card types in most cases (Visa/MC, Amex, and Discover).  The first two digits can distinguish between Visa/MC and Amex.',
+    'description' => 'Digits to display when masking credit cards.  Note that the first six digits are necessary to canonically identify the credit card type (Visa/MC, Amex, Discover, Maestro, etc.) in all cases.  The first four digits can identify the most common credit card types in most cases (Visa/MC, Amex, and Discover).  The first two digits can distinguish between Visa/MC and Amex.  Note: You should manually remove stored paymasks if you change this value on an existing database, to avoid problems using stored cards.',
     'type'        => 'select',
     'select_hash' => [
                        ''            => '123456xxxxxx1234',
index 4fa876b..61ae6c0 100644 (file)
@@ -996,6 +996,24 @@ sub ftp_invoice {
   );
 }
 
+=item spool_invoice [ TEMPLATENAME ] 
+
+Spools this invoice data (see L<FS::spool_csv>)
+
+TEMPLATENAME is unused?
+
+=cut
+
+sub spool_invoice {
+  my $self = shift;
+  my $template = scalar(@_) ? shift : '';
+
+  $self->spool_csv(
+    'format'       => $conf->config('cust_bill-spoolformat'),
+    'agent_spools' => $conf->exists('cust_bill-spoolagent'),
+  );
+}
+
 =item send_if_newest [ TEMPLATENAME [ , AGENTNUM [ , INVOICE_FROM ] ] ]
 
 Like B<send>, but only sends the invoice if it is the newest open invoice for
@@ -2887,7 +2905,7 @@ sub _items_payments {
 
 =over 4
 
-=item reprint
+=item process_reprint
 
 =cut
 
@@ -2895,7 +2913,7 @@ sub process_reprint {
   process_re_X('print', @_);
 }
 
-=item reemail
+=item process_reemail
 
 =cut
 
@@ -2903,7 +2921,7 @@ sub process_reemail {
   process_re_X('email', @_);
 }
 
-=item refax
+=item process_refax
 
 =cut
 
@@ -2911,7 +2929,7 @@ sub process_refax {
   process_re_X('fax', @_);
 }
 
-=item reftp
+=item process_reftp
 
 =cut
 
@@ -2919,6 +2937,14 @@ sub process_reftp {
   process_re_X('ftp', @_);
 }
 
+=item respool
+
+=cut
+
+sub process_respool {
+  process_re_X('spool', @_);
+}
+
 use Storable qw(thaw);
 use Data::Dumper;
 use MIME::Base64;
diff --git a/httemplate/misc/spool_invoices.cgi b/httemplate/misc/spool_invoices.cgi
new file mode 100644 (file)
index 0000000..bfe24e6
--- /dev/null
@@ -0,0 +1,9 @@
+<% $server->process %>
+<%init>
+
+die "access denied"
+  unless $FS::CurrentUser::CurrentUser->access_right('Resend invoices');
+
+my $server = new FS::UI::Web::JSRPC 'FS::cust_bill::process_respool', $cgi;
+
+</%init>
index d22c744..6f440db 100755 (executable)
@@ -188,7 +188,7 @@ my $html_init = join("\n", map {
  qq!<FORM NAME="${_}form">!,
  ( map qq!<INPUT TYPE="hidden" NAME="$_" VALUE="$search{$_}">!, keys %search ),
  qq!</FORM>!
-} qw( print_ email_ fax_ ftp_ ) ). 
+} qw( print_ email_ fax_ ftp_ spool_ ) ). 
 
 '<SCRIPT TYPE="text/javascript">
 
@@ -216,6 +216,12 @@ function confirm_ftp_process() {
   }
   ftp_process();
 }
+function confirm_spool_process() {
+  if ( ! confirm("Are you sure you want to re-spool these invoices?") ) {
+    return;
+  }
+  spool_process();
+}
 
 </SCRIPT>';
 
@@ -235,6 +241,11 @@ if ( $FS::CurrentUser::CurrentUser->access_right('Resend invoices') ) {
   push @$menubar, 'FTP these invoices' =>
                     "javascript:confirm_ftp_process()"
     if $conf->exists('cust_bill-ftpformat');
+
+  push @$menubar, 'Spool these invoices' =>
+                    "javascript:confirm_spool_process()"
+    if $conf->exists('cust_bill-spoolformat');
+
 }
 
 </%init>