diff options
Diffstat (limited to 'httemplate/search')
-rwxr-xr-x | httemplate/search/cust_main.cgi | 4 | ||||
-rwxr-xr-x | httemplate/search/cust_pkg.cgi | 2 | ||||
-rw-r--r-- | httemplate/search/elements/search.html | 59 | ||||
-rwxr-xr-x | httemplate/search/report_cc.cgi | 3 | ||||
-rwxr-xr-x | httemplate/search/report_credit.cgi | 3 | ||||
-rwxr-xr-x | httemplate/search/report_tax.cgi | 3 | ||||
-rwxr-xr-x | httemplate/search/sql.cgi | 76 | ||||
-rw-r--r-- | httemplate/search/sql.html | 12 | ||||
-rwxr-xr-x | httemplate/search/svc_acct.cgi | 25 | ||||
-rwxr-xr-x | httemplate/search/svc_acct_sm.cgi | 84 | ||||
-rwxr-xr-x | httemplate/search/svc_acct_sm.html | 23 | ||||
-rwxr-xr-x | httemplate/search/svc_domain.cgi | 13 |
12 files changed, 225 insertions, 82 deletions
diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 50d367e1e..2b5b73a4b 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -498,9 +498,7 @@ sub cardsearch { $card =~ /^(\d{13,16})$/ or eidiot "Illegal card number\n"; my($payinfo)=$1; - [ qsearch('cust_main',{'payinfo'=>$payinfo, 'payby'=>'CARD'}), - qsearch('cust_main',{'payinfo'=>$payinfo, 'payby'=>'DCRD'}) - ]; + [ qsearch('cust_main',{'payinfo'=>$payinfo, 'payby'=>'CARD'}) ]; } sub referralsearch { diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index 45420f4c4..f2c4115c3 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -223,7 +223,7 @@ if ( scalar(@cust_pkg) == 1 ) { <TH><FONT SIZE=-1>Setup</FONT></TH> END - print '<TH><FONT SIZE=-1>Last<BR>bill</FONT></TH>' + print '<TH><FONT SIZE=-1>Next<BR>bill</FONT></TH>' if defined dbdef->table('cust_pkg')->column('last_bill'); print <<END; diff --git a/httemplate/search/elements/search.html b/httemplate/search/elements/search.html deleted file mode 100644 index fbedcaa26..000000000 --- a/httemplate/search/elements/search.html +++ /dev/null @@ -1,59 +0,0 @@ -<% - - my %opt = @_; - unless (exists($opt{'count_query'}) && length($opt{'count_query'})) { - ( $opt{'count_query'} = $opt{'query'} ) =~ - s/^\s*SELECT\s*(.*)\s+FROM\s/SELECT COUNT(*) FROM /i; - } - - my $conf = new FS::Conf; - my $maxrecords = $conf->config('maxsearchrecordsperpage'); - - my $limit = $maxrecords ? "LIMIT $maxrecords" : ''; - - my $offset = $cgi->param('offset') || 0; - $limit .= " OFFSET $offset" if $offset; - - my $count_sth = dbh->prepare($opt{'count_query'}) - or die "Error preparing $opt{'count_query'}: ". dbh->errstr; - $count_sth->execute - or die "Error executing $opt{'count_query'}: ". $count_sth->errstr; - my $total = $count_sth->fetchrow_arrayref->[0]; - - my $sth = dbh->prepare("$opt{'query'} $limit") - or die "Error preparing $opt{'query'}: ". dbh->errstr; - $sth->execute - or die "Error executing $opt{'query'}: ". $sth->errstr; - - #can get # of rows without fetching them all? - my $rows = $sth->fetchall_arrayref; - -%> -<!-- mason kludge --> -<% my $pager = include ( '/elements/pager.html', - 'offset' => $offset, - 'num_rows' => scalar(@$rows), - 'total' => $total, - 'maxrecords' => $maxrecords, - ); -%> - -<%= $total %> total <%= $opt{'name'} %><BR><BR><%= $pager %> -<%= include( '/elements/table.html' ) %> - <TR> - <% foreach ( @{$sth->{NAME}} ) { %> - <TH><%= $_ %></TH> - <% } %> - </TR> - <% foreach my $row ( @$rows ) { %> - <TR> - <% foreach ( @$row ) { %> - <TD><%= $_ %></TD> - <% } %> - </TR> - <% } %> - -</TABLE> -<%= $pager %> -</BODY> -</HTML> diff --git a/httemplate/search/report_cc.cgi b/httemplate/search/report_cc.cgi index c2ab726b6..ff8c1fb0b 100755 --- a/httemplate/search/report_cc.cgi +++ b/httemplate/search/report_cc.cgi @@ -1,7 +1,8 @@ <!-- mason kludge --> <% -my $user = getotaker; +#my $user = getotaker; +my $user = $FS::UID::user; #dumb 1.4 8-char workaround $cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/; my $beginning = $1; diff --git a/httemplate/search/report_credit.cgi b/httemplate/search/report_credit.cgi index 2adafc06e..05017f4a9 100755 --- a/httemplate/search/report_credit.cgi +++ b/httemplate/search/report_credit.cgi @@ -1,7 +1,8 @@ <!-- mason kludge --> <% -my $user = getotaker; +#my $user = getotaker; +my $user = $FS::UID::user; #dumb 1.4 8-char workaround $cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/; my $beginning = $1; diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi index ac76fad6e..835554a2e 100755 --- a/httemplate/search/report_tax.cgi +++ b/httemplate/search/report_tax.cgi @@ -1,7 +1,8 @@ <!-- mason kludge --> <% -my $user = getotaker; +#my $user = getotaker; +my $user = $FS::UID::user; #dumb 1.4 8-char workaround $cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/; my $beginning = $1; diff --git a/httemplate/search/sql.cgi b/httemplate/search/sql.cgi new file mode 100755 index 000000000..b83ef039f --- /dev/null +++ b/httemplate/search/sql.cgi @@ -0,0 +1,76 @@ +<% + +my $conf = new FS::Conf; +my $maxrecords = $conf->config('maxsearchrecordsperpage'); + +my $limit = ''; +$limit .= "LIMIT $maxrecords" if $maxrecords; + +my $offset = $cgi->param('offset') || 0; +$limit .= " OFFSET $offset" if $offset; + +my $total; + +my $sql = $cgi->param('sql'); +$sql =~ s/^\s*SELECT//i; + +my $count_sql = $sql; +$count_sql =~ s/^(.*)\s+FROM\s/COUNT(*) FROM /i; + +my $sth = dbh->prepare("SELECT $count_sql") + or eidiot dbh->errstr. " doing $count_sql\n"; +$sth->execute or eidiot "Error executing \"$count_sql\": ". $sth->errstr; + +$total = $sth->fetchrow_arrayref->[0]; + +my $sth = dbh->prepare("SELECT $sql $limit") + or eidiot dbh->errstr. " doing $sql\n"; +$sth->execute or eidiot "Error executing \"$sql\": ". $sth->errstr; +my $rows = $sth->fetchall_arrayref; + +%> +<!-- mason kludge --> +<% + + #begin pager + my $pager = ''; + if ( $total != scalar(@$rows) && $maxrecords ) { + unless ( $offset == 0 ) { + $cgi->param('offset', $offset - $maxrecords); + $pager .= '<A HREF="'. $cgi->self_url. + '"><B><FONT SIZE="+1">Previous</FONT></B></A> '; + } + my $poff; + my $page; + for ( $poff = 0; $poff < $total; $poff += $maxrecords ) { + $page++; + if ( $offset == $poff ) { + $pager .= qq!<FONT SIZE="+2">$page</FONT> !; + } else { + $cgi->param('offset', $poff); + $pager .= qq!<A HREF="!. $cgi->self_url. qq!">$page</A> !; + } + } + unless ( $offset + $maxrecords > $total ) { + $cgi->param('offset', $offset + $maxrecords); + $pager .= '<A HREF="'. $cgi->self_url. + '"><B><FONT SIZE="+1">Next</FONT></B></A> '; + } + } + #end pager + + print header('Query Results', menubar('Main Menu'=>$p) ). + "$total total rows<BR><BR>$pager". table(). + "<TR>"; + print "<TH>$_</TH>" foreach @{$sth->{NAME}}; + print "</TR>"; + + foreach $row ( @$rows ) { + print "<TR>"; + print "<TD>$_</TD>" foreach @$row; + print "</TR>"; + } + + print "</TABLE>$pager</BODY></HTML>"; + +%> diff --git a/httemplate/search/sql.html b/httemplate/search/sql.html deleted file mode 100644 index 7d7fc0890..000000000 --- a/httemplate/search/sql.html +++ /dev/null @@ -1,12 +0,0 @@ -<%= include( '/elements/header.html', 'Query Results', - include( '/elements/menubar.html', 'Main Menu' => $p ) - ) -%> - -<%= include( 'elements/search.html', - 'name' => 'rows', - 'query' => 'SELECT '. ( $cgi->param('sql') - || eidiot('Empty query') ), - ) -%> - diff --git a/httemplate/search/svc_acct.cgi b/httemplate/search/svc_acct.cgi index 1e4a03d84..29e851d91 100755 --- a/httemplate/search/svc_acct.cgi +++ b/httemplate/search/svc_acct.cgi @@ -1,5 +1,7 @@ <% +my $mydomain = ''; + my $conf = new FS::Conf; my $maxrecords = $conf->config('maxsearchrecordsperpage'); @@ -162,8 +164,14 @@ END $domain = "<A HREF=\"${p}view/svc_domain.cgi?". $svc_domain->svcnum. "\">". $svc_domain->domain. "</A>"; } else { - die "No svc_domain.svcnum record for svc_acct.domsvc: ". - $svc_acct->domsvc; + unless ( $mydomain ) { + my $conf = new FS::Conf; + unless ( $mydomain = $conf->config('domain') ) { + die "No legacy domain config file and no svc_domain.svcnum record ". + "for svc_acct.domsvc: ". $svc_acct->domsvc; + } + } + $domain = "<i>$mydomain</i><FONT COLOR=\"#FF0000\">*</FONT>"; } my($cust_pkg,$cust_main); if ( $cust_svc->pkgnum ) { @@ -225,8 +233,17 @@ END } - print "</TABLE>$pager<BR>". - '</BODY></HTML>'; + print "</TABLE>$pager<BR>"; + + if ( $mydomain ) { + print "<BR><FONT COLOR=\"#FF0000\">*</FONT> The <I>$mydomain</I> domain ". + "is contained in your legacy <CODE>domain</CODE> ". + "<A HREF=\"${p}docs/config.html#domain\">configuration file</A>. ". + "You should run the <CODE>bin/fs-migrate-svc_acct_sm</CODE> script ". + "to create a proper svc_domain record for this domain."; + } + + print '</BODY></HTML>'; } diff --git a/httemplate/search/svc_acct_sm.cgi b/httemplate/search/svc_acct_sm.cgi new file mode 100755 index 000000000..4ee300612 --- /dev/null +++ b/httemplate/search/svc_acct_sm.cgi @@ -0,0 +1,84 @@ +<% + +my $conf = new FS::Conf; +my $mydomain = $conf->config('domain'); + +$cgi->param('domuser') =~ /^([a-z0-9_\-]{0,32})$/; +my $domuser = $1; + +$cgi->param('domain') =~ /^([\w\-\.]+)$/ or die "Illegal domain"; +my $svc_domain = qsearchs('svc_domain',{'domain'=>$1}) + or die "Unknown domain"; +my $domsvc = $svc_domain->svcnum; + +my @svc_acct_sm; +if ($domuser) { + @svc_acct_sm=qsearch('svc_acct_sm',{ + 'domuser' => $domuser, + 'domsvc' => $domsvc, + }); +} else { + @svc_acct_sm=qsearch('svc_acct_sm',{'domsvc' => $domsvc}); +} + +if ( scalar(@svc_acct_sm) == 1 ) { + my($svcnum)=$svc_acct_sm[0]->svcnum; + print $cgi->redirect(popurl(2). "view/svc_acct_sm.cgi?$svcnum"); +} elsif ( scalar(@svc_acct_sm) > 1 ) { +%> +<!-- mason kludge --> +<% + print header('Mail Alias Search Results'), &table(), <<END; + <TR> + <TH>Mail to<BR><FONT SIZE=-1>(click to view mail alias)</FONT></TH> + <TH>Forwards to<BR><FONT SIZE=-1>(click to view account)</FONT></TH> + </TR> +END + + my($svc_acct_sm); + foreach $svc_acct_sm (@svc_acct_sm) { + my($svcnum,$domuser,$domuid,$domsvc)=( + $svc_acct_sm->svcnum, + $svc_acct_sm->domuser, + $svc_acct_sm->domuid, + $svc_acct_sm->domsvc, + ); + + my $svc_domain = qsearchs( 'svc_domain', { 'svcnum' => $domsvc } ); + if ( $svc_domain ) { + my $domain = $svc_domain->domain; + + print qq!<TR><TD><A HREF="!. popurl(2). qq!view/svc_acct_sm.cgi?$svcnum">!, + #print '', ( ($domuser eq '*') ? "<I>(anything)</I>" : $domuser ); + ( ($domuser eq '*') ? "<I>(anything)</I>" : $domuser ), + qq!\@$domain</A> </TD>!, + ; + } else { + my $warning = "couldn't find svc_domain.svcnum $svcnum ( svc_acct_sm.svcnum $svcnum"; + warn $warning; + print "<TR><TD>WARNING: $warning</TD>"; + } + + my $svc_acct = qsearchs( 'svc_acct', { 'uid' => $domuid } ); + if ( $svc_acct ) { + my $username = $svc_acct->username; + my $svc_acct_svcnum =$svc_acct->svcnum; + print qq!<TD><A HREF="!, popurl(2), + qq!view/svc_acct.cgi?$svc_acct_svcnum">$username\@$mydomain</A>!, + qq!</TD></TR>! + ; + } else { + my $warning = "couldn't find svc_acct.uid $domuid (svc_acct_sm.svcnum $svcnum)!"; + warn $warning; + print "<TD>WARNING: $warning</TD></TR>"; + } + + } + + print '</TABLE></BODY></HTML>'; + +} else { #error + idiot("Mail Alias not found"); +} + +%> diff --git a/httemplate/search/svc_acct_sm.html b/httemplate/search/svc_acct_sm.html new file mode 100755 index 000000000..0719856db --- /dev/null +++ b/httemplate/search/svc_acct_sm.html @@ -0,0 +1,23 @@ +<HTML> + <HEAD> + <TITLE>Mail Alias Search</TITLE> + </HEAD> + <BODY> + <CENTER> + <H1>Mail Alias Search</H1> + </CENTER> + <HR> + <FORM ACTION="svc_acct_sm.cgi" METHOD="post"> + Search for <B>mail alias</B>: + <INPUT TYPE="text" NAME="domuser"><FONT SIZE=-1>(opt.)</FONT> @ + <INPUT TYPE="text" NAME="domain"><FONT SIZE=-1>(req.)</FONT> + + <P><INPUT TYPE="submit" VALUE="Search"> + + </FORM> + + <HR> + + </BODY> +</HTML> + diff --git a/httemplate/search/svc_domain.cgi b/httemplate/search/svc_domain.cgi index 948b1d9ae..cd78dc128 100755 --- a/httemplate/search/svc_domain.cgi +++ b/httemplate/search/svc_domain.cgi @@ -1,6 +1,7 @@ <% my $conf = new FS::Conf; +my $mydomain = $conf->config('domain'); my($query)=$cgi->keywords; $query ||= ''; #to avoid use of unitialized value errors @@ -74,6 +75,18 @@ END $svc_domain->svcnum, $svc_domain->domain, ); + #my($malias); + #if ( qsearch('svc_acct_sm',{'domsvc'=>$svcnum}) ) { + # $malias=( + # qq|<FORM ACTION="svc_acct_sm.cgi" METHOD="post">|. + # qq|<INPUT TYPE="hidden" NAME="domuser" VALUE="">|. + # qq|<INPUT TYPE="hidden" NAME="domain" VALUE="$domain">|. + # qq|<INPUT TYPE="submit" VALUE="(mail aliases)">|. + # qq|</FORM>| + # ); + #} else { + # $malias=''; + #} #don't display all accounts here my $rowspan = 1; |