From: ivan Date: Fri, 5 Apr 2002 16:37:42 +0000 (+0000) Subject: oops forgot these from working on the road X-Git-Tag: freeside_1_4_0_pre12~111 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=20d1b5c39c3674f3fdf5c0f784697a4442658648 oops forgot these from working on the road --- diff --git a/FS/t/part_export-infostreet.t b/FS/t/part_export-infostreet.t new file mode 100644 index 000000000..1b3341825 --- /dev/null +++ b/FS/t/part_export-infostreet.t @@ -0,0 +1,5 @@ +BEGIN { $| = 1; print "1..1\n" } +END {print "not ok 1\n" unless $loaded;} +use FS::part_export::infostreet; +$loaded=1; +print "ok 1\n"; diff --git a/FS/t/part_export-sqlradius.t b/FS/t/part_export-sqlradius.t new file mode 100644 index 000000000..5fb23a5a6 --- /dev/null +++ b/FS/t/part_export-sqlradius.t @@ -0,0 +1,5 @@ +BEGIN { $| = 1; print "1..1\n" } +END {print "not ok 1\n" unless $loaded;} +use FS::part_export::sqlradius; +$loaded=1; +print "ok 1\n"; diff --git a/eg/export_template.pm b/eg/export_template.pm new file mode 100644 index 000000000..11e1c3b14 --- /dev/null +++ b/eg/export_template.pm @@ -0,0 +1,47 @@ +package FS::part_export::myexport; + +use vars qw(@ISA); +use FS::part_export; + +@ISA = qw(FS::part_export); + +sub rebless { shift; } + +sub _export_insert { + my($self, $svc_something) = (shift, shift); + $self->myexport_queue( $svc_acct->svcnum, 'insert', + $svc_something->username, $svc_something->password ); +} + +sub _export_replace { + my( $self, $new, $old ) = (shift, shift, shift); + #return "can't change username with myexport" + # if $old->username ne $new->username; + #return '' unless $old->_password ne $new->_password; + $self->myexport_queue( $new->svcnum, + 'replace', $new->username, $new->password ); +} + +sub _export_delete { + my( $self, $svc_something ) = (shift, shift); + $self->myexport_queue( $svc_acct->svcnum, + 'delete', $svc_something->username ); +} + +#a good idea to queue anything that could fail or take any time +sub myexport_queue { + my( $self, $svcnum, $method ) = (shift, shift, shift); + my $queue = new FS::queue { + 'svcnum' => $svcnum, + 'job' => "FS::part_export::myexport::myexport_$method", + }; + $queue->insert( @_ ); +} + +sub myexport_insert { #subroutine, not method +} +sub myexport_replace { #subroutine, not method +} +sub myexport_delete { #subroutine, not method +} + 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; + +%> + +<% + + #begin pager + my $pager = ''; + if ( $total != scalar(@$rows) && $maxrecords ) { + unless ( $offset == 0 ) { + $cgi->param('offset', $offset - $maxrecords); + $pager .= 'Previous '; + } + my $poff; + my $page; + for ( $poff = 0; $poff < $total; $poff += $maxrecords ) { + $page++; + if ( $offset == $poff ) { + $pager .= qq!$page !; + } else { + $cgi->param('offset', $poff); + $pager .= qq!$page !; + } + } + unless ( $offset + $maxrecords > $total ) { + $cgi->param('offset', $offset + $maxrecords); + $pager .= 'Next '; + } + } + #end pager + + print header('Query Results', menubar('Main Menu'=>$p) ). + "$total total rows

$pager". table(). + ""; + print "$_" foreach @{$sth->{NAME}}; + print ""; + + foreach $row ( @$rows ) { + print ""; + print "$_" foreach @$row; + print ""; + } + + print "$pager"; + +%>