diff options
Diffstat (limited to 'httemplate/misc')
-rwxr-xr-x | httemplate/misc/bill.cgi | 36 | ||||
-rwxr-xr-x | httemplate/misc/cancel-unaudited.cgi | 47 | ||||
-rwxr-xr-x | httemplate/misc/cancel_pkg.cgi | 15 | ||||
-rwxr-xr-x | httemplate/misc/catchall.cgi | 133 | ||||
-rwxr-xr-x | httemplate/misc/delete-cust_pay.cgi | 16 | ||||
-rwxr-xr-x | httemplate/misc/delete-customer.cgi | 46 | ||||
-rwxr-xr-x | httemplate/misc/expire_pkg.cgi | 25 | ||||
-rwxr-xr-x | httemplate/misc/link.cgi | 46 | ||||
-rwxr-xr-x | httemplate/misc/print-invoice.cgi | 23 | ||||
-rwxr-xr-x | httemplate/misc/process/catchall.cgi | 33 | ||||
-rwxr-xr-x | httemplate/misc/process/delete-customer.cgi | 29 | ||||
-rwxr-xr-x | httemplate/misc/process/link.cgi | 40 | ||||
-rw-r--r-- | httemplate/misc/queue.cgi | 25 | ||||
-rwxr-xr-x | httemplate/misc/susp_pkg.cgi | 15 | ||||
-rwxr-xr-x | httemplate/misc/unsusp_pkg.cgi | 15 |
15 files changed, 544 insertions, 0 deletions
diff --git a/httemplate/misc/bill.cgi b/httemplate/misc/bill.cgi new file mode 100755 index 000000000..6f523a52c --- /dev/null +++ b/httemplate/misc/bill.cgi @@ -0,0 +1,36 @@ +<% + +#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 $error = $cust_main->bill( +# 'time'=>$time + ); +#&eidiot($error) if $error; + +unless ( $error ) { + $cust_main->apply_payments; + $cust_main->apply_credits; + + $error = $cust_main->collect( + # 'invoice-time'=>$time, + # 'batch_card'=> 'yes', + 'batch_card'=> 'no', + 'report_badcard'=> 'yes', + ); +} +#&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..5d3c87316 --- /dev/null +++ b/httemplate/misc/cancel-unaudited.cgi @@ -0,0 +1,47 @@ +<% + +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}); +&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'; + +local $SIG{HUP} = 'IGNORE'; +local $SIG{INT} = 'IGNORE'; +local $SIG{QUIT} = 'IGNORE'; +local $SIG{TERM} = 'IGNORE'; +local $SIG{TSTP} = 'IGNORE'; + +local $FS::UID::AutoCommit = 0; + +my $error = $svc_acct->cancel; +&myeidiot($error) if $error; +$error = $svc_acct->delete; +&myeidiot($error) if $error; + +$error = $cust_svc->delete; + +if ( $error ) { + $dbh->rollback; + %> +<!-- mason kludge --> +<% + &eidiot(@_); +} else { + + $dbh->commit or die $dbh->errstr; + + print $cgi->redirect(popurl(2)); +} + +%> diff --git a/httemplate/misc/cancel_pkg.cgi b/httemplate/misc/cancel_pkg.cgi new file mode 100755 index 000000000..0487677df --- /dev/null +++ b/httemplate/misc/cancel_pkg.cgi @@ -0,0 +1,15 @@ +<% + +#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->cancel; +eidiot($error) if $error; + +print $cgi->redirect($p. "view/cust_main.cgi?".$cust_pkg->getfield('custnum')); + +%> diff --git a/httemplate/misc/catchall.cgi b/httemplate/misc/catchall.cgi new file mode 100755 index 000000000..9aa84be18 --- /dev/null +++ b/httemplate/misc/catchall.cgi @@ -0,0 +1,133 @@ +<!-- 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{0} = "(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/delete-cust_pay.cgi b/httemplate/misc/delete-cust_pay.cgi new file mode 100755 index 000000000..3efd918ab --- /dev/null +++ b/httemplate/misc/delete-cust_pay.cgi @@ -0,0 +1,16 @@ +<% + +#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-customer.cgi b/httemplate/misc/delete-customer.cgi new file mode 100755 index 000000000..5088fef7b --- /dev/null +++ b/httemplate/misc/delete-customer.cgi @@ -0,0 +1,46 @@ +<!-- 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="../docs/config.html#hidecancelledcustomers">hidecancelledcustomers</a> configuration file) +<br> +<br>Are you <b>absolutely sure</b> you want to delete this customer? +<br><input type="submit" value="Yes"> +</form></body></html> +END + +%> diff --git a/httemplate/misc/expire_pkg.cgi b/httemplate/misc/expire_pkg.cgi new file mode 100755 index 000000000..9e4ce8b62 --- /dev/null +++ b/httemplate/misc/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(2). "view/cust_main.cgi?".$cust_pkg->getfield('custnum')); + +%> diff --git a/httemplate/misc/link.cgi b/httemplate/misc/link.cgi new file mode 100755 index 000000000..efc762cc5 --- /dev/null +++ b/httemplate/misc/link.cgi @@ -0,0 +1,46 @@ +<!-- mason kludge --> +<% + +my %link_field = ( + 'svc_acct' => 'username', + 'svc_domain' => 'domain', + 'svc_acct_sm' => '', + 'svc_charge' => '', + 'svc_wo' => '', +); + +my($query) = $cgi->keywords; +my($pkgnum, $svcpart) = ('', ''); +foreach $_ (split(/-/,$query)) { #get & untaint pkgnum & svcpart + $pkgnum=$1 if /^pkgnum(\d+)$/; + $svcpart=$1 if /^svcpart(\d+)$/; +} + +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}; + +print header("Link to existing $svc"), + qq!<FORM ACTION="!, popurl(1), qq!process/link.cgi" METHOD=POST>!; + +if ( $link_field ) { + print <<END; + <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="">!; +} + +print <<END; +<INPUT TYPE="hidden" NAME="pkgnum" VALUE="$pkgnum"> +<INPUT TYPE="hidden" NAME="svcpart" VALUE="$svcpart"> +<P><CENTER><INPUT TYPE="submit" VALUE="Link"></CENTER> + </FORM> + </BODY> +</HTML> +END + +%> diff --git a/httemplate/misc/print-invoice.cgi b/httemplate/misc/print-invoice.cgi new file mode 100755 index 000000000..a5500bff2 --- /dev/null +++ b/httemplate/misc/print-invoice.cgi @@ -0,0 +1,23 @@ +<% + +my $conf = new FS::Conf; +my $lpr = $conf->config('lpr'); + +#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; + + open(LPR,"|$lpr") or die "Can't open $lpr: $!"; + 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"); + +%> diff --git a/httemplate/misc/process/catchall.cgi b/httemplate/misc/process/catchall.cgi new file mode 100755 index 000000000..44a63f9f8 --- /dev/null +++ b/httemplate/misc/process/catchall.cgi @@ -0,0 +1,33 @@ +<% + +$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/delete-customer.cgi b/httemplate/misc/process/delete-customer.cgi new file mode 100755 index 000000000..16bdbaea8 --- /dev/null +++ b/httemplate/misc/process/delete-customer.cgi @@ -0,0 +1,29 @@ +<% + +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/link.cgi b/httemplate/misc/process/link.cgi new file mode 100755 index 000000000..4b220a867 --- /dev/null +++ b/httemplate/misc/process/link.cgi @@ -0,0 +1,40 @@ +<% + +$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($svc_x)=qsearchs($svcdb,{$link_field => $cgi->param('link_value') }); + 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; +#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 $error = $new->replace($old); + +unless ($error) { + #no errors, so let's view this customer. + print $cgi->redirect(popurl(3). "view/cust_pkg.cgi?$pkgnum"); +} else { +%> +<!-- mason kludge --> +<% + idiot($error); +} + +%> diff --git a/httemplate/misc/queue.cgi b/httemplate/misc/queue.cgi new file mode 100644 index 000000000..7e962d498 --- /dev/null +++ b/httemplate/misc/queue.cgi @@ -0,0 +1,25 @@ +<% + +$cgi->param('jobnum') =~ /^(\d+)$/ or die "Illegal jobnum"; +my $jobnum = $1; +my $job = qsearchs('queue', { 'jobnum' => $1 }) + or die "unknown jobnum $jobnum"; + +$cgi->param('action') =~ /^(new|del)$/ or die "Illegal action"; +my $action = $1; + +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; +} + +print $cgi->redirect(popurl(2). "browse/queue.cgi"); + +%> diff --git a/httemplate/misc/susp_pkg.cgi b/httemplate/misc/susp_pkg.cgi new file mode 100755 index 000000000..4a19fa830 --- /dev/null +++ b/httemplate/misc/susp_pkg.cgi @@ -0,0 +1,15 @@ +<% + +#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->suspend; +&eidiot($error) if $error; + +print $cgi->redirect(popurl(2). "view/cust_main.cgi?".$cust_pkg->getfield('custnum')); + +%> diff --git a/httemplate/misc/unsusp_pkg.cgi b/httemplate/misc/unsusp_pkg.cgi new file mode 100755 index 000000000..500872983 --- /dev/null +++ b/httemplate/misc/unsusp_pkg.cgi @@ -0,0 +1,15 @@ +<% + +#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')); + +%> |