diff options
Diffstat (limited to 'httemplate/misc')
-rwxr-xr-x | httemplate/misc/cust_main-cancel.cgi | 4 | ||||
-rwxr-xr-x | httemplate/misc/delete-cust_credit.cgi | 16 | ||||
-rw-r--r-- | httemplate/misc/download-batch.cgi | 16 | ||||
-rw-r--r-- | httemplate/misc/dump.cgi | 19 | ||||
-rwxr-xr-x | httemplate/misc/email-invoice.cgi | 23 | ||||
-rwxr-xr-x | httemplate/misc/print-invoice.cgi | 10 | ||||
-rw-r--r-- | httemplate/misc/process/meta-import.cgi | 4 | ||||
-rw-r--r-- | httemplate/misc/upload-batch.cgi | 29 |
8 files changed, 115 insertions, 6 deletions
diff --git a/httemplate/misc/cust_main-cancel.cgi b/httemplate/misc/cust_main-cancel.cgi index 526e128a4..257c3384f 100755 --- a/httemplate/misc/cust_main-cancel.cgi +++ b/httemplate/misc/cust_main-cancel.cgi @@ -7,8 +7,8 @@ my $custnum = $1; my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ); -my $error = $cust_main->cancel; -eidiot($error) if $error; +my @errors = $cust_main->cancel; +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/delete-cust_credit.cgi b/httemplate/misc/delete-cust_credit.cgi new file mode 100755 index 000000000..30de04d27 --- /dev/null +++ b/httemplate/misc/delete-cust_credit.cgi @@ -0,0 +1,16 @@ +<% + +#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/download-batch.cgi b/httemplate/misc/download-batch.cgi new file mode 100644 index 000000000..306ef5d63 --- /dev/null +++ b/httemplate/misc/download-batch.cgi @@ -0,0 +1,16 @@ +<% + +#http_header('Content-Type' => 'text/comma-separated-values' ); #IE chokes +http_header('Content-Type' => 'text/plain' ); + +for my $cust_pay_batch ( sort { $a->paybatchnum <=> $b->paybatchnum } + qsearch('cust_pay_batch', {} ) +) { + +$cust_pay_batch->exp =~ /^\d{2}(\d{2})[\/\-](\d+)[\/\-]\d+$/; +my( $mon, $y ) = ( $2, $1 ); +$mon = "0$mon" if $mon < 10; +my $exp = "$mon$y"; + +%>,,,,<%= $cust_pay_batch->cardnum %>,<%= $exp %>,<%= $cust_pay_batch->amount %>,<%= $cust_pay_batch->paybatchnum %> +<% } %> diff --git a/httemplate/misc/dump.cgi b/httemplate/misc/dump.cgi new file mode 100644 index 000000000..dc1323bb3 --- /dev/null +++ b/httemplate/misc/dump.cgi @@ -0,0 +1,19 @@ +<% + 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..7ab1613ee --- /dev/null +++ b/httemplate/misc/email-invoice.cgi @@ -0,0 +1,23 @@ +<% + +my $conf = new FS::Conf; + +#untaint invnum +my($query) = $cgi->keywords; +$query =~ /^(\d*)$/; +my $invnum = $1; +my $cust_bill = qsearchs('cust_bill',{'invnum'=>$invnum}); +die "Can't find invoice!\n" unless $cust_bill; + +my $error = send_email( + 'from' => $conf->config('invoice_from'), + 'to' => [ grep { $_ ne 'POST' } $cust_bill->cust_main->invoicing_list ], + 'subject' => 'Invoice', + 'body' => [ $cust_bill->print_text ], +); +eidiot($error) if $error; + +my $custnum = $cust_bill->getfield('custnum'); +print $cgi->redirect("${p}view/cust_main.cgi?$custnum"); + +%> diff --git a/httemplate/misc/print-invoice.cgi b/httemplate/misc/print-invoice.cgi index a5500bff2..144f6156a 100755 --- a/httemplate/misc/print-invoice.cgi +++ b/httemplate/misc/print-invoice.cgi @@ -11,13 +11,19 @@ my $cust_bill = qsearchs('cust_bill',{'invnum'=>$invnum}); die "Can't find invoice!\n" unless $cust_bill; open(LPR,"|$lpr") or die "Can't open $lpr: $!"; - print LPR $cust_bill->print_text; #( date ) + + if ( $conf->exists('invoice_latex') ) { + print LPR $cust_bill->print_ps; #( date ) + } else { + print LPR $cust_bill->print_text; #( date ) + } + close LPR or die $! ? "Error closing $lpr: $!" : "Exit status $? from $lpr"; my $custnum = $cust_bill->getfield('custnum'); -print $cgi->redirect(popurl(2). "view/cust_main.cgi?$custnum#history"); +print $cgi->redirect("${p}view/cust_main.cgi?$custnum"); %> diff --git a/httemplate/misc/process/meta-import.cgi b/httemplate/misc/process/meta-import.cgi index 2939c8fb2..59d236f64 100644 --- a/httemplate/misc/process/meta-import.cgi +++ b/httemplate/misc/process/meta-import.cgi @@ -116,8 +116,8 @@ function SafeOnsubmit() { #hashmaker widget sub hashmaker { my($name, $from, $to, $labelfrom, $labelto) = @_; - $fromsize = scalar(@$from); - $tosize = scalar(@$to); + 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 ). diff --git a/httemplate/misc/upload-batch.cgi b/httemplate/misc/upload-batch.cgi new file mode 100644 index 000000000..cc5346606 --- /dev/null +++ b/httemplate/misc/upload-batch.cgi @@ -0,0 +1,29 @@ +<% + + my $fh = $cgi->upload('batch_results'); + my $filename = $cgi->param('batch_results'); + $filename =~ /^.*[\/\\]([^\/\\]+)$/ or die; + my $paybatch = $1; + + my $error = defined($fh) + ? FS::cust_pay_batch::import_results( { + 'filehandle' => $fh, + 'format' => $cgi->param('format'), + 'paybatch' => $paybatch, + } ) + : 'No file'; + + if ( $error ) { + %> + <!-- mason kludge --> + <% + eidiot($error); +# $cgi->param('error', $error); +# print $cgi->redirect( "${p}cust_main-import.cgi + } else { + %> + <!-- mason kludge --> + <%= header('Batch results upload sucessful') %> <% + } +%> + |