[freeside-commits] freeside/httemplate/search cdr.html, 1.5, 1.6 report_cdr.html, 1.5, 1.6
Ivan,,,
ivan at wavetail.420.am
Sat Sep 29 17:26:05 PDT 2007
Update of /home/cvs/cvsroot/freeside/httemplate/search
In directory wavetail:/tmp/cvs-serv25538
Modified Files:
cdr.html report_cdr.html
Log Message:
better CDR searching
Index: report_cdr.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/report_cdr.html,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- report_cdr.html 3 Feb 2007 11:36:30 -0000 1.5
+++ report_cdr.html 30 Sep 2007 00:26:03 -0000 1.6
@@ -1,11 +1,38 @@
<% include('/elements/header.html', 'Call Detail Record Search' ) %>
<FORM ACTION="cdr.html" METHOD="GET">
-Status: <SELECT NAME="freesidestatus">
- <OPTION VALUE="">(all)
- <OPTION VALUE="NULL">unprocessed
- <OPTION VALUE="done">processed
-</SELECT><BR>
+
+<TABLE>
+ <TR>
+ <TD ALIGN="right">Status: </TD>
+ <TD>
+ <SELECT NAME="freesidestatus">
+ <OPTION VALUE="">(all)
+ <OPTION VALUE="NULL">unprocessed
+ <OPTION VALUE="done">processed
+ </SELECT>
+ </TD>
+ </TR>
+
+ <% include ( '/elements/tr-input-beginning_ending.html' ) %>
+
+ <TR>
+ <TD ALIGN="right">Source #: </TD>
+ <TD>
+ <INPUT TYPE="text" NAME="src">
+ </TD>
+ </TR>
+
+ <TR>
+ <TD ALIGN="right">Destination #: </TD>
+ <TD>
+ <INPUT TYPE="text" NAME="dst">
+ </TD>
+ </TR>
+
+</TABLE>
+
+<BR>
<INPUT TYPE="submit" VALUE="Search Call Detail Records">
<% include('/elements/footer.html') %>
Index: cdr.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/cdr.html,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- cdr.html 3 Feb 2007 11:36:30 -0000 1.5
+++ cdr.html 30 Sep 2007 00:26:03 -0000 1.6
@@ -1,8 +1,10 @@
<% include( 'elements/search.html',
'title' => $title,
'name' => 'call detail records',
- 'query' => { 'table' => 'cdr',
- 'hashref' => $hashref
+ 'query' => { 'table' => 'cdr',
+ 'hashref' => $hashref,
+ 'extra_sql' => $qsearch,
+ 'order_by' => 'ORDER BY calldate',
},
'count_query' => $count_query,
'header' => [ fields('cdr') ], #XXX fill in some nice names
@@ -17,25 +19,71 @@
my $title = 'Call Detail Records';
my $hashref = {};
-my $count_query = 'SELECT COUNT(*) FROM cdr';
#process params for CDR search, populate $hashref...
# and fixup $count_query
+my @search = ();
+my @qsearch = ();
+
+###
+# freesidestatus
+###
+
if ( $cgi->param('freesidestatus') eq 'NULL' ) {
my $title = "Unprocessed $title";
$hashref->{'freesidestatus'} = ''; # Record.pm will take care of it
- #$count_query .= " AND ( freesidestatus IS NULL OR freesidestatus = '' )";
- $count_query .= " WHERE ( freesidestatus IS NULL OR freesidestatus = '' )";
+ push @search, "( freesidestatus IS NULL OR freesidestatus = '' )";
} elsif ( $cgi->param('freesidestatus') =~ /^([\w ]+)$/ ) {
my $title = "Processed $title";
$hashref->{'freesidestatus'} = $1;
- #$count_query .= " AND freesidestatus = '$1'";
- $count_query .= " WHERE freesidestatus = '$1'";
+ push @search, "freesidestatus = '$1'";
+
+}
+
+###
+# dates
+###
+
+my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi);
+push @search,
+my @dsearch = ( "extract(epoch from calldate) >= $beginning ",
+ "extract(epoch from calldate) <= $ending"
+ );
+push @search, @dsearch;
+push @qsearch, @search;
+
+
+###
+# src/dest
+###
+if ( $cgi->param('src') =~ /^\s*([\d\-\+\ ]+)\s*$/ ) {
+ ( my $src = $1 ) =~ s/\D//g;
+ $hashref->{'src'} = $src;
+ push @search, "src = '$src'";
}
+if ( $cgi->param('dst') =~ /^\s*([\d\-\+ ]+)\s*$/ ) {
+ ( my $dst = $1 ) =~ s/\D//g;
+ $hashref->{'dst'} = $dst;
+ push @search, "dst = '$dst'";
+}
+
+###
+# finish it up
+###
+
+my $search = join(' AND ', @search);
+$search = "WHERE $search" if $search;
+
+my $count_query = "SELECT COUNT(*) FROM cdr $search";
+
+my $qsearch = join(' AND ', @qsearch);
+$qsearch = ( scalar(keys %$hashref) ? ' AND ' : ' WHERE ' ) . $qsearch
+ if $qsearch;
+
</%init>
More information about the freeside-commits
mailing list