diff options
| author | ivan <ivan> | 2006-07-12 00:20:23 +0000 |
|---|---|---|
| committer | ivan <ivan> | 2006-07-12 00:20:23 +0000 |
| commit | 1053db7f76169cbbc87840539959a4c362aff242 (patch) | |
| tree | 1d1895ce43bb5910a8de5e3ead26b2e179ed268e /httemplate/search | |
| parent | a8665e44dbd99bd864e48231928405a31cedce5f (diff) | |
svc_phone service and CDR billing from imported CDRs
Diffstat (limited to 'httemplate/search')
| -rw-r--r-- | httemplate/search/cdr.html | 6 | ||||
| -rw-r--r-- | httemplate/search/report_cdr.html | 2 | ||||
| -rw-r--r-- | httemplate/search/svc_phone.cgi | 94 |
3 files changed, 99 insertions, 3 deletions
diff --git a/httemplate/search/cdr.html b/httemplate/search/cdr.html index ec847e41f..e3d6043e8 100644 --- a/httemplate/search/cdr.html +++ b/httemplate/search/cdr.html @@ -11,13 +11,15 @@ 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 .= " AND ( freesidestatus IS NULL OR freesidestatus = '' )"; + $count_query .= " WHERE ( freesidestatus IS NULL OR freesidestatus = '' )"; } elsif ( $cgi->param('freesidestatus') =~ /^([\w ]+)$/ ) { my $title = "Processed $title"; $hashref->{'freesidestatus'} = $1; - $count_query .= " AND freesidestatus = '$1'"; + #$count_query .= " AND freesidestatus = '$1'"; + $count_query .= " WHERE freesidestatus = '$1'"; } diff --git a/httemplate/search/report_cdr.html b/httemplate/search/report_cdr.html index 924e28bd7..6febe6c4a 100644 --- a/httemplate/search/report_cdr.html +++ b/httemplate/search/report_cdr.html @@ -4,7 +4,7 @@ Status: <SELECT NAME="freesidestatus"> <OPTION VALUE="">(all) <OPTION VALUE="NULL">unprocessed - <OPTION VALUE="done"">processed + <OPTION VALUE="done">processed </SELECT><BR> <INPUT TYPE="submit" VALUE="Search Call Detail Records"> diff --git a/httemplate/search/svc_phone.cgi b/httemplate/search/svc_phone.cgi new file mode 100644 index 000000000..a68a13e39 --- /dev/null +++ b/httemplate/search/svc_phone.cgi @@ -0,0 +1,94 @@ +<% + +my $conf = new FS::Conf; + +my($query)=$cgi->keywords; +$query ||= ''; #to avoid use of unitialized value errors + +my $orderby = 'ORDER BY svcnum'; +my %svc_phone = (); +my @extra_sql = (); +if ( $query eq 'svcnum' ) { + #$orderby = 'ORDER BY svcnum'; +} elsif ( $query eq 'phonenum' ) { + $orderby = 'ORDER BY phonenum'; +} elsif ( $cgi->param('svcpart') =~ /^(\d+)$/ ) { + #$orderby = 'ORDER BY svcnum'; + push @extra_sql, "svcpart = $1"; +} else { + $cgi->param('phonenum') =~ /^([\d\- ]+)$/; + ( $svc_phone{'phonenum'} = $1 ) =~ s/\D//g; +} + +my $addl_from = ' LEFT JOIN cust_svc USING ( svcnum ) '. + ' LEFT JOIN part_svc USING ( svcpart ) '. + ' LEFT JOIN cust_pkg USING ( pkgnum ) '. + ' LEFT JOIN cust_main USING ( custnum ) '; + +#here is the agent virtualization +push @extra_sql, $FS::CurrentUser::CurrentUser->agentnums_sql; + +my $extra_sql = ''; +if ( @extra_sql ) { + $extra_sql = ( keys(%svc_phone) ? ' AND ' : ' WHERE ' ). + join(' AND ', @extra_sql ); +} + +my $count_query = "SELECT COUNT(*) FROM svc_phone $addl_from "; +if ( keys %svc_phone ) { + $count_query .= ' WHERE '. + join(' AND ', map "$_ = ". dbh->quote($svc_phone{$_}), + keys %svc_phone + ); +} +$count_query .= $extra_sql; + +my $sql_query = { + 'table' => 'svc_phone', + 'hashref' => \%svc_phone, + 'select' => join(', ', + 'svc_phone.*', + 'part_svc.svc', + 'cust_main.custnum', + FS::UI::Web::cust_sql_fields(), + ), + 'extra_sql' => "$extra_sql $orderby", + 'addl_from' => $addl_from, +}; + +my $link = [ "${p}view/svc_phone.cgi?", 'svcnum' ]; + +#smaller false laziness w/svc_*.cgi here +my $link_cust = sub { + my $svc_x = shift; + $svc_x->custnum ? [ "${p}view/cust_main.cgi?", 'custnum' ] : ''; +}; + +%><%= include( 'elements/search.html', + 'title' => "Phone number search results", + 'name' => 'phone numbers', + 'query' => $sql_query, + 'count_query' => $count_query, + 'redirect' => $link, + 'header' => [ '#', + 'Service', + 'Country code', + 'Phone number', + FS::UI::Web::cust_header(), + ], + 'fields' => [ 'svcnum', + 'svc', + 'countrycode', + 'phonenum', + \&FS::UI::Web::cust_fields, + ], + 'links' => [ $link, + $link, + $link, + $link, + ( map { $link_cust } + FS::UI::Web::cust_header() + ), + ], + ) +%> |
