summaryrefslogtreecommitdiff
path: root/httemplate/misc
diff options
context:
space:
mode:
Diffstat (limited to 'httemplate/misc')
-rw-r--r--httemplate/misc/batch-cust_pay.html395
-rwxr-xr-xhttemplate/misc/bill.cgi41
-rwxr-xr-xhttemplate/misc/cancel-unaudited.cgi36
-rwxr-xr-xhttemplate/misc/cancel_pkg.html95
-rwxr-xr-xhttemplate/misc/catchall.cgi134
-rw-r--r--httemplate/misc/cdr-import.html16
-rwxr-xr-xhttemplate/misc/change_pkg.cgi69
-rw-r--r--httemplate/misc/counties.cgi7
-rwxr-xr-xhttemplate/misc/cust_main-cancel.cgi23
-rw-r--r--httemplate/misc/cust_main-import.cgi76
-rw-r--r--httemplate/misc/cust_main-import_charges.cgi14
-rw-r--r--httemplate/misc/delete-agent_payment_gateway.cgi15
-rwxr-xr-xhttemplate/misc/delete-cust_credit.cgi17
-rwxr-xr-xhttemplate/misc/delete-cust_pay.cgi17
-rwxr-xr-xhttemplate/misc/delete-cust_refund.cgi17
-rwxr-xr-xhttemplate/misc/delete-customer.cgi61
-rwxr-xr-xhttemplate/misc/delete-domain_record.cgi16
-rwxr-xr-xhttemplate/misc/delete-part_export.cgi16
-rw-r--r--httemplate/misc/download-batch.cgi171
-rw-r--r--httemplate/misc/dump.cgi20
-rwxr-xr-xhttemplate/misc/email-invoice.cgi18
-rw-r--r--httemplate/misc/email_invoice_events.cgi4
-rw-r--r--httemplate/misc/email_invoices.cgi4
-rwxr-xr-xhttemplate/misc/fax-invoice.cgi18
-rw-r--r--httemplate/misc/fax_invoice_events.cgi4
-rw-r--r--httemplate/misc/fax_invoices.cgi4
-rw-r--r--httemplate/misc/inventory_item-import.html21
-rwxr-xr-xhttemplate/misc/link.cgi77
-rw-r--r--httemplate/misc/meta-import.cgi73
-rw-r--r--httemplate/misc/payment.cgi207
-rwxr-xr-xhttemplate/misc/print-invoice.cgi18
-rw-r--r--httemplate/misc/print_invoice_events.cgi4
-rw-r--r--httemplate/misc/print_invoices.cgi4
-rw-r--r--httemplate/misc/process/batch-cust_pay.cgi45
-rwxr-xr-xhttemplate/misc/process/cancel_pkg.html78
-rwxr-xr-xhttemplate/misc/process/catchall.cgi34
-rw-r--r--httemplate/misc/process/cdr-import.html30
-rw-r--r--httemplate/misc/process/cust_main-import.cgi35
-rw-r--r--httemplate/misc/process/cust_main-import_charges.cgi30
-rwxr-xr-xhttemplate/misc/process/delete-customer.cgi30
-rw-r--r--httemplate/misc/process/inventory_item-import.html31
-rwxr-xr-xhttemplate/misc/process/link.cgi78
-rw-r--r--httemplate/misc/process/meta-import.cgi185
-rw-r--r--httemplate/misc/process/payment.cgi148
-rwxr-xr-xhttemplate/misc/process/recharge_svc.html46
-rw-r--r--httemplate/misc/queue.cgi48
-rwxr-xr-xhttemplate/misc/recharge_svc.html48
-rw-r--r--httemplate/misc/states.cgi7
-rw-r--r--httemplate/misc/svc_acct-domains.cgi31
-rwxr-xr-xhttemplate/misc/unapply-cust_credit.cgi19
-rwxr-xr-xhttemplate/misc/unapply-cust_pay.cgi19
-rwxr-xr-xhttemplate/misc/unprovision.cgi31
-rwxr-xr-xhttemplate/misc/unsusp_pkg.cgi16
-rwxr-xr-xhttemplate/misc/unvoid-cust_pay_void.cgi17
-rw-r--r--httemplate/misc/upload-batch.cgi39
-rwxr-xr-xhttemplate/misc/void-cust_pay.cgi17
-rw-r--r--httemplate/misc/whois.cgi27
-rw-r--r--httemplate/misc/xmlhttp-cust_main-search.cgi22
-rw-r--r--httemplate/misc/xmlrpc.cgi18
59 files changed, 2841 insertions, 0 deletions
diff --git a/httemplate/misc/batch-cust_pay.html b/httemplate/misc/batch-cust_pay.html
new file mode 100644
index 000000000..d85f3b6c3
--- /dev/null
+++ b/httemplate/misc/batch-cust_pay.html
@@ -0,0 +1,395 @@
+<% include("/elements/header.html", 'Quick payment entry',
+ menubar(
+ 'Main Menu' => $p, #popurl(1),
+ ),
+ ( $cgi->param('error') ? '' : 'onload="addRow()"' ),
+ )
+%>
+% if ( $cgi->param('error') ) {
+
+ <FONT SIZE="+1" COLOR="#ff0000"><% $cgi->param('error') %></FONT><BR><BR>
+% }
+
+
+
+<FORM ACTION="process/batch-cust_pay.cgi" NAME="OneTrueForm" METHOD="POST" onsubmit="document.OneTrueForm.submit.disabled=true;">
+
+<!-- <B>Batch</B> <INPUT TYPE="text" NAME="paybatch"><BR><BR> -->
+
+<SCRIPT TYPE="text/javascript">
+
+ function clearhint_custnum() {
+
+ //this.style.color = '#000000';
+
+ if ( this.value == 'Not found' || this.value == 'Multiple' ) {
+ this.value = '';
+ this.style.color = '#000000';
+ }
+
+ }
+
+ function clearhint_customer() {
+
+ this.style.color = '#000000';
+
+ if ( this.value == '(last name or company)' || this.value == 'Not found' )
+ this.value = '';
+
+ }
+
+ function search_custnum() {
+
+ this.style.color = '#000000'
+
+ var custnum_obj = this;
+ var searchrow = this.getAttribute('rownum');
+ var custnum = this.value;
+
+ if ( custnum == 'searching...' || custnum == 'Not found' || custnum == '' )
+ return;
+
+ if ( this.getAttribute('magic') == 'nosearch' ) {
+ this.setAttribute('magic', '');
+ return;
+ }
+
+ if ( ( rownum - searchrow ) == 1 ) {
+ addRow();
+ }
+ var customer = document.getElementById('customer'+searchrow);
+ customer.value = 'searching...';
+ customer.disabled = true;
+ customer.style.color = '#000000';
+ customer.style.backgroundColor = '#dddddd';
+
+ var customer_select = document.getElementById('cust_select'+searchrow);
+
+ //alert('search for custnum ' + custnum + ', row#' + searchrow );
+
+ customer.style.display = '';
+ customer_select.style.display = 'none';
+
+ function search_custnum_update(name) {
+
+ var name = eval('(' + name + ')' );
+
+ customer.disabled = false;
+ customer.style.backgroundColor = '#ffffff';
+
+ if ( name.length > 0 ) {
+ //alert('custnum found: ' + name);
+ customer.value = name;
+ customer.setAttribute('magic', 'nosearch');
+ } else {
+ customer.value = 'Not found';
+ customer.style.color = '#ff0000';
+ custnum_obj.style.color = '#ff0000';
+
+ }
+
+ }
+
+ custnum_search( custnum, search_custnum_update );
+
+ }
+
+ function search_customer() {
+
+ var customer_obj = this;
+ var searchrow = this.getAttribute('rownum');
+ var customer = this.value;
+
+ if ( customer == 'searching...' || customer == 'Not found' || customer == '' )
+ return;
+
+ if ( this.getAttribute('magic') == 'nosearch' ) {
+ this.setAttribute('magic', '');
+ return;
+ }
+
+ if ( ( rownum - searchrow ) == 1 ) {
+ addRow();
+ }
+
+ var custnum_obj = document.getElementById('custnum'+searchrow);
+ custnum_obj.value = 'searching...';
+ custnum_obj.disabled = true;
+ custnum_obj.style.color = '#000000';
+ custnum_obj.style.backgroundColor = '#dddddd';
+
+ var customer_select = document.getElementById('cust_select'+searchrow);
+
+ //alert('search for customer ' + customer + ', row#' + searchrow );
+
+ function search_customer_update(customers) {
+
+ //alert('customers returned: ' + customers);
+
+ var customerArray = eval('(' + customers + ')');
+
+ custnum_obj.disabled = false;
+ custnum_obj.style.backgroundColor = '#ffffff';
+
+ if ( customerArray.length == 0 ) {
+
+ custnum_obj.value = 'Not found';
+ custnum_obj.style.color = '#ff0000';
+ customer_obj.style.color = '#ff0000';
+
+ customer_obj.style.display = '';
+ customer_select.style.display = 'none';
+
+
+ } else if ( customerArray.length == 1 ) {
+
+ //alert('one customer found: ' + customerArray[0]);
+
+ custnum_obj.value = customerArray[0][0];
+ customer_obj.value = customerArray[0][1];
+
+ customer_obj.style.display = '';
+ customer_select.style.display = 'none';
+
+
+ } else {
+
+ custnum_obj.value = 'Multiple'; // or something
+ custnum_obj.style.color = '#ff0000';
+
+ //alert('multiple customers found, have to create select dropdown');
+
+ //blank the current list
+ for ( var i = customer_select.length; i >= 0; i-- )
+ customer_select.options[i] = null;
+
+ opt(customer_select, '', 'Multiple customers match "' + customer + '" - select one', '#ff0000');
+
+ //add the multiple customers
+ for ( var s = 0; s < customerArray.length; s++ )
+ opt(customer_select, customerArray[s][0], customerArray[s][1], '#000000');
+
+ opt(customer_select, 'cancel', '(Edit search string)', '#000000');
+
+ customer_obj.style.display = 'none';
+
+ customer_select.style.display = '';
+
+ }
+
+ }
+
+ smart_search( customer, search_customer_update );
+
+ }
+
+ function select_customer() {
+
+ var custnum = this.options[this.selectedIndex].value;
+ var customer = this.options[this.selectedIndex].text;
+
+ var searchrow = this.getAttribute('rownum');
+ var custnum_obj = document.getElementById('custnum'+searchrow);
+ var customer_obj = document.getElementById('customer'+searchrow);
+
+ if ( custnum == '' ) {
+ //this.style.color = '#ff0000';
+
+ } else if ( custnum == 'cancel' ) {
+
+ custnum_obj.value = '';
+ custnum_obj.style.color = '#000000';
+
+ this.style.display = 'none';
+ customer_obj.style.display = '';
+ customer_obj.focus();
+
+ } else {
+
+
+ custnum_obj.value = custnum;
+ custnum_obj.style.color = '#000000';
+
+ customer_obj.value = customer;
+ customer_obj.style.color = '#000000';
+
+ this.style.display = 'none';
+ customer_obj.style.display = '';
+
+ }
+
+ }
+
+ function opt(what,value,text,color) {
+ var optionName = new Option(text, value, false, false);
+ optionName.style.color = color;
+ var length = what.length;
+ what.options[length] = optionName;
+ }
+
+</SCRIPT>
+
+<TABLE ID="OneTrueTable" BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0>
+
+<TR>
+ <TH>Cust #</TH>
+ <TH>Customer</TH>
+ <TH>Amount</TH>
+ <TH>Check #</TH>
+ <TH BGCOLOR="#e8e8e8"></TH>
+</TR>
+% my $row = 0;
+% if ( $cgi->param('error') ) {
+% my $param = $cgi->Vars;
+%
+% for ( $row = 0; exists($param->{"custnum$row"}); $row++ ) {
+
+
+ <TR>
+
+ <TD>
+ <INPUT TYPE="text" NAME="custnum<% $row %>" ID="custnum<% $row %>" SIZE=8 MAXLENGTH=12 VALUE="<% $param->{"custnum$row"} %>" rownum="<% $row %>">
+ <SCRIPT TYPE="text/javascript">
+ var custnum_input<% $row %> = document.getElementById("custnum<% $row %>");
+ custnum_input<% $row %>.onfocus = clearhint_custnum;
+ custnum_input<% $row %>.onchange = search_custnum;
+ </SCRIPT>
+ </TD>
+
+ <TD>
+ <INPUT TYPE="text" NAME="customer<% $row %>" ID="customer<% $row %>" SIZE=64 VALUE="<% $param->{"customer$row"} %>" rownum="<% $row %>">
+ <SCRIPT TYPE="text/javascript">
+ var customer_input<% $row %> = document.getElementById("customer<% $row %>");
+ customer_input<% $row %>.onfocus = clearhint_customer;
+ customer_input<% $row %>.onclick = clearhint_customer;
+ customer_input<% $row %>.onchange = search_customer;
+ </SCRIPT>
+ <SELECT NAME="cust_select<% $row %>" ID="cust_select<% $row %>" rownum="<% $row %>" STYLE="color:#ff0000; display:none">
+ </SELECT>
+ <SCRIPT TYPE="text/javascript">
+ var customer_select<% $row %> = document.getElementById("cust_select<% $row %>");
+ customer_select<% $row %>.onchange = select_customer;
+ </SCRIPT>
+ </TD>
+
+ <TD>
+ $<INPUT TYPE="text" NAME="paid<% $row %>" SIZE=8 MAXLENGTH=8 VALUE="<% $param->{"paid$row"} %>" >
+ </TD>
+
+ <TD>
+ <INPUT TYPE="text" NAME="payinfo<% $row %>" SIZE=10 VALUE="<% $param->{"payinfo$row"} %>" >
+ </TD>
+
+ <TD BGCOLOR="#e8e8e8">
+% if ( $param->{"error$row"} ) {
+
+ <FONT SIZE="-1" COLOR="#ff0000">Error: <% $param->{"error$row"} %></FONT>
+% }
+
+ </TD>
+
+ </TR>
+% }
+% }
+
+
+</TABLE>
+
+<!-- <BR>
+<INPUT TYPE="button" VALUE="TEST addrow" onclick="addRow()"> -->
+
+<BR>
+<INPUT TYPE="submit" NAME="submit" VALUE="Post payment batch">
+
+</FORM>
+
+
+<% include('/elements/xmlhttp.html',
+ 'url' => $p. 'misc/xmlhttp-cust_main-search.cgi',
+ 'subs' => [qw( custnum_search smart_search )],
+ )
+%>
+
+<SCRIPT TYPE="text/javascript">
+
+ var rownum = <% $row %>;
+
+ function addRow() {
+
+ var table = document.getElementById('OneTrueTable');
+ var tablebody = table.getElementsByTagName('tbody').item(0);
+
+ var row = document.createElement('TR');
+
+ var custnum_cell = document.createElement('TD');
+
+ var custnum_input = document.createElement('INPUT');
+ custnum_input.setAttribute('name', 'custnum'+rownum);
+ custnum_input.setAttribute('id', 'custnum'+rownum);
+ custnum_input.setAttribute('size', 8);
+ custnum_input.setAttribute('maxlength', 12);
+ custnum_input.setAttribute('rownum', rownum);
+ custnum_input.onfocus = clearhint_custnum;
+ custnum_input.onchange = search_custnum;
+ custnum_cell.appendChild(custnum_input);
+
+ row.appendChild(custnum_cell);
+
+ var customer_cell = document.createElement('TD');
+
+ var customer_input = document.createElement('INPUT');
+ customer_input.setAttribute('name', 'customer'+rownum);
+ customer_input.setAttribute('id', 'customer'+rownum);
+ customer_input.setAttribute('size', 64);
+ customer_input.setAttribute('value', '(last name or company)' );
+ customer_input.setAttribute('rownum', rownum);
+ customer_input.onfocus = clearhint_customer;
+ customer_input.onclick = clearhint_customer;
+ customer_input.onchange = search_customer;
+ customer_cell.appendChild(customer_input);
+
+ var customer_select = document.createElement('SELECT');
+ customer_select.setAttribute('name', 'cust_select'+rownum);
+ customer_select.setAttribute('id', 'cust_select'+rownum);
+ customer_select.setAttribute('rownum', rownum);
+ customer_select.style.color = '#ff0000';
+ customer_select.style.display = 'none';
+ customer_select.onchange = select_customer;
+ customer_cell.appendChild(customer_select);
+
+ row.appendChild(customer_cell);
+
+ var paid_cell = document.createElement('TD');
+
+ var paid_text = document.createTextNode('$');
+ paid_cell.appendChild(paid_text);
+
+ var paid_input = document.createElement('INPUT');
+ paid_input.setAttribute('name', 'paid'+rownum);
+ paid_input.setAttribute('size', 8);
+ paid_input.setAttribute('maxlength', 8);
+ paid_cell.appendChild(paid_input);
+
+ row.appendChild(paid_cell);
+
+ var payinfo_cell = document.createElement('TD');
+ var payinfo_input = document.createElement('INPUT');
+ payinfo_input.setAttribute('name', 'payinfo'+rownum);
+ payinfo_input.setAttribute('size', 10);
+ payinfo_cell.appendChild(payinfo_input);
+ row.appendChild(payinfo_cell);
+
+ var error_cell = document.createElement('TD');
+ error_cell.style.backgroundColor = '#e8e8e8';
+ row.appendChild(error_cell);
+
+ tablebody.appendChild(row);
+
+ rownum++;
+
+ }
+
+</SCRIPT>
+
+</BODY>
+</HTML>
diff --git a/httemplate/misc/bill.cgi b/httemplate/misc/bill.cgi
new file mode 100755
index 000000000..8d4b4ac65
--- /dev/null
+++ b/httemplate/misc/bill.cgi
@@ -0,0 +1,41 @@
+%
+%#untaint custnum
+%my($query) = $cgi->keywords;
+%$query =~ /^(\d*)$/;
+%my $custnum = $1;
+%my $cust_main = qsearchs('cust_main',{'custnum'=>$custnum});
+%die "Can't find customer!\n" unless $cust_main;
+%
+%my $conf = new FS::Conf;
+%
+%my $error = $cust_main->bill(
+%# 'time'=>$time
+% );
+%#&eidiot($error) if $error;
+%
+%unless ( $error ) {
+% $cust_main->apply_payments_and_credits;
+%
+% $error = $cust_main->collect(
+% # 'invoice-time'=>$time,
+% #'batch_card'=> 'yes',
+% #'batch_card'=> 'no',
+% #'report_badcard'=> 'yes',
+% #'retry_card' => 'yes',
+% 'retry' => 'yes',
+% 'realtime' => $conf->exists('realtime-backend'),
+% );
+%}
+%#&eidiot($error) if $error;
+%
+%if ( $error ) {
+%
+
+<!-- mason kludge -->
+%
+% &idiot($error);
+%} else {
+% print $cgi->redirect(popurl(2). "view/cust_main.cgi?$custnum");
+%}
+%
+
diff --git a/httemplate/misc/cancel-unaudited.cgi b/httemplate/misc/cancel-unaudited.cgi
new file mode 100755
index 000000000..6f070a444
--- /dev/null
+++ b/httemplate/misc/cancel-unaudited.cgi
@@ -0,0 +1,36 @@
+%
+%
+%my $dbh = dbh;
+%
+%#untaint svcnum
+%my($query) = $cgi->keywords;
+%$query =~ /^(\d+)$/;
+%my $svcnum = $1;
+%
+%#my $svc_acct = qsearchs('svc_acct',{'svcnum'=>$svcnum});
+%#die "Unknown svcnum!" unless $svc_acct;
+%
+%my $cust_svc = qsearchs('cust_svc',{'svcnum'=>$svcnum});
+%die "Unknown svcnum!" unless $cust_svc;
+%my $cust_pkg = $cust_svc->cust_pkg;
+%if ( $cust_pkg ) {
+% &eidiot( 'This account has already been audited. Cancel the '.
+% qq!<A HREF="${p}view/cust_main.cgi?!. $cust_pkg->custnum.
+% '#cust_pkg'. $cust_pkg->pkgnum. '">'.
+% 'package</A> instead.');
+%}
+%
+%my $error = $cust_svc->cancel;
+%
+%if ( $error ) {
+%
+
+<!-- mason kludge -->
+%
+% &eidiot($error);
+%} else {
+% print $cgi->redirect(popurl(2));
+%}
+%
+%
+
diff --git a/httemplate/misc/cancel_pkg.html b/httemplate/misc/cancel_pkg.html
new file mode 100755
index 000000000..e61000618
--- /dev/null
+++ b/httemplate/misc/cancel_pkg.html
@@ -0,0 +1,95 @@
+%# if ( $link eq 'popup' ) {
+ <% include('/elements/header-popup.html', $title ) %>
+%# } else {
+%# <% include("/elements/header.html", $title, '') %>
+%# }
+
+<LINK REL="stylesheet" TYPE="text/css" HREF="../elements/calendar-win2k-2.css" TITLE="win2k-2">
+<SCRIPT TYPE="text/javascript" SRC="../elements/calendar_stripped.js"></SCRIPT>
+<SCRIPT TYPE="text/javascript" SRC="../elements/calendar-en.js"></SCRIPT>
+<SCRIPT TYPE="text/javascript" SRC="../elements/calendar-setup.js"></SCRIPT>
+
+% if ( $cgi->param('error') ) {
+ <FONT SIZE="+1" COLOR="#ff0000">Error: <% $cgi->param('error') %></FONT>
+ <BR><BR>
+% }
+
+<FORM NAME="sc_popup" ACTION="<% popurl(1) %>process/cancel_pkg.html" METHOD=POST>
+<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>">
+<INPUT TYPE="hidden" NAME="method" VALUE="<% $method %>">
+
+
+<BR><BR>
+<% ucfirst($method) . " $pkgnum: " .$part_pkg->pkg. ' - ' .$part_pkg->comment %>
+<% ntable("#cccccc", 2) %>
+
+% if ($method eq 'expire') {
+<TR>
+ <TD>Cancel package on </TD>
+ <TD><INPUT TYPE="text" NAME="date" ID="expire_date" VALUE="<% $date %>">
+ <IMG SRC="<% $p %>images/calendar.png" ID="expire_button" STYLE="cursor:pointer" TITLE="Select date">
+ <BR><I>m/d/y</I>
+ </TD>
+</TR>
+<SCRIPT TYPE="text/javascript">
+ Calendar.setup({
+ inputField: "expire_date",
+ ifFormat: "%m/%d/%Y",
+ button: "expire_button",
+ align: "BR"
+ });
+</SCRIPT>
+%}
+%
+
+<% include('/elements/tr-select-reason.html', 'reasonnum', $class, '', '', '', 'document.sc_popup.submit' ) %>
+
+</TABLE>
+
+<BR>
+<INPUT TYPE="submit" NAME="submit" VALUE="<% $submit %>" disabled='true'>
+
+</FORM>
+</BODY>
+</HTML>
+
+<%init>
+my($method, $pkgnum, $reasonnum, $submit, $cust_pkg, $part_pkg,
+ $date, $curuser, $class);
+$date = time2str("%m/%d/%Y", time);
+if ( $cgi->param('error') ) {
+ $method = $cgi->param('method');
+ $pkgnum = $cgi->param('pkgnum');
+ $reasonnum = $cgi->param('reasonnum');
+ $date = $cgi->param('date');
+} elsif ( $cgi->param('pkgnum') =~ /^(\d+)$/ ) {
+ $pkgnum = $1;
+} else {
+ die "illegal query ". $cgi->keywords;
+}
+
+$method = $cgi->param('method');
+if ($method eq 'cancel') {
+ $class = 'C';
+ $submit = "Cancel Now";
+}elsif ($method eq 'expire') {
+ $class = 'C';
+ $submit = "Cancel Later";
+}elsif ($method eq 'suspend') {
+ $class = 'S';
+ $submit = "Suspend";
+}else{
+ die "illegal query ". $cgi->keywords;
+}
+
+my $title = ucfirst($method) . ' Package';
+
+$cust_pkg = qsearchs('cust_pkg', {'pkgnum' => $pkgnum});
+die "No such package: $pkgnum" unless $cust_pkg;
+
+$part_pkg = $cust_pkg->part_pkg;
+
+$curuser = $FS::CurrentUser::CurrentUser;
+
+</%init>
+
diff --git a/httemplate/misc/catchall.cgi b/httemplate/misc/catchall.cgi
new file mode 100755
index 000000000..8881746d1
--- /dev/null
+++ b/httemplate/misc/catchall.cgi
@@ -0,0 +1,134 @@
+<!-- mason kludge -->
+%
+%
+%my $conf = new FS::Conf;
+%
+%my($svc_domain, $svcnum, $pkgnum, $svcpart, $part_svc);
+%if ( $cgi->param('error') ) {
+% $svc_domain = new FS::svc_domain ( {
+% map { $_, scalar($cgi->param($_)) } fields('svc_domain')
+% } );
+% $svcnum = $svc_domain->svcnum;
+% $pkgnum = $cgi->param('pkgnum');
+% $svcpart = $cgi->param('svcpart');
+% $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart});
+% die "No part_svc entry!" unless $part_svc;
+%} else {
+% my($query) = $cgi->keywords;
+% if ( $query =~ /^(\d+)$/ ) { #editing
+% $svcnum=$1;
+% $svc_domain=qsearchs('svc_domain',{'svcnum'=>$svcnum})
+% or die "Unknown (svc_domain) svcnum!";
+%
+% my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum})
+% or die "Unknown (cust_svc) svcnum!";
+%
+% $pkgnum=$cust_svc->pkgnum;
+% $svcpart=$cust_svc->svcpart;
+%
+% $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart});
+% die "No part_svc entry!" unless $part_svc;
+%
+% } else {
+%
+% die "Invalid (svc_domain) svcnum!";
+%
+% }
+%}
+%
+%my %email;
+%if ($pkgnum) {
+%
+% #find all possible user svcnums (and emails)
+%
+% #starting with that currently attached
+% if ($svc_domain->catchall) {
+% my($svc_acct)=qsearchs('svc_acct',{'svcnum'=>$svc_domain->catchall});
+% $email{$svc_domain->catchall} = $svc_acct->email;
+% }
+%
+% #and including the rest for this customer
+% my($u_part_svc,@u_acct_svcparts);
+% foreach $u_part_svc ( qsearch('part_svc',{'svcdb'=>'svc_acct'}) ) {
+% push @u_acct_svcparts,$u_part_svc->getfield('svcpart');
+% }
+%
+% my($cust_pkg)=qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
+% my($custnum)=$cust_pkg->getfield('custnum');
+% my($i_cust_pkg);
+% foreach $i_cust_pkg ( qsearch('cust_pkg',{'custnum'=>$custnum}) ) {
+% my($cust_pkgnum)=$i_cust_pkg->getfield('pkgnum');
+% my($acct_svcpart);
+% foreach $acct_svcpart (@u_acct_svcparts) { #now find the corresponding
+% #record(s) in cust_svc ( for this
+% #pkgnum ! )
+% my($i_cust_svc);
+% foreach $i_cust_svc ( qsearch('cust_svc',{'pkgnum'=>$cust_pkgnum,'svcpart'=>$acct_svcpart}) ) {
+% my($svc_acct)=qsearchs('svc_acct',{'svcnum'=>$i_cust_svc->getfield('svcnum')});
+% $email{$svc_acct->getfield('svcnum')}=$svc_acct->email;
+% }
+% }
+% }
+%
+%} else {
+%
+% my($svc_acct)=qsearchs('svc_acct',{'svcnum'=>$svc_domain->catchall});
+% $email{$svc_domain->catchall} = $svc_acct->email;
+%}
+%
+%# add an absence of a catchall
+%$email{''} = "(none)";
+%
+%my $p1 = popurl(1);
+%print header("Domain Catchall Edit", '');
+%
+%print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'),
+% "</FONT>"
+% if $cgi->param('error');
+%
+%print qq!<FORM ACTION="${p1}process/catchall.cgi" METHOD=POST>!;
+%
+%#display
+%
+% #formatting
+% print "<PRE>";
+%
+%#svcnum
+%print qq!<INPUT TYPE="hidden" NAME="svcnum" VALUE="$svcnum">!;
+%print qq!Service #<FONT SIZE=+1><B>!, $svcnum ? $svcnum : " (NEW)", "</B></FONT>";
+%
+%#pkgnum
+%print qq!<INPUT TYPE="hidden" NAME="pkgnum" VALUE="$pkgnum">!;
+%
+%#svcpart
+%print qq!<INPUT TYPE="hidden" NAME="svcpart" VALUE="$svcpart">!;
+%
+%my($domain,$catchall)=(
+% $svc_domain->domain,
+% $svc_domain->catchall,
+%);
+%
+%print qq!<INPUT TYPE="hidden" NAME="domain" VALUE="$domain">!;
+%
+%#catchall
+%print qq!\n\nMail to <I>(anything)</I>@<B>$domain</B> forwards to <SELECT NAME="catchall" SIZE=1>!;
+%foreach $_ (keys %email) {
+% print "<OPTION", $_ eq $catchall ? " SELECTED" : "",
+% qq! VALUE="$_">$email{$_}!;
+%}
+%print "</SELECT>";
+%
+% #formatting
+% print "</PRE>\n";
+%
+%print qq!<CENTER><INPUT TYPE="submit" VALUE="Submit"></CENTER>!;
+%
+%print <<END;
+%
+% </FORM>
+% </BODY>
+%</HTML>
+%END
+%
+%
+
diff --git a/httemplate/misc/cdr-import.html b/httemplate/misc/cdr-import.html
new file mode 100644
index 000000000..5e9e2690d
--- /dev/null
+++ b/httemplate/misc/cdr-import.html
@@ -0,0 +1,16 @@
+<% include("/elements/header.html",'Call Detail Record Import') %>
+<FORM ACTION="process/cdr-import.html" METHOD="POST" ENCTYPE="multipart/form-data">
+Import a CSV file containing Call Detail Records (CDRs).<BR><BR>
+CDR Format: <SELECT NAME="format">
+<OPTION VALUE="asterisk">Asterisk (untested)</OPTION>
+<OPTION VALUE="unitel">Unitel/RSLCOM</OPTION>
+<OPTION VALUE="ams">AMS</OPTION>
+</SELECT><BR><BR>
+
+Filename: <INPUT TYPE="file" NAME="csvfile"><BR><BR>
+
+<INPUT TYPE="submit" VALUE="Upload">
+</FORM>
+
+<% include('/elements/footer.html') %>
+
diff --git a/httemplate/misc/change_pkg.cgi b/httemplate/misc/change_pkg.cgi
new file mode 100755
index 000000000..655799fc1
--- /dev/null
+++ b/httemplate/misc/change_pkg.cgi
@@ -0,0 +1,69 @@
+<% include('/elements/header.html', "Change Package") %>
+
+% if ( $cgi->param('error') ) {
+ <FONT SIZE="+1" COLOR="#ff0000">Error: <% $cgi->param('error') %></FONT>
+ <BR><BR>
+% }
+
+<% small_custview( $cust_main, $conf->config('countrydefault') || '' , '',
+ "${p}view/cust_main.cgi")
+%>
+
+<FORM ACTION="<% $p %>edit/process/cust_pkg.cgi" METHOD=POST>
+<INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
+<INPUT TYPE="hidden" NAME="remove_pkg" VALUE="<% $pkgnum %>">
+
+<BR>
+Current package: <% $part_pkg->pkg %> - <% $part_pkg->comment %>
+
+<BR>
+New package: <SELECT NAME="new_pkgpart"><OPTION VALUE=0></OPTION>
+
+%foreach my $part_pkg (
+% grep { ! $_->disabled && $_->pkgpart != $cust_pkg->pkgpart }
+% map { $_->part_pkg } $agent->agent_type->type_pkgs
+%) {
+% my $pkgpart = $part_pkg->pkgpart;
+
+ <OPTION VALUE="<% $pkgpart %>" <% ( $cgi->param('error') && $cgi->param('new_pkgpart') == $pkgpart ) ? ' SELECTED' : '' %>>
+ <% $pkgpart %>: <% $part_pkg->pkg %> - <% $part_pkg->comment %>
+ </OPTION>
+
+%}
+
+</SELECT>
+<BR><BR><INPUT TYPE="submit" VALUE="Change package">
+ </FORM>
+ </BODY>
+</HTML>
+<%init>
+
+my $pkgnum;
+if ( $cgi->param('error') ) {
+ #$custnum = $cgi->param('custnum');
+ #%remove_pkg = map { $_ => 1 } $cgi->param('remove_pkg');
+ $pkgnum = ($cgi->param('remove_pkg'))[0];
+} else {
+ my($query) = $cgi->keywords;
+ $query =~ /^(\d+)$/;
+ #$custnum = $1;
+ $pkgnum = $1;
+ #%remove_pkg = ();
+}
+
+my $cust_pkg = qsearchs( 'cust_pkg', { 'pkgnum' => $pkgnum } )
+ or die "unknown pkgnum $pkgnum";
+my $custnum = $cust_pkg->custnum;
+
+my $conf = new FS::Conf;
+
+my $p1 = popurl(1);
+
+my $cust_main = $cust_pkg->cust_main
+ or die "can't get cust_main record for custnum ". $cust_pkg->custnum.
+ " ( pkgnum ". cust_pkg->pkgnum. ")";
+my $agent = $cust_main->agent;
+
+my $part_pkg = $cust_pkg->part_pkg;
+
+</%init>
diff --git a/httemplate/misc/counties.cgi b/httemplate/misc/counties.cgi
new file mode 100644
index 000000000..c022a27d9
--- /dev/null
+++ b/httemplate/misc/counties.cgi
@@ -0,0 +1,7 @@
+[ <% join(', ', map { qq("$_") } @counties) %> ]
+<%init>
+
+my( $state, $country ) = $cgi->param('arg');
+my @counties = counties($state, $country);
+
+</%init>
diff --git a/httemplate/misc/cust_main-cancel.cgi b/httemplate/misc/cust_main-cancel.cgi
new file mode 100755
index 000000000..d29e4f5fc
--- /dev/null
+++ b/httemplate/misc/cust_main-cancel.cgi
@@ -0,0 +1,23 @@
+%
+%
+%my $custnum;
+%my $ban = '';
+%if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
+% $custnum = $1;
+% $ban = $cgi->param('ban');
+%} else {
+% my($query) = $cgi->keywords;
+% $query =~ /^(\d+)$/ || die "Illegal custnum";
+% $custnum = $1;
+%}
+%
+%my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } );
+%
+%my @errors = $cust_main->cancel( 'ban' => $ban );
+%eidiot(join(' / ', @errors)) if scalar(@errors);
+%
+%#print $cgi->redirect($p. "view/cust_main.cgi?". $cust_main->custnum);
+%print $cgi->redirect($p);
+%
+%
+
diff --git a/httemplate/misc/cust_main-import.cgi b/httemplate/misc/cust_main-import.cgi
new file mode 100644
index 000000000..73efd3705
--- /dev/null
+++ b/httemplate/misc/cust_main-import.cgi
@@ -0,0 +1,76 @@
+<% include("/elements/header.html",'Batch Customer Import') %>
+
+<FORM ACTION="process/cust_main-import.cgi" METHOD="post" ENCTYPE="multipart/form-data">
+
+Import a CSV file containing customer records.
+<BR><BR>
+
+<!-- Simple file format is CSV, with the following field order: <i>cust_pkg.setup, dayphone, first, last, address1, address2, city, state, zip, comments</i>
+<BR><BR> -->
+
+Extended file format is CSV, with the following field order: <i>agent_custid, refnum[1]<%$req%>, last<%$req%>, first<%$req%>, address1<%$req%>, address2, city<%$req%>, state<%$req%>, zip<%$req%>, country, daytime, night, ship_last, ship_first, ship_address1, ship_address2, ship_city, ship_state, ship_zip, ship_country, payinfo<%$req%>, paycvv, paydate<%$req%>, invoicing_list, pkgpart, username[2], _password[2]</i>
+<BR><BR>
+
+<%$req%> Required fields
+<BR><BR>
+
+[1] This field has special treatment upon import: If a string is passed instead
+of an integer, the string is searched for and if necessary auto-created in the
+target table.
+<BR><BR>
+
+[2] <i>username</i> and <i>_password</i> are required if <i>pkgpart</i> is specified.
+<BR><BR>
+
+<% &ntable("#cccccc") %>
+
+<% include('/elements/tr-select-agent.html', '', #$agentnum,
+ 'label' => "<B>Agent</B>",
+ 'empty_label' => 'Select agent',
+ )
+%>
+
+<TR>
+ <TH ALIGN="right">Format</TH>
+ <TD>
+ <SELECT NAME="format">
+<!-- <OPTION VALUE="simple">Simple -->
+ <OPTION VALUE="extended" SELECTED>Extended
+ </SELECT>
+ </TD>
+</TR>
+
+<TR>
+ <TH ALIGN="right">CSV filename</TH>
+ <TD><INPUT TYPE="file" NAME="csvfile"></TD>
+</TR>
+% #include('/elements/tr-select-part_referral.html')
+%
+
+
+<!--
+<TR>
+ <TH>First package</TH>
+ <TD>
+ <SELECT NAME="pkgpart"><OPTION VALUE="">(none)</OPTION>
+% foreach my $part_pkg ( qsearch('part_pkg',{'disabled'=>'' }) ) {
+
+ <OPTION VALUE="<% $part_pkg->pkgpart %>"><% $part_pkg->pkg. ' - '. $part_pkg->comment %></OPTION>
+% }
+
+ </SELECT>
+ </TD>
+</TR>
+-->
+
+</TABLE>
+<BR><BR>
+
+<INPUT TYPE="submit" VALUE="Import">
+</FORM>
+
+<% include('/elements/footer.html') %>
+
+<%once>
+my $req = qq!<font color="#ff0000">*</font>!;
+</%once>
diff --git a/httemplate/misc/cust_main-import_charges.cgi b/httemplate/misc/cust_main-import_charges.cgi
new file mode 100644
index 000000000..cd4441e0b
--- /dev/null
+++ b/httemplate/misc/cust_main-import_charges.cgi
@@ -0,0 +1,14 @@
+<!-- mason kludge -->
+<% include("/elements/header.html",'Batch Customer Charge') %>
+<FORM ACTION="process/cust_main-import_charges.cgi" METHOD="post" ENCTYPE="multipart/form-data">
+Import a CSV file containing customer charges.<BR><BR>
+Default file format is CSV, with the following field order: <i>custnum, amount, description</i><BR><BR>
+If <i>amount</i> is negative, a credit will be applied instead.<BR><BR>
+<BR><BR>
+
+ CSV Filename: <INPUT TYPE="file" NAME="csvfile"><BR><BR>
+ <INPUT TYPE="submit" VALUE="Import">
+ </FORM>
+ </BODY>
+<HTML>
+
diff --git a/httemplate/misc/delete-agent_payment_gateway.cgi b/httemplate/misc/delete-agent_payment_gateway.cgi
new file mode 100644
index 000000000..fb0f1e4b8
--- /dev/null
+++ b/httemplate/misc/delete-agent_payment_gateway.cgi
@@ -0,0 +1,15 @@
+% die "you don't have the 'Configuration' access right"
+% unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+%
+% my($query) = $cgi->keywords;
+% $query =~ /^(\d+)$/ || die "Illegal agentgatewaynum";
+% my $agentgatewaynum = $1;
+%
+% my $agent_payment_gateway = qsearchs('agent_payment_gateway', {
+% 'agentgatewaynum' => $agentgatewaynum,
+% });
+%
+% my $error = $agent_payment_gateway->delete;
+% eidiot($error) if $error;
+%
+% print $cgi->redirect($p. "browse/agent.cgi");
diff --git a/httemplate/misc/delete-cust_credit.cgi b/httemplate/misc/delete-cust_credit.cgi
new file mode 100755
index 000000000..e4756a922
--- /dev/null
+++ b/httemplate/misc/delete-cust_credit.cgi
@@ -0,0 +1,17 @@
+%
+%
+%#untaint crednum
+%my($query) = $cgi->keywords;
+%$query =~ /^(\d+)$/ || die "Illegal crednum";
+%my $crednum = $1;
+%
+%my $cust_credit = qsearchs('cust_credit',{'crednum'=>$crednum});
+%my $custnum = $cust_credit->custnum;
+%
+%my $error = $cust_credit->delete;
+%eidiot($error) if $error;
+%
+%print $cgi->redirect($p. "view/cust_main.cgi?". $custnum);
+%
+%
+
diff --git a/httemplate/misc/delete-cust_pay.cgi b/httemplate/misc/delete-cust_pay.cgi
new file mode 100755
index 000000000..1fda82e2a
--- /dev/null
+++ b/httemplate/misc/delete-cust_pay.cgi
@@ -0,0 +1,17 @@
+%
+%
+%#untaint paynum
+%my($query) = $cgi->keywords;
+%$query =~ /^(\d+)$/ || die "Illegal paynum";
+%my $paynum = $1;
+%
+%my $cust_pay = qsearchs('cust_pay',{'paynum'=>$paynum});
+%my $custnum = $cust_pay->custnum;
+%
+%my $error = $cust_pay->delete;
+%eidiot($error) if $error;
+%
+%print $cgi->redirect($p. "view/cust_main.cgi?". $custnum);
+%
+%
+
diff --git a/httemplate/misc/delete-cust_refund.cgi b/httemplate/misc/delete-cust_refund.cgi
new file mode 100755
index 000000000..3e44560d0
--- /dev/null
+++ b/httemplate/misc/delete-cust_refund.cgi
@@ -0,0 +1,17 @@
+%
+%
+%#untaint refundnum
+%my($query) = $cgi->keywords;
+%$query =~ /^(\d+)$/ || die "Illegal refundnum";
+%my $refundnum = $1;
+%
+%my $cust_refund = qsearchs('cust_refund',{'refundnum'=>$refundnum});
+%my $custnum = $cust_refund->custnum;
+%
+%my $error = $cust_refund->delete;
+%eidiot($error) if $error;
+%
+%print $cgi->redirect($p. "view/cust_main.cgi?". $custnum);
+%
+%
+
diff --git a/httemplate/misc/delete-customer.cgi b/httemplate/misc/delete-customer.cgi
new file mode 100755
index 000000000..378f69e61
--- /dev/null
+++ b/httemplate/misc/delete-customer.cgi
@@ -0,0 +1,61 @@
+<!-- mason kludge -->
+%
+%
+%my $conf = new FS::Conf;
+%die "Customer deletions not enabled" unless $conf->exists('deletecustomers');
+%
+%my($custnum, $new_custnum);
+%if ( $cgi->param('error') ) {
+% $custnum = $cgi->param('custnum');
+% $new_custnum = $cgi->param('new_custnum');
+%} else {
+% my($query) = $cgi->keywords;
+% $query =~ /^(\d+)$/ or die "Illegal query: $query";
+% $custnum = $1;
+% $new_custnum = '';
+%}
+%my $cust_main = qsearchs( 'cust_main', { 'custnum' => $custnum } )
+% or die "Customer not found: $custnum";
+%
+%print header('Delete customer');
+%
+%print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'),
+% "</FONT>"
+% if $cgi->param('error');
+%
+%print
+% qq!<form action="!, popurl(1), qq!process/delete-customer.cgi" method=post>!,
+% qq!<input type="hidden" name="custnum" value="$custnum">!;
+%
+%if ( qsearch('cust_pkg', { 'custnum' => $custnum, 'cancel' => '' } ) ) {
+% print "Move uncancelled packages to customer number ",
+% qq!<input type="text" name="new_custnum" value="$new_custnum"><br><br>!;
+%}
+%
+%print <<END;
+%This will <b>completely remove</b> all traces of this customer record. This
+%is <B>not</B> what you want if this is a real customer who has simply
+%canceled service with you. For that, cancel all of the customer's packages.
+%(you can optionally hide cancelled customers with the <a href="../config/config-view.cgi#hidecancelledcustomers">hidecancelledcustomers</a> configuration option)
+%<br>
+%<br>Are you <b>absolutely sure</b> you want to delete this customer?
+%<br><input type="submit" value="Yes">
+%</form></body></html>
+%END
+%
+%#Deleting a customer you have financial records on (i.e. credits) is
+%#typically considered fraudulant bookkeeping. Remember, deleting
+%#customers should ONLY be used for completely bogus records. You should
+%#NOT delete real customers who simply discontinue service.
+%#
+%#For real customers who simply discontinue service, cancel all of the
+%#customer's packages. Customers with all cancelled packages are not
+%#billed. There is no need to take further action to prevent billing on
+%#customers with all cancelled packages.
+%#
+%#Also see the "hidecancelledcustomers" and "hidecancelledpackages"
+%#configuration options, which will allow you to surpress the display of
+%#cancelled customers and packages, respectively.
+%
+%
+
diff --git a/httemplate/misc/delete-domain_record.cgi b/httemplate/misc/delete-domain_record.cgi
new file mode 100755
index 000000000..cccce357e
--- /dev/null
+++ b/httemplate/misc/delete-domain_record.cgi
@@ -0,0 +1,16 @@
+%
+%
+%#untaint recnum
+%my($query) = $cgi->keywords;
+%$query =~ /^(\d+)$/ || die "Illegal recnum";
+%my $recnum = $1;
+%
+%my $domain_record = qsearchs('domain_record',{'recnum'=>$recnum});
+%
+%my $error = $domain_record->delete;
+%eidiot($error) if $error;
+%
+%print $cgi->redirect($p. "view/svc_domain.cgi?". $domain_record->svcnum);
+%
+%
+
diff --git a/httemplate/misc/delete-part_export.cgi b/httemplate/misc/delete-part_export.cgi
new file mode 100755
index 000000000..16389a90c
--- /dev/null
+++ b/httemplate/misc/delete-part_export.cgi
@@ -0,0 +1,16 @@
+%
+%
+%#untaint exportnum
+%my($query) = $cgi->keywords;
+%$query =~ /^(\d+)$/ || die "Illegal exportnum";
+%my $exportnum = $1;
+%
+%my $part_export = qsearchs('part_export',{'exportnum'=>$exportnum});
+%
+%my $error = $part_export->delete;
+%eidiot($error) if $error;
+%
+%print $cgi->redirect($p. "browse/part_export.cgi");
+%
+%
+
diff --git a/httemplate/misc/download-batch.cgi b/httemplate/misc/download-batch.cgi
new file mode 100644
index 000000000..8d6c94969
--- /dev/null
+++ b/httemplate/misc/download-batch.cgi
@@ -0,0 +1,171 @@
+%if ($format eq "BoM") {
+%
+% my($origid,$datacenter,$typecode,$shortname,$longname,$mybank,$myacct) =
+% $conf->config("batchconfig-$format");
+%
+<% sprintf( "A%10s%04u%06u%05u%54s\n",$origid,$pay_batch->batchnum,$jdate,$datacenter,"").
+ sprintf( "XD%03u%06u%-15s%-30s%09u%-12s \n",$typecode,$jdate,$shortname,$longname,$mybank,$myacct )
+ %>
+%
+%}elsif ($format eq "PAP"){
+%
+% my($origid,$datacenter,$typecode,$shortname,$longname,$mybank,$myacct) =
+% $conf->config("batchconfig-$format");
+%
+<% sprintf( "H%10sD%3s%06u%-15s%09u%-12s%04u%19s\n",$origid,$typecode,$cdate,$shortname,$mybank,$myacct,$pay_batch->batchnum,"") %>
+%
+%
+%}elsif ($format eq "csv-td_canada_trust-merchant_pc_batch"){
+%# 1;
+%}elsif ($format eq "csv-chase_canada-E-xactBatch"){
+%
+% my($origid) = $conf->config("batchconfig-$format");
+<% sprintf( '$$E-xactBatchFileV1.0$$%s:%03u$$%s',$sdate,$pay_batch->batchnum, $origid)
+ %>
+%
+%}else{
+% die "Unknown format for batch in batchconfig. \n";
+%}
+%
+%
+%for my $cust_pay_batch ( sort { $a->paybatchnum <=> $b->paybatchnum }
+% qsearch('cust_pay_batch',
+% {'batchnum'=>$pay_batch->batchnum} )
+%) {
+%
+% $cust_pay_batch->exp =~ /^\d{2}(\d{2})[\/\-](\d+)[\/\-]\d+$/;
+% my( $mon, $y ) = ( $2, $1 );
+% if ( $conf->exists('batch-increment_expiration') ) {
+% my( $curmon, $curyear ) = (localtime(time))[4,5];
+% $curmon++; $curyear-=100;
+% $y++ while $y < $curyear || ( $y == $curyear && $mon < $curmon );
+% }
+% $mon = "0$mon" if $mon =~ /^\d$/;
+% $y = "0$y" if $y =~ /^\d$/;
+% my $exp = "$mon$y";
+%
+% if ( $first_download ) {
+% my $balance = $cust_pay_batch->cust_main->balance;
+% if ( $balance <= 0 ) {
+% my $error = $cust_pay_batch->delete;
+% if ( $error ) {
+% $dbh->rollback or die $dbh->errstr if $oldAutoCommit;
+% die $error;
+% }
+% next;
+% } elsif ( $balance < $cust_pay_batch->amount ) {
+% $cust_pay_batch->amount($balance);
+% my $error = $cust_pay_batch->replace;
+% if ( $error ) {
+% $dbh->rollback or die $dbh->errstr if $oldAutoCommit;
+% die $error;
+% }
+% #} elsif ( $balance > $cust_pay_batch->amount ) {
+% }
+% }
+%
+% $batchcount++;
+% $batchtotal += $cust_pay_batch->amount;
+%
+% if ($format eq "BoM") {
+%
+% my( $account, $aba ) = split( '@', $cust_pay_batch->payinfo );
+%
+<% sprintf( "D%010.0f%09u%-12s%-29s%-19s\n",$cust_pay_batch->amount*100,$aba,$account,$cust_pay_batch->payname,$cust_pay_batch->paybatchnum) %>
+%
+%
+% } elsif ($format eq "PAP"){
+%
+% my( $account, $aba ) = split( '@', $cust_pay_batch->payinfo );
+%
+<% sprintf( "D%-23s%06u%-19s%09u%-12s%010.0f\n",$cust_pay_batch->payname,$cdate,$cust_pay_batch->paybatchnum,$aba,$account,$cust_pay_batch->amount*100) %>
+%
+%
+% } elsif ($format eq "csv-td_canada_trust-merchant_pc_batch") {
+%
+%
+,,,,<% $cust_pay_batch->payinfo %>,<% $exp %>,<% $cust_pay_batch->amount %>,<% $cust_pay_batch->paybatchnum %>
+%
+%
+% } elsif ($format eq "csv-chase_canada-E-xactBatch"){
+%
+% my $payname=$cust_pay_batch->payname; $payname =~ tr/",/ /; #payinfo too? :P
+<% $cust_pay_batch->paybatchnum %>,<% $cust_pay_batch->custnum %>,<% $cust_pay_batch->invnum %>,"<% $payname %>",00,<% $cust_pay_batch->payinfo %>,<% $cust_pay_batch->amount %>,<% $exp %>,,
+%
+%
+% } else {
+% die "I'm already dead, but you did not know that.\n";
+% }
+%
+%}
+%
+%if ($format eq "BoM") {
+%
+%
+<% sprintf( "YD%08u%014.0f%56s\n",$batchcount,$batchtotal*100,"" ).
+ sprintf( "Z%014u%05u%014u%05u%41s\n",$batchtotal*100,$batchcount,"0","0","" ) %>
+%
+%
+%} elsif ($format eq "PAP"){
+%
+%
+<% sprintf( "T%08u%014.0f%57s\n",$batchcount,$batchtotal*100,"" ) %>
+%
+%
+%} elsif ($format eq "csv-td_canada_trust-merchant_pc_batch"){
+% #1;
+%} elsif ($format eq "csv-chase_canada-E-xactBatch"){
+% #1;
+%} else {
+% die "I'm already dead (again), but you did not know that.\n";
+%}
+%
+%$dbh->commit or die $dbh->errstr if $oldAutoCommit;
+<%init>
+
+my $conf=new FS::Conf;
+
+#http_header('Content-Type' => 'text/comma-separated-values' ); #IE chokes
+http_header('Content-Type' => 'text/plain' );
+
+my $batchnum;
+if ( $cgi->param('batchnum') =~ /^(\d+)$/ ) {
+ $batchnum = $1;
+} else {
+ die "No batch number (bad URL) \n";
+}
+
+my $format;
+if ( $cgi->param('format') =~ /^([\w\- ]+)$/ ) {
+ $format = $1;
+} else {
+ $format = $conf->config('batch-default_format');
+}
+
+my $oldAutoCommit = $FS::UID::AutoCommit;
+local $FS::UID::AutoCommit = 0;
+my $dbh = dbh;
+
+my $pay_batch = qsearchs('pay_batch', {'batchnum'=>$batchnum, 'status'=>'O'} );
+my $first_download = 1;
+unless ($pay_batch) {
+ $pay_batch = qsearchs('pay_batch', {'batchnum'=>$batchnum, 'status'=>'I'} )
+ if $FS::CurrentUser::CurrentUser->access_right('Reprocess batches');
+ $first_download = 0;
+}
+die "No pending batch. \n" unless $pay_batch;
+
+my $error = $pay_batch->set_status('I');
+die "error updating batch status: $error\n" if $error;
+
+my $batchtotal=0;
+my $batchcount=0;
+
+my (@date)=localtime($pay_batch->download);
+my $jdate = sprintf("%03d", $date[5] % 100).sprintf("%03d", $date[7] + 1);
+my $cdate = sprintf("%02d", $date[3]).sprintf("%02d", $date[4] + 1).
+ sprintf("%02d", $date[5] % 100);
+my $sdate = sprintf("%02d", $date[5] % 100).'/'.sprintf("%02d", $date[4] + 1).
+ '/'.sprintf("%02d", $date[3]);
+
+</%init>
diff --git a/httemplate/misc/dump.cgi b/httemplate/misc/dump.cgi
new file mode 100644
index 000000000..e8f4b6f38
--- /dev/null
+++ b/httemplate/misc/dump.cgi
@@ -0,0 +1,20 @@
+%
+% if ( driver_name =~ /^Pg$/ ) {
+% my $dbname = (split(':', datasrc))[2];
+% if ( $dbname =~ /[;=]/ ) {
+% my %elements = map { /^(\w+)=(.*)$/; $1=>$2 } split(';', $dbname);
+% $dbname = $elements{'dbname'};
+% }
+% open(DUMP,"pg_dump $dbname |");
+% } else {
+% eidiot "don't (yet) know how to dump ". driver_name. " databases\n";
+% }
+%
+% http_header('Content-Type' => 'text/plain' );
+%
+% while (<DUMP>) {
+% print $_;
+% }
+% close DUMP;
+%
+
diff --git a/httemplate/misc/email-invoice.cgi b/httemplate/misc/email-invoice.cgi
new file mode 100755
index 000000000..8a3dd90b1
--- /dev/null
+++ b/httemplate/misc/email-invoice.cgi
@@ -0,0 +1,18 @@
+%
+%
+%#untaint invnum
+%my($query) = $cgi->keywords;
+%$query =~ /^((.+)-)?(\d+)$/;
+%my $template = $2;
+%my $invnum = $3;
+%my $cust_bill = qsearchs('cust_bill',{'invnum'=>$invnum});
+%die "Can't find invoice!\n" unless $cust_bill;
+%
+%$cust_bill->email($template);
+%
+%my $custnum = $cust_bill->getfield('custnum');
+%
+%print $cgi->redirect("${p}view/cust_main.cgi?$custnum");
+%
+%
+
diff --git a/httemplate/misc/email_invoice_events.cgi b/httemplate/misc/email_invoice_events.cgi
new file mode 100644
index 000000000..ba6e72c1a
--- /dev/null
+++ b/httemplate/misc/email_invoice_events.cgi
@@ -0,0 +1,4 @@
+%
+%my $server = new FS::UI::Web::JSRPC 'FS::cust_bill_event::process_reemail', $cgi;
+%
+<% $server->process %>
diff --git a/httemplate/misc/email_invoices.cgi b/httemplate/misc/email_invoices.cgi
new file mode 100644
index 000000000..6c2103f7b
--- /dev/null
+++ b/httemplate/misc/email_invoices.cgi
@@ -0,0 +1,4 @@
+%
+%my $server = new FS::UI::Web::JSRPC 'FS::cust_bill::process_reemail', $cgi;
+%
+<% $server->process %>
diff --git a/httemplate/misc/fax-invoice.cgi b/httemplate/misc/fax-invoice.cgi
new file mode 100755
index 000000000..1ddc23ece
--- /dev/null
+++ b/httemplate/misc/fax-invoice.cgi
@@ -0,0 +1,18 @@
+%
+%
+%#untaint invnum
+%my($query) = $cgi->keywords;
+%$query =~ /^((.+)-)?(\d+)$/;
+%my $template = $2;
+%my $invnum = $3;
+%my $cust_bill = qsearchs('cust_bill',{'invnum'=>$invnum});
+%die "Can't find invoice!\n" unless $cust_bill;
+%
+%$cust_bill->fax($template);
+%
+%my $custnum = $cust_bill->getfield('custnum');
+%
+%print $cgi->redirect("${p}view/cust_main.cgi?$custnum");
+%
+%
+
diff --git a/httemplate/misc/fax_invoice_events.cgi b/httemplate/misc/fax_invoice_events.cgi
new file mode 100644
index 000000000..deb78d456
--- /dev/null
+++ b/httemplate/misc/fax_invoice_events.cgi
@@ -0,0 +1,4 @@
+%
+%my $server = new FS::UI::Web::JSRPC 'FS::cust_bill_event::process_refax', $cgi;
+%
+<% $server->process %>
diff --git a/httemplate/misc/fax_invoices.cgi b/httemplate/misc/fax_invoices.cgi
new file mode 100644
index 000000000..4bdac970c
--- /dev/null
+++ b/httemplate/misc/fax_invoices.cgi
@@ -0,0 +1,4 @@
+%
+%my $server = new FS::UI::Web::JSRPC 'FS::cust_bill::process_refax', $cgi;
+%
+<% $server->process %>
diff --git a/httemplate/misc/inventory_item-import.html b/httemplate/misc/inventory_item-import.html
new file mode 100644
index 000000000..87c6af34c
--- /dev/null
+++ b/httemplate/misc/inventory_item-import.html
@@ -0,0 +1,21 @@
+%
+%
+%my $classnum = $cgi->param('classnum');
+%$classnum =~ /^(\d+)$/ or eidiot "illegal classnum $classnum";
+%$classnum = $1;
+%my $inventory_class = qsearchs('inventory_class', { 'classnum' => $classnum } );
+%
+%
+<% include("/elements/header.html", $inventory_class->classname. 's') %>
+
+<FORM ACTION="process/inventory_item-import.html" METHOD="POST" ENCTYPE="multipart/form-data">
+<INPUT TYPE="hidden" NAME="classnum" VALUE="<% $classnum %>">
+Import a file containing <% $inventory_class->classname %>s, one per line.<BR><BR>
+
+Filename: <INPUT TYPE="file" NAME="filename"><BR><BR>
+
+<INPUT TYPE="submit" VALUE="Upload">
+</FORM>
+
+<% include('/elements/footer.html') %>
+
diff --git a/httemplate/misc/link.cgi b/httemplate/misc/link.cgi
new file mode 100755
index 000000000..ef72b4a5c
--- /dev/null
+++ b/httemplate/misc/link.cgi
@@ -0,0 +1,77 @@
+%my %link_field = (
+% 'svc_acct' => 'username',
+% 'svc_domain' => 'domain',
+%);
+%
+%my %link_field2 = (
+% 'svc_acct' => { label => 'Domain',
+% field => 'domsvc',
+% type => 'select',
+% select_table => 'svc_domain',
+% select_key => 'svcnum',
+% select_label => 'domain'
+% },
+%);
+%
+%$cgi->param('pkgnum') =~ /^(\d+)$/ or die 'unparsable pkgnum';
+%my $pkgnum = $1;
+%$cgi->param('svcpart') =~ /^(\d+)$/ or die 'unparsable svcpart';
+%my $svcpart = $1;
+%
+%my $part_svc = qsearchs('part_svc',{'svcpart'=>$svcpart});
+%my $svc = $part_svc->getfield('svc');
+%my $svcdb = $part_svc->getfield('svcdb');
+%my $link_field = $link_field{$svcdb};
+%my $link_field2 = $link_field2{$svcdb};
+%
+
+<% include("/elements/header.html","Link to existing $svc") %>
+<FORM ACTION="<% popurl(1) %>process/link.cgi" METHOD=POST>
+% if ( $link_field ) {
+
+ <INPUT TYPE="hidden" NAME="svcnum" VALUE="">
+ <INPUT TYPE="hidden" NAME="link_field" VALUE="<% $link_field %>">
+ <% $link_field %> of existing service: <INPUT TYPE="text" NAME="link_value">
+ <BR>
+% if ( $link_field2 ) {
+
+ <INPUT TYPE="hidden" NAME="link_field2" VALUE="<% $link_field2->{field} %>">
+ <% $link_field2->{'label'} %> of existing service:
+% if ( $link_field2->{'type'} eq 'select' ) {
+% if ( $link_field2->{'select_table'} ) {
+
+ <SELECT NAME="link_value2">
+ <OPTION> </OPTION>
+% foreach my $r ( qsearch( $link_field2->{'select_table'}, {})) {
+% my $key = $link_field2->{'select_key'};
+% my $label = $link_field2->{'select_label'};
+
+ <OPTION VALUE="<% $r->$key() %>"><% $r->$label() %></OPTION>
+% }
+
+ </SELECT>
+% } else {
+
+ Don't know how to process secondary link field for <% $svcdb %>
+ (type=>select but no select_table)
+% }
+% } else {
+
+ Don't know how to process secondary link field for <% $svcdb %>
+ (unknown type <% $link_field2->{'type'} %>)
+% }
+
+ <BR>
+% }
+% } else {
+
+ Service # of existing service: <INPUT TYPE="text" NAME="svcnum" VALUE="">
+% }
+
+
+<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>">
+<INPUT TYPE="hidden" NAME="svcpart" VALUE="<% $svcpart %>">
+<BR><INPUT TYPE="submit" VALUE="Link">
+ </FORM>
+ </BODY>
+</HTML>
diff --git a/httemplate/misc/meta-import.cgi b/httemplate/misc/meta-import.cgi
new file mode 100644
index 000000000..fc249a2ab
--- /dev/null
+++ b/httemplate/misc/meta-import.cgi
@@ -0,0 +1,73 @@
+<!-- mason kludge -->
+<% include("/elements/header.html",'Import') %>
+<FORM ACTION="process/meta-import.cgi" METHOD="post" ENCTYPE="multipart/form-data">
+Import data from a DBI data source<BR><BR>
+%
+% #false laziness with edit/cust_main.cgi
+% my @agents = qsearch( 'agent', {} );
+% die "No agents created!" unless @agents;
+% my $agentnum = $agents[0]->agentnum; #default to first
+%
+% if ( scalar(@agents) == 1 ) {
+%
+
+ <INPUT TYPE="hidden" NAME="agentnum" VALUE="<% $agentnum %>">
+% } else {
+
+ <BR><BR>Agent <SELECT NAME="agentnum" SIZE="1">
+% foreach my $agent (sort { $a->agent cmp $b->agent } @agents) {
+
+ <OPTION VALUE="<% $agent->agentnum %>" <% " SELECTED"x($agent->agentnum==$agentnum) %>><% $agent->agent %></OPTION>
+% }
+
+ </SELECT><BR><BR>
+% }
+%
+% my @referrals = qsearch('part_referral',{});
+% die "No advertising sources created!" unless @referrals;
+% my $refnum = $referrals[0]->refnum; #default to first
+%
+% if ( scalar(@referrals) == 1 ) {
+%
+
+ <INPUT TYPE="hidden" NAME="refnum" VALUE="<% $refnum %>">
+% } else {
+
+ <BR><BR>Advertising source <SELECT NAME="refnum" SIZE="1">
+% foreach my $referral ( sort { $a->referral <=> $b->referral } @referrals) {
+
+ <OPTION VALUE="<% $referral->refnum %>" <% " SELECTED"x($referral->refnum==$refnum) %>><% $referral->refnum %>: <% $referral->referral %></OPTION>
+% }
+
+ </SELECT><BR><BR>
+% }
+
+
+ First package: <SELECT NAME="pkgpart"><OPTION VALUE="">(none)</OPTION>
+% foreach my $part_pkg ( qsearch('part_pkg',{'disabled'=>'' }) ) {
+
+ <OPTION VALUE="<% $part_pkg->pkgpart %>"><% $part_pkg->pkg. ' - '. $part_pkg->comment %></OPTION>
+% }
+
+</SELECT><BR><BR>
+
+ <table>
+ <tr>
+ <td align="right">DBI data source: </td>
+ <td><INPUT TYPE="text" NAME="data_source"></td>
+ </tr>
+ <tr>
+ <td align="right">DBI username: </td>
+ <td><INPUT TYPE="text" NAME="username"></td>
+ </tr>
+ <tr>
+ <td align="right">DBI password: </td>
+ <td><INPUT TYPE="text" NAME="password"></td>
+ </tr>
+ </table>
+ <INPUT TYPE="submit" VALUE="Import">
+
+ </FORM>
+ </BODY>
+<HTML>
+
diff --git a/httemplate/misc/payment.cgi b/httemplate/misc/payment.cgi
new file mode 100644
index 000000000..728eba7b9
--- /dev/null
+++ b/httemplate/misc/payment.cgi
@@ -0,0 +1,207 @@
+%
+% my %type = ( 'CARD' => 'credit card',
+% 'CHEK' => 'electronic check (ACH)',
+% );
+%
+% $cgi->param('payby') =~ /^(CARD|CHEK)$/
+% or die "unknown payby ". $cgi->param('payby');
+% my $payby = $1;
+%
+% $cgi->param('custnum') =~ /^(\d+)$/
+% or die "illegal custnum ". $cgi->param('custnum');
+% my $custnum = $1;
+%
+% my $cust_main = qsearchs( 'cust_main', { 'custnum'=>$custnum } );
+% die "unknown custnum $custnum" unless $cust_main;
+%
+% my $balance = $cust_main->balance;
+%
+% my $payinfo = '';
+%
+% #false laziness w/selfservice make_payment.html shortcut for one-country
+% my $conf = new FS::Conf;
+% my %states = map { $_->state => 1 }
+% qsearch('cust_main_county', {
+% 'country' => $conf->config('countrydefault') || 'US'
+% } );
+% my @states = sort { $a cmp $b } keys %states;
+%
+% my $paybatch = "webui-payment-". time. "-$$-". rand() * 2**32;
+%
+%
+
+<% include( '/elements/header.html', "Process $type{$payby} payment" ) %>
+<% include( '/elements/small_custview.html', $cust_main, '', '', popurl(2) . "view/cust_main.cgi" ) %>
+<FORM NAME="OneTrueForm" ACTION="process/payment.cgi" METHOD="POST" onSubmit="document.OneTrueForm.process.disabled=true">
+<INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
+<INPUT TYPE="hidden" NAME="payby" VALUE="<% $payby %>">
+<INPUT TYPE="hidden" NAME="paybatch" VALUE="<% $paybatch %>">
+
+<SCRIPT TYPE="text/javascript" SRC="../elements/overlibmws.js"></SCRIPT>
+<SCRIPT TYPE="text/javascript" SRC="../elements/overlibmws_iframe.js"></SCRIPT>
+<SCRIPT TYPE="text/javascript" SRC="../elements/overlibmws_draggable.js"></SCRIPT>
+<SCRIPT TYPE="text/javascript">
+function OLiframeContent(src, width, height, name) {
+ return ('<iframe src="'+src+'" width="'+width+'" height="'+height+'"'
+ +(name?' name="'+name+'" id="'+name+'"':'')+' scrolling="auto">'
+ +'<div>[iframe not supported]</div></iframe>');
+}
+</SCRIPT>
+% #include( '/elements/table.html', '#cccccc' )
+
+<% ntable('#cccccc') %>
+ <TR>
+ <TD ALIGN="right">Payment amount</TD>
+ <TD>
+ <TABLE><TR><TD BGCOLOR="#ffffff">
+ $<INPUT TYPE="text" NAME="amount" SIZE=8 VALUE="<% $balance > 0 ? sprintf("%.2f", $balance) : '' %>">
+ </TD></TR></TABLE>
+ </TD>
+ </TR>
+% if ( $payby eq 'CARD' ) {
+% my( $payinfo, $paycvv, $month, $year ) = ( '', '', '', '' );
+% my $payname = $cust_main->first. ' '. $cust_main->getfield('last');
+% my $address1 = $cust_main->address1;
+% my $address2 = $cust_main->address2;
+% my $city = $cust_main->city;
+% my $state = $cust_main->state;
+% my $zip = $cust_main->zip;
+% if ( $cust_main->payby =~ /^(CARD|DCRD)$/ ) {
+% $payinfo = $cust_main->paymask;
+% $paycvv = $cust_main->paycvv;
+% ( $month, $year ) = $cust_main->paydate_monthyear;
+% $payname = $cust_main->payname if $cust_main->payname;
+% }
+%
+
+ <TR>
+ <TD ALIGN="right">Card&nbsp;number</TD>
+ <TD>
+ <TABLE>
+ <TR>
+ <TD>
+ <INPUT TYPE="text" NAME="payinfo" SIZE=20 MAXLENGTH=19 VALUE="<%$payinfo%>"> </TD>
+ <TD>Exp.</TD>
+ <TD>
+ <SELECT NAME="month">
+% for ( ( map "0$_", 1 .. 9 ), 10 .. 12 ) {
+
+ <OPTION<% $_ == $month ? ' SELECTED' : '' %>><% $_ %>
+% }
+
+ </SELECT>
+ </TD>
+ <TD> / </TD>
+ <TD>
+ <SELECT NAME="year">
+% my @a = localtime; for ( $a[5]+1900 .. $a[5]+1915 ) {
+
+ <OPTION<% $_ == $year ? ' SELECTED' : '' %>><% $_ %>
+% }
+
+ </SELECT>
+ </TD>
+ </TR>
+ </TABLE>
+ </TD>
+ </TR>
+ <TR>
+ <TD ALIGN="right">CVV2</TD>
+ <TD><INPUT TYPE="text" NAME="paycvv" VALUE="<% $paycvv %>" SIZE=4 MAXLENGTH=4>
+ (<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('../docs/cvv2.html', 480, 352, 'cvv2_popup' ), CAPTION, 'CVV2 Help', STICKY, AUTOSTATUSCAP, CLOSECLICK, DRAGGABLE ); return false;">help</A>)
+ </TD>
+ </TR>
+ <TR>
+ <TD ALIGN="right">Exact&nbsp;name&nbsp;on&nbsp;card</TD>
+ <TD><INPUT TYPE="text" SIZE=32 MAXLENGTH=80 NAME="payname" VALUE="<%$payname%>"></TD>
+ </TR><TR>
+ <TD ALIGN="right">Card&nbsp;billing&nbsp;address</TD>
+ <TD>
+ <INPUT TYPE="text" SIZE=40 MAXLENGTH=80 NAME="address1" VALUE="<%$address1%>">
+ </TD>
+ </TR><TR>
+ <TD ALIGN="right">Address&nbsp;line&nbsp;2</TD>
+ <TD>
+ <INPUT TYPE="text" SIZE=40 MAXLENGTH=80 NAME="address2" VALUE="<%$address2%>">
+ </TD>
+ </TR><TR>
+ <TD ALIGN="right">City</TD>
+ <TD>
+ <TABLE>
+ <TR>
+ <TD>
+ <INPUT TYPE="text" NAME="city" SIZE="12" MAXLENGTH=80 VALUE="<%$city%>">
+ </TD>
+ <TD>State</TD>
+ <TD>
+ <SELECT NAME="state">
+% for ( @states ) {
+
+ <OPTION<% $_ eq $state ? ' SELECTED' : '' %>><% $_ %>
+% }
+
+ </SELECT>
+ </TD>
+ <TD>Zip</TD>
+ <TD>
+ <INPUT TYPE="text" NAME="zip" SIZE=11 MAXLENGTH=10 VALUE="<%$zip%>">
+ </TD>
+ </TR>
+ </TABLE>
+ </TD>
+ </TR>
+% } elsif ( $payby eq 'CHEK' ) {
+% my( $payinfo1, $payinfo2, $payname, $ss ) = ( '', '', '', '' );
+% if ( $cust_main->payby =~ /^(CHEK|DCHK)$/ ) {
+% $cust_main->paymask =~ /^([\dx]+)\@([\dx]+)$/i
+% or die "unparsable payinfo ". $cust_main->payinfo;
+% ($payinfo1, $payinfo2) = ($1, $2);
+% $payname = $cust_main->payname;
+% $ss = $cust_main->ss;
+% }
+%
+
+ <INPUT TYPE="hidden" NAME="month" VALUE="12">
+ <INPUT TYPE="hidden" NAME="year" VALUE="2037">
+ <TR>
+ <TD ALIGN="right">Account&nbsp;number</TD>
+ <TD><INPUT TYPE="text" SIZE=10 NAME="payinfo1" VALUE="<%$payinfo1%>"></TD>
+ </TR>
+ <TR>
+ <TD ALIGN="right">ABA/Routing&nbsp;number</TD>
+ <TD>
+ <INPUT TYPE="text" SIZE=10 MAXLENGTH=9 NAME="payinfo2" VALUE="<%$payinfo2%>">
+ (<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('../docs/ach.html', 380, 240, 'ach_popup' ), CAPTION, 'ACH Help', STICKY, AUTOSTATUSCAP, CLOSECLICK, DRAGGABLE ); return false;">help</A>)
+ </TD>
+ </TR>
+ <TR>
+ <TD ALIGN="right">Bank&nbsp;name</TD>
+ <TD><INPUT TYPE="text" NAME="payname" VALUE="<%$payname%>"></TD>
+ </TR>
+ <TR>
+ <TD ALIGN="right">
+ Account&nbsp;holder<BR>
+ Social&nbsp;security&nbsp;or&nbsp;tax&nbsp;ID&nbsp;#
+ </TD>
+ <TD><INPUT TYPE="text" NAME="ss" VALUE="<%$ss%>"></TD>
+ </TR>
+% }
+
+
+<TR>
+ <TD COLSPAN=2>
+ <INPUT TYPE="checkbox" CHECKED NAME="save" VALUE="1">
+ Remember this information
+ </TD>
+</TR><TR>
+ <TD COLSPAN=2>
+ <INPUT TYPE="checkbox"<% ( ( $payby eq 'CARD' && $cust_main->payby ne 'DCRD' ) || ( $payby eq 'CHEK' && $cust_main->payby eq 'CHEK' ) ) ? ' CHECKED' : '' %> NAME="auto" VALUE="1" onClick="if (this.checked) { document.OneTrueForm.save.checked=true; }">
+ Charge future payments to this <% $type{$payby} %> automatically
+ </TD>
+</TR>
+</TABLE>
+<BR>
+<INPUT TYPE="submit" NAME="process" VALUE="Process payment">
+</FORM>
+
+<% include('/elements/footer.html') %>
diff --git a/httemplate/misc/print-invoice.cgi b/httemplate/misc/print-invoice.cgi
new file mode 100755
index 000000000..511bdce19
--- /dev/null
+++ b/httemplate/misc/print-invoice.cgi
@@ -0,0 +1,18 @@
+%
+%
+%#untaint invnum
+%my($query) = $cgi->keywords;
+%$query =~ /^((.+)-)?(\d+)$/;
+%my $template = $2;
+%my $invnum = $3;
+%my $cust_bill = qsearchs('cust_bill',{'invnum'=>$invnum});
+%die "Can't find invoice!\n" unless $cust_bill;
+%
+%$cust_bill->print($template);
+%
+%my $custnum = $cust_bill->getfield('custnum');
+%
+%print $cgi->redirect("${p}view/cust_main.cgi?$custnum");
+%
+%
+
diff --git a/httemplate/misc/print_invoice_events.cgi b/httemplate/misc/print_invoice_events.cgi
new file mode 100644
index 000000000..913e2683f
--- /dev/null
+++ b/httemplate/misc/print_invoice_events.cgi
@@ -0,0 +1,4 @@
+%
+%my $server = new FS::UI::Web::JSRPC 'FS::cust_bill_event::process_reprint', $cgi;
+
+<% $server->process %>
diff --git a/httemplate/misc/print_invoices.cgi b/httemplate/misc/print_invoices.cgi
new file mode 100644
index 000000000..826a081fd
--- /dev/null
+++ b/httemplate/misc/print_invoices.cgi
@@ -0,0 +1,4 @@
+%
+%my $server = new FS::UI::Web::JSRPC 'FS::cust_bill::process_reprint', $cgi;
+%
+<% $server->process %>
diff --git a/httemplate/misc/process/batch-cust_pay.cgi b/httemplate/misc/process/batch-cust_pay.cgi
new file mode 100644
index 000000000..e4d1bbff5
--- /dev/null
+++ b/httemplate/misc/process/batch-cust_pay.cgi
@@ -0,0 +1,45 @@
+%
+% my $param = $cgi->Vars;
+%
+% #my $paybatch = $param->{'paybatch'};
+% my $paybatch = time2str('webbatch-%Y/%m/%d-%T'. "-$$-". rand() * 2**32, time);
+%
+% my @cust_pay = ();
+% #my $row = 0;
+% #while ( exists($param->{"custnum$row"}) ) {
+% for ( my $row = 0; exists($param->{"custnum$row"}); $row++ ) {
+% push @cust_pay, new FS::cust_pay {
+% 'custnum' => $param->{"custnum$row"},
+% 'paid' => $param->{"paid$row"},
+% 'payby' => 'BILL',
+% 'payinfo' => $param->{"payinfo$row"},
+% 'paybatch' => $paybatch,
+% }
+% if $param->{"custnum$row"}
+% || $param->{"paid$row"}
+% || $param->{"payinfo$row"};
+% #$row++;
+% }
+%
+% my @errors = FS::cust_pay->batch_insert(@cust_pay);
+% my $num_errors = scalar(grep $_, @errors);
+%
+% if ( $num_errors ) {
+%
+% $cgi->param('error', "$num_errors error". ($num_errors>1 ? 's' : '').
+% ' - Batch not processed, correct and resubmit'
+% );
+%
+% my $erow=0;
+% $cgi->param('error'. $erow++, shift @errors) while @errors;
+%
+%
+<% $cgi->redirect($p.'batch-cust_pay.html?'. $cgi->query_string)
+
+ %>
+% } else {
+%
+%
+<% $cgi->redirect(popurl(3). "search/cust_pay.cgi?magic=paybatch;paybatch=$paybatch") %>
+% }
+
diff --git a/httemplate/misc/process/cancel_pkg.html b/httemplate/misc/process/cancel_pkg.html
new file mode 100755
index 000000000..cd533be10
--- /dev/null
+++ b/httemplate/misc/process/cancel_pkg.html
@@ -0,0 +1,78 @@
+<%init>
+#untaint method
+my $method = $cgi->param('method');
+$method =~ /^(cancel|expire|suspend)$/ || die "Illegal method";
+$method = $1;
+
+#untaint pkgnum
+my $pkgnum = $cgi->param('pkgnum');
+$pkgnum =~ /^(\d+)$/ || die "Illegal pkgnum";
+$pkgnum = $1;
+
+#untaint reasonnum
+my $reasonnum = $cgi->param('reasonnum');
+$reasonnum =~ /^(-?\d+)$/ || die "Illegal reasonnum";
+$reasonnum = $1;
+
+my $date = time;
+if ($method eq 'expire'){
+ #untaint date
+ $date = $cgi->param('date');
+ str2time($cgi->param('date')) =~ /^(\d+)$/ || die "Illegal date";
+ $date = $1;
+}
+
+my $cust_pkg = qsearchs( 'cust_pkg', {'pkgnum'=>$pkgnum} );
+
+my $oldAutoCommit = $FS::UID::AutoCommit;
+local $FS::UID::AutoCommit = 0;
+my $dbh = dbh;
+
+my $otaker = $FS::CurrentUser::CurrentUser->name;
+$otaker = $FS::CurrentUser::CurrentUser->username
+ if ($otaker eq "User, Legacy");
+
+my $error = '';
+if ($reasonnum == -1) {
+
+ $error = 'Enter a new reason (or select an existing one)'
+ unless $cgi->param('newreasonnum') !~ /^\s*$/;
+
+ my $reason = new FS::reason({ 'reason_type' => $cgi->param('newreasonnumT'),
+ 'reason' => $cgi->param('newreasonnum'),
+ });
+ $error ||= $reason->insert;
+ $reasonnum = $reason->reasonnum
+ unless $error;
+}
+
+unless ($error) {
+ if ($method eq 'expire'){
+ my %hash = $cust_pkg->hash;
+ $hash{'expire'}=$date;
+ my $new = new FS::cust_pkg (\%hash);
+ $error = $new->replace($cust_pkg, 'reason' => $reasonnum);
+ }else{
+ $error = $cust_pkg->$method( 'reason' => $reasonnum );
+ }
+}
+
+if ($error) {
+ $cgi->param('error', $error);
+ $dbh->rollback if $oldAutoCommit;
+ print $cgi->redirect(popurl(2). "cancel_pkg.html?". $cgi->query_string );
+}
+
+$dbh->commit or die $dbh->errstr if $oldAutoCommit;
+
+ my %past = ( 'cancel' => 'cancelled',
+ 'expire' => 'expired',
+ 'suspend' => 'suspended',
+ );
+</%init>
+<% header("Package $past{$method}") %>
+ <SCRIPT TYPE="text/javascript">
+ window.top.location.reload();
+ </SCRIPT>
+ </BODY></HTML>
+
diff --git a/httemplate/misc/process/catchall.cgi b/httemplate/misc/process/catchall.cgi
new file mode 100755
index 000000000..f2899c720
--- /dev/null
+++ b/httemplate/misc/process/catchall.cgi
@@ -0,0 +1,34 @@
+%
+%
+%$FS::svc_domain::whois_hack=1;
+%
+%$cgi->param('svcnum') =~ /^(\d*)$/ or die "Illegal svcnum!";
+%my $svcnum =$1;
+%
+%my $old = qsearchs('svc_domain',{'svcnum'=>$svcnum}) if $svcnum;
+%
+%my $new = new FS::svc_domain ( {
+% map {
+% ($_, scalar($cgi->param($_)));
+% } ( fields('svc_domain'), qw( pkgnum svcpart ) )
+%} );
+%
+%$new->setfield('action' => 'M');
+%
+%my $error;
+%if ( $svcnum ) {
+% $error = $new->replace($old);
+%} else {
+% $error = $new->insert;
+% $svcnum = $new->getfield('svcnum');
+%}
+%
+%if ($error) {
+% $cgi->param('error', $error);
+% print $cgi->redirect(popurl(2). "catchall.cgi?". $cgi->query_string );
+%} else {
+% print $cgi->redirect(popurl(3). "view/svc_domain.cgi?$svcnum");
+%}
+%
+%
+
diff --git a/httemplate/misc/process/cdr-import.html b/httemplate/misc/process/cdr-import.html
new file mode 100644
index 000000000..68edaa21c
--- /dev/null
+++ b/httemplate/misc/process/cdr-import.html
@@ -0,0 +1,30 @@
+%
+%
+% my $fh = $cgi->upload('csvfile');
+%
+% my $error = defined($fh)
+% ? FS::cdr::batch_import( {
+% 'filehandle' => $fh,
+% 'format' => $cgi->param('format'),
+% } )
+% : 'No file';
+%
+% if ( $error ) {
+%
+
+ <!-- mason kludge -->
+%
+% eidiot($error);
+%# $cgi->param('error', $error);
+%# print $cgi->redirect( "${p}cust_main-import.cgi
+% } else {
+%
+
+ <!-- mason kludge -->
+ <% include("/elements/header.html",'Import successful') %>
+ <!-- XXX redirect to batch search like the payment entry... -->
+ <% include("/elements/footer.html",'Import successful') %>
+%
+% }
+%
+
diff --git a/httemplate/misc/process/cust_main-import.cgi b/httemplate/misc/process/cust_main-import.cgi
new file mode 100644
index 000000000..a5ede99a1
--- /dev/null
+++ b/httemplate/misc/process/cust_main-import.cgi
@@ -0,0 +1,35 @@
+%
+%
+% my $fh = $cgi->upload('csvfile');
+% #warn $cgi;
+% #warn $fh;
+%
+% my $error = defined($fh)
+% ? FS::cust_main::batch_import( {
+% filehandle => $fh,
+% agentnum => scalar($cgi->param('agentnum')),
+% refnum => scalar($cgi->param('refnum')),
+% pkgpart => scalar($cgi->param('pkgpart')),
+% #'fields' => [qw( cust_pkg.setup dayphone first last address1 address2
+% # city state zip comments )],
+% 'format' => scalar($cgi->param('format')),
+% } )
+% : 'No file';
+%
+% if ( $error ) {
+%
+
+ <!-- mason kludge -->
+%
+% eidiot($error);
+%# $cgi->param('error', $error);
+%# print $cgi->redirect( "${p}cust_main-import.cgi
+% } else {
+%
+
+ <!-- mason kludge -->
+ <% include("/elements/header.html",'Import successful') %>
+%
+% }
+%
+
diff --git a/httemplate/misc/process/cust_main-import_charges.cgi b/httemplate/misc/process/cust_main-import_charges.cgi
new file mode 100644
index 000000000..e0ede576b
--- /dev/null
+++ b/httemplate/misc/process/cust_main-import_charges.cgi
@@ -0,0 +1,30 @@
+%
+%
+% my $fh = $cgi->upload('csvfile');
+% #warn $cgi;
+% #warn $fh;
+%
+% my $error = defined($fh)
+% ? FS::cust_main::batch_charge( {
+% filehandle => $fh,
+% 'fields' => [qw( custnum amount pkg )],
+% } )
+% : 'No file';
+%
+% if ( $error ) {
+%
+
+ <!-- mason kludge -->
+%
+% eidiot($error);
+%# $cgi->param('error', $error);
+%# print $cgi->redirect( "${p}cust_main-import_charges.cgi
+% } else {
+%
+
+ <!-- mason kludge -->
+ <% include("/elements/header.html",'Import successful') %>
+%
+% }
+%
+
diff --git a/httemplate/misc/process/delete-customer.cgi b/httemplate/misc/process/delete-customer.cgi
new file mode 100755
index 000000000..d0d237ee8
--- /dev/null
+++ b/httemplate/misc/process/delete-customer.cgi
@@ -0,0 +1,30 @@
+%
+%
+%my $conf = new FS::Conf;
+%die "Customer deletions not enabled" unless $conf->exists('deletecustomers');
+%
+%$cgi->param('custnum') =~ /^(\d+)$/;
+%my $custnum = $1;
+%my $new_custnum;
+%if ( $cgi->param('new_custnum') ) {
+% $cgi->param('new_custnum') =~ /^(\d+)$/
+% or die "Illegal new customer number: ". $cgi->param('new_custnum');
+% $new_custnum = $1;
+%} else {
+% $new_custnum = '';
+%}
+%my $cust_main = qsearchs( 'cust_main', { 'custnum' => $custnum } )
+% or die "Customer not found: $custnum";
+%
+%my $error = $cust_main->delete($new_custnum);
+%
+%if ( $error ) {
+% $cgi->param('error', $error);
+% print $cgi->redirect(popurl(2). "delete-customer.cgi?". $cgi->query_string );
+%} elsif ( $new_custnum ) {
+% print $cgi->redirect(popurl(3). "view/cust_main.cgi?$new_custnum");
+%} else {
+% print $cgi->redirect(popurl(3));
+%}
+%
+
diff --git a/httemplate/misc/process/inventory_item-import.html b/httemplate/misc/process/inventory_item-import.html
new file mode 100644
index 000000000..f6159dc99
--- /dev/null
+++ b/httemplate/misc/process/inventory_item-import.html
@@ -0,0 +1,31 @@
+%
+%
+% my $fh = $cgi->upload('filename');
+%
+% my $error = defined($fh)
+% ? FS::inventory_item::batch_import( {
+% 'filehandle' => $fh,
+% 'classnum' => $cgi->param('classnum'),
+% } )
+% : 'No file';
+%
+% if ( $error ) {
+%
+
+ <!-- mason kludge -->
+%
+% eidiot($error);
+%# $cgi->param('error', $error);
+%# print $cgi->redirect( "${p}cust_main-import.cgi
+% } else {
+%
+
+ <!-- mason kludge -->
+ <% include("/elements/header.html",'Import successful') %>
+ <!-- XXX redirect to batch search like the payment entry... -->
+ <% include("/elements/footer.html",'Import successful') %>
+%
+% }
+%
+
+
diff --git a/httemplate/misc/process/link.cgi b/httemplate/misc/process/link.cgi
new file mode 100755
index 000000000..fd3d8bb13
--- /dev/null
+++ b/httemplate/misc/process/link.cgi
@@ -0,0 +1,78 @@
+%
+%
+%my $DEBUG = 0;
+%
+%$cgi->param('pkgnum') =~ /^(\d+)$/;
+%my $pkgnum = $1;
+%$cgi->param('svcpart') =~ /^(\d+)$/;
+%my $svcpart = $1;
+%$cgi->param('svcnum') =~ /^(\d*)$/;
+%my $svcnum = $1;
+%
+%unless ( $svcnum ) {
+% my $part_svc = qsearchs('part_svc',{'svcpart'=>$svcpart});
+% my $svcdb = $part_svc->getfield('svcdb');
+% $cgi->param('link_field') =~ /^(\w+)$/;
+% my $link_field = $1;
+% my %search = ( $link_field => $cgi->param('link_value') );
+% if ( $cgi->param('link_field2') =~ /^(\w+)$/ ) {
+% $search{$1} = $cgi->param('link_value2');
+% }
+%
+% my @svc_x = ( sort { ($a->cust_svc->pkgnum > 0) <=> ($b->cust_svc->pkgnum > 0)
+% or ($b->cust_svc->svcpart == $svcpart)
+% <=> ($a->cust_svc->svcpart == $svcpart)
+% }
+% qsearch( $svcdb, \%search )
+% );
+%
+% if ( $DEBUG ) {
+% warn scalar(@svc_x). " candidate accounts found for linking ".
+% "(svcpart $svcpart):\n";
+% foreach my $svc_x ( @svc_x ) {
+% warn " ". $svc_x->email.
+% " (svcnum ". $svc_x->svcnum. ",".
+% " pkgnum ". $svc_x->cust_svc->pkgnum. ",".
+% " svcpart ". $svc_x->cust_svc->svcpart. ")\n";
+% }
+% }
+%
+% my $svc_x = $svc_x[0];
+%
+% eidiot("$link_field not found!") unless $svc_x;
+%
+% $svcnum = $svc_x->svcnum;
+%
+%}
+%
+%my $old = qsearchs('cust_svc',{'svcnum'=>$svcnum});
+%die "svcnum not found!" unless $old;
+%my $conf = new FS::Conf;
+%my($error, $new);
+%if ( $old->pkgnum && ! $conf->exists('legacy_link-steal') ) {
+% $error = "svcnum $svcnum already linked to package ". $old->pkgnum;
+%} else {
+% $new = new FS::cust_svc ({
+% 'svcnum' => $svcnum,
+% 'pkgnum' => $pkgnum,
+% 'svcpart' => $svcpart,
+% });
+%
+% $error = $new->replace($old);
+%}
+%
+%unless ($error) {
+% #no errors, so let's view this customer.
+% my $custnum = $new->cust_pkg->custnum;
+% print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum".
+% "#cust_pkg$pkgnum" );
+%} else {
+%
+
+<!-- mason kludge -->
+%
+% idiot($error);
+%}
+%
+%
+
diff --git a/httemplate/misc/process/meta-import.cgi b/httemplate/misc/process/meta-import.cgi
new file mode 100644
index 000000000..5a97d1160
--- /dev/null
+++ b/httemplate/misc/process/meta-import.cgi
@@ -0,0 +1,185 @@
+<!-- mason kludge -->
+<% include("/elements/header.html",'Map tables') %>
+
+<SCRIPT>
+var gSafeOnload = new Array();
+var gSafeOnsubmit = new Array();
+window.onload = SafeOnload;
+function SafeAddOnLoad(f) {
+ gSafeOnload[gSafeOnload.length] = f;
+}
+function SafeOnload() {
+ for (var i=0;i<gSafeOnload.length;i++)
+ gSafeOnload[i]();
+}
+function SafeAddOnSubmit(f) {
+ gSafeOnsubmit[gSafeOnsubmit.length] = f;
+}
+function SafeOnsubmit() {
+ for (var i=0;i<gSafeOnsubmit.length;i++)
+ gSafeOnsubmit[i]();
+}
+</SCRIPT>
+
+<FORM NAME="OneTrueForm" METHOD="POST" ACTION="meta-import.cgi">
+%
+% #use DBIx::DBSchema;
+% my $schema = new_native DBIx::DBSchema
+% map { $cgi->param($_) } qw( data_source username password );
+% foreach my $field (qw( data_source username password )) {
+
+ <INPUT TYPE="hidden" NAME=<% $field %> VALUE="<% $cgi->param($field) %>">
+% }
+%
+% my %schema;
+% use Tie::DxHash;
+% tie %schema, 'Tie::DxHash';
+% if ( $cgi->param('schema') ) {
+% my $schema_string = $cgi->param('schema');
+%
+ <INPUT TYPE="hidden" NAME="schema" VALUE="<%$schema_string%>">
+%
+% %schema = map { /^\s*(\w+)\s*=>\s*(\w+)\s*$/
+% or die "guru meditation #420: $_";
+% ( $1 => $2 );
+% }
+% split( /\n/, $schema_string );
+% }
+%
+% #first page
+% unless ( $cgi->param('magic') ) {
+
+
+ <INPUT TYPE="hidden" NAME="magic" VALUE="process">
+ <% hashmaker('schema', [ $schema->tables ],
+ [ grep !/^h_/, dbdef->tables ], ) %>
+ <br><INPUT TYPE="submit" VALUE="done">
+%
+%
+% #second page
+% } elsif ( $cgi->param('magic') eq 'process' ) {
+
+
+ <INPUT TYPE="hidden" NAME="magic" VALUE="process2">
+%
+%
+% my %unique;
+% foreach my $table ( keys %schema ) {
+%
+% my @from_columns = $schema->table($table)->columns;
+% my @fs_columns = dbdef->table($schema{$table})->columns;
+%
+%
+
+ <% hashmaker( $table.'__'.$unique{$table}++,
+ \@from_columns => \@fs_columns,
+ $table => $schema{$table}, ) %>
+ <br><hr><br>
+%
+%
+% }
+%
+%
+
+ <br><INPUT TYPE="submit" VALUE="done">
+%
+%
+% #third (results)
+% } elsif ( $cgi->param('magic') eq 'process2' ) {
+%
+% print "<pre>\n";
+%
+% my %unique;
+% foreach my $table ( keys %schema ) {
+% ( my $spaces = $table ) =~ s/./ /g;
+% print "'$table' => { 'table' => '$schema{$table}',\n".
+% #(length($table) x ' '). " 'map' => {\n";
+% "$spaces 'map' => {\n";
+% my %map = map { /^\s*(\w+)\s*=>\s*(\w+)\s*$/
+% or die "guru meditation #420: $_";
+% ( $1 => $2 );
+% }
+% split( /\n/, $cgi->param($table.'__'.$unique{$table}++) );
+% foreach ( keys %map ) {
+% print "$spaces '$_' => '$map{$_}',\n";
+% }
+% print "$spaces },\n";
+% print "$spaces },\n";
+%
+% }
+% print "\n</pre>";
+%
+% } else {
+% warn "unrecognized magic: ". $cgi->param('magic');
+% }
+%
+%
+
+</FORM>
+</BODY>
+</HTML>
+%
+% #hashmaker widget
+% sub hashmaker {
+% my($name, $from, $to, $labelfrom, $labelto) = @_;
+% my $fromsize = scalar(@$from);
+% my $tosize = scalar(@$to);
+% "<TABLE><TR><TH>$labelfrom</TH><TH>$labelto</TH></TR><TR><TD>".
+% qq!<SELECT NAME="${name}_from" SIZE=$fromsize>\n!.
+% join("\n", map { qq!<OPTION VALUE="$_">$_</OPTION>! } sort { $a cmp $b } @$from ).
+% "</SELECT>\n<BR>".
+% qq!<INPUT TYPE="button" VALUE="refill" onClick="repack_${name}_from()">!.
+% '</TD><TD>'.
+% qq!<SELECT NAME="${name}_to" SIZE=$tosize>\n!.
+% join("\n", map { qq!<OPTION VALUE="$_">$_</OPTION>! } sort { $a cmp $b } @$to ).
+% "</SELECT>\n<BR>".
+% qq!<INPUT TYPE="button" VALUE="refill" onClick="repack_${name}_to()">!.
+% '</TD></TR>'.
+% '<TR><TD COLSPAN=2>'.
+% qq!<INPUT TYPE="button" VALUE="map" onClick="toke_$name(this.form)">!.
+% '</TD></TR><TR><TD COLSPAN=2>'.
+% qq!<TEXTAREA NAME="$name" COLS=80 ROWS=8></TEXTAREA>!.
+% '</TD></TR></TABLE>'.
+% "<script>
+% function toke_$name() {
+% fromObject = document.OneTrueForm.${name}_from;
+% for (var i=fromObject.options.length-1;i>-1;i--) {
+% if (fromObject.options[i].selected)
+% fromname = deleteOption_$name(fromObject,i);
+% }
+% toObject = document.OneTrueForm.${name}_to;
+% for (var i=toObject.options.length-1;i>-1;i--) {
+% if (toObject.options[i].selected)
+% toname = deleteOption_$name(toObject,i);
+% }
+% document.OneTrueForm.$name.value = document.OneTrueForm.$name.value + fromname + ' => ' + toname + '\\n';
+% }
+% function deleteOption_$name(object,index) {
+% value = object.options[index].value;
+% object.options[index] = null;
+% return value;
+% }
+% function repack_${name}_from() {
+% var object = document.OneTrueForm.${name}_from;
+% object.options.length = 0;
+% ". join("\n",
+% map { "addOption_$name(object, '$_');\n" }
+% ( sort { $a cmp $b } @$from ) ). "
+% }
+% function repack_${name}_to() {
+% var object = document.OneTrueForm.${name}_to;
+% object.options.length = 0;
+% ". join("\n",
+% map { "addOption_$name(object, '$_');\n" }
+% ( sort { $a cmp $b } @$to ) ). "
+% }
+% function addOption_$name(object,value) {
+% var length = object.length;
+% object.options[length] = new Option(value, value, false, false);
+% }
+% </script>".
+% '';
+% }
+%
+%
+
diff --git a/httemplate/misc/process/payment.cgi b/httemplate/misc/process/payment.cgi
new file mode 100644
index 000000000..a5f4d4208
--- /dev/null
+++ b/httemplate/misc/process/payment.cgi
@@ -0,0 +1,148 @@
+%
+%#some false laziness w/MyAccount::process_payment
+%
+%$cgi->param('custnum') =~ /^(\d+)$/
+% or die "illegal custnum ". $cgi->param('custnum');
+%my $custnum = $1;
+%
+%my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } );
+%die "unknown custnum $custnum" unless $cust_main;
+%
+%$cgi->param('amount') =~ /^\s*(\d*(\.\d\d)?)\s*$/
+% or eidiot "illegal amount ". $cgi->param('amount');
+%my $amount = $1;
+%eidiot "amount <= 0" unless $amount > 0;
+%
+%$cgi->param('year') =~ /^(\d+)$/
+% or die "illegal year ". $cgi->param('year');
+%my $year = $1;
+%
+%$cgi->param('month') =~ /^(\d+)$/
+% or die "illegal month ". $cgi->param('month');
+%my $month = $1;
+%
+%$cgi->param('payby') =~ /^(CARD|CHEK)$/
+% or die "illegal payby ". $cgi->param('payby');
+%my $payby = $1;
+%my %payby2fields = (
+% 'CARD' => [ qw( address1 address2 city state zip ) ],
+% 'CHEK' => [ qw( ss ) ],
+%);
+%my %type = ( 'CARD' => 'credit card',
+% 'CHEK' => 'electronic check (ACH)',
+% );
+%
+%$cgi->param('payname') =~ /^([\w \,\.\-\']+)$/
+% or eidiot gettext('illegal_name'). " payname: ". $cgi->param('payname');
+%my $payname = $1;
+%
+%$cgi->param('paybatch') =~ /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=]*)$/
+% or eidiot gettext('illegal_text'). " paybatch: ". $cgi->param('paybatch');
+%my $paybatch = $1;
+%
+%my $payinfo;
+%my $paycvv = '';
+%if ( $payby eq 'CHEK' ) {
+%
+% if ($cgi->param('payinfo1') =~ /xx/i || $cgi->param('payinfo2') =~ /xx/i ) {
+% $payinfo = $cust_main->payinfo;
+% } else {
+% $cgi->param('payinfo1') =~ /^(\d+)$/
+% or eidiot "illegal account number ". $cgi->param('payinfo1');
+% my $payinfo1 = $1;
+% $cgi->param('payinfo2') =~ /^(\d+)$/
+% or eidiot "illegal ABA/routing number ". $cgi->param('payinfo2');
+% my $payinfo2 = $1;
+% $payinfo = $payinfo1. '@'. $payinfo2;
+% }
+%
+%} elsif ( $payby eq 'CARD' ) {
+%
+% $payinfo = $cgi->param('payinfo');
+% if ($payinfo eq $cust_main->paymask) {
+% $payinfo = $cust_main->payinfo;
+% }
+% $payinfo =~ s/\D//g;
+% $payinfo =~ /^(\d{13,16})$/
+% or eidiot gettext('invalid_card'); # . ": ". $self->payinfo;
+% $payinfo = $1;
+% validate($payinfo)
+% or eidiot gettext('invalid_card'); # . ": ". $self->payinfo;
+% eidiot gettext('unknown_card_type')
+% if cardtype($payinfo) eq "Unknown";
+%
+% if ( defined $cust_main->dbdef_table->column('paycvv') ) {
+% if ( length($cgi->param('paycvv') ) ) {
+% if ( cardtype($payinfo) eq 'American Express card' ) {
+% $cgi->param('paycvv') =~ /^(\d{4})$/
+% or eidiot "CVV2 (CID) for American Express cards is four digits.";
+% $paycvv = $1;
+% } else {
+% $cgi->param('paycvv') =~ /^(\d{3})$/
+% or eidiot "CVV2 (CVC2/CID) is three digits.";
+% $paycvv = $1;
+% }
+% }
+% }
+%
+%} else {
+% die "unknown payby $payby";
+%}
+%
+%my $error = $cust_main->realtime_bop( $FS::payby::payby2bop{$payby}, $amount,
+% 'quiet' => 1,
+% 'manual' => 1,
+% 'payinfo' => $payinfo,
+% 'paydate' => "$year-$month-01",
+% 'payname' => $payname,
+% 'paybatch' => $paybatch,
+% 'paycvv' => $paycvv,
+% map { $_ => $cgi->param($_) } @{$payby2fields{$payby}}
+%);
+%eidiot($error) if $error;
+%
+%$cust_main->apply_payments;
+%
+%if ( $cgi->param('save') ) {
+% my $new = new FS::cust_main { $cust_main->hash };
+% if ( $payby eq 'CARD' ) {
+% $new->set( 'payby' => ( $cgi->param('auto') ? 'CARD' : 'DCRD' ) );
+% } elsif ( $payby eq 'CHEK' ) {
+% $new->set( 'payby' => ( $cgi->param('auto') ? 'CHEK' : 'DCHK' ) );
+% } else {
+% die "unknown payby $payby";
+% }
+% $new->set( 'payinfo' => $payinfo );
+% $new->set( 'paydate' => "$year-$month-01" );
+% $new->set( 'payname' => $payname );
+%
+% #false laziness w/FS:;cust_main::realtime_bop - check both to make sure
+% # working correctly
+% my $conf = new FS::Conf;
+% if ( $payby eq 'CARD' &&
+% grep { $_ eq cardtype($payinfo) } $conf->config('cvv-save') ) {
+% $new->set( 'paycvv' => $paycvv );
+% } else {
+% $new->set( 'paycvv' => '');
+% }
+%
+% $new->set( $_ => $cgi->param($_) ) foreach @{$payby2fields{$payby}};
+%
+% my $error = $new->replace($cust_main);
+% eidiot "payment processed successfully, but error saving info: $error"
+% if $error;
+% $cust_main = $new;
+%}
+%
+%#success!
+%
+%
+
+<% include( '/elements/header.html', ucfirst($type{$payby}). ' processing successful',
+ include('/elements/menubar.html'),
+
+ )
+%>
+<% include( '/elements/small_custview.html', $cust_main, '', '', popurl(3). "view/cust_main.cgi" ) %>
+</BODY>
+</HTML>
diff --git a/httemplate/misc/process/recharge_svc.html b/httemplate/misc/process/recharge_svc.html
new file mode 100755
index 000000000..d9fa2070e
--- /dev/null
+++ b/httemplate/misc/process/recharge_svc.html
@@ -0,0 +1,46 @@
+%
+%
+%#untaint svcnum
+%my $svcnum = $cgi->param('svcnum');
+%$svcnum =~ /^(\d+)$/ || die "Illegal svcnum";
+%$svcnum = $1;
+%
+%#untaint prepaid
+%my $prepaid = $cgi->param('prepaid');
+%$prepaid =~ /^(\w*)$/;
+%$prepaid = $1;
+%
+%my $error = '';
+%my $svc_acct = qsearchs( 'svc_acct', {'svcnum'=>$svcnum} );
+%$error = "Can't recharge service $svcnum. " unless $svc_acct;
+%
+%my $cust_main = $svc_acct->cust_svc->cust_pkg->cust_main;
+%
+%my $oldAutoCommit = $FS::UID::AutoCommit;
+%local $FS::UID::AutoCommit = 0;
+%my $dbh = dbh;
+%
+%
+%unless ($error) {
+%
+%my ($amount, $seconds, $up, $down, $total) = (0, 0, 0, 0, 0);
+%$error = $cust_main->get_prepay($prepaid, \$amount, \$seconds, \$up, \$down, \$total)
+% || $svc_acct->increment_seconds($seconds)
+% || $svc_acct->increment_upbytes($up)
+% || $svc_acct->increment_downbytes($down)
+% || $svc_acct->increment_totalbytes($total)
+% || $cust_main->insert_cust_pay_prepay( $amount, $prepaid );
+%}
+%
+%if ($error) {
+% $cgi->param('error', $error);
+% $dbh->rollback if $oldAutoCommit;
+% print $cgi->redirect(popurl(2). "recharge_svc.html?". $cgi->query_string );
+%}
+%
+<% header("Package recharged") %>
+ <SCRIPT TYPE="text/javascript">
+ window.top.location.reload();
+ </SCRIPT>
+ </BODY></HTML>
+
diff --git a/httemplate/misc/queue.cgi b/httemplate/misc/queue.cgi
new file mode 100644
index 000000000..7370aabe1
--- /dev/null
+++ b/httemplate/misc/queue.cgi
@@ -0,0 +1,48 @@
+%
+%
+%$cgi->param('action') =~ /^(new|del|(retry|remove) selected)$/
+% or die "Illegal action";
+%my $action = $1;
+%
+%my $job;
+%if ( $action eq 'new' || $action eq 'del' ) {
+% $cgi->param('jobnum') =~ /^(\d+)$/ or die "Illegal jobnum";
+% my $jobnum = $1;
+% $job = qsearchs('queue', { 'jobnum' => $1 })
+% or die "unknown jobnum $jobnum - ".
+% "it probably completed normally or was removed by another user";
+%}
+%
+%if ( $action eq 'new' ) {
+% my %hash = $job->hash;
+% $hash{'status'} = 'new';
+% $hash{'statustext'} = '';
+% my $new = new FS::queue \%hash;
+% my $error = $new->replace($job);
+% die $error if $error;
+%} elsif ( $action eq 'del' ) {
+% my $error = $job->delete;
+% die $error if $error;
+%} elsif ( $action =~ /^(retry|remove) selected$/ ) {
+% foreach my $jobnum (
+% map { /^jobnum(\d+)$/; $1; } grep /^jobnum\d+$/, $cgi->param
+% ) {
+% my $job = qsearchs('queue', { 'jobnum' => $jobnum });
+% if ( $action eq 'retry selected' && $job ) { #new
+% my %hash = $job->hash;
+% $hash{'status'} = 'new';
+% $hash{'statustext'} = '';
+% my $new = new FS::queue \%hash;
+% my $error = $new->replace($job);
+% die $error if $error;
+% } elsif ( $action eq 'remove selected' && $job ) { #del
+% my $error = $job->delete;
+% die $error if $error;
+% }
+% }
+%}
+%
+%print $cgi->redirect(popurl(2). "search/queue.html");
+%
+%
+
diff --git a/httemplate/misc/recharge_svc.html b/httemplate/misc/recharge_svc.html
new file mode 100755
index 000000000..61f738455
--- /dev/null
+++ b/httemplate/misc/recharge_svc.html
@@ -0,0 +1,48 @@
+<% include('/elements/header-popup.html', 'Recharge Service' ) %>
+
+% if ( $cgi->param('error') ) {
+ <FONT SIZE="+1" COLOR="#ff0000">Error: <% $cgi->param('error') %></FONT>
+ <BR><BR>
+% }
+
+<FORM NAME="recharge_popup" ACTION="<% popurl(1) %>process/recharge_svc.html" METHOD=POST>
+<INPUT TYPE="hidden" NAME="svcnum" VALUE="<% $svcnum %>">
+
+<BR><BR>
+<% "Recharge $svcnum: $label - $value" %>
+<% ntable("#cccccc", 2) %>
+
+<TR>
+ <TD>Enter prepaid card: </TD>
+ <TD><INPUT TYPE="text" NAME="prepaid" VALUE="<% $prepaid %>"></TD>
+</TR>
+
+</TABLE>
+
+<BR>
+<INPUT TYPE="submit" NAME="submit" VALUE="Recharge">
+
+</FORM>
+</BODY>
+</HTML>
+
+<%init>
+my($svcnum, $cust_svc, $label, $value, $prepaid);
+if ( $cgi->param('error') ) {
+ $svcnum = $cgi->param('svcnum');
+ $prepaid = $cgi->param('prepaid');
+} elsif ( $cgi->param('svcnum') =~ /^(\d+)$/ ) {
+ $svcnum = $1;
+} else {
+ die "illegal query ". $cgi->keywords;
+}
+
+my $title = 'Recharge Service';
+
+$cust_svc = qsearchs('cust_svc', {'svcnum' => $svcnum});
+die "No such service: $svcnum" unless $cust_svc;
+
+($label, $value) = $cust_svc->label;
+
+</%init>
+
diff --git a/httemplate/misc/states.cgi b/httemplate/misc/states.cgi
new file mode 100644
index 000000000..cf2b46ee2
--- /dev/null
+++ b/httemplate/misc/states.cgi
@@ -0,0 +1,7 @@
+%
+%
+% my $country = $cgi->param('arg');
+% my @output = states_hash($country);
+%
+%
+[ <% join(', ', map { qq("$_") } @output) %> ]
diff --git a/httemplate/misc/svc_acct-domains.cgi b/httemplate/misc/svc_acct-domains.cgi
new file mode 100644
index 000000000..3f9599e30
--- /dev/null
+++ b/httemplate/misc/svc_acct-domains.cgi
@@ -0,0 +1,31 @@
+%
+%
+% my $pkgpart_svcpart = $cgi->param('arg');
+% $pkgpart_svcpart =~ /^\d+_(\d+)$/;
+% my $part_svc = qsearchs('part_svc', { 'svcpart' => $1 }) if $1;
+% my $part_svc_column = $part_svc->part_svc_column('domsvc');
+%
+% my @output = split /,/, $part_svc_column->columnvalue;
+% my @svc_domain = ();
+% my %seen = ();
+%
+% foreach (@output) {
+% my $svc_domain = qsearchs('svc_domain', { 'svcnum' => $_ })
+% or warn "unknown svc_domain.svcnum $_ for part_svc_column domsvc; ".
+% "svcpart = " . $part_svc->svcpart;
+% push @svc_domain, [ $_ => $svc_domain->domain ];
+% $seen{$_}++;
+% }
+% if ($conf->exists('svc_acct-alldomains')
+% && ( $part_svc_column->columnflag eq 'D'
+% || $part_svc_column->columnflag eq '' )
+% ) {
+% foreach (grep { $_->svcnum ne $output[0] } qsearch('svc_domain', {}) ){
+% push @svc_domain, [ $_->svcnum => $_->domain ];
+% }
+% }
+%
+[ <% join(', ', map { qq("$_->[0]", "$_->[1]") } @svc_domain) %> ]
+<%init>
+my $conf = new FS::Conf;
+</%init>
diff --git a/httemplate/misc/unapply-cust_credit.cgi b/httemplate/misc/unapply-cust_credit.cgi
new file mode 100755
index 000000000..56a3ff854
--- /dev/null
+++ b/httemplate/misc/unapply-cust_credit.cgi
@@ -0,0 +1,19 @@
+%
+%
+%#untaint crednum
+%my($query) = $cgi->keywords;
+%$query =~ /^(\d+)$/ || die "Illegal crednum";
+%my $crednum = $1;
+%
+%my $cust_credit = qsearchs('cust_credit', { 'crednum' => $crednum } );
+%my $custnum = $cust_credit->custnum;
+%
+%foreach my $cust_credit_bill ( $cust_credit->cust_credit_bill ) {
+% my $error = $cust_credit_bill->delete;
+% eidiot($error) if $error;
+%}
+%
+%print $cgi->redirect($p. "view/cust_main.cgi?". $custnum);
+%
+%
+
diff --git a/httemplate/misc/unapply-cust_pay.cgi b/httemplate/misc/unapply-cust_pay.cgi
new file mode 100755
index 000000000..b28f61b0f
--- /dev/null
+++ b/httemplate/misc/unapply-cust_pay.cgi
@@ -0,0 +1,19 @@
+%
+%
+%#untaint paynum
+%my($query) = $cgi->keywords;
+%$query =~ /^(\d+)$/ || die "Illegal paynum";
+%my $paynum = $1;
+%
+%my $cust_pay = qsearchs('cust_pay', { 'paynum' => $paynum } );
+%my $custnum = $cust_pay->custnum;
+%
+%foreach my $cust_bill_pay ( $cust_pay->cust_bill_pay ) {
+% my $error = $cust_bill_pay->delete;
+% eidiot($error) if $error;
+%}
+%
+%print $cgi->redirect($p. "view/cust_main.cgi?". $custnum);
+%
+%
+
diff --git a/httemplate/misc/unprovision.cgi b/httemplate/misc/unprovision.cgi
new file mode 100755
index 000000000..e42feda8a
--- /dev/null
+++ b/httemplate/misc/unprovision.cgi
@@ -0,0 +1,31 @@
+%
+%
+%my $dbh = dbh;
+%
+%#untaint svcnum
+%my($query) = $cgi->keywords;
+%$query =~ /^(\d+)$/;
+%my $svcnum = $1;
+%
+%#my $svc_acct = qsearchs('svc_acct',{'svcnum'=>$svcnum});
+%#die "Unknown svcnum!" unless $svc_acct;
+%
+%my $cust_svc = qsearchs('cust_svc',{'svcnum'=>$svcnum});
+%die "Unknown svcnum!" unless $cust_svc;
+%
+%my $custnum = $cust_svc->cust_pkg->custnum;
+%
+%my $error = $cust_svc->cancel;
+%
+%if ( $error ) {
+%
+
+<!-- mason kludge -->
+%
+% &eidiot($error);
+%} else {
+% print $cgi->redirect(popurl(2)."view/cust_main.cgi?$custnum");
+%}
+%
+%
+
diff --git a/httemplate/misc/unsusp_pkg.cgi b/httemplate/misc/unsusp_pkg.cgi
new file mode 100755
index 000000000..79c07a72a
--- /dev/null
+++ b/httemplate/misc/unsusp_pkg.cgi
@@ -0,0 +1,16 @@
+%
+%
+%#untaint pkgnum
+%my ($query) = $cgi->keywords;
+%$query =~ /^(\d+)$/ || die "Illegal pkgnum";
+%my $pkgnum = $1;
+%
+%my $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
+%
+%my $error = $cust_pkg->unsuspend;
+%&eidiot($error) if $error;
+%
+%print $cgi->redirect(popurl(2). "view/cust_main.cgi?".$cust_pkg->getfield('custnum'));
+%
+%
+
diff --git a/httemplate/misc/unvoid-cust_pay_void.cgi b/httemplate/misc/unvoid-cust_pay_void.cgi
new file mode 100755
index 000000000..75c3edc06
--- /dev/null
+++ b/httemplate/misc/unvoid-cust_pay_void.cgi
@@ -0,0 +1,17 @@
+%
+%
+%#untaint paynum
+%my($query) = $cgi->keywords;
+%$query =~ /^(\d+)$/ || die "Illegal paynum";
+%my $paynum = $1;
+%
+%my $cust_pay_void = qsearchs('cust_pay_void', { 'paynum' => $paynum } );
+%my $custnum = $cust_pay_void->custnum;
+%
+%my $error = $cust_pay_void->unvoid;
+%eidiot($error) if $error;
+%
+%print $cgi->redirect($p. "view/cust_main.cgi?". $custnum);
+%
+%
+
diff --git a/httemplate/misc/upload-batch.cgi b/httemplate/misc/upload-batch.cgi
new file mode 100644
index 000000000..69d3ca6b1
--- /dev/null
+++ b/httemplate/misc/upload-batch.cgi
@@ -0,0 +1,39 @@
+% if ( $error ) {
+
+ <!-- mason kludge -->
+
+% eidiot($error);
+%# $cgi->param('error', $error);
+%# print $cgi->redirect( "${p}cust_main-import.cgi
+% } else {
+
+ <% include("/elements/header.html",'Batch results upload successful') %>
+
+% }
+<%init>
+
+my $error;
+
+my $fh = $cgi->upload('batch_results');
+$error = 'No file uploaded' unless defined($fh);
+
+unless ( $error ) {
+
+ $cgi->param('batchnum') =~ /^(\d+)$/;
+ my $batchnum = $1;
+
+ my $pay_batch = qsearchs( 'pay_batch', { 'batchnum' => $batchnum } );
+ if ( ! $pay_batch ) {
+ $error = "batchnum $batchnum not found";
+ } elsif ( $pay_batch->status ne 'I' ) {
+ $error = "batch $batchnum is not in transit";
+ } else {
+ $error = $pay_batch->import_results(
+ 'filehandle' => $fh,
+ 'format' => $cgi->param('format'),
+ );
+ }
+
+}
+
+</%init>
diff --git a/httemplate/misc/void-cust_pay.cgi b/httemplate/misc/void-cust_pay.cgi
new file mode 100755
index 000000000..b55d22c41
--- /dev/null
+++ b/httemplate/misc/void-cust_pay.cgi
@@ -0,0 +1,17 @@
+%
+%
+%#untaint paynum
+%my($query) = $cgi->keywords;
+%$query =~ /^(\d+)$/ || die "Illegal paynum";
+%my $paynum = $1;
+%
+%my $cust_pay = qsearchs('cust_pay',{'paynum'=>$paynum});
+%my $custnum = $cust_pay->custnum;
+%
+%my $error = $cust_pay->void;
+%eidiot($error) if $error;
+%
+%print $cgi->redirect($p. "view/cust_main.cgi?". $custnum);
+%
+%
+
diff --git a/httemplate/misc/whois.cgi b/httemplate/misc/whois.cgi
new file mode 100644
index 000000000..d3d9649fd
--- /dev/null
+++ b/httemplate/misc/whois.cgi
@@ -0,0 +1,27 @@
+%
+% my $svcnum = $cgi->param('svcnum');
+% my $custnum = $cgi->param('custnum');
+% my $domain = $cgi->param('domain');
+%
+%
+
+<% include("/elements/header.html","Whois $domain", menubar(
+ ( $custnum
+ ? ( "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum",
+ )
+ : ()
+ ),
+ "View this domain (#$svcnum)" => "${p}view/svc_domain.cgi?$svcnum",
+ "Main menu" => $p,
+)) %>
+% my $whois = eval { whois($domain) };
+% if ( $@ ) {
+% ( $whois = $@ ) =~ s/ at \/.*Net\/Whois\/Raw\.pm line \d+.*$//s;
+% } else {
+% $whois =~ s/^\n+//;
+% }
+%
+
+<PRE><% $whois %></PRE>
+</BODY>
+</HTML>
diff --git a/httemplate/misc/xmlhttp-cust_main-search.cgi b/httemplate/misc/xmlhttp-cust_main-search.cgi
new file mode 100644
index 000000000..67512fad9
--- /dev/null
+++ b/httemplate/misc/xmlhttp-cust_main-search.cgi
@@ -0,0 +1,22 @@
+%
+% my $sub = $cgi->param('sub');
+%
+% if ( $sub eq 'custnum_search' ) {
+%
+% my $custnum = $cgi->param('arg');
+% my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } );
+%
+%
+"<% $cust_main ? $cust_main->name : '' %>"
+% } elsif ( $sub eq 'smart_search' ) {
+%
+% my $string = $cgi->param('arg');
+% my @cust_main = smart_search( 'search' => $string );
+% my $return = [ map [ $_->custnum, $_->name ], @cust_main ];
+%
+%
+<% objToJson($return) %>
+% }
+
+
+
diff --git a/httemplate/misc/xmlrpc.cgi b/httemplate/misc/xmlrpc.cgi
new file mode 100644
index 000000000..1d0383f2a
--- /dev/null
+++ b/httemplate/misc/xmlrpc.cgi
@@ -0,0 +1,18 @@
+%
+%
+% my $request_xml = $cgi->param('POSTDATA');
+%
+% #$r->log_error($request_xml);
+%
+% my $fsxmlrpc = new FS::XMLRPC;
+% my ($error, $response_xml) = $fsxmlrpc->serve($request_xml);
+%
+% #$r->log_error($error) if $error;
+%
+% http_header('Content-Type' => 'text/xml',
+% 'Content-Length' => length($response_xml));
+%
+% print $response_xml;
+%
+%
+