diff --git a/bin/AST_VDsales_export.pl b/bin/AST_VDsales_export.pl index b67096a6..7d9bb8b8 100644 --- a/bin/AST_VDsales_export.pl +++ b/bin/AST_VDsales_export.pl @@ -25,6 +25,7 @@ # 90807-1632 - Fixed call time bug and call length bug # 90825-1249 - Added without-camp and without-in options # 90902-0437 - Added outbound-calltime-ignore and ftp-norun options +# 90909-2322 - Added totals-only option # $txt = '.txt'; @@ -46,6 +47,13 @@ $campaign = 'TESTCAMP'; $sale_statuses = 'SALE-UPSELL'; $output_format = 'pipe-standard'; $outbound_calltime_ignore=0; +$totals_only=0; +$OUTcalls=0; +$OUTtalk=0; +$OUTtalkmin=0; +$INcalls=0; +$INtalk=0; +$INtalkmin=0; $secX = time(); $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 " [--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 " [--totals-only] = print totals of time and calls only\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-norun] = Stop program when you get to the FTP transfer\n"; @@ -137,6 +146,8 @@ if (length($ARGV[0])>1) { $q=1; $Q=1; } + if ($args =~ /-totals-only/i) + {$totals_only=1;} if ($args =~ /--date=/i) { @@ -738,14 +749,22 @@ if ($ftp_transfer > 0) $ftp->quit; } -if ( ($DB) && ($output_format =~ /^tab-QMcustomUSA$/) ) +if ( ( ($DB) || ($totals_only > 0) ) && ($output_format =~ /^tab-QMcustomUSA$/) ) { - $OUTtalkmin = ($OUTtalk / 60); - $INtalkmin = ($INtalk / 60); + if ($OUTtalk > 0) {$OUTtalkmin = ($OUTtalk / 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 TIME: $OUTtalk $OUTtalkmin\n"; + print "OUTBOUND SECONDS: $OUTtalk\n"; + print "OUTBOUND MINUTES: $OUTtalkmin\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) @@ -962,6 +981,7 @@ sub select_format_loop $sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr; $sthB->execute or die "executing: $stmtB ", $dbhB->errstr; $sthBrows=$sthB->rows; + if ($DBX > 0) {print "$sthBrows|$stmtB\n";} $rec_countB=0; while ($sthBrows > $rec_countB) { @@ -983,6 +1003,7 @@ sub select_format_loop $sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr; $sthB->execute or die "executing: $stmtB ", $dbhB->errstr; $sthBrowsR=$sthB->rows; + if ($DBX > 0) {print "$sthBrowsR|$stmtB\n";} $rec_countBR=0; while ($sthBrowsR > $rec_countBR) { @@ -1059,7 +1080,7 @@ sub select_format_loop # } } } - ##### BEGIN DID lookup ##### + ##### END DID lookup ##### if ($status =~ /UPSELL/) {$UPSELL='L5';} else {$UPSELL='N';} @@ -1185,6 +1206,7 @@ sub select_format_loop $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++;} else {$INtalk = ($INtalk + $talk_seconds); $INcalls++;} diff --git a/docs/SCRATCH_INSTALL.txt b/docs/SCRATCH_INSTALL.txt index 82b3e215..d3436906 100644 --- a/docs/SCRATCH_INSTALL.txt +++ b/docs/SCRATCH_INSTALL.txt @@ -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 +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 installing the Asterisk open-source PBX on a Linux system and also installing the astGUIclient suite. The instructions will assume starting from nothing and diff --git a/docs/Ubuntu_Install.txt b/docs/Ubuntu_Install.txt index afaa03f8..4cb1317e 100644 --- a/docs/Ubuntu_Install.txt +++ b/docs/Ubuntu_Install.txt @@ -1,11 +1,11 @@ -Ubuntu VICIDIAL Install: 2009-05-19 +Ubuntu VICIDIAL Install: 2009-09-13 ### NOTE ### 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 -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 $ sudo su @@ -13,10 +13,10 @@ $ passwd (set the root user's password) $ apt-get update (retrieves the latest repository information) $ 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) -apt-get install the following packages: +'apt-get install' the following packages: apache2 (web server) apache2-mpm-prefork (multi threaded portion to apache2) build-essential (this is the build tool chain for gcc) @@ -27,7 +27,6 @@ libncurses5-dev libploticus0-dev libsox-fmt-all (encoding and decoding libraries for sox) 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) mtop (utility for monitoring mysql) mysql-client-5.0 (command for connecting to mysql) @@ -49,7 +48,8 @@ subversion (code versioning tool) subversion-tools unzip libcurl3 -curl +curl +vim Go to terminal: @@ -176,10 +176,10 @@ $ modprobe zaptel $ modprobe ztdummy ****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/libpri/libpri-1.4.9.tar.gz -$ tar xzf asterisk-1.4.21.2.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-vici.tar.gz $ tar xzf zaptel-1.4.12.1.tar.gz $ tar xzf libpri-1.4.9.tar.gz $ cd libpri-1.4.9 @@ -187,22 +187,6 @@ $ make clean; make; make install $ cd ../zaptel-1.4.12.1 $ ./configure; make clean; make; make install $ 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 $ make samples $ modprobe zaptel @@ -214,59 +198,6 @@ $ asterisk -vvvvvvvvvvvvvvvvvvvvvvvvvvvvgc (to see if Asterisk runs) > show application meetme > 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: $ mkdir /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 through to the Sample configuration files and set that to 'y' : 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 -$ wget http://downloads.vicidial.com/sounds/conf.gsm +$ wget http://downloads.vicidial.com/conf/conf.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; > 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'; @@ -328,7 +257,7 @@ $ crontab -e ### updater for VICIDIAL hopper * * * * * /usr/share/astguiclient/AST_VDhopper.pl -q ### 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 2 1 * * * /usr/share/astguiclient/AST_reset_mysql_vars.pl ### optimize the database tables within the asterisk database diff --git a/extras/MySQL_AST_CREATE_tables.sql b/extras/MySQL_AST_CREATE_tables.sql index 21fb1416..3a3a5db7 100644 --- a/extras/MySQL_AST_CREATE_tables.sql +++ b/extras/MySQL_AST_CREATE_tables.sql @@ -1786,7 +1786,7 @@ remove ENUM('Y','N') default 'N' ); CREATE TABLE vicidial_music_on_hold_files ( -filename VARCHAR(255) NOT NULL, +filename VARCHAR(100) NOT NULL, moh_id VARCHAR(100) NOT NULL, rank SMALLINT(5), unique index mohfile (filename, moh_id) diff --git a/extras/upgrade_2.2.0.sql b/extras/upgrade_2.2.0.sql index 0a830988..d006363a 100644 --- a/extras/upgrade_2.2.0.sql +++ b/extras/upgrade_2.2.0.sql @@ -503,7 +503,7 @@ remove ENUM('Y','N') default 'N' ); CREATE TABLE vicidial_music_on_hold_files ( -filename VARCHAR(255) NOT NULL, +filename VARCHAR(100) NOT NULL, moh_id VARCHAR(100) NOT NULL, rank SMALLINT(5), unique index mohfile (filename, moh_id) diff --git a/www/agc/manager_send.php b/www/agc/manager_send.php index 6083e28b..bc4b1e3c 100644 --- a/www/agc/manager_send.php +++ b/www/agc/manager_send.php @@ -87,10 +87,11 @@ # 90305-1040 - Added agent_dialed_number and type for user_call_log feature # 90508-0727 - Changed to PHP long tags # 90511-1019 - Added restriction not allowing dialing into agent sessions from manual dial +# 90913-1410 - Fixed minor logging bug # -$version = '2.2.0-40'; -$build = '90511-1019'; +$version = '2.2.0-41'; +$build = '90913-1410'; $mel=1; # Mysql Error Log enabled = 1 $mysql_log_count=83; $one_mysql_log=0; @@ -707,7 +708,8 @@ if ($ACTION=="RedirectVD") $row=mysql_fetch_row($rslt); 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";} $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);} diff --git a/www/vicidial/AST_GROUP_ALIASstats.php b/www/vicidial/AST_GROUP_ALIASstats.php new file mode 100644 index 00000000..0c7fee84 --- /dev/null +++ b/www/vicidial/AST_GROUP_ALIASstats.php @@ -0,0 +1,245 @@ + 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";} + + +?> + + + + + +\n"; +echo "Group Alias Report\n"; + + $short_header=1; + + require("admin_header.php"); + +if ($DB > 0) + { + echo "
\n"; + echo "$query_date|$end_date\n"; + echo "
\n"; + } + +echo "
"; + +echo "
\n"; +echo "
\n"; +echo "\n"; +echo "
to
\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "           REPORTS \n"; +echo "
\n"; +echo "
\n"; + +echo "
";
+
+
+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
\n"; + + + +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $STARTtime); +echo "

\nRun Time: $RUNtime seconds\n"; + +} + +?> + +
+ +