Thread: [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. |
From: <dar...@us...> - 2007-09-22 06:11:09
|
Revision: 2131 http://astpp.svn.sourceforge.net/astpp/?rev=2131&view=rev Author: darrenkw Date: 2007-09-21 23:11:10 -0700 (Fri, 21 Sep 2007) Log Message: ----------- Converted "View Details" to use the account-info template. Modified Paths: -------------- trunk/astpp-admin.cgi Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-09-22 05:17:34 UTC (rev 2130) +++ trunk/astpp-admin.cgi 2007-09-22 06:11:10 UTC (rev 2131) @@ -1543,6 +1543,7 @@ return $template->output; } + sub build_account_info() { my ( $total, $body, $status, $description, @@ -1560,8 +1561,10 @@ else { @pricelists = &list_pricelists($astpp_db); } + return gettext("Cannot view account until pricelists configured") unless @pricelists; + if ( $params->{limit} < 1 ) { $params->{limit} = 0 } $results_per_page = $config->{results_per_page}; if ( $results_per_page eq "" ) { $results_per_page = 25; } @@ -1601,13 +1604,14 @@ &write_account_cdr( $astpp_db, $number, $params->{amount} * 10000, $params->{desc}, $timestamp, 0 ); + $status .= "Charge Posted"; } } else { &write_account_cdr( $astpp_db, $number, $params->{amount} * 10000, $params->{desc}, $timestamp, 0 ); + $status .= "Charge Posted"; } - $params->{action} = gettext("Information..."); } elsif ( $params->{action} eq gettext("Add Charge...") ) { if ( $params->{accountnum} ne "" ) { @@ -1639,9 +1643,8 @@ . $astpp_db->quote($number) . ", " . "1)"; $astpp_db->do($tmp); } - $params->{action} = gettext("Information..."); } - elsif ( $params->{action} eq gettext("Remove Charge") ) { + elsif ( $params->{action} eq gettext("Remove Charge...") ) { if ( $params->{accountnum} ne "" ) { $number = $params->{accountnum}; } @@ -1663,7 +1666,6 @@ . $astpp_db->quote( $params->{chargeid} ); $astpp_db->do($tmp); } - $params->{action} = gettext("Information..."); } elsif ( $params->{action} eq gettext("Remove DID") ) { if ( $params->{accountnum} ne "" ) { @@ -1675,7 +1677,6 @@ $status .= &remove_did( $astpp_db, $config, $params->{DID}, $number ); - $params->{action} = gettext("Information..."); } elsif ( $params->{action} eq gettext("Purchase DID") ) { if ( $params->{accountnum} ne "" ) { @@ -1687,7 +1688,6 @@ $status .= &purchase_did( $astpp_db, $config, $params->{did_list}, $number ); - $params->{action} = gettext("Information..."); } elsif ( $params->{action} eq gettext("Map ANI") ) { if ( $params->{accountnum} ne "" ) { @@ -1713,7 +1713,6 @@ . $params->{ANI} . "' " . gettext("FAILED to create!") . "<br>"; } - $params->{action} = gettext("Information..."); } elsif ( $params->{action} eq gettext("Remove ANI") ) { if ( $params->{accountnum} ne "" ) { @@ -1739,7 +1738,6 @@ . $params->{ANI} . "' " . gettext("FAILED to remove!") . "<br>"; } - $params->{action} = gettext("Information..."); } elsif ( $params->{action} eq gettext("Map IP") ) { if ( $params->{accountnum} ne "" ) { @@ -1767,7 +1765,6 @@ . $params->{ip} . "' " . gettext("FAILED to create!") . "<br>"; } - $params->{action} = gettext("Information..."); } elsif ( $params->{action} eq gettext("Remove IP") ) { if ( $params->{accountnum} ne "" ) { @@ -1795,10 +1792,7 @@ . $params->{ip} . "' " . gettext("FAILED to remove!") . "<br>"; } - $params->{action} = gettext("Information..."); } - if ( $params->{action} eq gettext("Information...") ) { - my ($balance); if ( $number ne "" ) { $accountinfo = &get_account( $astpp_db, $number ); } @@ -1808,541 +1802,233 @@ else { $accountinfo = &get_account( $astpp_db, $params->{numberlist} ); } - $balance = &accountbalance( $astpp_db, $accountinfo->{number} ); - $balance = sprintf( "%.2f", $balance / 10000 ); if ( $accountinfo->{number} ) { - $status .= - "<table class=\"default\"><tr><td colspan=2>" - . gettext("Name: ") - . $accountinfo->{first_name} . " " - . $accountinfo->{middle_name} . " " - . $accountinfo->{last_name} - . "</td></tr><tr><td width=400>" - . gettext("Company Name: ") - . $accountinfo->{company_name} - . "</td><td>" - . gettext("Phone: ") - . $accountinfo->{telephone_1} - . "</td></tr><tr><td>" - . gettext("Address 1: ") - . $accountinfo->{address_1} - . "</td><td>" - . gettext("Phone 2: ") - . $accountinfo->{telephone_2} - . "</td></tr><tr><td>" - . gettext("Address 2: ") - . $accountinfo->{address_2} - . "</td><td>" - . gettext("Facsimile: ") - . $accountinfo->{fascimilie} - . "</td></tr><tr><td>" - . gettext("Address 3: ") - . $accountinfo->{address_3} - . "</td><td>" - . gettext("Email: ") - . $accountinfo->{email} - . "</td></tr><tr><td colspan=2>" - . gettext("City, Postal Code, Country: ") - . $accountinfo->{city} . ", " - . $accountinfo->{postal_code} . ", " - . $accountinfo->{country} - . "</td></tr>" - . "<tr><td colspan=2>" - . gettext("Dialed Number Mods: ") - . $accountinfo->{dialed_modify} - . "<tr><td>" - . gettext("Pin:") . " " - . $accountinfo->{pin} - . "</td></tr></table"; - $status .= - "<br>Account </i><b>" - . $accountinfo->{'number'} - . " </b><i>" - . gettext("balance: ") - . "</i><b>$balance $currency[0] </b></i>" - . gettext("Max Channels:") . " " - . $accountinfo->{maxchannels} . "\n"; - $status .= - gettext("with a credit limit of") - . " </i><b>\$$accountinfo->{'credit_limit'} $currency[0]</b></i>\n"; - } - else { - $status .= - gettext("No such account number") - . " '$accountinfo->{number}' " - . gettext("found!") . "\n"; - } - $body .= - "<table class=\"default\">" - . "<tr class=\"header\"><td colspan=5>" - . gettext("Charges") - . "</td></tr>" - . "<tr class=\"header\"><td>" - . gettext("Action") - . "</td><td>" - . gettext("Id") - . "</td><td>" - . gettext("Description") - . "</td><td>" - . gettext("Cycle") - . "</td><td>" - . gettext("Amount") - . "</td></tr>"; + $accountinfo->{balance} = &accountbalance( $astpp_db, $accountinfo->{number} ); + $accountinfo->{balance} = sprintf( "%.2f", $accountinfo->{balance} / 10000 ); + $template->param(first_name => $accountinfo->{first_name}); + $template->param(middle_name => $accountinfo->{middle_name}); + $template->param(last_name => $accountinfo->{last_name}); + $template->param(company => $accountinfo->{company_name}); + $template->param(telephone_1 => $accountinfo->{telephone_1}); + $template->param(telephone_2 => $accountinfo->{telephone_2}); + $template->param(fascimilie => $accountinfo->{fascimilie}); + $template->param(address_1 => $accountinfo->{address_1}); + $template->param(address_2 => $accountinfo->{address_2}); + $template->param(address_3 => $accountinfo->{address_3}); + $template->param(email => $accountinfo->{email}); + $template->param(city =>$accountinfo->{city}); + $template->param(postal_code => $accountinfo->{postal_code}); + $template->param(country => $accountinfo->{country}); + $template->param(province => $accountinfo->{province}); + $template->param(dialed_modify => $accountinfo->{dialed_modify}); + $template->param(pin => $accountinfo->{pin}); + $template->param(accountnum => $accountinfo->{number}); + $template->param(balance => $accountinfo->{balance}); + $template->param(maxchannels => $accountinfo->{maxchannels}); + $template->param(credit_limit => $accountinfo->{credit_limit}); + my @chargelist; my @account_charge_list = &list_account_charges( $astpp_db, $accountinfo->{number} ); my @pricelist_charge_list = &list_pricelist_charges( $astpp_db, $accountinfo->{pricelist} ); foreach my $charge (@account_charge_list) { - my ( $sweep, $cost ); - $count++; - print STDERR "CHARGE_ID $charge->{charge_id}\n" - if $config->{debug} == 1; + my ( %row ); + $row{accountnum} = $accountinfo->{number}; my $chargeinfo = &get_charge( $astpp_db, $charge->{charge_id} ); - print STDERR "SWEEP: " . $chargeinfo->{sweep} - if $config->{debug} == 1; - if ( $chargeinfo->{sweep} == 0 ) { - $sweep = gettext("daily"); - } - elsif ( $chargeinfo->{sweep} == 1 ) { - $sweep = gettext("weekly"); - } - elsif ( $chargeinfo->{sweep} == 2 ) { - $sweep = gettext("monthly"); - } - elsif ( $chargeinfo->{sweep} == 3 ) { - $sweep = gettext("quarterly"); - } - elsif ( $chargeinfo->{sweep} == 4 ) { - $sweep = gettext("semi-annually"); - } - elsif ( $chargeinfo->{sweep} == 5 ) { - $sweep = gettext("annually"); - } - $cost = sprintf( "%.2f", $chargeinfo->{charge} / 10000 ); - if ( $count % 2 == 0 ) { - $body .= "<tr class=\"rowtwo\">"; - } - else { - $body .= "<tr class=\"rowone\">"; - } - $body .= - "<td><a href=\"astpp-admin.cgi?mode=" - . gettext("View Details") - . "&chargeid=" - . $charge->{id} - . "&accountnum=" - . $accountinfo->{number} - . "&action=" - . gettext("Remove Charge") . "\">" - . gettext("Remove Charge") . "</a>" - . "</td><td>" - . $charge->{id} - . "</td><td>" - . $chargeinfo->{description} - . "</td><td>" - . $sweep - . "</td><td> \$" - . $cost - . "</td></tr> -"; + $row{sweep} = $sweeplist{$chargeinfo->{Sweep}}; + $row{cost} = sprintf( "%.2f", $chargeinfo->{charge} / 10000 ); + $row{id} = $charge->{id}; + $row{description} = $chargeinfo->{description}; + push(@chargelist, \%row); } foreach my $charge (@pricelist_charge_list) { - my ($cost); - $count++; + my ( %row ); + $row{accountnum} = $accountinfo->{number}; my $chargeinfo = &get_charge( $astpp_db, $charge ); - if ( $chargeinfo->{sweep} == 0 ) { - $chargeinfo->{sweep} = gettext("daily"); - } - elsif ( $chargeinfo->{sweep} == 1 ) { - $chargeinfo->{sweep} = gettext("weekly"); - } - elsif ( $chargeinfo->{sweep} == 2 ) { - $chargeinfo->{sweep} = gettext("monthly"); - } - elsif ( $chargeinfo->{sweep} == 3 ) { - $chargeinfo->{sweep} = gettext("quarterly"); - } - elsif ( $chargeinfo->{sweep} == 4 ) { - $chargeinfo->{sweep} = gettext("semi-annually"); - } - elsif ( $chargeinfo->{sweep} == 5 ) { - $chargeinfo->{sweep} = gettext("annually"); - } - $cost = sprintf( "%.2f", $chargeinfo->{charge} / 10000 ); - if ( $count % 2 == 0 ) { - $body .= "<tr class=\"rowtwo\">"; - } - else { - $body .= "<tr class=\"rowone\">"; - } - $body .= "<td>" - . "</td><td>" - . $charge - . "</td><td>" - . $chargeinfo->{description} - . "</td><td>" - . $chargeinfo->{sweep} - . "</td><td> \$" - . $cost - . "</td></tr>"; + $row{sweep} = $sweeplist{$chargeinfo->{Sweep}}; + $row{cost} = sprintf( "%.2f", $chargeinfo->{charge} / 10000 ); + $row{id} = $charge; + $row{charge} = $chargeinfo->{description}; + push(@chargelist, \%row); } + $template->param( chargelist => \@chargelist); my %applyablecharges = &list_applyable_charges($astpp_db); - $count++; - if ( $count % 2 == 0 ) { - $body .= "<tr class=\"rowtwo\">"; - } - else { - $body .= "<tr class=\"rowone\">"; - } - $body .= "<td colspan=2>" - . popup_menu( + $template->param( applyable_charges => popup_menu( -name => "id_list", -values => \%applyablecharges - ) - . "</td><td>" - . textfield( -name => "id", -size => 5 ) - . "</td><td colspan=2>" - . submit( - -name => "action", - -value => gettext("Add Charge...") - ) . "</td></tr></table>"; - $count = 0; - $body .= - "<table class=\"default\">" - . "<tr class=\"header\"><td colspan=2>" - . gettext("DIDs") - . "</td></tr>" - . "<tr class=\"header\"><td>" - . gettext("Number") - . "</td><td>" - . gettext("Monthly Fee") - . "</td><td>" - . gettext("Action") - . "</td></tr>"; + )); + + my (@account_did_list); my @did_list = &list_dids_account( $astpp_db, $accountinfo->{number} ); foreach my $did_info (@did_list) { - my $cost = sprintf( "%.2f", $did_info->{monthlycost} / 10000 ); - $count++; - if ( $count % 2 == 0 ) { - $body .= "<tr class=\"rowtwo\">"; - } - else { - $body .= "<tr class=\"rowone\">"; - } - $body .= "<td>" - . $did_info->{number} - . "</td><td> \$" - . $cost - . "<td><a href=\"astpp-admin.cgi?mode=" - . gettext("View Details") - . "&accountnum=$accountinfo->{'number'}" - . "&DID=$did_info->{number}&action=" - . gettext("Remove DID") . " \">" - . gettext("Remove DID") . "</a>" - . "</td></tr>"; + my (%row); + $row{accountnum} = $accountinfo->{number}; + $row{cost} = sprintf( "%.2f", $did_info->{monthlycost} / 10000 ); + $row{number} = $did_info->{number}; + push(@account_did_list, \%row); } + $template->param( account_did_list => \@account_did_list); my @availabledids = &list_available_dids( $astpp_db, $accountinfo->{number} ); - $count++; - if ( $count % 2 == 0 ) { - $body .= "<tr class=\"rowtwo\">"; - } - else { - $body .= "<tr class=\"rowone\">"; - } - $body .= "<td>" - . popup_menu( + $template->param( available_dids => + popup_menu( -name => "did_list", -values => \@availabledids - ) - . "</td><td></td><td>" - . submit( - -name => "action", - -value => gettext("Purchase DID") - ) - . "</td></tr>" - . "<tr class=\"header\"><td colspan=2>" - . gettext("ANI & Prefix Mapping - Either enter prefix or ANI/CLID") - . "</td></tr>" - . "<tr class=\"header\"><td>" - . gettext("ANI") - . "</td><td>" - . gettext("Context - Leave blank for default") - . "</td><td>" - . gettext("ANI") - . "</td></tr> -\n"; + )); my $tmp = "SELECT * FROM ani_map WHERE account = " . $astpp_db->quote( $accountinfo->{'number'} ) . " ORDER BY number"; my $sql = $astpp_db->prepare($tmp); $sql->execute; - $count = 0; + my @account_ani_list; while ( my $record = $sql->fetchrow_hashref ) { - $count++; - if ( $count % 2 == 0 ) { - $body .= "<tr class=\"rowtwo\">"; - } - else { - $body .= "<tr class=\"rowone\">"; - } - $body .= - "<td>$record->{number}</td><td>$record->{context}</td>" - . "<td><a href=\"astpp-admin.cgi?mode=" - . gettext("View Details") - . "&accountnum=$accountinfo->{'number'}" - . "&ANI=$record->{number}&action=" - . gettext("Remove ANI") . " \">" - . gettext("Remove ANI") . "</a>" - . "</td></tr>"; + my (%row); + $row{accountnum} = $accountinfo->{number}; + $row{number} = $record->{number}; + $row{context} = $record->{context}; + push(@account_ani_list, \%row); } - $count++; - if ( $count % 2 == 0 ) { - $body .= "<tr class=\"rowtwo\">"; - } - else { - $body .= "<tr class=\"rowone\">"; - } + $template->param( account_ani_list => \@account_ani_list); - $body .= "<td>" - . textfield( - -name => "ANI", - -width => 20 - ) - . "</td><td>" - . textfield( - -name => "context", - -width => 20 - ) - . "</td><td>" - . submit( - -name => "action", - -value => gettext("Map ANI") - ) - . "</td></tr>" - . "<tr class=\"header\"><td colspan=2>" - . gettext("IP Address Mapping") - . "</td></tr>" - . "<tr class=\"header\"><td>" - . gettext("IP") - . "</td><td>" - . gettext("Prefix - Enter '0' for none.") - . "</td><td>" - . gettext("Context - Leave blank for default.") - . "</td><td>" - . gettext("Action") - . "</td></tr>\n"; $tmp = "SELECT * FROM ip_map WHERE account = " . $astpp_db->quote( $accountinfo->{'number'} ) . " ORDER BY ip"; $sql = $astpp_db->prepare($tmp); $sql->execute; - $count = 0; + my @account_ip_list; while ( my $record = $sql->fetchrow_hashref ) { - $count++; - if ( $count % 2 == 0 ) { - $body .= "<tr class=\"rowtwo\">"; - } - else { - $body .= "<tr class=\"rowone\">"; - } - $body .= -"<td>$record->{ip}</td><td>$record->{prefix}</td><td>$record->{context}</td>" - . "<td><a href=\"astpp-admin.cgi?mode=" - . gettext("View Details") - . "&accountnum=$accountinfo->{'number'}" - . "&prefix=$record->{prefix}" - . "&ip=$record->{ip}&action=" - . gettext("Remove IP") . " \">" - . gettext("Remove IP") . "</a>" - . "</td></tr>"; + my %row; + $row{accountnum} = $accountinfo->{number}; + $row{ip} = $record->{ip}; + $row{prefix} = $record->{prefix}; + $row{context} = $record->{context}; + push(@account_ip_list, \%row); } - $count++; - if ( $count % 2 == 0 ) { - $body .= "<tr class=\"rowtwo\">"; - } - else { - $body .= "<tr class=\"rowone\">"; - } - $body .= "<td>" - . textfield( - -name => "ip", - -width => 16 - ) - . "</td><td>" - . textfield( - -name => "prefix", - -width => 16 - ) - . "</td><td>" - . textfield( - -name => "ipcontext", - -width => 16 - ) - . "</td><td>" - . submit( - -name => "action", - -value => gettext("Map IP") - ) - . "</td></tr>" - . "<tr class=\"header\">" - . "<td colspan=2>" - . gettext("Post Charge to Account") - . "</td></tr> -<tr class=\"header\"><td>" - . gettext("Description") - . "</td><td>" - . gettext("Charge in: ") - . $currency[0] - . "</td><td>" - . gettext("Action") - . "</td></tr>" - . "<tr class=\"rowone\"><td>" - . textfield( - -name => "desc", - -width => 16 - ) - . "</td><td>" - . textfield( - -name => "amount", - -width => 16 - ) - . "</td><td>" - . submit( - -name => "action", - -value => gettext("Post Charge...") - ) - . "</td></tr>" - . "</table>" - . "<br><table class=\"default\">" - . "<tr class=\"header\"><td>" - . gettext("UniqueID") - . "</td><td>" - . gettext("Date & Time") - . "</td><td>" - . gettext("Caller*ID") - . "</td><td>" - . gettext("Called Number") - . "</td><td>" - . gettext("Trunk") - . "</td><td>" - . gettext("Disposition") - . "</td><td>" - . gettext("Billable Seconds") - . "</td><td>" - . gettext("Charge") - . "</td><td>" - . gettext("Credit") - . "</td><td>" - . gettext("Notes") - . "</td></tr>\n"; + $template->param( account_ip_list => \@account_ip_list); + $template->param( currency => $currency[0]); + ## START PAGINATION CODE + # set total_entries *once* then pass it around + # in the object's links from then on for efficiency: + + my $verify = CGI::param('ve') || ''; + my $total_entries = int( CGI::param('te') ); + my $te_match = + $total_entries + ? Digest::MD5::md5_hex("unique_cypher-$total_entries-$where") + : ''; + if ( !$total_entries || $verify ne $te_match ) { + + # its not ok so re-fetch $tmp = - "SELECT * FROM cdrs WHERE cardnum =" - . $astpp_db->quote( $accountinfo->{'number'} ) + "SELECT COUNT(*) FROM cdrs WHERE cardnum =" + . $astpp_db->quote( $accountinfo->{number} ) . "and status IN (NULL, '', 0, 1)" . " ORDER BY callstart DESC"; $sql = $astpp_db->prepare($tmp); $sql->execute; - $results = $sql->rows; - $pagesrequired = ceil( $results / $results_per_page ); + $record = $sql->fetchrow_hashref; + $total_entries = $record->{"COUNT(*)"}; + $sql->finish; + $te_match = Digest::MD5::md5_hex("unique_cypher-$total_entries-$where"); + } + if ( $total_entries <= 0 ) { $total_entries = 1; } + my $pgr = Data::Paginate->new( + { + 'start_array_index_at_zero' => 1, + 'total_entries' => $total_entries, + 'entries_per_page' => $results_per_page, + 'total_entries_verify_param_value' => $te_match + } + ); + + # only SELECT current page's records: + if ( $total_entries > $pgr->get_entries_on_this_page() ) { $tmp = "SELECT * FROM cdrs WHERE cardnum =" - . $astpp_db->quote( $accountinfo->{'number'} ) + . $astpp_db->quote( $accountinfo->{number} ) . "and status IN (NULL, '', 0, 1)" . " ORDER BY callstart DESC " - . " limit $params->{limit} , $results_per_page"; + . " LIMIT ". ($pgr->get_first() - 1) . ", " . $pgr->get_entries_on_this_page(); + } else { + $tmp = + "SELECT * FROM cdrs WHERE cardnum =" + . $astpp_db->quote( $accountinfo->{'number'} ) + . "and status IN (NULL, '', 0, 1)" + . " ORDER BY callstart DESC "; + } $sql = $astpp_db->prepare($tmp); $sql->execute; - $count = 0; - + my @account_cdr_list; while ( my $record = $sql->fetchrow_hashref ) { - my ( $debit, $credit ); - $count++; - $record->{callerid} = gettext("unknown") unless $record->{callerid}; - $record->{uniqueid} = gettext("N/A") unless $record->{uniqueid}; - $record->{disposition} = gettext("N/A") - unless $record->{disposition}; - $record->{notes} = "" unless $record->{notes}; - $record->{callstart} = "" unless $record->{callstart}; - $record->{callednum} = "" unless $record->{callednum}; - $record->{billseconds} = "" unless $record->{billseconds}; + my %row; + if (!$record->{callerid}) { + $row{callerid} = gettext("N/A"); + } else { + $row{callerid} = $record->{callerid}; + } + if (!$record->{uniqueid}) { $row{uniqueid} = gettext("N/A");} else { $row{uniqueid} = $record->{uniqueid};} + if (!$record->{disposition}) {$row{disposition} = gettext("N/A");} else {$row{disposition} = $record->{dispositio}; } + if (!$record->{notes}) { $row{notes} = ""; } else { $row{notes} = $record->{notes} ;} + if (!$record->{callstart}) { $row{callstart} = ""; } else { $row{callstart} = $record->{callstart}; } + if (!$record->{callednum}) { $row{callednum} = ""; } else {$row{callednum} = $record->{callednum};} + if (!$record->{billseconds}) { $row{billseconds} = ""; } else { $row{billseconds} = $record->{billseconds};} + if ( $record->{debit} ) { - $debit = $record->{debit} / 10000; - $debit = sprintf( "%.6f", $debit ); + $row{debit} = $record->{debit} / 10000; + $row{debit} = sprintf( "%.6f", $row{debit} ); } else { - $debit = "-"; + $row{debit} = "-"; } if ( $record->{credit} ) { - $credit = $record->{credit} / 10000; - $credit = sprintf( "%.6f", $credit ); + $row{credit} = $record->{credit} / 10000; + $row{credit} = sprintf( "%.6f", $row{credit} ); } else { - $credit = "-"; + $row{credit} = "-"; } - if ( $count % 2 == 0 ) { - $body .= "<tr class=\"rowtwo\">"; - } - else { - $body .= "<tr class=\"rowone\">"; - } - $body .= - "<td>$record->{uniqueid}</td><td>$record->{callstart}</td><td>" - . "$record->{callerid}</td><td>$record->{callednum}</td><td>" - . "N/A</td><td>$record->{disposition}</td><td>$record->{billseconds}</td><td>" - . "$debit</td><td>$credit</td><td>$record->{notes}</td></tr> -"; + push(@account_cdr_list, \%row); } + $template->param( account_cdr_list => \@account_cdr_list); + if ( $total_entries => 1 ) + { #This section only applies if we have more than 1 page. + $pagination = + "<a href=\"astpp-admin.cgi?mode=" + . gettext("View Details") . "&ve=" + . $params->{ve} . "&te=" + . $total_entries + . "&pg=1\">" + . gettext("First Page") + . "</a> | "; + $pagination .= scalar $pgr->get_navi_html(); + $pagination .= + "<a href=\"astpp-admin.cgi?mode=" + . gettext("View Details") . "&ve=" + . $params->{ve} . "&te=" + . $total_entries . "&pg=" + . $pgr->get_last_page() . "\">" + . gettext("Last Page") . "</a>"; } - $body .= "</table> -"; - for ( my $i = 0 ; $i <= $pagesrequired - 1 ; $i++ ) { - if ( $i == 0 ) { - if ( $params->{limit} != 0 ) { - $body .= - "<a href=\"astpp-admin.cgi?mode=" - . gettext("View Details") - . "&action=" - . gettext("Information...") - . "&accountnum=" - . $accountinfo->{number} - . "&limit=0\">"; - $body .= $i + 1; - $body .= "</a>"; - } - else { - $body .= $i + 1; - } + else { + $pagination = gettext("Page 1 of 1"); + } + + $template->param( pagination => $pagination ); } - if ( $i > 0 ) { - if ( $params->{limit} != ( $i * $results_per_page ) ) { - $body .= - "<a href=\"astpp-admin.cgi?mode=" - . gettext("View Details") - . "&action=" - . gettext("Information...") - . "&accountnum=" - . $accountinfo->{number} - . "&limit="; - $body .= ( $i * $results_per_page ); - $body .= "\">\n"; - $body .= $i + 1 . "</a>"; - } - else { - $pageno = $i + 1; - $body .= " |"; - } + else { + $status .= + gettext("No such account number") + . " '$accountinfo->{number}' " + . gettext("found!") . "\n"; } - } - $body .= ""; - $body .= "Page $pageno of $pagesrequired"; - return $body; + $template->param( status => $status ); + return $template->output; } sub build_list_accounts() { - my ( $total, $count, $reseller, @accountdetaillist ); + my ( $body, $total, $count, $reseller, @accountdetaillist ); my $template = HTML::Template->new( filename => '/var/lib/astpp/templates/account-list.tpl' ); @@ -2359,7 +2045,7 @@ $reseller = ""; } $types{-1} = gettext("All"); - my $body = start_form + $body = start_form . "<table class=\"default\"><tr class=\"header\"><td colspan=9>" . hidden( -name => "mode", @@ -6859,6 +6545,7 @@ -size => 3, -default => 0 ) + . "</td><td>" . textfield( -name => 'dial_as', -size => This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <son...@us...> - 2007-09-27 11:20:48
|
Revision: 2134 http://astpp.svn.sourceforge.net/astpp/?rev=2134&view=rev Author: sonalikh Date: 2007-09-27 04:20:49 -0700 (Thu, 27 Sep 2007) Log Message: ----------- Conversion in time and amount to standard formats Modified Paths: -------------- trunk/astpp-admin.cgi Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-09-22 07:12:03 UTC (rev 2133) +++ trunk/astpp-admin.cgi 2007-09-27 11:20:49 UTC (rev 2134) @@ -155,7 +155,7 @@ my @timezones = DateTime::TimeZone->all_names; @timezones = sort(@timezones); my ( - $rt_db, $astpp_db, $config, $config, $params, + $rt_db, $astpp_db, $config, $params, $param, $cdr_db, $agile_db, $body, $menu, $status, $msg, $loginstat, @modes, $openser_db ); @@ -1045,10 +1045,18 @@ my $row4 = $sql4->fetchrow_hashref(); $act = $row4->{'actual'}; $sql4->finish; - + + $act = int($act/60) . ":" . ($act%60); + $acd = int($acd/60) . ":" . ($acd%60); + $mcd = int($mcd/60) . ":" . ($mcd%60); + $bill = int($bill/60) . ":" . ($bill%60); + $price = $price/10000.0; + $cost = $cost/10000.0; + $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>" + . "<td align=right>$acd</td><td align=right>$mcd</td><td align=right>$act</td>" + . "<td align=right>$bill</td><td>$price</td><td>$cost</td>" . "</tr>"; } $sql1->finish; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-01 06:15:01
|
Revision: 2140 http://astpp.svn.sourceforge.net/astpp/?rev=2140&view=rev Author: darrenkw Date: 2007-10-31 23:15:04 -0700 (Wed, 31 Oct 2007) Log Message: ----------- We have support for multiple pricelists for resellers but when an account was created by a reseller it was always taking the default resellers pricelist. This has been resolved and is ready for final testing. Modified Paths: -------------- trunk/astpp-admin.cgi Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-11-01 06:01:57 UTC (rev 2139) +++ trunk/astpp-admin.cgi 2007-11-01 06:15:04 UTC (rev 2140) @@ -2229,7 +2229,8 @@ unless @pricelists; if ( $params->{action} eq gettext("Generate Account") ) { if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { - $params->{pricelist} = $params->{username}; + my $pricelistinfo = &get_pricelist($astpp_db, $params->{pricelist}); + $params->{pricelist} = $params->{username} if $pricelistinfo->{reseller} ne $params->{username}; $params->{reseller} = $params->{username}; } $params->{count} = 1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-02 02:46:17
|
Revision: 2142 http://astpp.svn.sourceforge.net/astpp/?rev=2142&view=rev Author: darrenkw Date: 2007-11-01 19:46:14 -0700 (Thu, 01 Nov 2007) Log Message: ----------- Patch Resolves: FS#282: WWW Create trunks, reseller not added Modified Paths: -------------- trunk/astpp-admin.cgi Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-11-02 02:24:30 UTC (rev 2141) +++ trunk/astpp-admin.cgi 2007-11-02 02:46:14 UTC (rev 2142) @@ -8397,6 +8397,7 @@ return $body; } elsif ( $params->{action} eq gettext("Insert...") ) { + my @resellers = &list_resellers($astpp_db); my $resellerlist = ""; foreach my $reseller (@resellers) { my $resellerparam = "reseller-" . $reseller; @@ -8416,6 +8417,7 @@ . $astpp_db->quote( $params->{precedence} ) . ", " . $astpp_db->quote($resellerlist) . ", " . $astpp_db->quote( $params->{provider} ) . ")"; + print STDERR $tmp if $config->{debug} == 1; if ( $astpp_db->do($tmp) ) { $status .= gettext("Trunk: ") @@ -8425,7 +8427,6 @@ else { $status .= gettext("Trunk: ") . $params->{name} . gettext(" Failed to Add!"); - print STDERR $tmp if $config->{debug} == 1; } $params->{action} = gettext("Information..."); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <son...@us...> - 2007-11-06 22:58:35
|
Revision: 2156 http://astpp.svn.sourceforge.net/astpp/?rev=2156&view=rev Author: sonalikh Date: 2007-11-06 14:58:39 -0800 (Tue, 06 Nov 2007) Log Message: ----------- Some minor bug fixes to reseller reports Modified Paths: -------------- trunk/astpp-admin.cgi Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-11-06 03:33:07 UTC (rev 2155) +++ trunk/astpp-admin.cgi 2007-11-06 22:58:39 UTC (rev 2156) @@ -108,11 +108,20 @@ ); # Report added by Sonia Ali Khan <son...@gm...> -my @AdminReports = ( gettext("Reseller Report"), gettext("Vendor Report") ); -my @CallShopReports = ( gettext("Booth Report") ); +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") +# gettext("Brand Report"), + gettext("CallShop Report"), + gettext("Reseller Report"), + gettext("User Report") ); @@ -513,8 +522,8 @@ 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_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() @@ -790,12 +799,16 @@ return &build_report("Booth","6"); } +sub build_reseller_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"); + return &build_report("User","0"); } sub build_list_box($$) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2007-11-18 03:12:46
|
Revision: 2162 http://astpp.svn.sourceforge.net/astpp/?rev=2162&view=rev Author: darrenkw Date: 2007-11-17 19:12:44 -0800 (Sat, 17 Nov 2007) Log Message: ----------- Cleaned up the debugging in astpp-admin.cgi and added call hangup abilities. Modified Paths: -------------- trunk/astpp-admin.cgi Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2007-11-18 00:26:27 UTC (rev 2161) +++ trunk/astpp-admin.cgi 2007-11-18 03:12:44 UTC (rev 2162) @@ -1200,7 +1200,7 @@ or dstchannel like '$row->{tech}\[$row->{path}\]%' ) "; my $sth4 = $cdr_db->prepare($sql4); - print STDERR " SQL: $sql4 \n " if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => " SQL: $sql4"); $sth4->execute(); my $ref4 = $sth4->fetchrow_hashref(); $sth4->finish; @@ -1337,7 +1337,7 @@ . $cdr_db->quote($sd) . " and calldate <= " . $cdr_db->quote($ed); - print STDERR " SQL: $tmp \n " if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => " SQL: $tmp"); } else { $tmp = @@ -1345,7 +1345,7 @@ . $cdr_db->quote($sd) . " and calldate <= " . $cdr_db->quote($ed); - print STDERR " SQL: $tmp \n " if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => " SQL: $tmp"); } if ( $params->{accountcode} && $params->{logintype} == 2 ) { $tmp .= @@ -1356,7 +1356,7 @@ "SELECT * FROM trunks WHERE name = " . $astpp_db->quote( $params->{trunk} ) . " LIMIT 1"; - print STDERR $tmpsql if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmpsql); $sql = $astpp_db->prepare($tmpsql); $sql->execute || return gettext("Something is wrong with the trunks database") @@ -1367,7 +1367,7 @@ " and (dstchannel like '$row->{tech}/$row->{path}\%'" . " or dstchannel like '$row->{tech}\[$row->{path}\]\%')"; } - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp); $sql = $cdr_db->prepare($tmp); $sql->execute; $results = $sql->rows; @@ -1492,7 +1492,7 @@ $accounts .= ","; } } - print STDERR $accounts if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $accounts); $template->param( customer_count => &count_accounts( $astpp_db, "WHERE type = 0 AND reseller = '$params->{username}'" @@ -1759,7 +1759,7 @@ . $astpp_db->quote($number) . ", " . $astpp_db->quote( $params->{prefix} ) . ", " . $astpp_db->quote( $params->{ipcontext} ) . ")"; - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp); if ( $astpp_db->do($tmp) ) { $status .= gettext("IP") . " '" @@ -2110,7 +2110,7 @@ "You have added $params->{count} calling cards in the amount of $params->{value} cents. \n\n"; } my $brandinfo = &get_cc_brand( $astpp_db, $params->{brand} ); - print STDERR "BRAND: $params->{brand}\n" if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "BRAND: $params->{brand}"); while ( $count < $params->{count} ) { my ( $number, $pin ) = &add_callingcard( $astpp_db, $config, $brandinfo, @@ -2384,7 +2384,7 @@ "DELETE FROM callingcardbrands WHERE name = " . $astpp_db->quote( $params->{name} ); } - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp); if ( $astpp_db->do($tmp) ) { $status .= gettext("Brand Deleted!"); } @@ -2431,7 +2431,7 @@ . $astpp_db->quote( $params->{min_length_minutes} ) . ", " . $astpp_db->quote( $params->{min_length_pennies} ) . ")"; } - print STDERR "sql" if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "sql"); if ( $astpp_db->do($sql) ) { $status .= gettext("Brand Added!"); } @@ -2571,7 +2571,7 @@ . " WHERE name =" . $astpp_db->quote( $params->{name} ); } - print STDERR "$sql" if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $sql); if ( $astpp_db->do($sql) ) { $status .= gettext("Brand Updated!"); } @@ -2726,7 +2726,7 @@ $tmp = "SELECT name FROM callingcardbrands WHERE status < 2 AND reseller IN (NULL,'')"; } - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp); $sql = $astpp_db->prepare($tmp); $sql->execute || return gettext( @@ -2748,7 +2748,7 @@ $tmp = "SELECT * FROM callingcardbrands WHERE status < 2 AND reseller IN (NULL,'') ORDER BY name limit $params->{limit} , $results_per_page"; } - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); $sql = $astpp_db->prepare($tmp); $sql->execute || return gettext( @@ -3038,7 +3038,7 @@ . $astpp_db->quote( $cardinfo->{cardnumber} ) . " AND brand " . $brandsql; - print STDERR $sql if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $sql); $astpp_db->do($sql) || print "$sql " . gettext("FAILED"); } @@ -3048,8 +3048,7 @@ if ( $params->{action} eq gettext("Refill") ) { $cardinfo = &get_callingcard( $astpp_db, $params->{cardnumber}, $config ); - print STDERR "CARDNUMBER: " . $cardinfo->{cardnumber} - if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "CARDNUMBER: " . $cardinfo->{cardnumber}); &update_balance( $cardinfo, $params->{pennies} * 100 ); $status .= "$params->{cardnumber} " . gettext("Refilled") . "<br>\n"; } @@ -3240,7 +3239,7 @@ "SELECT * FROM callingcards WHERE status < 2 AND brand $brandsql ORDER BY id LIMIT " . ( $pgr->get_first() - 1 ) . ", " . $pgr->get_entries_on_this_page(); - print STDERR $sql if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $sql); $sql = $astpp_db->prepare($sql); $sql->execute; @@ -3872,9 +3871,8 @@ sub default_callback { my (%stuff) = @_; foreach ( keys %stuff ) { - print STDERR "$_: " . $stuff{$_} . "\n"; + $ASTPP->debug( user=> $param->{username}, debug => "$_: " . $stuff{$_}); } - print STDERR "\n"; } sub build_statistics() { @@ -4584,7 +4582,7 @@ . $astpp_db->quote( $params->{desc} ) . ", " . $astpp_db->quote( $params->{charge} ) . ", " . $astpp_db->quote( $params->{sweep} ) . ", 1)"; - print STDERR "sql" if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $sql); if ( $astpp_db->do($sql) ) { $status .= gettext("Periodic Charge Added!"); } @@ -4715,7 +4713,7 @@ . $astpp_db->quote( $params->{sweep} ) . ", status = '1' WHERE id = " . $astpp_db->quote( $params->{chargeid} ); - print STDERR "sql" if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $sql); if ( $astpp_db->do($sql) ) { $status .= gettext("Periodic Charge Updated!"); } @@ -4729,7 +4727,7 @@ my $sql = "DELETE FROM charges WHERE id = " . $astpp_db->quote( $params->{chargeid} ); - print STDERR "sql" if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $sql); if ( $astpp_db->do($sql) ) { $status .= gettext("Periodic Charge Deleted!"); } @@ -4740,7 +4738,7 @@ $sql = "DELETE FROM charge_to_account WHERE charge_id = " . $astpp_db->quote( $params->{chargeid} ); - print STDERR $sql if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $sql); if ( $astpp_db->do($sql) ) { $status .= gettext("Periodic Charge Deleted!"); } @@ -4914,7 +4912,7 @@ $uploaded = upload('rateimport'); my ( @data, $record ); while ( my $record = <$uploaded> ) { - print STDERR $record if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $record ); chomp; push @data, $record; } @@ -4955,7 +4953,7 @@ . $astpp_db->quote( $columns[9] ) . "," . $astpp_db->quote( $columns[1] ) . ", 1," . $astpp_db->quote( $columns[10] ) . ")"; - print STDERR $tmp; # if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); if ( $astpp_db->do($tmp) ) { $status .= gettext("Pattern: ") . " '" . $pattern . "' " @@ -5044,7 +5042,7 @@ $uploaded = upload('rateimport'); my ( @data, $record ); while ( my $record = <$uploaded> ) { - print STDERR $record if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $record ); chomp; push @data, $record; } @@ -5076,7 +5074,7 @@ . " AND pricelist = " . $astpp_db->quote( $resellerdata->{pricelist} ) . " LIMIT 1"; - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp); $sql = $astpp_db->prepare($tmp); $sql->execute; while ( $row = $sql->fetchrow_hashref ) { @@ -5266,7 +5264,7 @@ . $astpp_db->quote( $columns[13] ) . "," . $astpp_db->quote( $columns[14] ) . "," . $astpp_db->quote( $columns[15] ) . ")"; - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp); if ( $astpp_db->do($tmp) ) { $status .= gettext("DID: ") . " '" @@ -5296,7 +5294,7 @@ gettext("The old pattern for") . " '" . $params->{number} . "' " . gettext("FAILED to remove!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $tmp = "INSERT INTO routes (pattern,comment,pricelist,connectcost,includedseconds,cost) VALUES (" @@ -5586,7 +5584,7 @@ gettext("Pricelist: ") . $params->{name} . gettext(" Failed to Reactivate!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } } else { @@ -5624,7 +5622,7 @@ gettext("Pricelist: ") . $params->{name} . gettext(" Failed to Add!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } } $params->{action} = gettext("Information..."); @@ -5666,7 +5664,7 @@ gettext("Pricelist: ") . $params->{name} . gettext(" Failed to Update!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } } else { @@ -5705,7 +5703,7 @@ gettext("Pricelist: ") . $params->{name} . gettext(" Failed to Deactivate!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } } $params->{action} = gettext("Information..."); @@ -5773,7 +5771,7 @@ $tmp = "SELECT * FROM pricelists WHERE status < 2 AND reseller IS NULL"; } - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); $sql = $astpp_db->prepare($tmp); $sql->execute || return gettext("Something is wrong with the ASTPP database!") @@ -5795,7 +5793,7 @@ $tmp = "SELECT * FROM pricelists WHERE status < 2 AND reseller IS NULL ORDER BY name limit $params->{limit} , $results_per_page"; } - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); $sql = $astpp_db->prepare($tmp); $sql->execute || return gettext("Something is wrong with the ASTPP database!") @@ -6158,7 +6156,7 @@ gettext("DID") . " '" . $params->{number} . "' " . gettext("FAILED to create!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $tmp = "DELETE FROM routes WHERE pattern = " @@ -6176,7 +6174,7 @@ gettext("The old pattern for") . " '" . $params->{number} . "' " . gettext("FAILED to remove!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $tmp = "INSERT INTO routes (pattern,comment,pricelist,connectcost,includedseconds,cost) VALUES (" @@ -6200,7 +6198,7 @@ gettext("Pattern") . " '" . $params->{number} . "' " . gettext("FAILED to create!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $params->{action} = gettext("Information..."); } @@ -6258,7 +6256,7 @@ gettext("DID") . " '" . $params->{number} . "' " . gettext("FAILED to update!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $tmp = "UPDATE routes SET" @@ -6288,7 +6286,7 @@ gettext("Pattern") . " '" . $params->{number} . "' " . gettext("FAILED to create!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $params->{action} = gettext("Information..."); } @@ -6307,7 +6305,7 @@ gettext("DID: ") . $params->{number} . gettext(" Failed to Deactivate!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $params->{action} = gettext("Information..."); } @@ -6900,7 +6898,7 @@ . $astpp_db->quote($params->{username}) . " AND type = '1' AND note = " . $astpp_db->quote($params->{number}); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); $astpp_db->do($tmp); $tmp = "INSERT INTO reseller_pricing (reseller,type,note,monthlycost,prorate,setup,cost,inc,disconnectionfee,connectcost,includedseconds,status) VALUES (" @@ -6916,7 +6914,7 @@ . $astpp_db->quote( $params->{connectcost} ) . "," . $astpp_db->quote( $params->{included} ) . ", '1')"; - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); if ( $astpp_db->do($tmp) ) { $status .= gettext("DID.") . " '" @@ -6928,7 +6926,7 @@ gettext("DID") . " '" . $params->{number} . "' " . gettext("FAILED to create!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $astpp_db->do("UPDATE dids SET dial_as = " . $astpp_db->quote($params->{dial_as})); $tmp = @@ -6936,7 +6934,7 @@ . $astpp_db->quote( "^" . $params->{number} . "\$" ) . " AND pricelist = " . $astpp_db->quote( $params->{username} ); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); if ( $astpp_db->do($tmp) ) { $status .= gettext("The old pattern for") . " '" @@ -6948,7 +6946,7 @@ gettext("The old pattern for") . " '" . $params->{number} . "' " . gettext("FAILED to remove!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $tmp = "INSERT INTO routes (pattern,comment,pricelist,connectcost,includedseconds,cost) VALUES (" @@ -6961,7 +6959,7 @@ . $astpp_db->quote( $params->{connectcost} ) . "," . $astpp_db->quote( $params->{included} ) . "," . $astpp_db->quote( $params->{cost} ) . ")"; - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); if ( $astpp_db->do($tmp) ) { $status .= gettext("Pattern") . " '" @@ -6973,7 +6971,7 @@ gettext("Pattern") . " '" . $params->{number} . "' " . gettext("FAILED to create!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $params->{action} = gettext("Information..."); } @@ -6983,7 +6981,7 @@ . $astpp_db->quote( $params->{number} ) . " AND type = '1' AND reseller = " . $astpp_db->quote( $params->{username} ); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); if ( $astpp_db->do($tmp) ) { $status .= gettext("DID: ") @@ -6995,7 +6993,7 @@ gettext("DID: ") . $params->{number} . gettext(" Failed to Deactivate!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $params->{action} = gettext("Information..."); } @@ -7365,7 +7363,7 @@ "SELECT * FROM routes WHERE id = " . $astpp_db->quote( $params->{id} ); } - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); $sql = $astpp_db->prepare($tmp); $sql->execute; $record = $sql->fetchrow_hashref; @@ -7467,7 +7465,7 @@ . " AND pricelist = " . $astpp_db->quote( $resellerdata->{pricelist} ) . " LIMIT 1"; - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); $sql = $astpp_db->prepare($tmp); $sql->execute; while ( $row = $sql->fetchrow_hashref ) { @@ -7503,7 +7501,7 @@ . $astpp_db->quote( $params->{cost} ) . "," . $astpp_db->quote( $params->{inc} ) . "," . $astpp_db->quote($reseller) . ")"; - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); if ( $astpp_db->do($tmp) ) { $status .= gettext("Pattern") . " '" @@ -7515,7 +7513,7 @@ gettext("Pattern") . " '" . $params->{pattern} . "' " . gettext("FAILED to create!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp); } $params->{action} = gettext("Information..."); } @@ -7533,15 +7531,14 @@ . " AND pricelist = " . $astpp_db->quote( $resellerdata->{pricelist} ) . " LIMIT 1"; - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp); $sql = $astpp_db->prepare($tmp); $sql->execute; while ( $row = $sql->fetchrow_hashref ) { $routeinfo = $row; } $sql->finish; - print STDERR "Reseller Cost = $routeinfo->{cost}" - if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "Reseller Cost = $routeinfo->{cost}" ); if ( $routeinfo->{cost} > $params->{cost} ) { $status .= "<br><b>" . gettext("Pattern: ") @@ -7586,7 +7583,7 @@ gettext("Pattern") . " '" . $params->{id} . "' " . gettext("FAILED to saved!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $params->{action} = gettext("Information..."); } @@ -7614,7 +7611,7 @@ gettext("Route: ") . $params->{id} . gettext(" Failed to Deactivate!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $params->{action} = gettext("Information..."); } @@ -7737,7 +7734,7 @@ $tmp = "SELECT * FROM routes WHERE status < 2 AND reseller IN (NULL,'')"; } - print STDERR $tmp if ( $config->{debug} == 1 ); + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); $sql = $astpp_db->prepare($tmp); $sql->execute || return gettext("Something is wrong with the ASTPP database!") @@ -7865,7 +7862,7 @@ my $results = $astpp_db->prepare($sql); $results->execute; while ( my $counterinfo = $results->fetchrow_hashref ) { - print STDERR "COUNTER: " . $counterinfo->{id} if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "COUNTER: " . $counterinfo->{id} ); my (%row); $row{id} = $counterinfo->{id}; $row{package} = $counterinfo->{name}; @@ -7927,7 +7924,7 @@ gettext("Package: ") . $params->{name} . gettext(" Failed to Add!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $params->{action} = gettext("Information..."); } @@ -7940,7 +7937,7 @@ . $astpp_db->quote( $params->{edit_includedseconds} ) . " WHERE id = " . $astpp_db->quote( $params->{id} ); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); if ( $astpp_db->do($tmp) ) { $status .= gettext("Package: ") @@ -7970,7 +7967,7 @@ gettext("Package: ") . $params->{id} . gettext(" Failed to Deactivate!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $params->{action} = gettext("Information..."); } @@ -7999,7 +7996,7 @@ my $results = $astpp_db->prepare($sql); $results->execute; while ( my $packageinfo = $results->fetchrow_hashref ) { - print STDERR "PACKAGE: " . $packgeinfo->{id} if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "PACKAGE: " . $packgeinfo->{id} ); my (%row); $row{id} = $packageinfo->{id}; $row{name} = $packageinfo->{name}; @@ -8096,22 +8093,18 @@ -default => $record->{precedence} ) . "</td><td>"; my @resellers = &list_resellers($astpp_db); - print STDERR "RESELLER LIST: $record->{resellers}" - if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "RESELLER LIST: $record->{resellers}"); foreach my $reseller (@resellers) { my $reseller_enabled; -# my $regex_pattern = "m\/'" . $reseller . "'\/"; # This cryptic bit of code searches for $reseller surrounded by quotation marks. -# print STDERR "REGEX PATTERN: $regex_pattern" if $config->{debug} == 1; if ( $record->{resellers} =~ m/'$reseller'/ ) { $reseller_enabled = 1; } else { $reseller_enabled = 0; } - print STDERR "RESELLER_ENABLED: $reseller_enabled" - if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "RESELLER_ENABLED: $reseller_enabled"); $body .= checkbox( -name => "reseller-$reseller", -checked => $reseller_enabled, @@ -8144,7 +8137,7 @@ . $astpp_db->quote( $params->{precedence} ) . ", " . $astpp_db->quote($resellerlist) . ", " . $astpp_db->quote( $params->{provider} ) . ")"; - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); if ( $astpp_db->do($tmp) ) { $status .= gettext("Trunk: ") @@ -8186,7 +8179,7 @@ . $astpp_db->quote( $params->{maxchannels} ) . " WHERE name = " . $astpp_db->quote( $params->{name} ); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); if ( $astpp_db->do($tmp) ) { $status .= gettext("Trunk: ") @@ -8198,7 +8191,7 @@ gettext("Trunk: ") . $params->{name} . gettext(" Failed to Update!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $params->{action} = gettext("Information..."); } @@ -8217,7 +8210,7 @@ gettext("Trunk: ") . $params->{name} . gettext(" Failed to Deactivate!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $tmp = "DELETE FROM routes WHERE trunk = " @@ -8227,7 +8220,7 @@ } else { $status .= gettext("Related Routes Failed to Remove!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $params->{action} = gettext("Information..."); } @@ -8292,21 +8285,16 @@ -size => 2 ) . "</td><td>"; my @resellers = &list_resellers($astpp_db); - print STDERR "RESELLER LIST: $record->{resellers}" - if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "RESELLER LIST: $record->{resellers}"); foreach my $reseller (@resellers) { my $reseller_enabled; - -# my $regex_pattern = "m\/'" . $reseller . "'\/"; # This cryptic bit of code searches for $reseller surrounded by quotation marks. -# print STDERR "REGEX PATTERN: $regex_pattern" if $config->{debug} == 1; if ( $record->{resellers} =~ m/'$reseller'/ ) { $reseller_enabled = 1; } else { $reseller_enabled = 0; } - print STDERR "RESELLER_ENABLED: $reseller_enabled" - if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "RESELLER_ENABLED: $reseller_enabled"); $body .= checkbox( -name => "reseller-$reseller", -checked => $reseller_enabled, @@ -8697,22 +8685,17 @@ -default => $record->{precedence} ) . "</td><td>"; my @resellers = &list_resellers($astpp_db); - print STDERR "RESELLER LIST: $record->{resellers}" - if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "RESELLER LIST: $record->{resellers}"); foreach my $reseller (@resellers) { my $reseller_enabled; - -# my $regex_pattern = "m\/'" . $reseller . "'\/"; # This cryptic bit of code searches for $reseller surrounded by quotation marks. -# print STDERR "REGEX PATTERN: $regex_pattern" if $config->{debug} == 1; if ( $record->{resellers} =~ m/'$reseller'/ ) { $reseller_enabled = 1; } else { $reseller_enabled = 0; } - print STDERR "RESELLER_ENABLED: $reseller_enabled" - if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "RESELLER_ENABLED: $reseller_enabled"); $body .= checkbox( -name => "reseller-$reseller", -checked => $reseller_enabled, @@ -8772,7 +8755,7 @@ gettext("Outbound Route: ") . " '" . $params->{pattern} . "' " . gettext("FAILED to create!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp); } $params->{action} = gettext("Information..."); } @@ -8820,7 +8803,7 @@ gettext("Outbound Route:") . " '" . $params->{id} . "' " . gettext("FAILED to saved!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $params->{action} = gettext("Information..."); } @@ -8828,7 +8811,7 @@ my $tmp = "UPDATE outbound_routes SET status = 2 WHERE id = " . $astpp_db->quote( $params->{id} ); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); if ( $astpp_db->do($tmp) ) { $status .= gettext("Outbound Route: ") @@ -8840,7 +8823,7 @@ gettext("Outbound Route: ") . $params->{id} . gettext(" Failed to Deactivate!"); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); } $params->{action} = gettext("Information..."); } @@ -8923,21 +8906,16 @@ -size => 2 ) . "</td><td>"; my @resellers = &list_resellers($astpp_db); - print STDERR "RESELLER LIST: $record->{resellers}" - if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "RESELLER LIST: $record->{resellers}"); foreach my $reseller (@resellers) { my $reseller_enabled; - -# my $regex_pattern = "m\/'" . $reseller . "'\/"; # This cryptic bit of code searches for $reseller surrounded by quotation marks. -# print STDERR "REGEX PATTERN: $regex_pattern" if $config->{debug} == 1; if ( $record->{resellers} =~ m/'$reseller'/ ) { $reseller_enabled = 1; } else { $reseller_enabled = 0; } - print STDERR "RESELLER_ENABLED: $reseller_enabled" - if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "RESELLER_ENABLED: $reseller_enabled"); $body .= checkbox( -name => "reseller-$reseller", -checked => $reseller_enabled, @@ -9144,10 +9122,9 @@ else { $increment = $branddata->{inc}; } - print STDERR "$numdata->{connectcost}, $numdata->{cost}, " + $ASTPP->debug( user=> $param->{username}, debug => "$numdata->{connectcost}, $numdata->{cost}, " . $params->{length} * 60 - . ", $increment, $numdata->{includedseconds}" - if $config->{debug} == 1; + . ", $increment, $numdata->{includedseconds}"); my $cost = &calc_call_cost( $numdata->{connectcost}, $numdata->{cost}, $params->{length} * 60, $increment, @@ -9216,7 +9193,7 @@ "SELECT * FROM system WHERE reseller = " . $astpp_db->quote( $params->{username} ) . " ORDER BY name"; } - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp); my $sql = $astpp_db->prepare($tmp); $sql->execute; while ( my $record = $sql->fetchrow_hashref ) { @@ -9357,9 +9334,7 @@ . $rt_db->quote( $params->{rt_sip_cancallforward} ) . " WHERE id = " . $rt_db->quote( $params->{devicenumber} ); - if ( $config->{debug} == 1 ) { - print STDERR " $tmp \n" if $config->{debug} == 1; - } + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); if ( $rt_db->do($tmp) ) { $status .= gettext("Updated Device:") . " $params->{name}<br>"; } @@ -9733,7 +9708,7 @@ . int( rand() * 9000 + 1000 ); $sipid = substr( $sipid, 0, 5 ); $sipid = $name . $sipid; - print STDERR "SIPID: $sipid\n" if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "SIPID: $sipid" ); $sql = $rt_db->prepare( "SELECT COUNT(*) FROM $config->{rt_sip_table} WHERE name = " @@ -9821,9 +9796,7 @@ . $rt_db->quote( $params->{rt_codec_allow} ) . " WHERE name = " . $rt_db->quote( $params->{devicenumber} ); - if ( $config->{debug} == 1 ) { - print STDERR " $tmp \n" if $config->{debug} == 1; - } + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); if ( $rt_db->do($tmp) ) { $status .= gettext("Updated Device:") . " $params->{devicenumber}<br>"; @@ -10161,7 +10134,7 @@ . int( rand() * 9000 + 1000 ); $iaxid = substr( $iaxid, 0, 5 ); $iaxid = $name . $iaxid; - print STDERR "IAXID: $iaxid\n" if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "IAXID: $iaxid"); $sql = $rt_db->prepare( "SELECT COUNT(*) FROM $config->{rt_iax_table} WHERE name = " @@ -10234,9 +10207,7 @@ . $rt_db->quote( $params->{appdata} ) . " WHERE id = " . $rt_db->quote( $params->{id} ); - if ( $config->{debug} == 1 ) { - print STDERR " $tmp \n" if $config->{debug} == 1; - } + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); if ( $rt_db->do($tmp) ) { $status .= gettext("Updated Dialplan Entry:") . " $params->{id}<br>"; @@ -10507,7 +10478,7 @@ . $astpp_db->quote( $params->{osc_dbuser} ) . ", " . $astpp_db->quote( $params->{osc_dbhost} ) . ", " . $astpp_db->quote( $params->{osc_site} ) . ", 1)"; - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); if ( $astpp_db->do($tmp) ) { $status .= gettext("CallShop Added Successfully!"); } @@ -10555,7 +10526,7 @@ $tmp = "DELETE FROM callshops WHERE name = " . $astpp_db->quote( $params->{callshop} ); - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); if ( $astpp_db->do($tmp) ) { $status .= gettext("CallShop") @@ -10625,7 +10596,7 @@ . $astpp_db->quote( $params->{number} ) . " LIMIT 1" ); if ( $params->{SIP} ) { - print STDERR gettext("Adding SIP Device!") if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => gettext("Adding SIP Device!")); $config->{rt_sip_type} = "friend"; #$params->{devicetype}; $config->{ipaddr} = $params->{ipaddr}; if ( $config->{users_dids_rt} == 1 ) { @@ -10663,8 +10634,7 @@ } } if ( $params->{IAX2} ) { - print STDERR gettext("Adding IAX2 Device!") - if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => gettext("Adding IAX2 Device!")); $config->{rt_iax_type} = "friend"; #$params->{devicetype}; $config->{ipaddr} = $params->{ipaddr}; if ( $config->{users_dids_amp} == 1 ) { @@ -10715,7 +10685,7 @@ . $osc_db->quote( $params->{number} ) . ",''," . $osc_db->quote( $config->{emailadd} ) . ",''," . $osc_db->quote( $params->{accountpassword} ) . ",'')"; - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); $sql = $osc_db->prepare($tmp); $sql->execute; my $customerid = $sql->{'mysql_insertid'}; @@ -10723,7 +10693,7 @@ $tmp = "INSERT INTO customers_info (customers_info_id) VALUES (" . $osc_db->quote($customerid) . ")"; - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); $sql = $osc_db->prepare($tmp); $sql->execute; $sql->finish; @@ -10735,7 +10705,7 @@ . $osc_db->quote( $params->{number} ) . ",''," . "'Address','Postal Code','City','State'," . $osc_db->quote( $record->{countries_id} ) . ",'0')"; - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); $sql = $osc_db->prepare($tmp); $sql->execute; my $addressid = $sql->{'mysql_insertid'}; @@ -10786,7 +10756,7 @@ . $astpp_db->quote( $params->{booth_name} ) . " AND reseller = " . $astpp_db->quote( $params->{username} ); - print STDERR $sql if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $sql); if ( $astpp_db->do($sql) ) { $status .= gettext("Booth:") . " " @@ -10803,9 +10773,7 @@ #If this account doesn't exist we don't go through the rest if ( $accountinfo->{number} ) { if ( $config->{users_dids_rt} == 1 ) { - print STDERR - "NUMBER: $accountinfo->{number} CC: $accountinfo->{cc}" - if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "NUMBER: $accountinfo->{number} CC: $accountinfo->{cc}"); my @iax_devicelist = &list_iax_account_rt( $rt_db, $config, $accountinfo->{number}, @@ -10826,9 +10794,7 @@ } } if ( $config->{users_dids_amp} == 1 ) { - print STDERR - "NUMBER: $accountinfo->{number} CC: $accountinfo->{cc}" - if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "NUMBER: $accountinfo->{number} CC: $accountinfo->{cc}" ); my @iax_devicelist = &list_iax_account_amp( $freepbx_db, $config, $accountinfo->{number}, @@ -10874,11 +10840,15 @@ if ( $params->{action} eq gettext("Deactivate Booth") ) { $astpp_db->do( "UPDATE accounts SET status = 0 WHERE number = " . $astpp_db->quote( $params->{booth_name} ) ); + &hangup_call($astpp_db,$config,$params->{channel}); } elsif ( $params->{action} eq gettext("Restore Booth") ) { $astpp_db->do( "UPDATE accounts SET status = 1 WHERE number = " . $astpp_db->quote( $params->{booth_name} ) ); } + elsif ( $params->{action} eq gettext("Hangup Call") ) { + &hangup_call($astpp_db,$config,$params->{channel}); + } foreach my $name (@booth_list) { my ( %row, $balance, $tmp, $sql ); my $boothinfo = &get_account_including_closed( $astpp_db, $name ); @@ -10902,7 +10872,7 @@ . " WHERE accountcode = " . $rt_db->quote( $boothinfo->{cc} ) . " LIMIT 1"; - print STDERR $tmp; # if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); my $sql = $rt_db->prepare($tmp); $sql->execute; $sip_login = $sql->fetchrow_hashref; @@ -10913,7 +10883,7 @@ . " WHERE accountcode = " . $rt_db->quote( $boothinfo->{cc} ) . " LIMIT 1"; - print STDERR $tmp; # if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); $sql = $rt_db->prepare($tmp); $sql->execute; $iax2_login = $sql->fetchrow_hashref; @@ -10940,7 +10910,7 @@ . " ORDER BY id DESC LIMIT 1"; } if ( $tmp ne "" ) { - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); $sql = $astpp_db->prepare($tmp); $sql->execute; $booth_status = $sql->fetchrow_hashref; @@ -10949,10 +10919,11 @@ if ( $row{callstart} ne "" && $booth_status->{status} eq "Dial" || $booth_status->{status} eq "Answer" ) { + $row{channel} = $booth_status->{Channel}; $row{number} = $booth_status->{number}; my $tmp = "SELECT TIMEDIFF(NOW(),'$row{callstart}') AS length"; - print STDERR $tmp; + $ASTPP->debug( user=> $param->{username}, debug => $tmp); $sql = $astpp_db->prepare($tmp); $sql->execute; my $record = $sql->fetchrow_hashref; @@ -11006,11 +10977,9 @@ } push( @booths, \%row ); $sql->finish; - if ( $config->{debug} == 1 ) { - print STDERR $tmp; - print STDERR $record->{"COUNT(*)"}; - print STDERR $balance / 10000; - } + $ASTPP->debug( user=> $param->{username}, debug => $tmp); + $ASTPP->debug( user=> $param->{username}, debug => $record->{"COUNT(*)"}); + $ASTPP->debug( user=> $param->{username}, debug => $balance / 10000); } my $template = @@ -11052,9 +11021,9 @@ if ( $config->{externalbill} eq "oscommerce" ) { if ( $accountinfo->{posttoexternal} == 1 ) { - print STDERR gettext("Connecting to OSCommerce."); + $ASTPP->debug( user=> $param->{username}, debug => gettext("Connecting to OSCommerce.")); my $osc_db = &osc_connect_db( $config ); - print STDERR gettext("Generating Invoice"); + $ASTPP->debug( user=> $param->{username}, debug => gettext("Generating Invoice")); $invoiceno = &osc_charges( $astpp_db, $osc_db, $config, $params->{booth_name} ); @@ -11097,7 +11066,7 @@ . " WHERE accountcode = " . $rt_db->quote( $accountinfo->{cc} ) . " LIMIT 1"; - print STDERR $tmp; # if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); my $sql = $rt_db->prepare($tmp); $sql->execute; $sip_login = $sql->fetchrow_hashref; @@ -11108,7 +11077,7 @@ . " WHERE accountcode = " . $rt_db->quote( $accountinfo->{cc} ) . " LIMIT 1"; - print STDERR $tmp; # if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp ); $sql = $rt_db->prepare($tmp); $sql->execute; $iax2_login = $sql->fetchrow_hashref; @@ -11124,7 +11093,7 @@ . $astpp_db->quote( $params->{booth_name} ) . "and status = 0" . " ORDER BY callstart DESC"; - print STDERR $tmp if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $tmp); $sql = $astpp_db->prepare($tmp); $sql->execute; @@ -11158,7 +11127,7 @@ else { $record->{credit} = "-"; } - print STDERR $record->{id} if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => $record->{id}); $record->{profit} = ( $record->{debit} - $record->{cost} ); push( @cdrs, $record ); } @@ -11170,7 +11139,7 @@ my $balance = &accountbalance( $astpp_db, $params->{booth_name} ) / 10000; my $unrated = &count_unrated_cdrs_account( $cdr_db, $accountinfo->{number}, $accountinfo->{cc} ); - print STDERR $balance; + $ASTPP->debug( user=> $param->{username}, debug => $balance); $template->param( unrated_cdrs => $unrated ); $template->param( booths => $booths ); $template->param( balance => $balance ); @@ -11189,7 +11158,7 @@ die_on_bad_params => $config->{template_die_on_bad_params} ); foreach my $param ( param() ) { $params->{$param} = param($param); - print STDERR "$param $params->{$param}\n" if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "$param $params->{$param}" ); } if ( !$params->{mode} ) { $params->{mode} = gettext("Home"); @@ -11208,9 +11177,9 @@ if ( $loginstat == 1 ) { # In here we setup privileges for the different account levels - print STDERR "LOGIN TYPE = $params->{logintype}\n" if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "LOGIN TYPE = $params->{logintype}"); if ( $params->{logintype} == 0 ) { # User Login - Not allowed to do anything - print STDERR "ASTPP USER LOGIN - DISABLED\n" if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "ASTPP USER LOGIN - DISABLED"); @modes = (); } elsif ( $params->{logintype} == 1 ) { # Reseller Login @@ -11222,7 +11191,7 @@ if $config->{users_dids_amp} == 1; $rt_db = &rt_connect_db( $config, @output ) if $config->{users_dids_rt} == 1; - print STDERR "ASTPP RESELLER LOGIN\n" if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "ASTPP RESELLER LOGIN" ); @modes = ( gettext("Accounts"), gettext("Rates"), gettext("DIDs"), gettext("Logout"), @@ -11252,7 +11221,7 @@ $params->{logged_in_reseller} = $params->{username}; } elsif ( $params->{logintype} == 2 ) { - print STDERR "ASTPP ADMINISTRATOR LOGIN\n" if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "ASTPP ADMINISTRATOR LOGIN"); @modes = ( gettext("Accounts"), gettext("Rates"), gettext("DIDs"), gettext("Statistics"), @@ -11286,14 +11255,14 @@ } elsif ( $params->{logintype} == 3 ) { # Vendor Login - Vendors are only allowed to look at stuff that pertains to them. - print STDERR "ASTPP VENDOR LOGIN\n" if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "ASTPP VENDOR LOGIN" ); @modes = ( gettext("Trunk Statistics"), gettext("View CDRs"), gettext("Home"), gettext("Outbound Routes") ); } elsif ( $params->{logintype} == 4 ) { # Customer Service Login - print STDERR "ASTPP CUSTOMER SERVICE LOGIN\n" if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "ASTPP CUSTOMER SERVICE LOGIN" ); @modes = ( gettext("Accounts"), gettext("DIDs"), gettext("Statistics"), gettext("Home") @@ -11320,7 +11289,7 @@ if $config->{users_dids_rt} == 1; $osc_db = &osc_connect_db( $config, $config, @output ) if $config->{externalbill} eq "oscommerce"; - print STDERR "ASTPP CALLSHOP LOGIN\n" if $config->{debug} == 1; + $ASTPP->debug( user=> $param->{username}, debug => "ASTPP CALLSHOP LOGIN" ); @modes = ( gettext("Booths"), gettext("Home"), gettext("Routes"), gettext("Pricelists"), gettext("CallShop Reports") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-05-31 20:44:14
|
Revision: 2182 http://astpp.svn.sourceforge.net/astpp/?rev=2182&view=rev Author: darrenkw Date: 2008-05-31 13:44:22 -0700 (Sat, 31 May 2008) Log Message: ----------- Finished the logging support as per [ 1825335 ] DID Change Logs. Modified Paths: -------------- trunk/astpp-admin.cgi Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2008-05-25 23:15:33 UTC (rev 2181) +++ trunk/astpp-admin.cgi 2008-05-31 20:44:22 UTC (rev 2182) @@ -11136,10 +11136,15 @@ my $template = HTML::Template->new( filename => '/var/lib/astpp/templates/main.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); +my $log_call = "astpp-admin.cgi,user=$param->{username}"; foreach my $param ( param() ) { $params->{$param} = param($param); $ASTPP->debug( user=> $param->{username}, debug => "$param $params->{$param}" ); + $log_call .= "$param=$params->{param},"; } + +$ASTPP->debug( debug => $log_call ); + if ( !$params->{mode} ) { $params->{mode} = gettext("Home"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |