diff options
Diffstat (limited to 'httemplate/misc')
-rwxr-xr-x | httemplate/misc/cancel-unaudited.cgi | 11 | ||||
-rwxr-xr-x | httemplate/misc/cust_main-cancel.cgi | 4 | ||||
-rw-r--r-- | httemplate/misc/dump.cgi | 19 | ||||
-rwxr-xr-x | httemplate/misc/email-invoice.cgi | 23 | ||||
-rwxr-xr-x | httemplate/misc/expire_pkg.cgi | 64 | ||||
-rwxr-xr-x | httemplate/misc/link.cgi | 68 | ||||
-rwxr-xr-x | httemplate/misc/print-invoice.cgi | 2 | ||||
-rwxr-xr-x | httemplate/misc/process/expire_pkg.cgi | 25 | ||||
-rwxr-xr-x | httemplate/misc/process/link.cgi | 29 | ||||
-rwxr-xr-x | httemplate/misc/unapply-cust_credit.cgi | 18 | ||||
-rwxr-xr-x | httemplate/misc/unprovision.cgi | 4 | ||||
-rw-r--r-- | httemplate/misc/upload-batch.cgi | 5 | ||||
-rw-r--r-- | httemplate/misc/whois.cgi | 25 |
13 files changed, 238 insertions, 59 deletions
diff --git a/httemplate/misc/cancel-unaudited.cgi b/httemplate/misc/cancel-unaudited.cgi index 11cde968d..43e439b58 100755 --- a/httemplate/misc/cancel-unaudited.cgi +++ b/httemplate/misc/cancel-unaudited.cgi @@ -12,10 +12,13 @@ my $svcnum = $1; my $cust_svc = qsearchs('cust_svc',{'svcnum'=>$svcnum}); die "Unknown svcnum!" unless $cust_svc; -&eidiot(qq!This account has already been audited. Cancel the - <A HREF="!. popurl(2). qq!view/cust_pkg.cgi?! . $cust_svc->getfield('pkgnum') . - qq!pkgnum"> package</A> instead.!) - if $cust_svc->pkgnum ne '' && $cust_svc->pkgnum ne '0'; +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; 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/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/expire_pkg.cgi b/httemplate/misc/expire_pkg.cgi index 9e4ce8b62..b59674a69 100755 --- a/httemplate/misc/expire_pkg.cgi +++ b/httemplate/misc/expire_pkg.cgi @@ -1,25 +1,55 @@ +<!-- mason kludge --> <% -#untaint date & pkgnum - -my $date; -if ( $cgi->param('date') ) { - str2time($cgi->param('date')) =~ /^(\d+)$/ or die "Illegal date"; - $date=$1; -} else { - $date=''; -} - -$cgi->param('pkgnum') =~ /^(\d+)$/ or die "Illegal pkgnum"; +my($query) = $cgi->keywords; +$query =~ /^(\d+)$/; my $pkgnum = $1; +#get package record my $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); -my %hash = $cust_pkg->hash; -$hash{expire}=$date; -my $new = new FS::cust_pkg ( \%hash ); -my $error = $new->replace($cust_pkg); -&eidiot($error) if $error; +die "Unknown pkgnum $pkgnum" unless $cust_pkg; +my $part_pkg = $cust_pkg->part_pkg; + +my $custnum = $cust_pkg->getfield('custnum'); -print $cgi->redirect(popurl(2). "view/cust_main.cgi?".$cust_pkg->getfield('custnum')); +my $date = $cust_pkg->expire ? time2str('%D', $cust_pkg->expire) : ''; %> + +<%= header('Expire package', menubar( + "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum", + 'Main Menu' => popurl(2) +)) %> + +<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> + +<%= $pkgnum %>: <%= $part_pkg->pkg. ' - '. $part_pkg->comment %> + +<FORM NAME="formname" ACTION="process/expire_pkg.cgi" METHOD="post"> +<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<%= $pkgnum %>"> +<TABLE> + <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> +</TABLE> + +<SCRIPT TYPE="text/javascript"> + Calendar.setup({ + inputField: "expire_date", + ifFormat: "%m/%d/%Y", + button: "expire_button", + align: "BR" + }); +</SCRIPT> + +<INPUT TYPE="submit" VALUE="Cancel later"> +</FORM> +</BODY> +</HTML> diff --git a/httemplate/misc/link.cgi b/httemplate/misc/link.cgi index efc762cc5..18cd378d3 100755 --- a/httemplate/misc/link.cgi +++ b/httemplate/misc/link.cgi @@ -4,9 +4,16 @@ my %link_field = ( 'svc_acct' => 'username', 'svc_domain' => 'domain', - 'svc_acct_sm' => '', - 'svc_charge' => '', - 'svc_wo' => '', +); + +my %link_field2 = ( + 'svc_acct' => { label => 'Domain', + field => 'domsvc', + type => 'select', + select_table => 'svc_domain', + select_key => 'svcnum', + select_label => 'domain' + }, ); my($query) = $cgi->keywords; @@ -20,27 +27,48 @@ 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}; + +%> -print header("Link to existing $svc"), - qq!<FORM ACTION="!, popurl(1), qq!process/link.cgi" METHOD=POST>!; +<%= header("Link to existing $svc") %> +<FORM ACTION="<%= popurl(1) %>process/link.cgi" METHOD=POST> -if ( $link_field ) { - print <<END; +<% 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"> -END -} else { - print qq!Service # of existing service: <INPUT TYPE="text" 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=""> +<% } %> -print <<END; -<INPUT TYPE="hidden" NAME="pkgnum" VALUE="$pkgnum"> -<INPUT TYPE="hidden" NAME="svcpart" VALUE="$svcpart"> -<P><CENTER><INPUT TYPE="submit" VALUE="Link"></CENTER> +<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<%= $pkgnum %>"> +<INPUT TYPE="hidden" NAME="svcpart" VALUE="<%= $svcpart %>"> +<BR><INPUT TYPE="submit" VALUE="Link"> </FORM> </BODY> </HTML> -END - -%> diff --git a/httemplate/misc/print-invoice.cgi b/httemplate/misc/print-invoice.cgi index 0dda68a4e..144f6156a 100755 --- a/httemplate/misc/print-invoice.cgi +++ b/httemplate/misc/print-invoice.cgi @@ -24,6 +24,6 @@ die "Can't find invoice!\n" unless $cust_bill; 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/expire_pkg.cgi b/httemplate/misc/process/expire_pkg.cgi new file mode 100755 index 000000000..dc35592ce --- /dev/null +++ b/httemplate/misc/process/expire_pkg.cgi @@ -0,0 +1,25 @@ +<% + +#untaint date & pkgnum + +my $date; +if ( $cgi->param('date') ) { + str2time($cgi->param('date')) =~ /^(\d+)$/ or die "Illegal date"; + $date=$1; +} else { + $date=''; +} + +$cgi->param('pkgnum') =~ /^(\d+)$/ or die "Illegal pkgnum"; +my $pkgnum = $1; + +my $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); +my %hash = $cust_pkg->hash; +$hash{expire}=$date; +my $new = new FS::cust_pkg ( \%hash ); +my $error = $new->replace($cust_pkg); +&eidiot($error) if $error; + +print $cgi->redirect(popurl(3). "view/cust_main.cgi?".$cust_pkg->getfield('custnum')); + +%> diff --git a/httemplate/misc/process/link.cgi b/httemplate/misc/process/link.cgi index 5d80adeb9..32a5360d9 100755 --- a/httemplate/misc/process/link.cgi +++ b/httemplate/misc/process/link.cgi @@ -12,8 +12,12 @@ unless ( $svcnum ) { 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 = ( grep { $_->cust_svc->svcpart == $svcpart } - qsearch( $svcdb, { $link_field => $cgi->param('link_value') }) + qsearch( $svcdb, \%search ) )[0]; eidiot("$link_field not found!") unless $svc_x; $svcnum = $svc_x->svcnum; @@ -21,18 +25,25 @@ unless ( $svcnum ) { my $old = qsearchs('cust_svc',{'svcnum'=>$svcnum}); die "svcnum not found!" unless $old; -#die "svcnum $svcnum already linked to package ". $old->pkgnum if $old->pkgnum; -my $new = new FS::cust_svc ({ - 'svcnum' => $svcnum, - 'pkgnum' => $pkgnum, - 'svcpart' => $svcpart, -}); +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, + }); -my $error = $new->replace($old); + $error = $new->replace($old); +} unless ($error) { #no errors, so let's view this customer. - print $cgi->redirect(popurl(3). "view/cust_pkg.cgi?$pkgnum"); + my $custnum = $new->cust_pkg->custnum; + print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum". + "#cust_pkg$pkgnum" ); } else { %> <!-- mason kludge --> diff --git a/httemplate/misc/unapply-cust_credit.cgi b/httemplate/misc/unapply-cust_credit.cgi new file mode 100755 index 000000000..c658d2acc --- /dev/null +++ b/httemplate/misc/unapply-cust_credit.cgi @@ -0,0 +1,18 @@ +<% + +#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/unprovision.cgi b/httemplate/misc/unprovision.cgi index 8f2a7d13d..3c92a4e2e 100755 --- a/httemplate/misc/unprovision.cgi +++ b/httemplate/misc/unprovision.cgi @@ -12,10 +12,6 @@ my $svcnum = $1; my $cust_svc = qsearchs('cust_svc',{'svcnum'=>$svcnum}); die "Unknown svcnum!" unless $cust_svc; -#&eidiot(qq!This account has already been audited. Cancel the -# <A HREF="!. popurl(2). qq!view/cust_pkg.cgi?! . $cust_svc->getfield('pkgnum') . -# qq!pkgnum"> package</A> instead.!) -# if $cust_svc->pkgnum ne '' && $cust_svc->pkgnum ne '0'; my $custnum = $cust_svc->cust_pkg->custnum; diff --git a/httemplate/misc/upload-batch.cgi b/httemplate/misc/upload-batch.cgi index cc5346606..5d0150177 100644 --- a/httemplate/misc/upload-batch.cgi +++ b/httemplate/misc/upload-batch.cgi @@ -2,8 +2,9 @@ my $fh = $cgi->upload('batch_results'); my $filename = $cgi->param('batch_results'); - $filename =~ /^.*[\/\\]([^\/\\]+)$/ or die; - my $paybatch = $1; + $filename =~ /^(.*[\/\\])?([^\/\\]+)$/ + or die "unparsable filename: $filename\n"; + my $paybatch = $2; my $error = defined($fh) ? FS::cust_pay_batch::import_results( { diff --git a/httemplate/misc/whois.cgi b/httemplate/misc/whois.cgi new file mode 100644 index 000000000..dd7851dc2 --- /dev/null +++ b/httemplate/misc/whois.cgi @@ -0,0 +1,25 @@ +<% + my $svcnum = $cgi->param('svcnum'); + my $custnum = $cgi->param('custnum'); + my $domain = $cgi->param('domain'); + +%> +<%= header("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> |