[freeside-commits] freeside/httemplate/search/elements metasearch.html, NONE, 1.1.2.1 search-xml.html, NONE, 1.1.2.1 search-html.html, 1.2.2.3, 1.2.2.4 search.html, 1.46.2.1, 1.46.2.2
Jeff Finucane,420,,
jeff at wavetail.420.am
Sat May 22 12:49:21 PDT 2010
- Previous message: [freeside-commits] freeside/httemplate/search 477partIA_detail.html, NONE, 1.1.2.1 477partIA_summary.html, NONE, 1.1.2.1 477partIIA.html, NONE, 1.1.2.1 477partIIB.html, NONE, 1.1.2.1 477partIV.html, NONE, 1.1.2.1 477partV.html, NONE, 1.1.2.1 477partVI.html, NONE, 1.1.2.1 477.html, 1.2.2.2, 1.2.2.3 report_477.html, 1.2, 1.2.2.1
- Next message: [freeside-commits] freeside/FS MANIFEST,1.143.2.12,1.143.2.13
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/cvsroot/freeside/httemplate/search/elements
In directory wavetail.420.am:/tmp/cvs-serv31798/httemplate/search/elements
Modified Files:
Tag: FREESIDE_1_9_BRANCH
search-html.html search.html
Added Files:
Tag: FREESIDE_1_9_BRANCH
metasearch.html search-xml.html
Log Message:
improved fcc 477 report #7783
Index: search.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/elements/search.html,v
retrieving revision 1.46.2.1
retrieving revision 1.46.2.2
diff -u -w -d -r1.46.2.1 -r1.46.2.2
--- search.html 1 Apr 2010 04:44:20 -0000 1.46.2.1
+++ search.html 22 May 2010 19:49:19 -0000 1.46.2.2
@@ -171,6 +171,10 @@
%
<% include('search-xls.html', header=>$header, rows=>$rows, opt=>\%opt ) %>
%
+% } elsif ( $type eq 'xml' ) {
+%
+<% include('search-xml.html', rows=>$rows, opt=>\%opt ) %>
+%
% } else { # regular HTML
%
<% include('search-html.html',
@@ -194,7 +198,7 @@
my $curuser = $FS::CurrentUser::CurrentUser;
-my $type = $cgi->param('_type') =~ /^(csv|\w*\.xls|select|html(-print)?)$/
+my $type = $cgi->param('_type') =~ /^(csv|\w*\.xls|xml|select|html(-print)?)$/
? $1 : 'html' ;
my %align = (
@@ -223,9 +227,13 @@
} while ( exists($h->[$i]) );
}
+# wtf?
$opt{disable_download} = 0
if $opt{disable_download} && $curuser->access_right('Configuration download');
+$opt{disable_download} = 1
+ if $opt{really_disable_download};
+
my @link_agentnums = ();
my $null_link = '';
if ( $opt{'agent_virt'} ) {
--- NEW FILE: metasearch.html ---
<%doc>
Example:
include( 'elements/metasearch.html',
###
# required
###
'title' => 'Page title',
#arrayref of hashrefs suited for passing to elements/search.html
#see that documentation
'search' => [
{
query => { 'table' => 'tablename',
#everything else is optional...
'hashref' => { 'f1' => 'value',
'f2' => { 'op' => '<',
'value' => '54',
},
},
'select' => '*',
'order_by' => 'ORDER BY something',
},
count_query => 'SELECT COUNT(*) FROM tablename',
},
{
query => 'table' => 'anothertablename',
count_query => 'SELECT COUNT(*) FROM anothertablename',
},
],
###
# optional
###
# some HTML callbacks...
'menubar' => '', #menubar arrayref
'html_init' => '', #after the header/menubar and before the pager
'html_form' => '', #after the pager, right before the results
# (only shown if there are results)
# (use this for any form-opening tag rather than
# html_init, to avoid a nested form)
'html_foot' => '', #at the bottom
'html_posttotal' => '', #at the bottom
# (these three can be strings or coderefs)
);
</%doc>
% foreach my $search ( @{$opt{search}} ) {
<% include('search.html',
%$search,
'type' => $type,
'nohtmlheader' => 1,
)
%>
%
% }
<%init>
my(%opt) = @_;
#warn join(' / ', map { "$_ => $opt{$_}" } keys %opt ). "\n";
my $type = $cgi->param('_type') =~ /^(csv|\w*\.xls|select|html(-print)?)$/
? $1 : 'html' ;
</%init>
--- NEW FILE: search-xml.html ---
% foreach my $row ( @$rows ) {
%
% if (&{$beginrow}($row)){
<% &{$beginrow}($row) %>
% }
%
% foreach my $i ( 0 .. scalar( @{$opt{'fields'}} ) - 1 ) {
% my $field = $opt{'fields'}->[$i];
% my $value = '';
% if ( ref($field) eq 'CODE' ) {
% $value = &{$field}($row);
% $value = '(N/A)' #unimplemented
% if ref($value) eq 'ARRAY';
% } else {
% $value = $row->$field();
% }
%
<% &{$beginfield}($row, $i) %><% $value |h %><% &{$endfield}($row, $i) %>
%
% }
%
% if (&{$endrow}($row)) {
<% &{$endrow}($row) %>
% }
%
% }
<%init>
my %args = @_;
my $header = $args{'header'};
my $rows = $args{'rows'};
my %opt = %{ $args{'opt'} };
http_header('Content-Type' => 'application/XML' ); # So saith RFC 4180
http_header('Content-Disposition' =>
'attachment;filename="'.($opt{'name'} || PL($opt{'name_singular'}) ).'.xml"');
unless ( $opt{'fields'} ) {
foreach my $i ( 0 .. ( $#{ @$rows[0] } ) ) {
$opt{'fields'}->[$i] = sub { my $row = shift; $row->[$i]; };
}
}
my $beginrow = sub { return ''; };
my $endrow = sub { return ''; };
if ($opt{xml_row_element}) {
$beginrow = sub { my ($row, $index) = @_;
my $value;
if ( ref($opt{xml_row_element}) eq 'CODE' ) {
$value = &{$opt{xml_row_element}}($row);
} else {
$value = $opt{xml_row_element};
}
return "<$value>";
};
$endrow = sub { my ($row, $index) = @_;
my $value;
if ( ref($opt{xml_row_element}) eq 'CODE' ) {
$value = &{$opt{xml_row_element}}($row);
} else {
$value = $opt{xml_row_element};
}
return "</$value>";
};
}
my $beginfield = sub { my ($row, $index) = @_;
my $value;
if ( ref($opt{xml_elements}->[$index]) eq 'CODE' ) {
$value = &{$opt{xml_elements}->[$index]}($row);
} else {
$value = $opt{xml_elements}->[$index];
}
return "<$value>";
};
my $endfield = sub { my ($row, $index) = @_;
my $value;
if ( ref($opt{xml_elements}->[$index]) eq 'CODE' ) {
$value = &{$opt{xml_elements}->[$index]}($row);
} else {
$value = $opt{xml_elements}->[$index];
}
return "</$value>";
};
$beginfield = sub { return ''; } if $opt{no_field_elements}; #hmm
$endfield = sub { return ''; } if $opt{no_field_elements}; #hmm
</%init>
Index: search-html.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/elements/search-html.html,v
retrieving revision 1.2.2.3
retrieving revision 1.2.2.4
diff -u -w -d -r1.2.2.3 -r1.2.2.4
--- search-html.html 1 Apr 2010 04:44:19 -0000 1.2.2.3
+++ search-html.html 22 May 2010 19:49:19 -0000 1.2.2.4
@@ -32,11 +32,17 @@
%
% if ( $type eq 'html-print' ) {
- <% include( '/elements/header-popup.html', $opt{'title'} ) %>
+ <% $opt{nohtmlheader}
+ ? ''
+ : include( '/elements/header-popup.html', $opt{'title'} )
+ %>
% } elsif ( $type eq 'select' ) {
- <% include( '/elements/header-popup.html', $opt{'title'} ) %>
+ <% $opt{nohtmlheader}
+ ? ''
+ : include( '/elements/header-popup.html', $opt{'title'} )
+ %>
<% defined($opt{'html_init'})
? ( ref($opt{'html_init'})
? &{$opt{'html_init'}}()
@@ -54,7 +60,9 @@
% # @menubar = ( 'Main menu' => $p );
% }
- <% include( '/elements/header.html', $opt{'title'},
+ <% $opt{nohtmlheader}
+ ? ''
+ : include( '/elements/header.html', $opt{'title'},
include( '/elements/menubar.html', @menubar )
)
%>
@@ -95,7 +103,7 @@
% $cgi->delete('maxrecords');
% $cgi->param('_dummy', 1);
- ( show <SELECT NAME="maxrecords" onChange="window.location = '<% $cgi->self_url %>;maxrecords=' + this.options[this.selectedIndex].value;">
+ ( show <SELECT NAME="maxrecords" onChange="window.location = '<% $self_url %>;maxrecords=' + this.options[this.selectedIndex].value;">
% foreach my $max ( map { $_ * $confmax } qw( 1 5 10 25 ) ) {
<OPTION VALUE="<% $max %>" <% ( $maxrecords == $max ) ? 'SELECTED' : '' %>><% $max %></OPTION>
@@ -136,13 +144,18 @@
Download full results<BR>
% $cgi->param('_type', "$xlsname.xls" );
- as <A HREF="<% $cgi->self_url %>">Excel spreadsheet</A><BR>
+ as <A HREF="<% $self_url %>">Excel spreadsheet</A><BR>
% $cgi->param('_type', 'csv');
- as <A HREF="<% $cgi->self_url %>">CSV file</A><BR>
+ as <A HREF="<% $self_url %>">CSV file</A><BR>
+
+% if ( defined($opt{xml_elements}) ) {
+% $cgi->param('_type', 'xml');
+ as <A HREF="<% $self_url %>">XML file</A><BR>
+% }
% $cgi->param('_type', 'html-print');
- as <A HREF="<% $cgi->self_url %>">printable copy</A>
+ as <A HREF="<% $self_url %>">printable copy</A>
</TD>
% $cgi->param('_type', "html" );
@@ -416,9 +429,11 @@
% }
% if ( $type eq 'html-print' ) {
+% unless ( $opt{nohtmlheader} ) {
</BODY></HTML>
+% }
% } else {
<% defined($opt{'html_foot'})
@@ -429,7 +444,10 @@
: ''
%>
- <% include( '/elements/footer.html' ) %>
+ <% $opt{nohtmlheader}
+ ? ''
+ : include( '/elements/footer.html' )
+ %>
% }
@@ -446,6 +464,7 @@
my $maxrecords = $args{'maxrecords'};
my $offset = $args{'offset'};
my %opt = %{ $args{'opt'} };
+my $self_url = $opt{'url'} || $cgi->self_url;
my $count_sth = dbh->prepare($opt{'count_query'})
or die "Error preparing $opt{'count_query'}: ". dbh->errstr;
- Previous message: [freeside-commits] freeside/httemplate/search 477partIA_detail.html, NONE, 1.1.2.1 477partIA_summary.html, NONE, 1.1.2.1 477partIIA.html, NONE, 1.1.2.1 477partIIB.html, NONE, 1.1.2.1 477partIV.html, NONE, 1.1.2.1 477partV.html, NONE, 1.1.2.1 477partVI.html, NONE, 1.1.2.1 477.html, 1.2.2.2, 1.2.2.3 report_477.html, 1.2, 1.2.2.1
- Next message: [freeside-commits] freeside/FS MANIFEST,1.143.2.12,1.143.2.13
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the freeside-commits
mailing list