summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorJonathan Prykop <jonathan@freeside.biz>2015-07-02 13:17:00 -0500
committerJonathan Prykop <jonathan@freeside.biz>2015-07-02 13:17:00 -0500
commit379c06ccd4b984bfa8130d98f862799239a8d00c (patch)
treee505a4e60c018ea146b997ddfe745711bd0081f8 /httemplate
parent0b9c15a3add1d3715c3895171894ac6480d1dfc1 (diff)
parent838897525d851ea5cb1386c253471a02a3f41b5f (diff)
Merge branch 'master' of git.freeside.biz:/home/git/freeside
Diffstat (limited to 'httemplate')
-rw-r--r--httemplate/pref/pref.html3
-rw-r--r--httemplate/search/elements/search-html.html8
-rw-r--r--httemplate/search/elements/search.html83
-rw-r--r--httemplate/search/sql.html5
4 files changed, 61 insertions, 38 deletions
diff --git a/httemplate/pref/pref.html b/httemplate/pref/pref.html
index ffc90fde8..46291066c 100644
--- a/httemplate/pref/pref.html
+++ b/httemplate/pref/pref.html
@@ -281,12 +281,13 @@ tie my %customer_views, 'Tie::IxHash',
'Basics' => 'basics',
'Notes' => 'notes', #notes and files?
'Tickets' => 'tickets',
+ 'Appointments' => 'appointments',
+ 'Quotations' => 'quotations',
'Packages' => 'packages',
'Payment History' => 'payment_history',
;
$customer_views{'Change History'} = 'change_history'
if $curuser->access_right('View customer history');
-$customer_views{'Jumbo'} = 'jumbo';
# XSS via your own preferences? seems unlikely, but nice try anyway...
( $curuser->option('menu_position') || 'top' )
diff --git a/httemplate/search/elements/search-html.html b/httemplate/search/elements/search-html.html
index 6121aea94..12f6c1e04 100644
--- a/httemplate/search/elements/search-html.html
+++ b/httemplate/search/elements/search-html.html
@@ -349,6 +349,7 @@ $rows => []
% }
% my $i = 0; # for row striping # XXX CSS - nth-child
+% my $id = 0;
% foreach my $row ( @$rows ) {
%
% my $rowstyle = '';
@@ -504,7 +505,11 @@ $rows => []
%
% $tooltip = &{$tooltip}($row)
% if ref($tooltip) eq 'CODE';
-% $tooltip = qq! title="<% $tooltip |h %>"!;
+% $tooltip = qq! id="a$id" !.
+% qq! onmouseover="return overlib(!.
+% $m->interp->apply_escapes($tooltip, 'h', 'js_string').
+% qq!, FGCLASS, 'tooltip', REF, 'a$id', !.
+% qq!REFC, 'LL', REFP, 'UL')"! if $tooltip;
%
% if ( $link ) {
% my( $url, $method ) = @{$link};
@@ -521,6 +526,7 @@ $rows => []
% elsif ( $tooltip ) {
% $a = qq(<A $tooltip>);
% }
+% $id++;
% }
%
diff --git a/httemplate/search/elements/search.html b/httemplate/search/elements/search.html
index c58e63698..f136832a2 100644
--- a/httemplate/search/elements/search.html
+++ b/httemplate/search/elements/search.html
@@ -277,11 +277,17 @@ if ( $opt{'agent_virt'} ) {
'table' => $query->{'table'},
);
+ # this is ridiculous, but we do have searches where $query has constraints
+ # and $count_query doesn't, or vice versa.
if ( $query->{'extra_sql'} =~ /\bWHERE\b/i or keys %{$query->{hashref}} ) {
$query->{'extra_sql'} .= " AND $agentnums_sql";
- $count_query .= " AND $agentnums_sql";
} else {
$query->{'extra_sql'} .= " WHERE $agentnums_sql";
+ }
+
+ if ( $count_query =~ /\bWHERE\b/i ) {
+ $count_query .= " AND $agentnums_sql";
+ } else {
$count_query .= " WHERE $agentnums_sql";
}
@@ -400,48 +406,55 @@ $order_by = $cgi->param('order_by') if $cgi->param('order_by');
my $header = [ map { ref($_) ? $_->{'label'} : $_ } @{$opt{header}} ];
my $rows;
-my @query;
-if (ref($query) eq 'HASH') {
- @query = $query;
-
- if ( $order_by ) {
- if ( $query->{'order_by'} ) {
- if ( $query->{'order_by'} =~ /^(\s*ORDER\s+BY\s+)?(\S.*)$/is ) {
- $query->{'order_by'} = "ORDER BY $order_by, $2";
+if ( ref $query ) {
+ my @query;
+ if (ref($query) eq 'HASH') {
+ @query = $query;
+
+ if ( $order_by ) {
+ if ( $query->{'order_by'} ) {
+ if ( $query->{'order_by'} =~ /^(\s*ORDER\s+BY\s+)?(\S.*)$/is ) {
+ $query->{'order_by'} = "ORDER BY $order_by, $2";
+ } else {
+ warn "unparsable query order_by: ". $query->{'order_by'};
+ die "unparsable query order_by: ". $query->{'order_by'};
+ }
} else {
- warn "unparsable query order_by: ". $query->{'order_by'};
- die "unparsable query order_by: ". $query->{'order_by'};
+ $query->{'order_by'} = "ORDER BY $order_by";
}
- } else {
- $query->{'order_by'} = "ORDER BY $order_by";
}
+
+ $query->{'order_by'} .= " $limit";
+
+ } elsif (ref($query) eq 'ARRAY') {
+ # do we still use this? it was for the old 477 report.
+ @query = @{ $query };
+ } else {
+ die "invalid query reference";
}
- $query->{'order_by'} .= " $limit";
+ #eval "use FS::$opt{'query'};";
+ my @param = qw( select table addl_from hashref extra_sql order_by debug );
+ $rows = [ qsearch( [ map { my $query = $_;
+ ({ map { $_ => $query->{$_} } @param });
+ }
+ @query
+ ],
+ #'order_by' => $opt{order_by}. " ". $limit,
+ )
+ ];
-} elsif (ref($query) eq 'ARRAY') {
- # do we still use this? it was for the old 477 report.
- @query = @{ $query };
-} else {
- die "invalid query reference";
-}
+} else { # not ref $query; plain SQL (still used as of 07/2015)
-if ( $opt{disableable} && ! $cgi->param('showdisabled') ) {
- #%search = ( 'disabled' => '' );
- $opt{'query'}->{'hashref'}->{'disabled'} = '';
- $opt{'query'}->{'extra_sql'} =~ s/^\s*WHERE/ AND/i;
-}
+ $query .= " $limit";
+ my $sth = dbh->prepare($query)
+ or die "Error preparing $query: ". dbh->errstr;
+ $sth->execute
+ or die "Error executing $query: ". $sth->errstr;
-#eval "use FS::$opt{'query'};";
-my @param = qw( select table addl_from hashref extra_sql order_by debug );
-$rows = [ qsearch( [ map { my $query = $_;
- ({ map { $_ => $query->{$_} } @param });
- }
- @query
- ],
- #'order_by' => $opt{order_by}. " ". $limit,
- )
- ];
+ $rows = $sth->fetchall_arrayref;
+ $header ||= $sth->{NAME};
+}
# run the count query to get number of rows and other totals
my $count_sth = dbh->prepare($count_query);
diff --git a/httemplate/search/sql.html b/httemplate/search/sql.html
index 71aa00671..54d6c2d79 100644
--- a/httemplate/search/sql.html
+++ b/httemplate/search/sql.html
@@ -2,7 +2,7 @@
'title' => 'Query Results',
'name' => 'rows',
'query' => "SELECT $sql",
-
+ 'count_query' => $count,
&>
<%init>
@@ -12,4 +12,7 @@ die "access denied"
my $sql = $cgi->param('sql') or errorpage('Empty query');
$sql =~ s/;+\s*$//; #remove trailing ;
+my $count = $sql;
+$count =~ s/.* FROM /SELECT COUNT(*) FROM /i;
+
</%init>