[Astpp-commit] SF.net SVN: astpp: [2128] trunk/astpp-admin.cgi
Brought to you by:
darrenkw
|
From: <dar...@us...> - 2007-09-19 01:57:08
|
Revision: 2128
http://astpp.svn.sourceforge.net/astpp/?rev=2128&view=rev
Author: darrenkw
Date: 2007-09-18 18:57:11 -0700 (Tue, 18 Sep 2007)
Log Message:
-----------
Added reporting functionality from Sonia Khan. Bug number 167. Thanks Sonia
Modified Paths:
--------------
trunk/astpp-admin.cgi
Modified: trunk/astpp-admin.cgi
===================================================================
--- trunk/astpp-admin.cgi 2007-09-19 01:37:31 UTC (rev 2127)
+++ trunk/astpp-admin.cgi 2007-09-19 01:57:11 UTC (rev 2128)
@@ -100,17 +100,30 @@
gettext("Create Booth"), gettext("Remove Booth"),
gettext("List Booths"), gettext("View Booth")
);
+
+# Report added by Sonia Ali Khan <son...@gm...>
+my @AdminReports = ( gettext("Reseller Report"), gettext("Vendor Report") );
+my @CallShopReports = ( gettext("Booth Report") );
+my @ResellerReports = (
+ gettext("Brand Report"), gettext("CallShop Report"),
+ gettext("Reseller Report"), gettext("User Report")
+);
+
+
my %menumap = (
- gettext('Accounts') => \@Accounts,
- gettext('Rates') => \@Rates,
- gettext('DIDs') => \@DIDs,
- gettext('Statistics') => \@Statistics,
- gettext('System') => \@System,
- gettext('LCR') => \@LCR,
- gettext('Calling Cards') => \@Callingcards,
- gettext('Switch Config') => \@SwitchConfig,
- gettext('Booths') => \@Booths,
- gettext('Call Shops') => \@CallShops
+ gettext('Accounts') => \@Accounts,
+ gettext('Rates') => \@Rates,
+ gettext('DIDs') => \@DIDs,
+ gettext('Statistics') => \@Statistics,
+ gettext('System') => \@System,
+ gettext('LCR') => \@LCR,
+ gettext('Calling Cards') => \@Callingcards,
+ gettext('Switch Config') => \@SwitchConfig,
+ gettext('Booths') => \@Booths,
+ gettext('Call Shops') => \@CallShops,
+ gettext('Admin Reports') => \@AdminReports,
+ gettext('CallShop Reports') => \@CallShopReports,
+ gettext('Reseller Reports') => \@ResellerReports
);
my @months = (
'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
@@ -399,6 +412,11 @@
return &build_remove_callshop()
if $params->{mode} eq gettext("Remove CallShop");
+ return &build_admin_reseller_report()
+ if $params->{mode} eq gettext("Reseller Report");
+ return &build_admin_vendor_report()
+ if $params->{mode} eq gettext("Vendor Report");
+
# return &build_add_booth() if $params->{mode} eq gettext("Create Booth");
# return &build_remove_booth() if $params->{mode} eq gettext("Remove Booth");
# return &build_list_booths() if $params->{mode} eq gettext("List Booths");
@@ -503,6 +521,15 @@
if $params->{mode} eq gettext("Create CallShop");
return &build_remove_callshop()
if $params->{mode} eq gettext("Remove CallShop");
+ return &build_reseller_brand_report()
+ if $params->{mode} eq gettext("Brand Report");
+ return &build_reseller_callshop_report()
+ if $params->{mode} eq gettext("CallShop Report");
+ return &build_reseller_reseller_report()
+ if $params->{mode} eq gettext("Reseller Report");
+ return &build_reseller_user_report()
+ if $params->{mode} eq gettext("User Report");
+
return &build_homepage()
if $params->{mode} eq gettext("Home Page")
|| $params->{mode} eq gettext("Home")
@@ -539,6 +566,8 @@
if $params->{mode} eq gettext("Delete Card");
return &build_refill_card()
if $params->{mode} eq gettext("Refill Card");
+ return &build_callshop_callshop_report()
+ if $params->{mode} eq gettext("Booth Report");
return &build_list_booths()
if $params->{mode} eq gettext("Home Page")
@@ -648,7 +677,11 @@
######## Reporting Module ################
#
-sub build_reporting() {
+# Modified and Extended By Sonia Ali Khan <son...@gm...>
+# Last updated: Sept. 11, 2007 at 1445hours GMT.
+
+sub build_filter($$) {
+ my ($additional_fields, $submit_title) = @_;
my ($body);
return gettext("ASTPP Database Not Available!") . "<br>" unless $astpp_db;
$cdr_db = &cdr_connect_db( $config, @output );
@@ -679,7 +712,7 @@
$end_second = "59";
}
else {
- $start_year = $params->{star_year};
+ $start_year = $params->{start_year};
$start_month = sprintf( "%02d", $params->{start_month} + 1 );
$start_day = sprintf( "%02d", $params->{start_day} );
$start_hour = sprintf( "%02d", $params->{start_hour} );
@@ -692,101 +725,383 @@
$end_minute = sprintf( "%02d", $params->{end_minute} );
$end_second = sprintf( "%02d", $params->{end_second} );
}
-}
-#################### Stats stuff ###########################
-sub build_stats_acd() {
- my ( $body, $id );
- return gettext("Cannot display stats until database is configured")
- unless $astpp_db;
- $cdr_db = &cdr_connect_db( $config, @output );
- return gettext("Cannot display stats until database is configured")
- unless $cdr_db;
- my ( undef, undef, undef, $day, $mnth, $yr ) = localtime();
- my (
- $sd_yr, $sd_mnth, $sd_day, $st_hr, $st_min, $st_sec,
- $ed_yr, $ed_mnth, $ed_day, $et_hr, $et_min, $et_sec
- );
- my $count = 0;
- if ( param('sd_mnth') eq "" ) {
- $sd_yr = $yr + 1900;
- $sd_mnth = sprintf( "%02d", $mnth + 1 );
- $sd_day = "01";
- $st_hr = "00";
- $st_min = "00";
- $st_sec = "00";
- $ed_yr = $yr + 1900;
- $ed_mnth = sprintf( "%02d", $mnth + 1 );
- $ed_day = $day;
- $et_hr = "23";
- $et_min = "59";
- $et_sec = "59";
- }
- else {
- $sd_yr = param('sd_yr');
- $sd_mnth = sprintf( "%02d", param('sd_mnth') + 1 );
- $sd_day = sprintf( "%02d", param('sd_day') );
- $st_hr = sprintf( "%02d", param('st_hr') );
- $st_min = sprintf( "%02d", param('st_min') );
- $st_sec = sprintf( "%02d", param('st_sec') );
- $ed_yr = param('ed_yr');
- $ed_mnth = sprintf( "%02d", param('ed_mnth') + 1 );
- $ed_day = sprintf( "%02d", param('ed_day') );
- $et_hr = sprintf( "%02d", param('et_hr') );
- $et_min = sprintf( "%02d", param('et_min') );
- $et_sec = sprintf( "%02d", param('et_sec') );
- }
- $body .=
- "<form method=get><input type=hidden name=mode value=\""
- . param('mode')
- . "\"><table class=\"default\" width=100%>";
- $body .=
- "<tr><td width=50%>"
- . gettext("Start date:")
- . "</td><td><input type=text name=sd_yr value=\"$sd_yr\" size=5><select name=sd_mnth>";
+ $body .= "<form method=get><input type=hidden name=mode value=\"". param('mode')
+ . "\"><table class=\"default\" width=100%>";
+ $body .= "<tr><td width=50%>". gettext("Start date:")
+ . "</td><td><input type=text name=start_year value=\"$start_year\" size=5><select name=start_month>";
+
for ( $id = 0 ; $id < 12 ; $id++ ) {
- if ( $id == ( $sd_mnth - 1 ) ) {
+ if ( $id == ( $start_month - 1 ) ) {
$body .= "<option value=$id selected>$months[$id]";
}
else {
$body .= "<option value=$id>$months[$id]";
}
}
- $body .=
- "</select><input type=text name=sd_day value=\"$sd_day\" size=3></td></tr>
-
-";
- $body .= "<tr><td>"
- . gettext("Start time:")
- . "</td><td><input type=text name=st_hr value=\"$st_hr\" size=3><input type=text name=st_min value=\"$st_min\" size=3><input type=text name=st_sec value=\"$st_sec\" size=3></td></tr>
-";
- $body .= "<tr><td>"
- . gettext("End date:")
- . "</td><td><input type=text name=ed_yr value=\"$ed_yr\" size=5><select name=ed_mnth>";
+ $body .= "</select><input type=text name=start_day value=\"$start_day\" size=3></td></tr>";
+ $body .= "<tr><td>". gettext("Start time:")
+ . "</td><td><input type=text name=start_hour value=\"$start_hour\" size=3>"
+ . "<input type=text name=start_minute value=\"$start_minute\" size=3>"
+ . "<input type=text name=start_second value=\"$start_second\" size=3></td></tr>";
+ $body .= "<tr><td>". gettext("End date:")
+ . "</td><td><input type=text name=end_year value=\"$end_year\" size=5><select name=end_month>";
for ( $id = 0 ; $id < 12 ; $id++ ) {
- if ( $id == ( $ed_mnth - 1 ) ) {
+ if ( $id == ( $end_month - 1 ) ) {
$body .= "<option value=$id selected>$months[$id]";
}
else {
$body .= "<option value=$id>$months[$id]";
}
}
- $body .=
- "</select><input type=text name=ed_day value=\"$ed_day\" size=3></td></tr>
-";
- $body .= "<tr><td>"
- . gettext("End time:")
- . "</td><td><input type=text name=et_hr value=\"$et_hr\" size=3><input type=text name=et_min value=\"$et_min\" size=3><input type=text name=et_sec value=\"$et_sec\" size=3></td></tr>
-";
- $body .=
-"<tr><td align=center colspan=2><input type=submit value=Filter!></td></tr>
-";
- $body .= "</table>
-</form>";
- my $sd = "$sd_yr-$sd_mnth-$sd_day $st_hr:$st_min:$st_sec";
- my $ed = "$ed_yr-$ed_mnth-$ed_day $et_hr:$et_min:$et_sec";
- my $sth;
+ $submit_title = "Filter!" if !$submit_title;
+ $body .= "</select><input type=text name=end_day value=\"$end_day\" size=3></td></tr>";
+ $body .= "<tr><td>". gettext("End time:")
+ . "</td><td><input type=text name=end_hour value=\"$end_hour\" size=3>"
+ . "<input type=text name=end_minute value=\"$end_minute\" size=3>"
+ . "<input type=text name=end_second value=\"$end_second\" size=3></td></tr>\n";
+ $body .= $additional_fields if $additional_fields;
+ $body .= "<tr><td align=center colspan=2><input type=submit value=$submit_title></td></tr>";
+ $body .= "</table>\n</form>";
+
+ my %report_filter = (
+ 'start_year' => $start_year,
+ 'start_month' => $start_month,
+ 'start_day' => $start_day,
+ 'start_hour' => $start_hour,
+ 'start_minute'=> $start_minute,
+ 'start_second'=> $start_second,
+ 'end_year' => $end_year,
+ 'end_month' => $end_month,
+ 'end_day' => $end_day,
+ 'end_hour' => $end_hour,
+ 'end_minute' => $end_minute,
+ 'end_second' => $end_second,
+ 'start_date' => "$start_year-$start_month-$start_day $start_hour:$start_minute:$start_second",
+ 'end_date' => "$end_year-$end_month-$end_day $end_hour:$end_minute:$end_second",
+ 'form_body' => $body
+ );
+ return \%report_filter;
+}
+
+sub build_admin_reseller_report() {
+ return &build_report("Reseller","1");
+}
+
+sub build_admin_vendor_report() {
+ return &build_report("Vendor","3");
+}
+
+sub build_callshop_callshop_report() {
+ return &build_report("Booth","6");
+}
+
+sub build_reseller_reseller_report() {
+ return &build_report("Reseller","1");
+}
+
+sub build_reseller_user_report() {
+ return &build_report("User","1,6");
+}
+
+sub build_list_box($$) {
+ my ($in, $selected) = @_;
+ my $body = "";
+ undef %list;
+ @list{@$in} = ();
+ my @out = sort keys %list; # remove sort if undesired
+ for(my $i=0; $i < @out; $i++) {
+ if($out[$i] eq $selected) {
+ $body .= "<option value='$out[$i]' selected>$out[$i]</option>\n";
+ } else {
+ $body .= "<option value='$out[$i]'>$out[$i]</option>\n";
+ }
+ }
+ return $body;
+}
+
+sub build_report($$) {
+
+ return gettext("Cannot display reports until database is configured")
+ unless $astpp_db;
+ $cdr_db = &cdr_connect_db( $config, $enh_config, @output );
+ return gettext("Cannot display reports until database is configured")
+ unless $cdr_db;
+
+ my $name = shift;
+ my $type = shift;
+ my ($sth,$body);
+
+ my $destination = $params->{destination};
+ my $pattern = $params->{pattern};
+
+ if ($params->{logintype} == 1 || $params->{logintype} == 5) {
+ $sth =
+ $astpp_db->prepare( "SELECT * FROM accounts WHERE reseller = "
+ . $astpp_db->quote( $params->{username} )
+ . " AND type IN ($type)");
+ }
+ else {
+ $sth = $astpp_db->prepare("SELECT * FROM accounts WHERE type IN ($type)");
+ }
+
+ $sth->execute() || return gettext("Something is wrong with astpp database"). "\n";
+
+ $body = "<tr><td align=right> $name:"
+ . "<select name=$name value='$params->{$name}'>\n<option value='ALL'>ALL</option>\n";
+
+ while (my $row = $sth->fetchrow_hashref) {
+ if($row->{'number'} eq $params->{$name}) {
+ $body .= "<option value='$row->{'number'}' selected>$row->{'number'}</option>\n";
+ } else {
+ $body .= "<option value='$row->{'number'}'>$row->{'number'}</option>\n";
+ }
+ }
+
+ $sth->finish;
+
+ $body .= "</select> <strong>AND</strong> ";
+
+ if ($params->{logintype} == 1 || $params->{logintype} == 5) {
+ $sth =
+ $astpp_db->prepare("SELECT DISTINCT notes FROM cdrs WHERE notes LIKE "
+ . $astpp_db->quote($params->{username}."|%"));
+ }
+ else {
+ $sth = $astpp_db->prepare("SELECT DISTINCT notes FROM cdrs");
+ }
+
+ $sth->execute() || return gettext("Something is wrong with astpp database"). "\n";
+
+ my ($dest,$ptrn);
+ my (@dst,@ptn,$i);
+ $dest = "Destination: </td><td align=left><select name=destination value='Destination'>\n"
+ . "<option value='ALL'>ALL</option>\n";
+ $ptrn = " <strong>OR</strong> "
+ . "IDD Code: <select name=pattern value='IDD Code'>\n"
+ . "<option value='ALL'>ALL</option>\n";
+
+ while (my $notes = $sth->fetchrow_hashref) {
+ my @note = split(m/(\^|DID:)/,$notes->{'notes'},2);
+ $ptn[$i] = $note[1].$note[2];
+ @note = split(/\|/,$note[0]);
+ $dst[$i] = (@note == 1) ? $note[0] : $note[1] if $note[0] ne "";
+ $i++;
+ }
+ $sth->finish;
+
+ $dest .= build_list_box(\@dst,$destination);
+ $dest .= "</select>\n";
+
+ $ptrn .= build_list_box(\@ptn,$pattern);
+ $ptrn .= "</select>\n";
+
+ $body .= $dest . $ptrn . "</td></tr>";
+
+ my $filter = build_filter($body,undef);
+ my $sd = $filter->{'start_date'};
+ my $ed = $filter->{'end_date'};
+ $body = $filter->{'form_body'};
+
+ my $where = "callstart BETWEEN ".$astpp_db->quote($sd)
+ ." AND ".$astpp_db->quote($ed)." ";
+
+ if($params->{$name} eq 'ALL') {
+ if ($params->{logintype} == 1 || $params->{logintype} == 5) {
+ $where .= "AND cardnum IN (SELECT `number` FROM accounts WHERE reseller = "
+ .$astpp_db->quote($params->{username})." AND type IN ($type)) ";
+ } else {
+ if(index($type,"1") != -1) {
+ $where .= "AND cardnum IN (SELECT `number` FROM accounts WHERE type IN ($type)) ";
+ } elsif(index($type,"3") != -1) {
+ $where .= "AND provider = ".$astpp_db->quote($params->{$name});
+ }
+ }
+ } else {
+ if ($params->{logintype} == 1 || $params->{logintype} == 5) {
+ $where .= "AND cardnum = ".$astpp_db->quote($params->{$name})." ";
+ } else {
+ if(index($type,"1") != -1) {
+ $where .= "AND cardnum IN (SELECT `number` FROM accounts WHERE `number` = "
+ .$astpp_db->quote($params->{$name})." AND type IN ($type)) ";
+ } elsif(index($type,"3") != -1) {
+ $where .= "AND provider = ".$astpp_db->quote($params->{$name});
+ }
+ }
+ }
+
+ if($destination eq 'ALL') {
+ if($pattern eq 'ALL') {
+ $where .= "";
+ } else {
+ $where .= "AND notes LIKE ".$astpp_db->quote("%|".$pattern)." ";
+ }
+ } else {
+ if($pattern eq 'ALL') {
+ $where .= "AND notes LIKE ".$astpp_db->quote("%|".$destination."|%")." ";
+ } else {
+ $where .= "AND (notes LIKE ".$astpp_db->quote("%|".$destination."|%")." ";
+ $where .= "OR notes LIKE ".$astpp_db->quote("%|".$pattern).") ";
+ }
+ }
+
+ $where = 0 if $param->{$name} eq "" && $destination eq "" && $pattern eq "";
+
+ $body .= start_form()
+ . "<table class=\"default\" width=100%><tr><td colspan=12 align=center><b>$sd - $ed</b></td></tr>"
+ . "<tr class=\"header\"><td>"
+ . gettext("$name")
+ . "</td><td>"
+ . gettext("Destination")
+ . "</td><td>"
+ . gettext("IDD Code")
+ . "</td><td>"
+ . gettext("Attempted Calls")
+ . "</td><td>"
+ . gettext("Completed Calls")
+ . "</td><td>"
+ . "<acronym title=\""
+ . gettext("Answer Seizure Rate") . "\">"
+ . gettext("ASR")
+ . "</acronym>"
+ . "</td><td>"
+ . "<acronym title=\""
+ . gettext("Average Call Duration") . "\">"
+ . gettext("ACD")
+ . "</acronym>"
+ . "</td><td>"
+ . "<acronym title=\""
+ . gettext("Maximum Call Duration") . "\">"
+ . gettext("MCD")
+ . "</acronym>"
+ . "</td><td>"
+ . gettext("Actual")
+ . "</td><td>"
+ . gettext("Billable")
+ . "</td><td>"
+ . gettext("Price")
+ . "</td><td>"
+ . gettext("Cost")
+ . "</td></tr>\n";
+
+ my $table = "tmp_".time();
+ my ($bth,$dst,$idd,$atmpt,$cmplt,$asr,$acd,$mcd,$act,$bill,$price,$cost);
+ my $query = "CREATE TEMPORARY TABLE $table SELECT * FROM cdrs WHERE uniqueid != '' AND $where";
+ $sth = $astpp_db->do($query) || return gettext("Something is wrong with astpp database"). "\n";
+ print STDERR " SQL: $query \n " if $config->{debug} == 1;
+
+ my $sql = $astpp_db->prepare("SELECT DISTINCT cardnum AS $name FROM $table");
+ $sql->execute() || return gettext("Something is wrong with astpp database"). "\n";
+
+ while(my $row = $sql->fetchrow_hashref) {
+ $bth = $row->{$name};
+ my $sql1 = $astpp_db->prepare("SELECT notes, COUNT(*) AS attempts, AVG(billseconds) AS acd,
+ MAX(billseconds) AS mcd, SUM(billseconds) AS billable,
+ SUM(debit) AS cost, SUM(cost) AS price FROM $table
+ WHERE (notes IS NOT NULL AND notes != '') AND cardnum = "
+ .$astpp_db->quote($bth)." GROUP BY notes");
+ $sql1->execute() || return gettext("Something is wrong with astpp database"). "\n";
+
+ while(my $row1 = $sql1->fetchrow_hashref()) {
+ my @note1 = split(m/(\^|DID:)/,$row1->{notes},2);
+ $idd = $note1[1].$note1[2];
+ @note1 = split(/\|/,$note1[0]);
+ $dst = (@note1 == 1) ? $note1[0] : $note1[1];
+ $dst = 'N/A' if $dst eq "";
+
+ $atmpt = $row1->{'attempts'};
+ $acd = $row1->{'acd'};
+ $mcd = $row1->{'mcd'};
+ $bill = $row1->{'billable'};
+ $price = $row1->{'price'};
+ $cost = $row1->{'cost'};
+
+ $notes = "notes = ".$astpp_db->quote($row1->{notes});
+
+ my $sql2 = $astpp_db->prepare("SELECT COUNT(*) AS completed FROM $table
+ WHERE $notes AND disposition = 'ANSWERED'");
+ $sql2->execute() || return gettext("Something is wrong with astpp database"). "\n";
+ my $row2 = $sql2->fetchrow_hashref();
+ $cmplt = $row2->{'completed'} || 0;
+ $sql2->finish;
+
+ $asr = (($atmpt - $cmplt)/$atmpt) * 100;
+
+ my $in = "";
+ my $sql3 = $astpp_db->prepare("SELECT uniqueid FROM $table WHERE $notes ");
+ $sql3->execute() || return gettext("Something is wrong with astpp database"). "\n";
+
+ while(my $row3 = $sql3->fetchrow_hashref) {
+ $in .= "'".$row3->{'uniqueid'}."'," if $row3->{'uniqueid'};
+ }
+
+ $in = substr($in,0,-1) if length($in) > 0;
+ $sql3->finish;
+
+ print STDERR " SQL: SELECT SUM(duration) AS actual FROM cdr WHERE uniqueid IN ($in) \n " if $config->{debug} == 1;
+ my $sql4 = $cdr_db->prepare("SELECT SUM(duration) AS actual FROM cdr WHERE uniqueid IN ($in)");
+ $sql4->execute() || return gettext("Something is wrong with cdr database"). "\n";
+ my $row4 = $sql4->fetchrow_hashref();
+ $act = $row4->{'actual'};
+ $sql4->finish;
+
+ $body .= "<tr>"
+ . "<td>$bth</td><td>$dst</td><td>$idd</td><td>$atmpt</td><td>$cmplt</td><td>$asr</td>"
+ . "<td>$acd</td><td>$mcd</td><td>$act</td><td>$bill</td><td>$price</td><td>$cost</td>"
+ . "</tr>";
+ }
+ $sql1->finish;
+ }
+ $sql->finish;
+
+ $sth = $astpp_db->do("DROP TEMPORARY TABLE $table")
+ || return gettext("Something is wrong with astpp database"). "\n";
+
+ $body .= "</table>";
+ return $body;
+}
+
+sub build_admin_report() {
+ my ($body);
+ return gettext("Cannot display reports until database is configured")
+ unless $astpp_db;
+ $cdr_db = &cdr_connect_db( $config, $enh_config, @output );
+ return gettext("Cannot display reports until database is configured")
+ unless $cdr_db;
+
+ return gettext("Comming Soon!");
+}
+
+sub build_reseller_report() {
+ my ($body);
+ return gettext("Cannot display reports until database is configured")
+ unless $astpp_db;
+ $cdr_db = &cdr_connect_db( $config, $enh_config, @output );
+ return gettext("Cannot display reports until database is configured")
+ unless $cdr_db;
+
+ return gettext("Comming Soon!");
+}
+
+# End of code changes by Sonia Ali Khan.
+
+#################### Stats stuff ###########################
+sub build_stats_acd() {
+ my ( $body, $id );
+ return gettext("Cannot display stats until database is configured")
+ unless $astpp_db;
+ $cdr_db = &cdr_connect_db( $config, $enh_config, @output );
+ return gettext("Cannot display stats until database is configured")
+ unless $cdr_db;
+
+ my $filter = build_filter(undef,undef);
+ my $sd = $filter->{'start_date'};
+ my $ed = $filter->{'end_date'};
+ $body = $filter->{'form_body'};
+
+ my $sth;
+
if ( $params->{logintype} == 3 ) {
$sth =
$astpp_db->prepare( "SELECT * FROM trunks WHERE provider = "
@@ -799,8 +1114,7 @@
|| return gettext("Something is wrong with the trunks database") . "\n";
$body .=
start_form()
- . "<table class=\"default\" width=100%><tr><td colspan=5 align=center><b>$sd - $ed</b></td></tr>
-"
+ . "<table class=\"default\" width=100%><tr><td colspan=5 align=center><b>$sd - $ed</b></td></tr>"
. "<tr class=\"header\"><td>"
. gettext("Trunk Name")
. "</td><td>"
@@ -819,8 +1133,7 @@
. gettext("Success")
. "</td><td>"
. gettext("Congestion")
- . "</td></tr>
-\n";
+ . "</td></tr>\n";
while ( my $row = $sth->fetchrow_hashref ) {
$count++;
@@ -901,12 +1214,10 @@
. " %</td><td>"
. "$ref3->{ct} "
. sprintf( "%.04f", $congestion_rate )
- . "%</td></tr>
-\n";
+ . "%</td></tr>\n";
}
$sth->finish;
- $body .= "</table>
-";
+ $body .= "</table>";
return $body;
}
@@ -942,85 +1253,8 @@
push( @trunklist, "" );
}
@trunklist = sort @trunklist;
- my (
- $sd_yr, $sd_mnth, $sd_day, $st_hr, $st_min, $st_sec,
- $ed_yr, $ed_mnth, $ed_day, $et_hr, $et_min, $et_sec
- );
- my $count = 0;
-
- if ( $params->{sd_mnth} eq "" ) {
- $sd_yr = $yr + 1900;
- $sd_mnth = sprintf( "%02d", $mnth + 1 );
- $sd_day = "01";
- $st_hr = "00";
- $st_min = "00";
- $st_sec = "00";
- $ed_yr = $yr + 1900;
- $ed_mnth = sprintf( "%02d", $mnth + 1 );
- $ed_day = $day;
- $et_hr = "23";
- $et_min = "59";
- $et_sec = "59";
- }
- else {
- $sd_yr = $params->{sd_yr};
- $sd_mnth = sprintf( "%02d", param('sd_mnth') + 1 );
- $sd_day = sprintf( "%02d", param('sd_day') );
- $st_hr = sprintf( "%02d", param('st_hr') );
- $st_min = sprintf( "%02d", param('st_min') );
- $st_sec = sprintf( "%02d", param('st_sec') );
- $ed_yr = param('ed_yr');
- $ed_mnth = sprintf( "%02d", param('ed_mnth') + 1 );
- $ed_day = sprintf( "%02d", param('ed_day') );
- $et_hr = sprintf( "%02d", param('et_hr') );
- $et_min = sprintf( "%02d", param('et_min') );
- $et_sec = sprintf( "%02d", param('et_sec') );
- }
- $body .=
- "<form method=get><input type=hidden name=mode value=\""
- . param('mode')
- . "\"><table class=\"default\" width=100%>"
- . "<tr><td width=50%>"
- . gettext("Start date:")
- . "</td><td><input type=text name=sd_yr value=\"$sd_yr\" size=5><select name=sd_mnth>";
- for ( $id = 0 ; $id < 12 ; $id++ ) {
- if ( $id == ( $sd_mnth - 1 ) ) {
- $body .= "<option value=$id selected>$months[$id]";
- }
- else {
- $body .= "<option value=$id>$months[$id]";
- }
- }
- $body .=
- "</select><input type=text name=sd_day value=\"$sd_day\" size=3>"
- . "</td></tr>
-<tr><td>"
- . gettext("Start time:")
- . "</td><td><input type=text name=st_hr value=\"$st_hr\" size=3>"
- . "<input type=text name=st_min value=\"$st_min\" size=3>"
- . "<input type=text name=st_sec value=\"$st_sec\" size=3></td></tr>
-"
- . "<tr><td>"
- . gettext("End date:")
- . "</td><td><input type=text name=ed_yr value=\"$ed_yr\" size=5><select name=ed_mnth>";
- for ( $id = 0 ; $id < 12 ; $id++ ) {
- if ( $id == ( $ed_mnth - 1 ) ) {
- $body .= "<option value=$id selected>$months[$id]";
- }
- else {
- $body .= "<option value=$id>$months[$id]";
- }
- }
- $body .=
- "</select><input type=text name=ed_day value=\"$ed_day\" size=3></td></tr>
-"
- . "<tr><td>"
- . gettext("End time:")
- . "</td><td><input type=text name=et_hr value=\"$et_hr\" size=3>"
- . "<input type=text name=et_min value=\"$et_min\" size=3>"
- . "<input type=text name=et_sec value=\"$et_sec\" size=3></td></tr>
-"
- . "<tr><td>" . gettext("Answered Calls Only?")
+
+ $body = "<tr><td>" . gettext("Answered Calls Only?")
. popup_menu(
-name => "answered",
-values => \%yesno
@@ -1032,20 +1266,19 @@
-width => 8
);
}
- $body .= "</td></tr>
-" . "<tr><td>" . gettext("Select Outbound Trunk?")
- . popup_menu(
- -name => "trunk",
- -values => \@trunklist
- )
- . "</td></tr>
-"
- . "<tr><td align=center colspan=2><input type=submit value=Filter!></td></tr>
-"
- . "</table>
-</form>";
- my $sd = "$sd_yr-$sd_mnth-$sd_day $st_hr:$st_min:$st_sec";
- my $ed = "$ed_yr-$ed_mnth-$ed_day $et_hr:$et_min:$et_sec";
+ $body .= "</td></tr>"
+ . "<tr><td>" . gettext("Select Outbound Trunk?")
+ . popup_menu(
+ -name => "trunk",
+ -values => \@trunklist
+ )
+ . "</td></tr>";
+
+ my $filter = build_filter($body,undef);
+ my $sd = $filter->{'start_date'};
+ my $ed = $filter->{'end_date'};
+ $body = $filter->{'form_body'};
+
$body .=
start_form()
. "<table class=\"viewcdrs\" width=100%><tr><td colspan=5 align=center><b>$sd - $ed</b></td></tr>
@@ -1164,31 +1397,20 @@
\n";
}
$sql->finish;
- $sd_month = $sd_mnth - 1;
+ $filter{'start_month'} = $filter{'start_month'} - 1;
$string =
- "&sd_yr=" . $sd_yr
- . "&sd_mnth="
- . $sd_month
- . "&sd_day="
- . $sd_day
- . "&st_hr="
- . $st_hr
- . "&st_min="
- . $st_min
- . "&st_sec="
- . $st_sec
- . "&ed_yr="
- . $ed_yr
- . "&ed_mnth="
- . $ed_mnth
- . "&ed_day="
- . $ed_day
- . "&et_hr="
- . $et_hr
- . "&et_min="
- . $et_min
- . "&et_sec="
- . $et_sec
+ "&start_year=" . $filter{'start_year'}
+ . "&start_month=" . $filter{'start_month'}
+ . "&start_day=" . $filter{'start_day'}
+ . "&start_hour=" . $filter{'start_hour'}
+ . "&start_minute=". $filter{'start_minute'}
+ . "&start_second=". $filter{'start_second'}
+ . "&end_year=" . $filter{'end_year'}
+ . "&end_month=" . $filter{'end_month'}
+ . "&end_day=" . $filter{'end_day'}
+ . "&end_hour=" . $filter{'end_hour'}
+ . "&end_minute=" . $filter{'end_minute'}
+ . "&end_second=" . $filter{'end_second'}
. "&trunk="
. $params->{trunk};
for ( my $i = 0 ; $i <= $pagesrequired - 1 ; $i++ ) {
@@ -3426,7 +3648,7 @@
$body .= "</td><td>$cardstat" . "</td></tr>\n";
}
$body .= "</table><table><tr><td>";
- if ( $total_entries => 1 ) {
+ if ( $total_entries >= 1 ) {
$body .=
"<a href=\"astpp-admin.cgi?mode="
. gettext("List Cards") . "&ve="
@@ -8053,7 +8275,7 @@
$row{seconds} = $counterinfo->{seconds};
push( @counter_list, $counterinfo );
}
- if ( $total_entries => 1 )
+ if ( $total_entries >= 1 )
{ #This section only applies if we have more than 1 page.
$pagination =
"<a href=\"astpp-admin.cgi?mode="
@@ -11585,7 +11807,8 @@
@modes = (
gettext("Accounts"), gettext("Rates"),
gettext("DIDs"), gettext("Logout"),
- gettext("Call Shops"), gettext("Home")
+ gettext("Call Shops"), gettext("Home"),
+ gettext("Reseller Reports")
);
@Accounts = (
gettext("Create Account"), gettext("Process Payment"),
@@ -11613,7 +11836,8 @@
@modes = (
gettext("Accounts"), gettext("Rates"),
gettext("DIDs"), gettext("Statistics"),
- gettext("System"), gettext("Home")
+ gettext("System"), gettext("Home"),
+ gettext("Admin Reports")
);
if ( $config->{enablelcr} == 1 ) {
push @modes, gettext("LCR");
@@ -11678,7 +11902,7 @@
print STDERR "ASTPP CALLSHOP LOGIN\n" if $config->{debug} == 1;
@modes = (
gettext("Booths"), gettext("Home"),
- gettext("Routes"), gettext("Pricelists")
+ gettext("Routes"), gettext("Pricelists"), gettext("CallShop Reports")
);
if ( $config->{callingcards} == 1 ) {
push @modes, gettext("Calling Cards");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|