Fixed minor logging bug in manager_send.php

Added AST_GROUP_ALIASstats.php report

git-svn-id: svn://192.168.202.10@1226 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2009-09-14 15:38:03 +00:00
parent 5c4662a32d
commit dbd0c43c5c
7 changed files with 297 additions and 94 deletions
+28 -6
View File
@@ -25,6 +25,7 @@
# 90807-1632 - Fixed call time bug and call length bug # 90807-1632 - Fixed call time bug and call length bug
# 90825-1249 - Added without-camp and without-in options # 90825-1249 - Added without-camp and without-in options
# 90902-0437 - Added outbound-calltime-ignore and ftp-norun options # 90902-0437 - Added outbound-calltime-ignore and ftp-norun options
# 90909-2322 - Added totals-only option
# #
$txt = '.txt'; $txt = '.txt';
@@ -46,6 +47,13 @@ $campaign = 'TESTCAMP';
$sale_statuses = 'SALE-UPSELL'; $sale_statuses = 'SALE-UPSELL';
$output_format = 'pipe-standard'; $output_format = 'pipe-standard';
$outbound_calltime_ignore=0; $outbound_calltime_ignore=0;
$totals_only=0;
$OUTcalls=0;
$OUTtalk=0;
$OUTtalkmin=0;
$INcalls=0;
$INtalk=0;
$INtalkmin=0;
$secX = time(); $secX = time();
$time = $secX; $time = $secX;
@@ -106,6 +114,7 @@ if (length($ARGV[0])>1)
print " [--without-in=XXX-XXY] = inbound groups that will be excluded from ALL\n"; print " [--without-in=XXX-XXY] = inbound groups that will be excluded from ALL\n";
print " [--calltime=XXX] = filter results to only include those calls during this call time\n"; print " [--calltime=XXX] = filter results to only include those calls during this call time\n";
print " [--outbound-calltime-ignore] = for outbound calls ignores call time\n"; print " [--outbound-calltime-ignore] = for outbound calls ignores call time\n";
print " [--totals-only] = print totals of time and calls only\n";
print " [--ftp-transfer] = Send results file by FTP to another server\n"; print " [--ftp-transfer] = Send results file by FTP to another server\n";
print " [--ftp-audio-transfer] = Send associated audio files to FTP server, dated directories\n"; print " [--ftp-audio-transfer] = Send associated audio files to FTP server, dated directories\n";
print " [--ftp-norun] = Stop program when you get to the FTP transfer\n"; print " [--ftp-norun] = Stop program when you get to the FTP transfer\n";
@@ -137,6 +146,8 @@ if (length($ARGV[0])>1)
{ {
$q=1; $Q=1; $q=1; $Q=1;
} }
if ($args =~ /-totals-only/i)
{$totals_only=1;}
if ($args =~ /--date=/i) if ($args =~ /--date=/i)
{ {
@@ -738,14 +749,22 @@ if ($ftp_transfer > 0)
$ftp->quit; $ftp->quit;
} }
if ( ($DB) && ($output_format =~ /^tab-QMcustomUSA$/) ) if ( ( ($DB) || ($totals_only > 0) ) && ($output_format =~ /^tab-QMcustomUSA$/) )
{ {
$OUTtalkmin = ($OUTtalk / 60); if ($OUTtalk > 0) {$OUTtalkmin = ($OUTtalk / 60);}
$INtalkmin = ($INtalk / 60); if ($INtalk > 0) {$INtalkmin = ($INtalk / 60);}
$OUTtalkmin = sprintf("%10.2f",$OUTtalkmin);
$INtalkmin = sprintf("%10.2f",$INtalkmin);
$OUTcalls = sprintf("%10s",$OUTcalls);
$INcalls = sprintf("%10s",$INcalls);
$OUTtalk = sprintf("%10s",$OUTtalk);
$INtalk = sprintf("%10s",$INtalk);
print "OUTBOUND CALLS: $OUTcalls\n"; print "OUTBOUND CALLS: $OUTcalls\n";
print "OUTBOUND TIME: $OUTtalk $OUTtalkmin\n"; print "OUTBOUND SECONDS: $OUTtalk\n";
print "OUTBOUND MINUTES: $OUTtalkmin\n";
print "INBOUND CALLS: $INcalls\n"; print "INBOUND CALLS: $INcalls\n";
print "INBOUND TIME: $INtalk $INtalkmin\n"; print "INBOUND SECONDS: $INtalk\n";
print "INBOUND MINUTES: $INtalkmin\n";
} }
if ($ftp_audio_transfer > 0) if ($ftp_audio_transfer > 0)
@@ -962,6 +981,7 @@ sub select_format_loop
$sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr; $sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr;
$sthB->execute or die "executing: $stmtB ", $dbhB->errstr; $sthB->execute or die "executing: $stmtB ", $dbhB->errstr;
$sthBrows=$sthB->rows; $sthBrows=$sthB->rows;
if ($DBX > 0) {print "$sthBrows|$stmtB\n";}
$rec_countB=0; $rec_countB=0;
while ($sthBrows > $rec_countB) while ($sthBrows > $rec_countB)
{ {
@@ -983,6 +1003,7 @@ sub select_format_loop
$sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr; $sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr;
$sthB->execute or die "executing: $stmtB ", $dbhB->errstr; $sthB->execute or die "executing: $stmtB ", $dbhB->errstr;
$sthBrowsR=$sthB->rows; $sthBrowsR=$sthB->rows;
if ($DBX > 0) {print "$sthBrowsR|$stmtB\n";}
$rec_countBR=0; $rec_countBR=0;
while ($sthBrowsR > $rec_countBR) while ($sthBrowsR > $rec_countBR)
{ {
@@ -1059,7 +1080,7 @@ sub select_format_loop
# } # }
} }
} }
##### BEGIN DID lookup ##### ##### END DID lookup #####
if ($status =~ /UPSELL/) {$UPSELL='L5';} if ($status =~ /UPSELL/) {$UPSELL='L5';}
else {$UPSELL='N';} else {$UPSELL='N';}
@@ -1185,6 +1206,7 @@ sub select_format_loop
$uniqueidLIST .= "$uniqueid|"; $uniqueidLIST .= "$uniqueid|";
if ($DBX > 0) {print "UNIQUE: -----$uniqueidLIST-----$uniqueid";} if ($DBX > 0) {print "UNIQUE: -----$uniqueidLIST-----$uniqueid";}
# if ($DBX > 0) {print "$uniqueid|$talk_seconds|$outbound|$INcalls|$OUTcalls\n";}
if ($outbound =~ /Y/) {$OUTtalk = ($OUTtalk + $talk_seconds); $OUTcalls++;} if ($outbound =~ /Y/) {$OUTtalk = ($OUTtalk + $talk_seconds); $OUTcalls++;}
else {$INtalk = ($INtalk + $talk_seconds); $INcalls++;} else {$INtalk = ($INtalk + $talk_seconds); $INcalls++;}
+5
View File
@@ -12,6 +12,11 @@ If you want to skip the experience of installing step-by-step completely, take
a look at our ISO installer: http://www.vicibox.com a look at our ISO installer: http://www.vicibox.com
This document will be depricated and not supported after the 2.2.0 release.
This document is meant to be a very in-depth step-by-step explanation of This document is meant to be a very in-depth step-by-step explanation of
installing the Asterisk open-source PBX on a Linux system and also installing installing the Asterisk open-source PBX on a Linux system and also installing
the astGUIclient suite. The instructions will assume starting from nothing and the astGUIclient suite. The instructions will assume starting from nothing and
+12 -83
View File
@@ -1,11 +1,11 @@
Ubuntu VICIDIAL Install: 2009-05-19 Ubuntu VICIDIAL Install: 2009-09-13
### NOTE ### ### NOTE ###
If you just want a quick setup of ViciDial on Ubuntu, take a look at our If you just want a quick setup of ViciDial on Ubuntu, take a look at our
downloadable ViciBox server install ISO available at: http://www.vicibox.com downloadable ViciBox server install ISO available at: http://www.vicibox.com
From a full default install of Ubuntu Server 8.0.4.2: From a full default install of Ubuntu Server 8.0.4.3:
Open a terminal on the system Open a terminal on the system
$ sudo su $ sudo su
@@ -13,10 +13,10 @@ $ passwd (set the root user's password)
$ apt-get update (retrieves the latest repository information) $ apt-get update (retrieves the latest repository information)
$ apt-get upgrade (upgrades any out of date packages $ apt-get upgrade (upgrades any out of date packages
$ apt-get install linux-server (install the latest version of the linux kernel) $ apt-get install linux-headers-server (Used for zaptel compil)
$ reboot (reboot to use the new kernel) $ reboot (reboot to use the new kernel)
apt-get install the following packages: 'apt-get install' the following packages:
apache2 (web server) apache2 (web server)
apache2-mpm-prefork (multi threaded portion to apache2) apache2-mpm-prefork (multi threaded portion to apache2)
build-essential (this is the build tool chain for gcc) build-essential (this is the build tool chain for gcc)
@@ -27,7 +27,6 @@ libncurses5-dev
libploticus0-dev libploticus0-dev
libsox-fmt-all (encoding and decoding libraries for sox) libsox-fmt-all (encoding and decoding libraries for sox)
linux-source (needed if you are going to recompile the linux kernel) linux-source (needed if you are going to recompile the linux kernel)
linux-headers-KERNELVERSION-server (where KERNELVERSION is your current kernel version IE 2.6.24-24. Used for zaptel compile)
mpg123 (mp3 playback utility for the commandline) mpg123 (mp3 playback utility for the commandline)
mtop (utility for monitoring mysql) mtop (utility for monitoring mysql)
mysql-client-5.0 (command for connecting to mysql) mysql-client-5.0 (command for connecting to mysql)
@@ -49,7 +48,8 @@ subversion (code versioning tool)
subversion-tools subversion-tools
unzip unzip
libcurl3 libcurl3
curl curl
vim
Go to terminal: Go to terminal:
@@ -176,10 +176,10 @@ $ modprobe zaptel
$ modprobe ztdummy $ modprobe ztdummy
****FOR 1.4 asterisk do the following: ****FOR 1.4 asterisk do the following:
$ wget http://downloads.digium.com/pub/asterisk/old-releases/asterisk-1.4.21.2.tar.gz $ wget http://downloads.vicidial.com/required-apps/asterisk-1.4.21.2-vic.tar.gz
$ wget http://downloads.digium.com/pub/zaptel/zaptel-1.4.12.1.tar.gz $ wget http://downloads.digium.com/pub/zaptel/zaptel-1.4.12.1.tar.gz
$ wget http://downloads.digium.com/pub/libpri/libpri-1.4.9.tar.gz $ wget http://downloads.asterisk.org/pub/telephony/libpri/old/libpri-1.4.10.1.tar.gz
$ tar xzf asterisk-1.4.21.2.tar.gz $ tar xzf asterisk-1.4.21.2-vici.tar.gz
$ tar xzf zaptel-1.4.12.1.tar.gz $ tar xzf zaptel-1.4.12.1.tar.gz
$ tar xzf libpri-1.4.9.tar.gz $ tar xzf libpri-1.4.9.tar.gz
$ cd libpri-1.4.9 $ cd libpri-1.4.9
@@ -187,22 +187,6 @@ $ make clean; make; make install
$ cd ../zaptel-1.4.12.1 $ cd ../zaptel-1.4.12.1
$ ./configure; make clean; make; make install $ ./configure; make clean; make; make install
$ cd ../asterisk-1.4.21.2 $ cd ../asterisk-1.4.21.2
$ wget http://www.eflo.net/files/enter.h
$ wget http://www.eflo.net/files/leave.h
$ mv -f enter.h apps/enter.h
$ mv -f leave.h apps/leave.h
$ vi codecs/gsm/Makefile
add OPTIMIZE=-O2 to the file before the ifeq section, to fix GSM audio problems
$ wget http://download.vicidial.com/conf/res_agi_defunct.patch
$ patch -p1 < res_agi_defunct.patch
File to patch: res/res_agi.c
$ cd apps/
$ rm app_waitforsilence.c
$ wget http://download.vicidial.com/conf/app_waitforsilence.c
$ cd ../channels/
$ rm chan_sip.c
$ wget http://download.vicidial.com/conf/chan_sip.c
$ cd ../
$ ./configure; make clean; make; make install $ ./configure; make clean; make; make install
$ make samples $ make samples
$ modprobe zaptel $ modprobe zaptel
@@ -214,59 +198,6 @@ $ asterisk -vvvvvvvvvvvvvvvvvvvvvvvvvvvvgc (to see if Asterisk runs)
> show application meetme > show application meetme
> stop now > stop now
*** for asterisk 1.2
$ cd /var/lib/asterisk/mohmp3/
$ mpg123 -s --rate 44100 --mono /var/lib/asterisk/mohmp3/fpm-sunshine.mp3 > /var/lib/asterisk/mohmp3/fpm-sunshine.raw
$ sox -r 44100 -w -s -c 1 fpm-sunshine.raw -r 8000 -c 1 fpm-sunshine.wav
$ sox fpm-sunshine.wav -t gsm -r 8000 -b -c 1 fpm-sunshine.gsm
$ sox fpm-sunshine.wav -t ul -r 8000 -b -c 1 fpm-sunshine.pcm
$ mpg123 -s --rate 44100 --mono /var/lib/asterisk/mohmp3/fpm-calm-river.mp3 > /var/lib/asterisk/mohmp3/fpm-calm-river.raw
$ sox -r 44100 -w -s -c 1 fpm-calm-river.raw -r 8000 -c 1 fpm-calm-river.wav
$ sox fpm-calm-river.wav -t gsm -r 8000 -b -c 1 fpm-calm-river.gsm
$ sox fpm-calm-river.wav -t ul -r 8000 -b -c 1 fpm-calm-river.pcm
$ mpg123 -s --rate 44100 --mono /var/lib/asterisk/mohmp3/fpm-world-mix.mp3 > /var/lib/asterisk/mohmp3/fpm-world-mix.raw
$ sox -r 44100 -w -s -c 1 fpm-world-mix.raw -r 8000 -c 1 fpm-world-mix.wav
$ sox fpm-world-mix.wav -t gsm -r 8000 -b -c 1 fpm-world-mix.gsm
$ sox fpm-world-mix.wav -t ul -r 8000 -b -c 1 fpm-world-mix.pcm
$ mkdir ../orig-mp3
$ mv -f *.mp3 ../orig-mp3/
$ mkdir ../quiet-mp3
$ cd ../quiet-mp3
$ sox -r 44100 -w -s -c 1 ../mohmp3/fpm-sunshine.raw -r 8000 -c 1 fpm-sunshine.wav vol 0.25
$ sox fpm-sunshine.wav -t gsm -r 8000 -b -c 1 fpm-sunshine.gsm
$ sox fpm-sunshine.wav -t ul -r 8000 -b -c 1 fpm-sunshine.pcm
$ sox -r 44100 -w -s -c 1 ../mohmp3/fpm-calm-river.raw -r 8000 -c 1 fpm-calm-river.wav vol 0.25
$ sox fpm-calm-river.wav -t gsm -r 8000 -b -c 1 fpm-calm-river.gsm
$ sox fpm-calm-river.wav -t ul -r 8000 -b -c 1 fpm-calm-river.pcm
$ sox -r 44100 -w -s -c 1 ../mohmp3/fpm-world-mix.raw -r 8000 -c 1 fpm-world-mix.wav vol 0.25
$ sox fpm-world-mix.wav -t gsm -r 8000 -b -c 1 fpm-world-mix.gsm
$ sox fpm-world-mix.wav -t ul -r 8000 -b -c 1 fpm-world-mix.pcm
$ rm -f ../mohmp3/*.raw
**** for asterisk 1.4
$ cp -a /var/lib/asterisk/moh /var/lib/asterisk/mohmp3/
$ cd /var/lib/asterisk/mohmp3/
$ sox fpm-sunshine.wav -t gsm -r 8000 -b -c 1 fpm-sunshine.gsm
$ sox fpm-sunshine.wav -t ul -r 8000 -b -c 1 fpm-sunshine.pcm
$ sox fpm-calm-river.wav -t gsm -r 8000 -b -c 1 fpm-calm-river.gsm
$ sox fpm-calm-river.wav -t ul -r 8000 -b -c 1 fpm-calm-river.pcm
$ sox -r 44100 -w -s -c 1 fpm-world-mix.raw -r 8000 -c 1 fpm-world-mix.wav
$ sox fpm-world-mix.wav -t gsm -r 8000 -b -c 1 fpm-world-mix.gsm
$ sox fpm-world-mix.wav -t ul -r 8000 -b -c 1 fpm-world-mix.pcm
$ mkdir ../quiet-mp3
$ cd ../quiet-mp3
$ sox ../mohmp3/fpm-sunshine.wav -r 8000 -c 1 fpm-sunshine.wav vol 0.25
$ sox fpm-sunshine.wav -t gsm -r 8000 -b -c 1 fpm-sunshine.gsm
$ sox fpm-sunshine.wav -t ul -r 8000 -b -c 1 fpm-sunshine.pcm
$ sox ../mohmp3/fpm-calm-river.wav -r 8000 -c 1 fpm-calm-river.wav vol 0.25
$ sox fpm-calm-river.wav -t gsm -r 8000 -b -c 1 fpm-calm-river.gsm
$ sox fpm-calm-river.wav -t ul -r 8000 -b -c 1 fpm-calm-river.pcm
$ sox ../mohmp3/fpm-world-mix.wav -r 8000 -c 1 fpm-world-mix.wav vol 0.25
$ sox fpm-world-mix.wav -t gsm -r 8000 -b -c 1 fpm-world-mix.gsm
$ sox fpm-world-mix.wav -t ul -r 8000 -b -c 1 fpm-world-mix.pcm
**** for SVN 2.0.5 branch: **** for SVN 2.0.5 branch:
$ mkdir /usr/src/astguiclient $ mkdir /usr/src/astguiclient
$ cd /usr/src/astguiclient $ cd /usr/src/astguiclient
@@ -285,13 +216,11 @@ $ perl install.pl
: press enter until you get to webroot and set that to the following: /var/www : press enter until you get to webroot and set that to the following: /var/www
: press enter through to the Sample configuration files and set that to 'y' : press enter through to the Sample configuration files and set that to 'y'
: press enter through to the end of the script : press enter through to the end of the script
: add the highlighted lines to the top of your [default] context:
$ vi /etc/asterisk/extensions.conf
$ cd /var/lib/asterisk/sounds $ cd /var/lib/asterisk/sounds
$ wget http://downloads.vicidial.com/sounds/conf.gsm $ wget http://downloads.vicidial.com/conf/conf.gsm
$ cp conf.gsm park.gsm $ cp conf.gsm park.gsm
$ mysql $ mysql -p (enter the mysql root user's password you set earlier)
> CREATE DATABASE `asterisk` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; > CREATE DATABASE `asterisk` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
> GRANT SELECT,INSERT,UPDATE,DELETE,LOCK TABLES on asterisk.* TO cron@'%' IDENTIFIED BY '1234'; > GRANT SELECT,INSERT,UPDATE,DELETE,LOCK TABLES on asterisk.* TO cron@'%' IDENTIFIED BY '1234';
> GRANT SELECT,INSERT,UPDATE,DELETE,LOCK TABLES on asterisk.* TO cron@localhost IDENTIFIED BY '1234'; > GRANT SELECT,INSERT,UPDATE,DELETE,LOCK TABLES on asterisk.* TO cron@localhost IDENTIFIED BY '1234';
@@ -328,7 +257,7 @@ $ crontab -e
### updater for VICIDIAL hopper ### updater for VICIDIAL hopper
* * * * * /usr/share/astguiclient/AST_VDhopper.pl -q * * * * * /usr/share/astguiclient/AST_VDhopper.pl -q
### adjust the GMT offset for the leads in the vicidial_list table ### adjust the GMT offset for the leads in the vicidial_list table
1 1,7 * * * /usr/share/astguiclient/ADMIN_adjust_GMTnow_on_leads.pl --debug --postal-code-gmt 1 1,7 * * * /usr/share/astguiclient/ADMIN_adjust_GMTnow_on_leads.pl --debug
### reset several temporary-info tables in the database ### reset several temporary-info tables in the database
2 1 * * * /usr/share/astguiclient/AST_reset_mysql_vars.pl 2 1 * * * /usr/share/astguiclient/AST_reset_mysql_vars.pl
### optimize the database tables within the asterisk database ### optimize the database tables within the asterisk database
@@ -1786,7 +1786,7 @@ remove ENUM('Y','N') default 'N'
); );
CREATE TABLE vicidial_music_on_hold_files ( CREATE TABLE vicidial_music_on_hold_files (
filename VARCHAR(255) NOT NULL, filename VARCHAR(100) NOT NULL,
moh_id VARCHAR(100) NOT NULL, moh_id VARCHAR(100) NOT NULL,
rank SMALLINT(5), rank SMALLINT(5),
unique index mohfile (filename, moh_id) unique index mohfile (filename, moh_id)
+1 -1
View File
@@ -503,7 +503,7 @@ remove ENUM('Y','N') default 'N'
); );
CREATE TABLE vicidial_music_on_hold_files ( CREATE TABLE vicidial_music_on_hold_files (
filename VARCHAR(255) NOT NULL, filename VARCHAR(100) NOT NULL,
moh_id VARCHAR(100) NOT NULL, moh_id VARCHAR(100) NOT NULL,
rank SMALLINT(5), rank SMALLINT(5),
unique index mohfile (filename, moh_id) unique index mohfile (filename, moh_id)
+5 -3
View File
@@ -87,10 +87,11 @@
# 90305-1040 - Added agent_dialed_number and type for user_call_log feature # 90305-1040 - Added agent_dialed_number and type for user_call_log feature
# 90508-0727 - Changed to PHP long tags # 90508-0727 - Changed to PHP long tags
# 90511-1019 - Added restriction not allowing dialing into agent sessions from manual dial # 90511-1019 - Added restriction not allowing dialing into agent sessions from manual dial
# 90913-1410 - Fixed minor logging bug
# #
$version = '2.2.0-40'; $version = '2.2.0-41';
$build = '90511-1019'; $build = '90913-1410';
$mel=1; # Mysql Error Log enabled = 1 $mel=1; # Mysql Error Log enabled = 1
$mysql_log_count=83; $mysql_log_count=83;
$one_mysql_log=0; $one_mysql_log=0;
@@ -707,7 +708,8 @@ if ($ACTION=="RedirectVD")
$row=mysql_fetch_row($rslt); $row=mysql_fetch_row($rslt);
if ($row[0] > 0) if ($row[0] > 0)
{ {
$stmt = "UPDATE vicidial_closer_log set end_epoch='$StarTtime', length_in_sec='$secondS',status='XFER' where lead_id='$lead_id' order by start_epoch desc limit 1;"; $four_hours_ago = date("Y-m-d H:i:s", mktime(date("H")-4,date("i"),date("s"),date("m"),date("d"),date("Y")));
$stmt = "UPDATE vicidial_closer_log set end_epoch='$StarTtime', length_in_sec=(queue_seconds + $secondS),status='XFER' where lead_id='$lead_id' and call_date > \"$four_hours_ago\" order by start_epoch desc limit 1;";
if ($format=='debug') {echo "\n<!-- $stmt -->";} if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link); $rslt=mysql_query($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02022',$user,$server_ip,$session_name,$one_mysql_log);} if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02022',$user,$server_ip,$session_name,$one_mysql_log);}
@@ -0,0 +1,245 @@
<?php
# AST_GROUP_ALIASstats.php
#
# Copyright (C) 2009 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# If you are going to run this report I would recommend adding the following in MySQL:
# CREATE INDEX extension on call_log (extension);
#
# CHANGES
#
# 90914-1003 - First build
#
require("dbconnect.php");
require("functions.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];}
elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];}
if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];}
elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
if (strlen($shift)<2) {$shift='ALL';}
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin FROM system_settings;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysql_num_rows($rslt);
$i=0;
while ($i < $qm_conf_ct)
{
$row=mysql_fetch_row($rslt);
$non_latin = $row[0];
$i++;
}
##### END SETTINGS LOOKUP #####
###########################################
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level >= 6 and view_reports='1';";
if ($DB) {echo "|$stmt|\n";}
if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
$NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$STARTtime = date("U");
if (!isset($group)) {$group = '';}
if (!isset($query_date)) {$query_date = "$NOW_DATE 00:00:00";}
if (!isset($end_date)) {$end_date = "$NOW_DATE 23:59:59";}
?>
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
.green {color: black; background-color: #99FF99}
.red {color: black; background-color: #FF9999}
.orange {color: black; background-color: #FFCC99}
-->
</STYLE>
<?php
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo "<TITLE>Group Alias Report</TITLE></HEAD><BODY BGCOLOR=WHITE marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
$short_header=1;
require("admin_header.php");
if ($DB > 0)
{
echo "<BR>\n";
echo "$query_date|$end_date\n";
echo "<BR>\n";
}
echo "<TABLE CELLPADDING=4 CELLSPACING=0><TR><TD>";
echo "<FORM ACTION=\"$PHP_SELF\" METHOD=GET>\n";
echo "<TABLE BORDER=0 CELLPADDING=2 CELLSPACING=2><TR><TD align=center valign=top>\n";
echo "<INPUT TYPE=TEXT NAME=query_date SIZE=20 MAXLENGTH=20 VALUE=\"$query_date\">\n";
echo "<BR> to <BR><INPUT TYPE=TEXT NAME=end_date SIZE=20 MAXLENGTH=20 VALUE=\"$end_date\">\n";
echo "</TD><TD align=center valign=top>\n";
echo "</TD><TD align=center valign=top>\n";
echo "</TD><TD align=center valign=top>\n";
echo "<INPUT TYPE=hidden NAME=DB VALUE=\"$DB\">\n";
echo "<INPUT TYPE=submit NAME=SUBMIT VALUE=SUBMIT>\n";
echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href=\"./admin.php?ADD=999999\">REPORTS</a> </FONT>\n";
echo "</TD></TR></TABLE>\n";
echo "</FORM>\n";
echo "<PRE><FONT SIZE=2>";
if (!$query_date)
{
echo "\n\n";
echo "PLEASE SELECT A DATE RANGE ABOVE AND CLICK SUBMIT\n";
}
else
{
echo "Group Alias Report $NOW_TIME\n";
echo "\n";
echo "Time range $query_date to $end_date\n\n";
### GRAB ALL RECORDS WITHIN RANGE FROM THE DATABASE ###
echo "Group Alias Summary:\n";
echo "+------------------------------------------------------------------------+------------+----------+\n";
echo "| GROUP ALIAS | MINUTES | CALLS |\n";
echo "+------------------------------------------------------------------------+------------+----------+\n";
$stmt="SELECT count(*),ucl.group_alias_id,group_alias_name from user_call_log ucl,groups_alias ga where call_date >= '$query_date' and call_date <= '$end_date' and ucl.group_alias_id=ga.group_alias_id group by ucl.group_alias_id order by ucl.group_alias_id;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$records_to_grab = mysql_num_rows($rslt);
$i=0;
while ($i < $records_to_grab)
{
$row=mysql_fetch_row($rslt);
$TOTcount = ($TOTcount + $row[0]);
$count[$i] = sprintf("%-8s", $row[0]);
$group_alias_id[$i] = $row[1];
$group_alias_name[$i] = sprintf("%-70s", "$row[1] - $row[2]");
$i++;
}
$total_sec=0;
$i=0;
while ($i < $records_to_grab)
{
$stmt="SELECT UNIX_TIMESTAMP(call_date),call_type,phone_number,number_dialed from user_call_log where group_alias_id='$group_alias_id[$i]' and call_date >= '$query_date' and call_date <= '$end_date';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$records_to_grabC = mysql_num_rows($rslt);
$k=0;
while ($k < $records_to_grabC)
{
$row=mysql_fetch_row($rslt);
$call_dateS[$k] = ($row[0] - 5);
$call_dateE[$k] = ($row[0] + 5);
$call_type[$k] = $row[1];
$phone_number[$k] = $row[2];
$number_dialed[$k] = $row[3];
$k++;
}
$found_sec=0;
$group_sec=0;
$k=0;
while ($k < $records_to_grabC)
{
$stmt="SELECT length_in_sec from call_log where extension='$phone_number[$k]'";
if (eregi("MANUAL_OVERRIDE",$call_type[$k]))
{$stmt="SELECT length_in_sec from call_log where extension='$phone_number[$k]'";}
if (eregi("XFER_OVERRIDE",$call_type[$k]))
{
$number_dialed[$k] = eregi_replace("Local/",'',$number_dialed[$k]);
$number_dialed[$k] = eregi_replace("@default",'',$number_dialed[$k]);
$stmt="SELECT length_in_sec from call_log where extension='$number_dialed[$k]'";
}
if (eregi("XFER_3WAY",$call_type[$k]))
{
$number_dialed[$k] = eregi_replace("Local/",'',$number_dialed[$k]);
$number_dialed[$k] = eregi_replace("@default",'',$number_dialed[$k]);
$stmt="SELECT length_in_sec from call_log where extension='$number_dialed[$k]'";
}
if (eregi("MANUAL_DIALNOW",$call_type[$k]))
{$stmt="SELECT length_in_sec from call_log where extension='$phone_number[$k]'";}
if (eregi("MANUAL_DIALFAST",$call_type[$k]))
{$stmt="SELECT length_in_sec from call_log where extension='$phone_number[$k]'";}
$stmt .= " and start_epoch >= $call_dateS[$k] and start_epoch <= $call_dateE[$k];";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$records_to_grabCL = mysql_num_rows($rslt);
if ($records_to_grabCL > 0)
{
$row=mysql_fetch_row($rslt);
$length_in_sec[$k] = $row[0];
$group_sec = ($group_sec + $row[0]);
$total_sec = ($total_sec + $row[0]);
$found_sec++;
}
$k++;
}
$Ccall_time_MS = sec_convert($group_sec,'M');
$Ccall_time_MS = sprintf("%10s", $Ccall_time_MS);
echo "| $group_alias_name[$i] | $Ccall_time_MS | $count[$i] |";
if ($DB) {echo "$found_sec";}
echo "\n";
$i++;
}
$TOTcount = sprintf("%-8s", $TOTcount);
$Tcall_time_MS = sec_convert($total_sec,'M');
$Tcall_time_MS = sprintf("%10s", $Tcall_time_MS);
echo "+------------------------------------------------------------------------+------------+----------+\n";
echo " | $Tcall_time_MS | $TOTcount |\n";
echo " +------------+----------+\n";
echo "\n</PRE>\n";
$ENDtime = date("U");
$RUNtime = ($ENDtime - $STARTtime);
echo "<BR><BR>\nRun Time: $RUNtime seconds\n";
}
?>
</TD></TR></TABLE>
</BODY></HTML>