[freeside-commits] freeside/httemplate/search/elements search.html, 1.51, 1.52 search-html.html, 1.9, 1.10 cust_pay_or_refund.html, 1.12, 1.13
Ivan,,,
ivan at wavetail.420.am
Wed Nov 10 17:44:45 PST 2010
- Previous message: [freeside-commits] freeside/rt FREESIDE_MODIFIED,1.43,1.43.2.1
- Next message: [freeside-commits] freeside/httemplate/search cust_bill_event.cgi, 1.18, 1.19 cust_bill.html, 1.37, 1.38 cust_bill_pay.html, 1.2, 1.3 cust_bill_pkg.cgi, 1.37, 1.38 cust_bill_pkg_discount.html, 1.2, 1.3 cust_credit_bill.html, 1.1, 1.2 cust_credit.html, 1.16, 1.17 cust_credit_refund.html, 1.1, 1.2 cust_event.html, 1.8, 1.9 cust_pkg_svc.html, 1.1, 1.2 cust_svc.html, 1.9, 1.10 pay_batch.cgi, 1.5, 1.6 queue.html, 1.7, 1.8 svc_domain.cgi, 1.24, 1.25 svc_external.cgi, 1.7, 1.8 svc_forward.cgi, 1.13, 1.14 svc_phone.cgi, 1.9, 1.10 svc_www.cgi, 1.11, 1.12
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/cvsroot/freeside/httemplate/search/elements
In directory wavetail.420.am:/tmp/cvs-serv22886/httemplate/search/elements
Modified Files:
search.html search-html.html cust_pay_or_refund.html
Log Message:
sort by clicking on headers, RT#6465
Index: search.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/elements/search.html,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -w -d -r1.51 -r1.52
--- search.html 6 Jun 2010 03:01:47 -0000 1.51
+++ search.html 11 Nov 2010 01:44:43 -0000 1.52
@@ -132,7 +132,10 @@
# qsearch hashref and header & fields need to
# be defined)
- # link & display properties for fields
+ # sort, link & display properties for fields
+
+ 'sort_fields' => [], #optional list of field names or SQL expressions for
+ # sorts
#listref - each item is the empty string,
# or a listref of link and method name to append,
@@ -369,6 +372,13 @@
}
+#order by override
+my $order_by = '';
+#if ( $cgi->param('order_by') =~ /^([\w\, ]+)$/ ) {
+# $order_by = $1;
+#}
+$order_by = $cgi->param('order_by') if $cgi->param('order_by');
+
# run the query
my $header = [ map { ref($_) ? $_->{'label'} : $_ } @{$opt{header}} ];
@@ -378,6 +388,20 @@
my @query;
if (ref($opt{query}) eq 'HASH') {
@query = ( $opt{query} );
+
+ if ( $order_by ) {
+ if ( $opt{query}->{'order_by'} ) {
+ if ( $opt{query}->{'order_by'} =~ /^(\s*ORDER\s+BY\s+)?(\S.*)$/is ) {
+ $opt{query}->{'order_by'} = "ORDER BY $order_by, $2";
+ } else {
+ warn "unparsable query order_by: ". $opt{query}->{'order_by'};
+ die "unparsable query order_by: ". $opt{query}->{'order_by'};
+ }
+ } else {
+ $opt{query}->{'order_by'} = "ORDER BY $order_by";
+ }
+ }
+
} elsif (ref($opt{query}) eq 'ARRAY') {
@query = @{ $opt{query} };
} else {
Index: search-html.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/elements/search-html.html,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -w -d -r1.9 -r1.10
--- search-html.html 5 Jun 2010 05:56:07 -0000 1.9
+++ search-html.html 11 Nov 2010 01:44:43 -0000 1.10
@@ -190,11 +190,26 @@
<TR>
% my $h2 = 0;
% my $colspan = 0;
+% my @fields = @{ $opt{'sort_fields'} || $opt{'fields'}};
+% my $order_by = $cgi->param('order_by');
% foreach my $header ( @{ $opt{header} } ) {
+%
+% my $field = shift @fields;
+%
% $colspan-- if $colspan > 0;
% next if $colspan;
%
% my $label = ref($header) ? $header->{label} : $header;
+% unless ( ref($field) || !$field ) {
+% if ( $order_by eq $field ) {
+% $cgi->param('order_by', "$field DESC");
+% } else {
+% $cgi->param('order_by', $field);
+% }
+% $label = qq(<A HREF="$self_url?). $cgi->query_string.
+% qq(">$label</A>);
+% }
+%
% $colspan = ref($header) ? $header->{colspan} : 0;
% my $rowspan = 1;
% my $style = '';
Index: cust_pay_or_refund.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/elements/cust_pay_or_refund.html,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -w -d -r1.12 -r1.13
--- cust_pay_or_refund.html 22 Sep 2010 00:08:30 -0000 1.12
+++ cust_pay_or_refund.html 11 Nov 2010 01:44:43 -0000 1.13
@@ -48,6 +48,7 @@
'redirect_empty' => $opt{'redirect_empty'},
'header' => \@header,
'fields' => \@fields,
+ 'sort_fields' => \@sort_fields,
'align' => $align,
'links' => \@links,
'color' => \@color,
@@ -135,6 +136,7 @@
my @header = ();
my @fields = ();
+my @sort_fields = ();
my $align = '';
my @links = ();
if ( $opt{'pre_header'} ) {
@@ -142,6 +144,7 @@
$align .= 'c' x scalar(@{ $opt{'pre_header'} });
push @links, map '', @{ $opt{'pre_header'} };
push @fields, @{ $opt{'pre_fields'} };
+ push @sort_fields, @{ $opt{'pre_fields'} };
}
push @header, "\u$name_singular",
@@ -152,18 +155,21 @@
push @fields, 'payby_payinfo_pretty',
sub { sprintf('$%.2f', shift->$amount_field() ) },
;
+push @sort_fields, '', $amount_field;
if ( $unapplied ) {
push @header, 'Unapplied';
$align .= 'r';
push @links, '';
push @fields, sub { sprintf('$%.2f', shift->unapplied_amount) };
+ push @sort_fields, '';
}
push @header, 'Date';
$align .= 'r';
push @links, '';
push @fields, sub { time2str('%b %d %Y', shift->_date ) };
+push @sort_fields, '_date';
unless ( $opt{'disable_by'} ) {
push @header, 'By';
@@ -414,7 +420,8 @@
'table' => $table,
'select' => join(', ', @select),
'hashref' => {},
- 'extra_sql' => "$search $group_by ORDER BY $orderby",
+ 'extra_sql' => "$search $group_by",
+ 'order_by' => "ORDER BY $orderby",
'addl_from' => $addl_from,
};
- Previous message: [freeside-commits] freeside/rt FREESIDE_MODIFIED,1.43,1.43.2.1
- Next message: [freeside-commits] freeside/httemplate/search cust_bill_event.cgi, 1.18, 1.19 cust_bill.html, 1.37, 1.38 cust_bill_pay.html, 1.2, 1.3 cust_bill_pkg.cgi, 1.37, 1.38 cust_bill_pkg_discount.html, 1.2, 1.3 cust_credit_bill.html, 1.1, 1.2 cust_credit.html, 1.16, 1.17 cust_credit_refund.html, 1.1, 1.2 cust_event.html, 1.8, 1.9 cust_pkg_svc.html, 1.1, 1.2 cust_svc.html, 1.9, 1.10 pay_batch.cgi, 1.5, 1.6 queue.html, 1.7, 1.8 svc_domain.cgi, 1.24, 1.25 svc_external.cgi, 1.7, 1.8 svc_forward.cgi, 1.13, 1.14 svc_phone.cgi, 1.9, 1.10 svc_www.cgi, 1.11, 1.12
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the freeside-commits
mailing list