diff --git a/LANG_www/agc_se/active_list_refresh.php b/LANG_www/agc_se/active_list_refresh.php new file mode 100644 index 00000000..605edadc --- /dev/null +++ b/LANG_www/agc_se/active_list_refresh.php @@ -0,0 +1,483 @@ + LICENSE: AGPLv2 +# +# This script is designed purely to serve updates of the live data to the display scripts +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $ADD - ('1','2','3','4','5') +# - $order - ('asc','desc') +# - $format - ('text','table','menu','selectlist','textarea') +# - $bgcolor - ('#123456','white','black','etc...') +# - $txtcolor - ('#654321','black','white','etc...') +# - $txtsize - ('1','2','3','etc...') +# - $selectsize - ('2','3','4','etc...') +# - $selectfontsize - ('8','10','12','etc...') +# - $selectedext - ('cc100') +# - $selectedtrunk - ('Zap/25-1') +# - $selectedlocal - ('SIP/cc100') +# - $textareaheight - ('8','10','12','etc...') +# - $textareawidth - ('8','10','12','etc...') +# - $field_name - ('extension','busyext','extension_xfer','etc...') +# +# +# changes +# 50323-1147 - First build of script +# 50401-1132 - small formatting changes +# 50502-1402 - added field_name as modifiable variable +# 50503-1213 - added session_name checking for extra security +# 50503-1311 - added conferences list +# 50610-1155 - Added NULL check on MySQL results to reduced errors +# 50711-1209 - removed HTTP authentication in favor of user/pass vars +# 60421-1155 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60619-1118 - Added variable filters to close security holes for login form +# 90508-0727 - Changed to PHP long tags +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["ADD"])) {$ADD=$_GET["ADD"];} + elseif (isset($_POST["ADD"])) {$ADD=$_POST["ADD"];} +if (isset($_GET["order"])) {$order=$_GET["order"];} + elseif (isset($_POST["order"])) {$order=$_POST["order"];} +if (isset($_GET["bgcolor"])) {$bgcolor=$_GET["bgcolor"];} + elseif (isset($_POST["bgcolor"])) {$bgcolor=$_POST["bgcolor"];} +if (isset($_GET["txtcolor"])) {$txtcolor=$_GET["txtcolor"];} + elseif (isset($_POST["txtcolor"])) {$txtcolor=$_POST["txtcolor"];} +if (isset($_GET["txtsize"])) {$txtsize=$_GET["txtsize"];} + elseif (isset($_POST["txtsize"])) {$txtsize=$_POST["txtsize"];} +if (isset($_GET["selectsize"])) {$selectsize=$_GET["selectsize"];} + elseif (isset($_POST["selectsize"])) {$selectsize=$_POST["selectsize"];} +if (isset($_GET["selectfontsize"])) {$selectfontsize=$_GET["selectfontsize"];} + elseif (isset($_POST["selectfontsize"])) {$selectfontsize=$_POST["selectfontsize"];} +if (isset($_GET["selectedext"])) {$selectedext=$_GET["selectedext"];} + elseif (isset($_POST["selectedext"])) {$selectedext=$_POST["selectedext"];} +if (isset($_GET["selectedtrunk"])) {$selectedtrunk=$_GET["selectedtrunk"];} + elseif (isset($_POST["selectedtrunk"])) {$selectedtrunk=$_POST["selectedtrunk"];} +if (isset($_GET["selectedlocal"])) {$selectedlocal=$_GET["selectedlocal"];} + elseif (isset($_POST["selectedlocal"])) {$selectedlocal=$_POST["selectedlocal"];} +if (isset($_GET["textareaheight"])) {$textareaheight=$_GET["textareaheight"];} + elseif (isset($_POST["textareaheight"])) {$textareaheight=$_POST["textareaheight"];} +if (isset($_GET["textareawidth"])) {$textareawidth=$_GET["textareawidth"];} + elseif (isset($_POST["textareawidth"])) {$textareawidth=$_POST["textareawidth"];} +if (isset($_GET["field_name"])) {$field_name=$_GET["field_name"];} + elseif (isset($_POST["field_name"])) {$field_name=$_POST["field_name"];} + +### security strip all non-alphanumeric characters out of the variables ### + $user=ereg_replace("[^0-9a-zA-Z]","",$user); + $pass=ereg_replace("[^0-9a-zA-Z]","",$pass); + $ADD=ereg_replace("[^0-9]","",$ADD); + $order=ereg_replace("[^0-9a-zA-Z]","",$order); + $format=ereg_replace("[^0-9a-zA-Z]","",$format); + $bgcolor=ereg_replace("[^\#0-9a-zA-Z]","",$bgcolor); + $txtcolor=ereg_replace("[^\#0-9a-zA-Z]","",$txtcolor); + $txtsize=ereg_replace("[^0-9a-zA-Z]","",$txtsize); + $selectsize=ereg_replace("[^0-9a-zA-Z]","",$selectsize); + $selectfontsize=ereg_replace("[^0-9a-zA-Z]","",$selectfontsize); + $selectedext=ereg_replace("[^ \#\*\:\/\@\.\-\_0-9a-zA-Z]","",$selectedext); + $selectedtrunk=ereg_replace("[^ \#\*\:\/\@\.\-\_0-9a-zA-Z]","",$selectedtrunk); + $selectedlocal=ereg_replace("[^ \#\*\:\/\@\.\-\_0-9a-zA-Z]","",$selectedlocal); + $textareaheight=ereg_replace("[^0-9a-zA-Z]","",$textareaheight); + $textareawidth=ereg_replace("[^0-9a-zA-Z]","",$textareawidth); + $field_name=ereg_replace("[^ \#\*\:\/\@\.\-\_0-9a-zA-Z]","",$field_name); + +# default optional vars if not set +if (!isset($ADD)) {$ADD="1";} +if (!isset($order)) {$order='desc';} +if (!isset($format)) {$format="text";} +if (!isset($bgcolor)) {$bgcolor='white';} +if (!isset($txtcolor)) {$txtcolor='black';} +if (!isset($txtsize)) {$txtsize='2';} +if (!isset($selectsize)) {$selectsize='4';} +if (!isset($selectfontsize)) {$selectfontsize='10';} +if (!isset($textareaheight)) {$textareaheight='10';} +if (!isset($textareawidth)) {$textareawidth='20';} + +$version = '0.0.8'; +$build = '60619-1118'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Felaktig Användarnamn/Lösenord: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Felaktig server_ip: |$server_ip| or Felaktig session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Felaktig session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='table') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Visa Lista: "; +if ($ADD==1) {echo "Aktiva anknytningar";} +if ($ADD==2) {echo "Upptagna anknytningar";} +if ($ADD==3) {echo "Externa linjer";} +if ($ADD==4) {echo "Lokala anknytningar";} +if ($ADD==5) {echo "Konferenser";} +if ($ADD==99999) {echo "HJÄLP";} +echo "\n"; +echo "\n"; +echo "\n"; +} + + + + + +###################### +# ADD=1 display all live extensions on a server +###################### +if ($ADD==1) +{ + $pt='pt'; + if (!$field_name) {$field_name = 'extension';} + if ($format=='table') {echo "\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + + +###################### +# ADD=2 display all busy extensions on a server +###################### +if ($ADD==2) +{ + if (!$field_name) {$field_name = 'busyext';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + +###################### +# ADD=3 display all busy outside lines(trunks) on a server +###################### +if ($ADD==3) +{ + if (!$field_name) {$field_name = 'trunk';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + +###################### +# ADD=4 display all busy Local lines on a server +###################### +if ($ADD==4) +{ + if (!$field_name) {$field_name = 'local';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + +###################### +# ADD=5 display all agc-usable conferences on a server +###################### +if ($ADD==5) +{ + $pt='pt'; + if (!$field_name) {$field_name = 'conferences';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + + + + + + + + + +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $StarTtime); +if ($format=='table') {echo "\n";} +if ($format=='table') {echo "\n\n\n";} + +exit; + +?> + + + + + diff --git a/LANG_www/agc_se/astguiclient.php b/LANG_www/agc_se/astguiclient.php new file mode 100644 index 00000000..a26a8a2d --- /dev/null +++ b/LANG_www/agc_se/astguiclient.php @@ -0,0 +1,2908 @@ + LICENSE: AGPLv2 +# +# make sure you have added a user to the vicidial_users MySQL table with at least +# user_level 1 or greater to access this page. Also you need to have the login +# and pass of a phone listed in the asterisk.phones table. The page grabs the +# server info and other details from this login and pass +# +# Other scripts that this application depends on: +# - active_list_refresh.php: displays active/live channels and phones +# - manager_send.php: sends Actions to be executed on Asterisk servers +# - live_exten_check.php: checks to see if user's phone is on a live call +# - call_log_display.php: retrieves log of inbound and outbound calls +# - voicemail_check.php: retrieves counts of new and old messages +# - inbound_popup.php: opens upon live_inbound call coming in +# - conf_exten_check.php: checks to see if and calls are in a specific conf +# - park_calls_display.php: retrieves list of parked calls +# - vdc_db_query.php: Changes values in the DB for non-calling records +# +# CHANGES +# 50215-1356 - Proof-of-concept test of XMLHttpRequest for astGUIclient web +# 50323-1411 - First build version display-only +# 50331-1040 - Second-build, added phone login and hangup/hijack display +# 50401-1006 - Trunk/Local Hangup functions enabled +# 50404-1056 - Trunk/Local Hijack functions enabled +# 50404-1459 - Simple live calls display and grabs updated time from server +# 50405-1221 - Reorganized the display and layers, added some images +# 50406-1005 - Added In/Out call log display to MAIN panel +# 50407-1254 - Start/Stop Recording on live calls enabled +# 50422-1101 - Activated Check Voicemail button and new/old messages count +# 50428-1449 - Added dial from log and basic live_inbound call popup +# 50429-1455 - Modified inbound popup code for IE and to add more functions +# 50502-1442 - Added basic method to transfer live calls somewhere else +# 50503-1205 - Added web_client_sessions entry for more security of subscripts +# 50503-1537 - Added basic conferences display +# 50509-1132 - Added conference connected list and hangup/xfer for them +# 50511-1129 - Added registration of conference rooms and added manual dial +# 50523-1342 - Added Conference recording and send DTMF +# 50523-1622 - Added Local Dial window frame for calling local extensions +# 50524-1456 - Added ability to park call and display number of parked calls +# 50524-1600 - Added ability to display and pickup/hangup/xfer parked calls +# 50525-1224 - Added ability to place outbound call from within conferene +# 50531-1225 - Added ability to do dual transfers to meetme rooms from Main +# 50711-1229 - removed HTTP authentication in favor of user/pass vars +# 50711-1610 - Added Zap monitoring to Trunk/Local Action screens +# 50804-1604 - Minor bug fix in inbound_popup functions +# 50818-1715 - Added pretty login section +# 50913-1137 - Added custom outbound_cid from phones table +# 51110-1430 - Fixed non-standard http port issue +# 60103-1421 - Added code for favorite extensions chooser +# 60104-1347 - Added basic layout for favorites editing frame +# 60105-1124 - Finished Favorites frame and added DB submission +# 60112-1622 - Several formatting changes +# 60421-1357 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60619-1103 - Added variable filters to close security holes for login form +# 60829-1528 - Made compatible with WeBRooTWritablE setting in dbconnect.php +# 90508-0727 - Changed to PHP long tags +# 91129-2211 - Replaced SELECT STAR in SQL query +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];} + elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];} +if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];} + elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];} +if (isset($_GET["relogin"])) {$relogin=$_GET["relogin"];} + elseif (isset($_POST["relogin"])) {$relogin=$_POST["relogin"];} + if (!isset($phone_login)) + { + if (isset($_GET["pl"])) {$phone_login=$_GET["pl"];} + elseif (isset($_POST["pl"])) {$phone_login=$_POST["pl"];} + } + if (!isset($phone_pass)) + { + if (isset($_GET["pp"])) {$phone_pass=$_GET["pp"];} + elseif (isset($_POST["pp"])) {$phone_pass=$_POST["pp"];} + } + +$forever_stop=0; +$user_abb = "$user$user$user$user"; +while ( (strlen($user_abb) > 4) and ($forever_stop < 200) ) + {$user_abb = eregi_replace("^.","",$user_abb); $forever_stop++;} + +$version = '2.2.0'; +$build = '91129-2211'; + +### security strip all non-alphanumeric characters out of the variables ### + $DB=ereg_replace("[^0-9a-z]","",$DB); + $phone_login=ereg_replace("[^0-9a-zA-Z]","",$phone_login); + $phone_pass=ereg_replace("[^0-9a-zA-Z]","",$phone_pass); + $user=ereg_replace("[^0-9a-zA-Z]","",$user); + $pass=ereg_replace("[^0-9a-zA-Z]","",$pass); + + +if ($force_logout) + { + if( (strlen($_SERVER['user'])>0) or (strlen($_SERVER['pass'])>0) ) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + } + echo "Du är nu utloggad ur systemet, välkommen åter! +\n"; + exit; + } + +$StarTtime = date("U"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_TIME = date("Ymd-His"); + $month_old = mktime(0, 0, 0, date("m"), date("d")-7, date("Y")); + $past_month_date = date("Y-m-d H:i:s",$month_old); + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$US='_'; +$CL=':'; +if ($WeBRooTWritablE > 0) + {$fp = fopen ("./astguiclient_auth_entries.txt", "a");} +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +if (($server_port == '80') or ($server_port == '443') ) {$server_port='';} +else {$server_port = "$CL$server_port";} +$agcPAGE = "$HTTPprotocol$server_name$server_port$script_name"; +$agcDIR = $agcPAGE; +$agcDIR = eregi_replace('astguiclient.php','',$agcDIR); + +if( (strlen($user)<2) or (strlen($pass)<2) or (!$auth) or ($relogin == 'YES') ) + { + header ("Content-type: text/html; charset=utf-8"); + + echo " astGUI webklient: Login\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Svenska
\n"; + echo "
\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Logga in
 
Användare:
Lösenord:
Telefonlogin:
Telefonlösenord:

VERSION: $version       SKAPA: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } +else + { + + if($auth>0) + { + $office_no=strtoupper($user); + $password=strtoupper($pass); + $stmt="SELECT full_name,user_level from vicidial_users where user='$user' and pass='$pass'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|GOOD|$date|$user|$pass|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + } + else + { + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$user|$pass|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + } + } + +header ("Content-type: text/html; charset=utf-8"); +header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header ("Pragma: no-cache"); // HTTP/1.0 +echo "\n"; +echo "\n"; +echo "\n"; + +if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) ) +{ +echo " astGUI webklient: Telefonlogin\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n";echo "\n";echo "
English Svenska
\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "


"; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Telefonlogin
 
Telefonlogin:
Telefonlösenord:

VERSION: $version       SKAPA: $build
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; +exit; +} +else +{ +$authphone=0; +$stmt="SELECT count(*) from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$authphone=$row[0]; +if (!$authphone) + { + echo " astGUI webklient: Telefonlogin\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Svenska
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Telefonlogin
 
Tyvärr är din telefons inloggningsuppgifter inte aktiva I detta system, vänligen försök igen:
 
Telefonlogin:
Telefonlösenord:

VERSION: $version       SKAPA: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } +else + { + echo " astGUI webklient\n"; + $stmt="SELECT extension,dialplan_number,voicemail_id,phone_ip,computer_ip,server_ip,login,pass,status,active,phone_type,fullname,company,picture,messages,old_messages,protocol,local_gmt,ASTmgrUSERNAME,ASTmgrSECRET,login_user,login_pass,login_campaign,park_on_extension,conf_on_extension,VICIDIAL_park_on_extension,VICIDIAL_park_on_filename,monitor_prefix,recording_exten,voicemail_exten,voicemail_dump_exten,ext_context,dtmf_send_extension,call_out_number_group,client_browser,install_directory,local_web_callerID_URL,VICIDIAL_web_URL,AGI_call_logging_enabled,user_switching_enabled,conferencing_enabled,admin_hangup_enabled,admin_hijack_enabled,admin_monitor_enabled,call_parking_enabled,updater_check_enabled,AFLogging_enabled,QUEUE_ACTION_enabled,CallerID_popup_enabled,voicemail_button_enabled,enable_fast_refresh,fast_refresh_rate,enable_persistant_mysql,auto_dial_next_number,VDstop_rec_after_each_call,DBX_server,DBX_database,DBX_user,DBX_pass,DBX_port,DBY_server,DBY_database,DBY_user,DBY_pass,DBY_port,outbound_cid,enable_sipsak_messages,email,template_id,conf_override,phone_context,phone_ring_timeout,conf_secret from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $extension=$row[0]; + $dialplan_number=$row[1]; + $voicemail_id=$row[2]; + $phone_ip=$row[3]; + $computer_ip=$row[4]; + $server_ip=$row[5]; + $phone_login=$row[6]; + $phone_pass=$row[7]; + $status=$row[8]; + $active=$row[9]; + $phone_type=$row[10]; + $fullname=$row[11]; + $company=$row[12]; + $picture=$row[13]; + $messages=$row[14]; + $old_messages=$row[15]; + $protocol=$row[16]; + $local_gmt=$row[17]; + $ASTmgrUSERNAME=$row[18]; + $ASTmgrSECRET=$row[19]; + $login_user=$row[20]; + $login_pass=$row[21]; + $login_campaign=$row[22]; + $park_on_extension=$row[23]; + $conf_on_extension=$row[24]; + $VICIDiaL_park_on_extension=$row[25]; + $VICIDiaL_park_on_filename=$row[26]; + $monitor_prefix=$row[27]; + $recording_exten=$row[28]; + $voicemail_exten=$row[29]; + $voicemail_dump_exten=$row[30]; + $ext_context=$row[31]; + $dtmf_send_extension=$row[32]; + $call_out_number_group=$row[33]; + $client_browser=$row[34]; + $install_directory=$row[35]; + $local_web_callerID_URL=$row[36]; + $VICIDiaL_web_URL=$row[37]; + $AGI_call_logging_enabled=$row[38]; + $user_switching_enabled=$row[39]; + $conferencing_enabled=$row[40]; + $admin_hangup_enabled=$row[41]; + $admin_hijack_enabled=$row[42]; + $admin_monitor_enabled=$row[43]; + $call_parking_enabled=$row[44]; + $updater_check_enabled=$row[45]; + $AFLogging_enabled=$row[46]; + $QUEUE_ACTION_enabled=$row[47]; + $CaLLerID_popup_enabled=$row[48]; + $voicemail_button_enabled=$row[49]; + $enable_fast_refresh=$row[50]; + $fast_refresh_rate=$row[51]; + $enable_persistant_mysql=$row[52]; + $auto_dial_next_number=$row[53]; + $VDstop_rec_after_each_call=$row[54]; + $DBX_server=$row[55]; + $DBX_database=$row[56]; + $DBX_user=$row[57]; + $DBX_pass=$row[58]; + $DBX_port=$row[59]; + $outbound_cid=$row[65]; + + $local_web_callerID_URL_enc = rawurlencode($local_web_callerID_URL); + + $session_ext = eregi_replace("[^a-z0-9]", "", $extension); + if (strlen($session_ext) > 10) {$session_ext = substr($session_ext, 0, 10);} + $session_rand = (rand(1,9999999) + 10000000); + $session_name = "$StarTtime$US$session_ext$session_rand"; + + $stmt="DELETE from web_client_sessions where start_time < '$past_month_date' and extension='$extension' and server_ip = '$server_ip' and program = 'agc';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO web_client_sessions values('$extension','$server_ip','agc','$NOW_TIME','$session_name');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT count(*) from phone_favorites where extension='$extension' and server_ip = '$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $favorites_present=$row[0]; + if ($favorites_present > 0) + { + $stmt="SELECT extensions_list from phone_favorites where extension='$extension' and server_ip = '$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $favorites_list=$row[0]; + $h=0; + $favorites_listX = eregi_replace("'",'',$favorites_list); + $favorites = explode(',',$favorites_listX); + $favorites_count = count($favorites); + $favorites_listX=''; + + $o=0; + while ($favorites_count > $o) + { + $stmt="SELECT fullname,protocol from phones where extension = '$favorites[$o]' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $favorites_names[$o] = $rowx[0]; + $favorites_listX .= "$rowx[1]/$favorites[$o],"; + $o++; + } + + echo "\n"; + echo "\n"; + } + else + { + echo "\n"; + } + +### gather phone extensions and fullnames for favorites editor ### + $stmt="SELECT extension,fullname from phones where server_ip = '$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $exten_ct = mysql_num_rows($rslt); + $favlistCT=0; + $nofavlistCT=0; + while ($favlistCT < $exten_ct) + { + $row=mysql_fetch_row($rslt); + $favlist[$favlistCT]= "$row[0] - $row[1]"; + $favlistCT++; + } + + } +} + + +?> + + + + + + +\n"; + + +?> + +
+ + + + + + + + + +
+ + +LOGGA UT
\n"; ?> +
HuvudpanelLinjerpanelKonferenspanelKolla röstbrevlådanLivesamtal
+
+ + +

Logout
+
+ + +
TRUNK HANGUP

+ Active Trunks Menu
+ Lägg på trunk   |   + Kapa trunk   |   + Lyssna på trunk   |   + Uppdatera   |   + Tillbaka till startsidan +
+
+ + +
SAMTAL AVSLUTATS LOKALT

+ Aktiv lokal meny
+ Lägg på lokalt   |   + Kapa lokalt   |   + Lyssna lokalt   |   + Uppdatera   |   + Tillbaka till startsidan +
+
+ + + + + + + +
LIVESAMTAL KOPPLAR
Kanal att förflytta: Channel
Anknytningar:
Anknytningsmeny
+
+ Koppla vidare till vald anknytning

+ Koppla till röstbrevlåda

+ Koppla till detta nummer:


+ Uppdatera


+ Tillbaka till startsidan

+
Konferenser:
(klicka på ett nummer nedan för att koppla vidare till en konferens)
Skicka min kanal också
Konferensmeny
+
+ + + + + +
LOKALA Anknytningar
Ringer…: Channel
Anknytningar:
Anknytningsmeny
+
+ Ring anknytning

+ Ring röstbrevlåda

+ Uppdatera


+ Tillbaka till startsidan

+
+
+ + +
PARKERAERADE SAMTAL:
+ Tillbaka till startsidan

+
+
+ + + + + + + + + + + + + + + +
  +
RÖSTBREVLÅDA     NY:     GAMMAL:             MANUELL UPPRINGNING       DIAL
PARKERAERADE SAMTAL: 0                LOKALA ANKNYTNINGAR
UTGÅENDE SAMTAL:
INGÅENDE SAMTAL:
astGUI webklientversion: SKAPA:
+ + + + $h) + { + if (strlen($favorites[$h])>1) + { + echo "\n"; + } + $h++; + } +?> + +
FAVORITER       ändra
$favorites[$h] - $favorites_names[$h]
 
+
+ + + + + + + +
FAVORITER

 
Skicka favoritändringar - detta kräver att du loggar ut
TILLBAKA TILL HUVUDFÖNSTRET - ignorera gjorda ändringar
+
+ +
+ + + + + + + + + + + + + +
+STOP | START     Uppdateringsfrekvens: 1000 ms Snabbare | Långsammare

+
Initierar..
+
Aktiva anknytningar
+UPPDATERA | +ORDER | +
Externa linjer
+UPPDATERA | +ORDER | +
Lokala anknytningar
+UPPDATERA | +ORDER | +
+ Skriv in data här

+
+ Skriv in data här

Trunk action +
+ Skriv in data här

Lokal action +
+
+ + + + +
+ + +Konferenslista + + + +
+Klicka på konferensnumret till vänster för mer info om konferensen +
+ + + + + + + + + + + + + + + + + + diff --git a/LANG_www/agc_se/call_log_display.php b/LANG_www/agc_se/call_log_display.php new file mode 100644 index 00000000..00f96202 --- /dev/null +++ b/LANG_www/agc_se/call_log_display.php @@ -0,0 +1,197 @@ + LICENSE: AGPLv2 +# +# This script is designed purely to send the inbound and outbound calls for a specific phone +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $format - ('text','debug') +# - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +# - $protocol - ('SIP','Zap','IAX2',...) +# - $in_limit - ('10','20','50','100',...) +# - $out_limit - ('10','20','50','100',...) +# +# +# changes +# 50406-1013 - First build of script +# 50407-1452 - Added definable limits +# 50503-1236 - added session_name checking for extra security +# 50610-1158 - Added NULL check on MySQL results to reduced errors +# 50711-1202 - removed HTTP authentication in favor of user/pass vars +# 60323-1550 - added option for showing different number dialed in log +# 60421-1401 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60619-1202 - Added variable filters to close security holes for login form +# 90508-0727 - Changed to PHP long tags +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} + +$user=ereg_replace("[^0-9a-zA-Z]","",$user); +$pass=ereg_replace("[^0-9a-zA-Z]","",$pass); + +# default optional vars if not set +if (!isset($format)) {$format="text";} +if (!isset($in_limit)) {$in_limit="100";} +if (!isset($out_limit)) {$out_limit="100";} +$number_dialed = 'number_dialed'; +#$number_dialed = 'extension'; + +$version = '0.0.8'; +$build = '60619-1202'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Felaktig Användarnamn/Lösenord: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Felaktig server_ip: |$server_ip| or Felaktig session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Felaktig session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Visa samtalslogg"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<1) or (strlen($protocol)<3) ) + { + $channel_live=0; + echo "Exten $exten är ej giltig eller protokoll $protocol är ej giltig\n"; + exit; + } + else + { + ##### print outbound calls from the call_log table + $stmt="SELECT uniqueid,start_time,$number_dialed,length_in_sec FROM call_log where server_ip = '$server_ip' and channel LIKE \"$protocol/$exten%\" order by start_time desc limit $out_limit;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$out_calls_count = mysql_num_rows($rslt);} + echo "$out_calls_count|"; + $loop_count=0; + while ($out_calls_count>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + + $call_time_M = ($row[3] / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + + if ($number_dialed == 'extension') {$row[2] = substr($row[2],-10);} + echo "$row[0] ~$row[1] ~$row[2] ~$call_time_MS|"; + } + echo "\n"; + + ##### print inbound calls from the live_inbound_log table + $stmt="SELECT call_log.uniqueid,live_inbound_log.start_time,live_inbound_log.extension,caller_id,length_in_sec from live_inbound_log,call_log where phone_ext='$exten' and live_inbound_log.server_ip = '$server_ip' and call_log.uniqueid=live_inbound_log.uniqueid order by start_time desc limit $in_limit;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$in_calls_count = mysql_num_rows($rslt);} + echo "$in_calls_count|"; + $loop_count=0; + while ($in_calls_count>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + + $call_time_M = ($row[4] / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $callerIDnum = $row[3]; $callerIDname = $row[3]; + $callerIDnum = preg_replace("/.*<|>.*/","",$callerIDnum); + $callerIDname = preg_replace("/\"| <\d*>/","",$callerIDname); + + echo "$row[0] ~$row[1] ~$row[2] ~$callerIDnum ~$callerIDname ~$call_time_MS|"; + } + echo "\n"; + + } + + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/LANG_www/agc_se/conf_exten_check.php b/LANG_www/agc_se/conf_exten_check.php new file mode 100644 index 00000000..3016acc7 --- /dev/null +++ b/LANG_www/agc_se/conf_exten_check.php @@ -0,0 +1,684 @@ + LICENSE: AGPLv2 +# +# This script is designed purely to send whether the meetme conference has live channels connected and which they are +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $format - ('text','debug') +# - $ACTION - ('refresh','register') +# - $client - ('agc','vdc') +# - $conf_exten - ('8600011',...) +# - $exten - ('123test',...) +# - $auto_dial_level - ('0','1','1.2',...) +# - $campagentstdisp - ('YES',...) +# + +# changes +# 50509-1054 - First build of script +# 50511-1112 - Added ability to register a conference room +# 50610-1159 - Added NULL check on MySQL results to reduced errors +# 50706-1429 - script changed to not use HTTP login vars, user/pass instead +# 50706-1525 - Added date-time display for vicidial client display +# 50816-1500 - Added random update to vicidial_live_agents table for vdc users +# 51121-1353 - Altered echo statements for several small PHP speed optimizations +# 60410-1424 - Added ability to grab calls-being-placed and agent status +# 60421-1405 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60619-1201 - Added variable filters to close security holes for login form +# 61128-2255 - Added update for manual dial vicidial_live_agents +# 70319-1542 - Added agent disabled display function +# 71122-0205 - Added vicidial_live_agent status output +# 80424-0442 - Added non_latin lookup from system_settings +# 80519-1425 - Added calls-in-queue tally +# 80703-1106 - Added API functionality for Hangup and Dispo +# 81104-0229 - Added mysql error logging capability +# 81104-1409 - Added multi-retry for some vicidial_live_agents table MySQL queries +# 90102-1402 - Added check for system and database time synchronization +# 90120-1720 - Added compatibility for API pause/resume and dial a number +# 90307-1855 - Added shift enforcement to send logout flag if outside of shift hours +# 90408-0020 - Added API vtiger specific callback activity record ability +# 90508-0727 - Changed to PHP long tags +# 90706-1430 - Fixed AGENTDIRECT calls in queue display count +# 90908-1037 - Added DEAD call logging +# 91130-2022 - Added code for manager override of in-group selection +# 91228-1341 - Added API fields update functions +# 100109-1337 - Fixed Manual dial live call detection +# + +$version = '2.2.0-25'; +$build = '100109-1337'; +$mel=1; # Mysql Error Log enabled = 1 +$mysql_log_count=32; +$one_mysql_log=0; + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];} + elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];} +if (isset($_GET["client"])) {$client=$_GET["client"];} + elseif (isset($_POST["client"])) {$client=$_POST["client"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["campagentstdisp"])) {$campagentstdisp=$_GET["campagentstdisp"];} + elseif (isset($_POST["campagentstdisp"])) {$campagentstdisp=$_POST["campagentstdisp"];} + +header ("Content-type: text/html; charset=utf-8"); +header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header ("Pragma: no-cache"); // HTTP/1.0 + + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin FROM system_settings;"; +$rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03001',$user,$server_ip,$session_name,$one_mysql_log);} +if ($DB) {echo "$stmt\n";} +$qm_conf_ct = mysql_num_rows($rslt); +if ($qm_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $non_latin = $row[0]; + } +##### END SETTINGS LOOKUP ##### +########################################### + +if ($non_latin < 1) +{ +$user=ereg_replace("[^0-9a-zA-Z]","",$user); +$pass=ereg_replace("[^0-9a-zA-Z]","",$pass); +} + +# default optional vars if not set +if (!isset($format)) {$format="text";} +if (!isset($ACTION)) {$ACTION="refresh";} +if (!isset($client)) {$client="agc";} + +$Alogin='N'; +$RingCalls='N'; +$DiaLCalls='N'; + +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_TIME = date("Ymd_His"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +$random = (rand(1000000, 9999999) + 10000000); + + +$stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; +if ($DB) {echo "|$stmt|\n";} +if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");} +$rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03002',$user,$server_ip,$session_name,$one_mysql_log);} +$row=mysql_fetch_row($rslt); +$auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Felaktig Användarnamn/Lösenord: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Felaktig server_ip: |$server_ip| or Felaktig session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03002',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Felaktig session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Kolla konfanknytningen"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + if ($ACTION == 'refresh') + { + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if (strlen($conf_exten)<1) + { + $channel_live=0; + echo "Conf Exten $conf_exten är ej giltig\n"; + exit; + } + else + { + + if ($client == 'vdc') + { + $Acount=0; + $AexternalDEAD=0; + $Aagent_log_id=''; + $Acallerid=''; + $DEADcustomer=0; + + ### see if the agent has a record in the vicidial_live_agents table + $stmt="SELECT count(*) from vicidial_live_agents where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03003',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $Acount=$row[0]; + + if ($Acount > 0) + { + $stmt="SELECT status,callerid,agent_log_id,campaign_id from vicidial_live_agents where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03004',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $Astatus = $row[0]; + $Acallerid = $row[1]; + $Aagent_log_id = $row[2]; + $Acampaign_id = $row[3]; + } + # ### find out if external table shows agent should be disabled + # $stmt="SELECT count(*) from another_table where user='$user' and status='DEAD';"; + # if ($DB) {echo "|$stmt|\n";} + # $rslt=mysql_query($stmt, $link); + # $row=mysql_fetch_row($rslt); + # $AexternalDEAD=$row[0]; + + if ($auto_dial_level > 0) + { + ### update the vicidial_live_agents every second with a new random number so it is shown to be alive + $stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03005',$user,$server_ip,$session_name,$one_mysql_log);} + $retry_count=0; + while ( ($errno > 0) and ($retry_count < 5) ) + { + $rslt=mysql_query($stmt, $link); + $one_mysql_log=1; + $errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9305$retry_count",$user,$server_ip,$session_name,$one_mysql_log); + $one_mysql_log=0; + $retry_count++; + } + + ##### BEGIN DEAD logging section ##### + ### find whether the call the agent is på is hung up + $stmt="SELECT count(*) from vicidial_auto_calls where callerid='$Acallerid';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03018',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $AcalleridCOUNT=$row[0]; + + if ( ($AcalleridCOUNT < 1) and (eregi("INCALL",$Astatus)) and (strlen($Aagent_log_id) > 0) ) + { + $DEADcustomer++; + ### find whether the agent log record has already logged DEAD + $stmt="SELECT count(*) from vicidial_agent_log where agent_log_id='$Aagent_log_id' and ( (dead_epoch IS NOT NULL) or (dead_epoch > 10000) );"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03019',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $Aagent_log_idCOUNT=$row[0]; + + if ($Aagent_log_idCOUNT < 1) + { + $NEWdead_epoch = date("U"); + $deadNOW_TIME = date("Y-m-d H:i:s"); + $stmt="UPDATE vicidial_agent_log set dead_epoch='$NEWdead_epoch' where agent_log_id='$Aagent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03020',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt="UPDATE vicidial_live_agents set last_state_change='$deadNOW_TIME' where agent_log_id='$Aagent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03021',$user,$server_ip,$session_name,$one_mysql_log);} + } + } + ##### END DEAD logging section ##### + + if ($campagentstdisp == 'YES') + { + $ADsql=''; + ### grab the status of this agent to display + $stmt="SELECT status,campaign_id,closer_campaigns from vicidial_live_agents where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03006',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $Alogin=$row[0]; + $Acampaign=$row[1]; + $AccampSQL=$row[2]; + $AccampSQL = ereg_replace(' -','', $AccampSQL); + $AccampSQL = ereg_replace(' ',"','", $AccampSQL); + if (eregi('AGENTDIRECT', $AccampSQL)) + { + $AccampSQL = ereg_replace('AGENTDIRECT','', $AccampSQL); + $ADsql = "or ( (campaign_id LIKE \"%AGENTDIRECT%\") and (agent_only='$user') )"; + } + + ### grab the number of calls being placed from this server and campaign + $stmt="SELECT count(*) from vicidial_auto_calls where status IN('LIVE') and ( (campaign_id='$Acampaign') or (campaign_id IN('$AccampSQL')) $ADsql);"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03007',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $RingCalls=$row[0]; + if ($RingCalls > 0) {$RingCalls = "Samtal i kö: $RingCalls";} + else {$RingCalls = "Samtal i kö: $RingCalls";} + + ### grab the number of calls being placed from this server and campaign + $stmt="SELECT count(*) from vicidial_auto_calls where status NOT IN('XFER') and ( (campaign_id='$Acampaign') or (campaign_id IN('$AccampSQL')) );"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03008',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $DiaLCalls=$row[0]; + + } + else + { + $Alogin='N'; + $RingCalls='N'; + $DiaLCalls='N'; + } + } + else + { + $Alogin='N'; + $RingCalls='N'; + $DiaLCalls='N'; + + ### update the vicidial_live_agents every second with a new random number so it is shown to be alive + $stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03009',$user,$server_ip,$session_name,$one_mysql_log);} + $retry_count=0; + while ( ($errno > 0) and ($retry_count < 5) ) + { + $rslt=mysql_query($stmt, $link); + $one_mysql_log=1; + $errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9309$retry_count",$user,$server_ip,$session_name,$one_mysql_log); + $one_mysql_log=0; + $retry_count++; + } + ##### BEGIN DEAD logging section ##### + ### find whether the call the agent is på is hung up + $stmt="SELECT count(*) from vicidial_auto_calls where callerid='$Acallerid';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03029',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $AcalleridCOUNT=$row[0]; + + if ( ($AcalleridCOUNT < 1) and (eregi("INCALL",$Astatus)) and (strlen($Aagent_log_id) > 0) ) + { + $DEADcustomer++; + ### find whether the agent log record has already logged DEAD + $stmt="SELECT count(*) from vicidial_agent_log where agent_log_id='$Aagent_log_id' and ( (dead_epoch IS NOT NULL) or (dead_epoch > 10000) );"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03030',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $Aagent_log_idCOUNT=$row[0]; + + if ($Aagent_log_idCOUNT < 1) + { + $NEWdead_epoch = date("U"); + $deadNOW_TIME = date("Y-m-d H:i:s"); + $stmt="UPDATE vicidial_agent_log set dead_epoch='$NEWdead_epoch' where agent_log_id='$Aagent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03031',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt="UPDATE vicidial_live_agents set last_state_change='$deadNOW_TIME' where agent_log_id='$Aagent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03032',$user,$server_ip,$session_name,$one_mysql_log);} + } + } + ##### END DEAD logging section ##### + } + + ### grab the API hangup and API dispo fields in vicidial_live_agents + $stmt="SELECT external_hangup,external_status,external_pause,external_dial,external_update_fields,external_update_fields_data,external_timer_action,external_timer_action_message,external_timer_action_seconds from vicidial_live_agents where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03010',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $external_hangup = $row[0]; + $external_status = $row[1]; + $external_pause = $row[2]; + $external_dial = $row[3]; + $external_update_fields = $row[4]; + $external_update_fields_data = $row[5]; + $timer_action = $row[6]; + $timer_action_message = $row[7]; + $timer_action_seconds = $row[8]; + + if (strlen($external_status)<1) {$external_status = '::::::::::';} + + $web_epoch = date("U"); + $stmt="SELECT UNIX_TIMESTAMP(last_update),UNIX_TIMESTAMP(db_time) from server_updater where server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03014',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $server_epoch = $row[0]; + $db_epoch = $row[1]; + $time_diff = ($server_epoch - $db_epoch); + $web_diff = ($db_epoch - $web_epoch); + + ##### check for in-group change details + $InGroupChangeDetails = '0|||'; + $manager_ingroup_set=0; + $stmt="SELECT count(*) FROM vicidial_live_agents where user='$user' and manager_ingroup_set='SET';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03022',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $mis_record_ct = mysql_num_rows($rslt); + if ($mis_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $manager_ingroup_set = $row[0]; + } + if ($manager_ingroup_set > 0) + { + $stmt="UPDATE vicidial_live_agents SET closer_campaigns=external_ingroups, manager_ingroup_set='Y' where user='$user' and manager_ingroup_set='SET';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03023',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $VLAMISaffected_rows_update = mysql_affected_rows($link); + if ($VLAMISaffected_rows_update > 0) + { + $stmt="SELECT external_ingroups,external_blended,external_igb_set_user,outbound_autodial,dial_method FROM vicidial_live_agents vla, vicidial_campaigns vc where user='$user' and manager_ingroup_set='Y' and vla.campaign_id=vc.campaign_id;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03024',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $migs_record_ct = mysql_num_rows($rslt); + if ($migs_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $external_ingroups = $row[0]; + $external_blended = $row[1]; + $external_igb_set_user = $row[2]; + $outbound_autodial = $row[3]; + $dial_method = $row[4]; + + $stmt="SELECT full_name FROM vicidial_users where user='$external_igb_set_user';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03025',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $mign_record_ct = mysql_num_rows($rslt); + if ($mign_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $external_igb_set_name = $row[0]; + } + + $NEWoutbound_autodial='N'; + if ( ($external_blended > 0) and ($dial_method != "INBOUND_MAN") and ($dial_method != "MANUAL") ) + {$NEWoutbound_autodial='Y';} + + $stmt="UPDATE vicidial_live_agents SET outbound_autodial='$NEWoutbound_autodial' where user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03026',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $VLAMIBaffected_rows_update = mysql_affected_rows($link); + + $InGroupChangeDetails = "1|$external_blended|$external_igb_set_user|$external_igb_set_name"; + + $stmt="INSERT INTO vicidial_user_closer_log set user='$user',campaign_id='$Acampaign_id',event_date='$NOW_TIME',blended='$external_blended',closer_campaigns='$external_ingroups',manager_change='$external_igb_set_user';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03027',$user,$server_ip,$session_name,$one_mysql_log);} + } + } + } + + ##### grab the shift information the agent + $stmt="SELECT user_group,agent_shift_enforcement_override from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03015',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $VU_user_group = $row[0]; + $VU_agent_shift_enforcement_override = $row[1]; + + ### Gather timeclock and shift enforcement restriction settings + $stmt="SELECT shift_enforcement,group_shifts from vicidial_user_groups where user_group='$VU_user_group';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03016',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $shift_enforcement = $row[0]; + $LOGgroup_shiftsSQL = eregi_replace(' ','',$row[1]); + $LOGgroup_shiftsSQL = eregi_replace(' ',"','",$LOGgroup_shiftsSQL); + $LOGgroup_shiftsSQL = "shift_id IN('$LOGgroup_shiftsSQL')"; + + ### CHECK TO SEE IF AGENT IS WITHIN THEIR SHIFT IF RESTRICTED, IF NOT, OUTPUT ERROR + $Ashift_logout=0; + if ( ( (ereg("ALL",$shift_enforcement)) and (!ereg("OFF|START",$VU_agent_shift_enforcement_override)) ) or (ereg("ALL",$VU_agent_shift_enforcement_override)) ) + { + $shift_ok=0; + if (strlen($LOGgroup_shiftsSQL) < 3) + {$Ashift_logout++;} + else + { + $HHMM = date("Hi"); + $wday = date("w"); + + $stmt="SELECT shift_id,shift_start_time,shift_length,shift_weekdays from vicidial_shifts where $LOGgroup_shiftsSQL order by shift_id"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'3017',$user,$server_ip,$session_name,$one_mysql_log);} + $shifts_to_print = mysql_num_rows($rslt); + + $o=0; + while ( ($shifts_to_print > $o) and ($shift_ok < 1) ) + { + $rowx=mysql_fetch_row($rslt); + $shift_id = $rowx[0]; + $shift_start_time = $rowx[1]; + $shift_length = $rowx[2]; + $shift_weekdays = $rowx[3]; + + if (eregi("$wday",$shift_weekdays)) + { + $HHshift_length = substr($shift_length,0,2); + $MMshift_length = substr($shift_length,3,2); + $HHshift_start_time = substr($shift_start_time,0,2); + $MMshift_start_time = substr($shift_start_time,2,2); + $HHshift_end_time = ($HHshift_length + $HHshift_start_time); + $MMshift_end_time = ($MMshift_length + $MMshift_start_time); + if ($MMshift_end_time > 59) + { + $MMshift_end_time = ($MMshift_end_time - 60); + $HHshift_end_time++; + } + if ($HHshift_end_time > 23) + {$HHshift_end_time = ($HHshift_end_time - 24);} + $HHshift_end_time = sprintf("%02s", $HHshift_end_time); + $MMshift_end_time = sprintf("%02s", $MMshift_end_time); + $shift_end_time = "$HHshift_end_time$MMshift_end_time"; + + if ( + ( ($HHMM >= $shift_start_time) and ($HHMM < $shift_end_time) ) or + ( ($HHMM < $shift_start_time) and ($HHMM < $shift_end_time) and ($shift_end_time <= $shift_start_time) ) or + ( ($HHMM >= $shift_start_time) and ($HHMM >= $shift_end_time) and ($shift_end_time <= $shift_start_time) ) + ) + {$shift_ok++;} + } + $o++; + } + + if ($shift_ok < 1) + {$Ashift_logout++;} + } + } + + + if ( ( ($time_diff > 8) or ($time_diff < -8) or ($web_diff > 8) or ($web_diff < -8) ) and (eregi("0$",$StarTtime)) ) + {$Alogin='TIME_SYNC';} + if ($Acount < 1) + {$Alogin='DEAD_VLA';} + if ($AexternalDEAD > 0) + {$Alogin='DEAD_EXTERNAL';} + if ($Ashift_logout > 0) + {$Alogin='SHIFT_LOGOUT';} + + echo 'DateTime: ' . $NOW_TIME . '|UnixTime: ' . $StarTtime . '|Logged-in: ' . $Alogin . '|CampCalls: ' . $RingCalls . '|Status: ' . $Astatus . '|DiaLCalls: ' . $DiaLCalls . '|APIHanguP: ' . $external_hangup . '|APIStatuS: ' . $external_status . '|APIPausE: ' . $external_pause . '|APIDiaL: ' . $external_dial . '|DEADcall: ' . $DEADcustomer . '|InGroupChange: ' . $InGroupChangeDetails . '|APIFields: ' . $external_update_fields . '|APIFieldsData: ' . $external_update_fields_data . '|APITimerAction: ' . $timer_action . '|APITimerMessage: ' . $timer_action_message . '|APITimerSeconds: ' . $timer_action_seconds . "\n"; + + if (strlen($timer_action) > 3) + { + $stmt="UPDATE vicidial_live_agents SET external_timer_action='' where user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03028',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $VLAETAaffected_rows_update = mysql_affected_rows($link); + } + } + $total_conf=0; + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = '$conf_exten';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03011',$user,$server_ip,$session_name,$one_mysql_log);} + if ($rslt) {$sip_list = mysql_num_rows($rslt);} + # echo "$sip_list|"; + $loop_count=0; + while ($sip_list>$loop_count) + { + $loop_count++; $total_conf++; + $row=mysql_fetch_row($rslt); + $ChannelA[$total_conf] = "$row[0]"; + if ($format=='debug') {echo "\n";} + } + $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and extension = '$conf_exten';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03012',$user,$server_ip,$session_name,$one_mysql_log);} + if ($rslt) {$channels_list = mysql_num_rows($rslt);} + # echo "$channels_list|"; + $loop_count=0; + while ($channels_list>$loop_count) + { + $loop_count++; $total_conf++; + $row=mysql_fetch_row($rslt); + $ChannelA[$total_conf] = "$row[0]"; + if ($format=='debug') {echo "\n";} + } + } + $channels_list = ($channels_list + $sip_list); + echo "$channels_list|"; + + $counter=0; + $countecho=''; + while($total_conf > $counter) + { + $counter++; + $countecho = "$countecho$ChannelA[$counter] ~"; + # echo "$ChannelA[$counter] ~"; + } + + echo "$countecho\n"; + } + + if ($ACTION == 'register') + { + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($conf_exten)<1) || (strlen($exten)<1) ) + { + $channel_live=0; + echo "Conf Exten $conf_exten är ej giltig or Exten $exten är ej giltig\n"; + exit; + } + else + { + $stmt="UPDATE conferences set extension='$exten' where server_ip = '$server_ip' and conf_exten = '$conf_exten';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03013',$user,$server_ip,$session_name,$one_mysql_log);} + } + echo "Konferens $conf_exten har blivit registrerad $exten\n"; + } + + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + + +##### MySQL Error Logging ##### +function mysql_error_logging($NOW_TIME,$link,$mel,$stmt,$query_id,$user,$server_ip,$session_name,$one_mysql_log) +{ +$NOW_TIME = date("Y-m-d H:i:s"); +# mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00001',$user,$server_ip,$session_name,$one_mysql_log); +$errno=''; $error=''; +if ( ($mel > 0) or ($one_mysql_log > 0) ) + { + $errno = mysql_errno($link); + if ( ($errno > 0) or ($mel > 1) or ($one_mysql_log > 0) ) + { + $error = mysql_error($link); + $efp = fopen ("./vicidial_mysql_errors.txt", "a"); + fwrite ($efp, "$NOW_TIME|conf_check |$query_id|$errno|$error|$stmt|$user|$server_ip|$session_name|\n"); + fclose($efp); + } + } +$one_mysql_log=0; +return $errno; +} + +?> diff --git a/LANG_www/agc_se/dbconnect.php b/LANG_www/agc_se/dbconnect.php new file mode 100644 index 00000000..e02ca392 --- /dev/null +++ b/LANG_www/agc_se/dbconnect.php @@ -0,0 +1,61 @@ + LICENSE: AGPLv2 +# +if ( file_exists("/etc/astguiclient.conf") ) + { + $DBCagc = file("/etc/astguiclient.conf"); + foreach ($DBCagc as $DBCline) + { + $DBCline = preg_replace("/ |>|\n|\r|\t|\#.*|;.*/","",$DBCline); + if (ereg("^PATHlogs", $DBCline)) + {$PATHlogs = $DBCline; $PATHlogs = preg_replace("/.*=/","",$PATHlogs);} + if (ereg("^PATHweb", $DBCline)) + {$WeBServeRRooT = $DBCline; $WeBServeRRooT = preg_replace("/.*=/","",$WeBServeRRooT);} + if (ereg("^VARserver_ip", $DBCline)) + {$WEBserver_ip = $DBCline; $WEBserver_ip = preg_replace("/.*=/","",$WEBserver_ip);} + if (ereg("^VARDB_server", $DBCline)) + {$VARDB_server = $DBCline; $VARDB_server = preg_replace("/.*=/","",$VARDB_server);} + if (ereg("^VARDB_database", $DBCline)) + {$VARDB_database = $DBCline; $VARDB_database = preg_replace("/.*=/","",$VARDB_database);} + if (ereg("^VARDB_user", $DBCline)) + {$VARDB_user = $DBCline; $VARDB_user = preg_replace("/.*=/","",$VARDB_user);} + if (ereg("^VARDB_pass", $DBCline)) + {$VARDB_pass = $DBCline; $VARDB_pass = preg_replace("/.*=/","",$VARDB_pass);} + if (ereg("^VARDB_port", $DBCline)) + {$VARDB_port = $DBCline; $VARDB_port = preg_replace("/.*=/","",$VARDB_port);} + } + } +else + { + #defaults for DB connection + $VARDB_server = 'localhost'; + $VARDB_port = '3306'; + $VARDB_user = 'cron'; + $VARDB_pass = '1234'; + $VARDB_database = '1234'; + $WeBServeRRooT = '/usr/local/apache2/htdocs'; + } + +$link=mysql_connect("$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass"); +if (!$link) + { + die('MySQL connect ERROR: ' . mysql_error()); + } +mysql_select_db("$VARDB_database"); + +$local_DEF = 'Local/'; +$conf_silent_prefix = '7'; +$local_AMP = '@'; +$ext_context = 'demo'; +$recording_exten = '8309'; +$WeBRooTWritablE = '1'; +$non_latin = '0'; # set to 1 for UTF rules, overridden by system_settings +$flag_channels=0; +$flag_string = 'VICIast20'; + +?> diff --git a/LANG_www/agc_se/inbound_popup.php b/LANG_www/agc_se/inbound_popup.php new file mode 100644 index 00000000..824bf4cc --- /dev/null +++ b/LANG_www/agc_se/inbound_popup.php @@ -0,0 +1,352 @@ + LICENSE: AGPLv2 +# +# This script is designed to open up when a live_inbound call comes in giving the user +# options of what to do with the call or options to lookup the callerID on various web sites +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $uniqueid - ('1234567890.123456',...) +# - $user +# - $pass +# optional variables: +# - $format - ('text','debug') +# - $vmail_box - ('101','1234',...) +# - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +# - $ext_context - ('default','demo',...) +# - $ext_priority - ('1','2',...) +# - $voicemail_dump_exten - ('85026666666666') +# - $local_web_callerID_URL_enc - ( rawurlencoded custom callerid lookup URL) +# +# +# changes +# 50428-1500 - First build of script display only +# 50429-1241 - some formatting, hangup and Vmail redirect, 30s timeout on actions, and CID web lookup links +# 50503-1244 - added session_name checking for extra security +# 50711-1203 - removed HTTP authentication in favor of user/pass vars +# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60619-1205 - Added variable filters to close security holes for login form +# 90508-0727 - Changed to PHP long tags +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} + elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["vmail_box"])) {$vmail_box=$_GET["vmail_box"];} + elseif (isset($_POST["vmail_box"])) {$vmail_box=$_POST["vmail_box"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];} + elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];} +if (isset($_GET["voicemail_dump_exten"])) {$voicemail_dump_exten=$_GET["voicemail_dump_exten"];} + elseif (isset($_POST["voicemail_dump_exten"])) {$voicemail_dump_exten=$_POST["voicemail_dump_exten"];} +if (isset($_GET["local_web_callerID_URL_enc"])) {$local_web_callerID_URL_enc=$_GET["local_web_callerID_URL_enc"];} + elseif (isset($_POST["local_web_callerID_URL_enc"])) {$local_web_callerID_URL_enc=$_POST["local_web_callerID_URL_enc"];} +if (isset($_GET["local_web_callerID_URL_enc"])) {$local_web_callerID_URL = rawurldecode($local_web_callerID_URL_enc);} + else {$local_web_callerID_URL = '';} + +$user=ereg_replace("[^0-9a-zA-Z]","",$user); +$pass=ereg_replace("[^0-9a-zA-Z]","",$pass); + +# default optional vars if not set +if (!isset($format)) {$format="text";} + +$version = '0.0.6'; +$build = '60619-1205'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +$DO = '-1'; +if ( (eregi("^Zap",$channel)) and (!eregi("-",$channel)) ) {$channel = "$channel$DO";} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Felaktig Användarnamn/Lösenord: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Felaktig server_ip: |$server_ip| or Felaktig session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Felaktig session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +$forever_stop=0; +$user_abb = "$user$user$user$user"; +while ( (strlen($user_abb) > 4) and ($forever_stop < 200) ) + {$user_abb = eregi_replace("^.","",$user_abb); $forever_stop++;} + +echo "\n"; +echo "\n"; +echo "\n"; +?> + + +AKTIVT INGÅENDE SAMTAL"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "

AKTIVT INGÅENDE SAMTAL

\n"; +echo "$NOW_TIME

\n"; +} + + +$MT[0]=''; +$row=''; $rowx=''; +$channel_live=1; +if (strlen($uniqueid)<9) + { + $channel_live=0; + echo "Uniqueid $uniqueid är ej giltig\n"; + exit; + } +else + { + $stmt="SELECT uniqueid,channel,server_ip,caller_id,extension,phone_ext,start_time,acknowledged,inbound_number,comment_a,comment_b,comment_c,comment_d,comment_e FROM live_inbound where server_ip = '$server_ip' and uniqueid = '$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $channels_list = mysql_num_rows($rslt); + if ($channels_list>0) + { + $row=mysql_fetch_row($rslt); +# echo "$LIuniqueid|$LIchannel|$LIcallerid|$LIdatetime|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|"; +# Zap/73|"V.I.C.I. MARKET" <7275338730>|2005-04-28 14:01:21|7274514936|Inbound direct to Matt||||| + if ($format=='debug') {echo "\n";} + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Channel: $row[1]
CallerID: $row[3]
\n"; + + $phone = eregi_replace(".*\<","",$row[3]); + $phone = eregi_replace("\>.*","",$phone); + $NPA = substr($phone, 0, 3); + $NXX = substr($phone, 3, 3); + $XXXX = substr($phone, 6, 4); + $D='-'; + echo "GOOGLE - \n"; + echo "ANYWHO - \n"; + echo "SWITCHBOARD - \n"; + echo "VERIZON - \n"; + echo "WHITEPAGES - \n"; + echo "411.COM - \n"; + echo "411.COM - \n"; + + $local_web_callerID_QUERY_STRING =''; + $local_web_callerID_QUERY_STRING.="?callerID_areacode=$NPA"; + $local_web_callerID_QUERY_STRING.="&callerID_prefix=$NXX"; + $local_web_callerID_QUERY_STRING.="&callerID_last4=$XXXX"; + $local_web_callerID_QUERY_STRING.="&callerID_Time=$row[6]"; + $local_web_callerID_QUERY_STRING.="&callerID_Channel=$row[1]"; + $local_web_callerID_QUERY_STRING.="&callerID_uniqueID=$row[0]"; + $local_web_callerID_QUERY_STRING.="&callerID_phone_ext=$row[5]"; + $local_web_callerID_QUERY_STRING.="&callerID_server_ip=$row[2]"; + $local_web_callerID_QUERY_STRING.="&callerID_extension=$row[4]"; + $local_web_callerID_QUERY_STRING.="&callerID_inbound_number=$row[8]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_a=$row[9]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_b=$row[10]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_c=$row[11]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_d=$row[12]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_e=$row[13]"; + echo "CUSTOM - \n"; + + echo "
Uppringt nummer: $row[8]
Noteringar:$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|
\n"; + echo "Lägg på - \n"; + echo "SKICKA TILL MIN RÖSTBREVLÅDA\n"; + echo "
\n"; + + + $stmt="UPDATE live_inbound set acknowledged='Y' where server_ip = '$server_ip' and uniqueid = '$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + + } + + + } + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/LANG_www/agc_se/live_exten_check.php b/LANG_www/agc_se/live_exten_check.php new file mode 100644 index 00000000..d320a030 --- /dev/null +++ b/LANG_www/agc_se/live_exten_check.php @@ -0,0 +1,279 @@ + LICENSE: AGPLv2 +# +# This script is designed purely to send whether the client channel is live and to what channel it is connected +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $format - ('text','debug') +# - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +# - $protocol - ('SIP','Zap','IAX2',...) +# +# +# changes +# 50404-1249 - First build of script +# 50406-1402 - added connected trunk lookup +# 50428-1452 - added live_inbound check for exten on 2nd line of output +# 50503-1233 - added session_name checking for extra security +# 50524-1429 - added parked calls count +# 50610-1204 - Added NULL check on MySQL results to reduced errors +# 50711-1204 - removed HTTP authentication in favor of user/pass vars +# 60103-1541 - added favorite extens status display +# 60421-1359 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60619-1203 - Added variable filters to close security holes for login form +# 60825-1029 - Fixed translation variable issue ChannelA +# 90508-0727 - Changed to PHP long tags +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} +if (isset($_GET["favorites_count"])) {$favorites_count=$_GET["favorites_count"];} + elseif (isset($_POST["favorites_count"])) {$favorites_count=$_POST["favorites_count"];} +if (isset($_GET["favorites_list"])) {$favorites_list=$_GET["favorites_list"];} + elseif (isset($_POST["favorites_list"])) {$favorites_list=$_POST["favorites_list"];} + +$user=ereg_replace("[^0-9a-zA-Z]","",$user); +$pass=ereg_replace("[^0-9a-zA-Z]","",$pass); + +# default optional vars if not set +if (!isset($format)) {$format="text";} + +$version = '2.0.1'; +$build = '60825-1029'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Felaktig Användarnamn/Lösenord: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Felaktig server_ip: |$server_ip| or Felaktig session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Felaktig session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Kolla aktiv anknytning"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + +echo "DateTime: $NOW_TIME|"; +echo "UnixTime: $StarTtime|"; + +$stmt="SELECT count(*) FROM parked_channels where server_ip = '$server_ip';"; + if ($format=='debug') {echo "\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +echo "$row[0]|"; + + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<1) or (strlen($protocol)<3) ) + { + $channel_live=0; + echo "Exten $exten är ej giltig eller protokoll $protocol är ej giltig\n"; + exit; + } + else + { + $stmt="SELECT channel,extension FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$protocol/$exten%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$channels_list = mysql_num_rows($rslt);} + echo "$channels_list|"; + $loop_count=0; + while ($channels_list>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + $ChanneLA[$loop_count] = "$row[0]"; + $ChanneLB[$loop_count] = "$row[1]"; + if ($format=='debug') {echo "\n";} + } + } + + $counter=0; + while($loop_count > $counter) + { + $counter++; + $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and channel_data = '$ChanneLA[$counter]';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "ChannelA: $ChanneLA[$counter] ~"; + echo "ChannelB: $ChanneLB[$counter] ~"; + echo "ChannelBtrunk: $row[0]|"; + } + else + { + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel_data = '$ChanneLA[$counter]';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "ChannelA: $ChanneLA[$counter] ~"; + echo "ChannelB: $ChanneLB[$counter] ~"; + echo "ChannelBtrunk: $row[0]|"; + } + else + { + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$ChanneLB[$counter]%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "ChannelA: $ChanneLA[$counter] ~"; + echo "ChannelB: $ChanneLB[$counter] ~"; + echo "ChannelBtrunk: $row[0]|"; + } + else + { + $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and channel LIKE \"$ChanneLB[$counter]%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "ChannelA: $ChanneLA[$counter] ~"; + echo "ChannelB: $ChanneLB[$counter] ~"; + echo "ChannelBtrunk: $row[0]|"; + } + else + { + echo "Conversation: $counter ~"; + echo "ChannelA: $ChanneLA[$counter] ~"; + echo "ChannelB: $ChanneLB[$counter] ~"; + echo "ChannelBtrunk: $ChanneLA[$counter]|"; + } + } + } + } + } + +echo "\n"; + +### check for live_inbound entry +$stmt="select * from live_inbound where server_ip = '$server_ip' and phone_ext = '$exten' and acknowledged='N';"; + if ($format=='debug') {echo "\n";} +$rslt=mysql_query($stmt, $link); +if ($rslt) {$channels_list = mysql_num_rows($rslt);} + if ($channels_list>0) + { + $row=mysql_fetch_row($rslt); + $LIuniqueid = "$row[0]"; + $LIchannel = "$row[1]"; + $LIcallerid = "$row[3]"; + $LIdatetime = "$row[6]"; + echo "$LIuniqueid|$LIchannel|$LIcallerid|$LIdatetime|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|"; + if ($format=='debug') {echo "\n";} + } + +echo "\n"; + + +### if favorites are present do a lookup to see if any are active +if ($favorites_count > 0) + { + $favorites = explode(',',$favorites_list); + $h=0; + $favs_print=''; + while ($favorites_count > $h) + { + $fav_extension = explode('/',$favorites[$h]); + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$favorites[$h]%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $favs_print .= "$fav_extension[1]: $row[0] ~"; + $h++; + } + echo "$favs_print\n"; + } + +if ($format=='debug') {echo "\n";} + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/LANG_www/agc_se/manager_send.php b/LANG_www/agc_se/manager_send.php new file mode 100644 index 00000000..c3407d4d --- /dev/null +++ b/LANG_www/agc_se/manager_send.php @@ -0,0 +1,1670 @@ + LICENSE: AGPLv2 +# +# This script is designed purely to insert records into the vicidial_manager table to signal Actions to an asterisk server +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $ACTION - ('Originate','Redirect','Hangup','Command','Monitor','StopMonitor','SysCIDOriginate','RedirectName','RedirectNameVmail','MonitorConf','StopMonitorConf','RedirectXtra','RedirectXtraCX','RedirectVD','HangupConfDial','VolumeControl','OriginateVDRelogin') +# - $queryCID - ('CN012345678901234567',...) +# - $format - ('text','debug') +# - $channel - ('Zap/41-1','SIP/test101-1jut','IAX2/iaxy@iaxy',...) +# - $exten - ('1234','913125551212',...) +# - $ext_context - ('default','demo',...) +# - $ext_priority - ('1','2',...) +# - $filename - ('20050406-125623_44444',...) +# - $extenName - ('phone100',...) +# - $parkedby - ('phone100',...) +# - $extrachannel - ('Zap/41-1','SIP/test101-1jut','IAX2/iaxy@iaxy',...) +# - $auto_dial_level - ('0','1','1.1',...) +# - $campaign - ('CLOSER','TESTCAMP',...) +# - $uniqueid - ('1120232758.2406800',...) +# - $lead_id - ('1234',...) +# - $seconds - ('32',...) +# - $outbound_cid - ('3125551212','0000000000',...) +# - $agent_log_id - ('123456',...) +# - $call_server_ip - ('10.10.10.15',...) +# - $CalLCID - ('VD01234567890123456',...) +# - $stage - ('UP','DOWN','2NDXfeR') +# - $session_id - ('8600051') +# - $FROMvdc - ('YES','NO') +# - $agentchannel - ('SIP/cc101-g7yr','Zap/1-1',...) +# - $usegroupalias - ('0','1') +# - $account - ('DEFAULT',...) +# - $agent_dialed_number - ('1','') +# - $agent_dialed_type - ('MANUAL_OVERRIDE','MANUAL_DIALNOW','MANUAL_PREVIEW',...) +# - $nodeletevdac - ('0','1') +# +# CHANGELOG: +# 50401-1002 - First build of script, Hangup function only +# 50404-1045 - Redirect basic function enabled +# 50406-1522 - Monitor basic function enabled +# 50407-1647 - Monitor and StopMonitor full functions enabled +# 50422-1120 - basic Originate function enabled +# 50428-1451 - basic SysCIDOriginate function enabled for checking voicemail +# 50502-1539 - basic RedirectName and RedirectNameVmail added +# 50503-1227 - added session_name checking for extra security +# 50523-1341 - added Conference call start/stop recording +# 50523-1421 - added OriginateName and OriginateNameVmail for local calls +# 50524-1602 - added RedirectToPark and RedirectFromPark +# 50531-1203 - added RedirecXtra for dual channel redirection +# 50630-1100 - script changed to not use HTTP login vars, user/pass instead +# 50804-1148 - Added RedirectVD for VICIDIAL blind redirection with logging +# 50815-1204 - Added NEXTAVAILABLE to RedirectXtra function +# 50903-2343 - Added HangupConfDial function to hangup in-dial channels in conf +# 50913-1057 - Added outbound_cid set if present to originate call +# 51020-1556 - Added agent_log_id framework for detailed agent activity logging +# 51118-1204 - Fixed Blind transfer bug from VICIDIAL when in manual dial mode +# 51129-1014 - Added ability to accept calls from other VICIDIAL servers +# 51129-1253 - Fixed Hangups of other agents channels in VICIDIAL AD +# 60310-2022 - Fixed NEXTAVAILABLE bug in leave-3way-call redirect function +# 60421-1413 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60619-1158 - Added variable filters to close security holes for login form +# 60809-1544 - Added direct transfers to leave-3ways in consultative transfers +# 61004-1526 - Added parsing of volume control command and lookup or number +# 61130-1617 - Added lead_id to MonitorConf for recording_log +# 61201-1115 - Added user to MonitorConf for recording_log +# 70111-1600 - added ability to use BLEND/INBND/*_C/*_B/*_I as closer campaigns +# 70226-1251 - Added Mute/UnMute to conference volume control +# 70320-1502 - Added option to allow retry of leave-3way-call and debug logging +# 70322-1636 - Added sipsak display ability +# 80331-1433 - Added second transfer try for VICIDIAL transfers on manual dial calls +# 80402-0121 - Fixes for manual dial transfers on some systems +# 80424-0442 - Added non_latin lookup from system_settings +# 80707-2325 - Added vicidial_id to recording_log for tracking of vicidial or closer log to recording +# 80915-1755 - Rewrote leave-3way functions for external calling +# 81011-1404 - Fixed bugs in leave3way when transferring a manual dial call +# 81020-1459 - Fixed bugs in queue_log logging +# 81104-0203 - Added mysql error logging capability +# 90303-1144 - Fixed manual dial live hangup bug +# 90304-1334 - Added account and usegroupalias and user campaign/in-group specific variables +# 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 +# 90916-1830 - Added nodeletevdac +# 90924-1555 - Added am_message_exten_override for list_id option +# 91112-1110 - Added CALLOUTBOUND value to QM entry lookup +# 91205-2103 - Code cleanup +# 91213-1208 - Added queue_position to queue_log COMPLETE... records +# 100327-0846 - Fix for list_id override answering machine message + +$version = '2.2.0-47'; +$build = '100327-0846'; +$mel=1; # Mysql Error Log enabled = 1 +$mysql_log_count=85; +$one_mysql_log=0; + +require("dbconnect.php"); + +### These are variable assignments for PHP globals off +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];} + elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];} +if (isset($_GET["queryCID"])) {$queryCID=$_GET["queryCID"];} + elseif (isset($_POST["queryCID"])) {$queryCID=$_POST["queryCID"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];} + elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];} +if (isset($_GET["filename"])) {$filename=$_GET["filename"];} + elseif (isset($_POST["filename"])) {$filename=$_POST["filename"];} +if (isset($_GET["extenName"])) {$extenName=$_GET["extenName"];} + elseif (isset($_POST["extenName"])) {$extenName=$_POST["extenName"];} +if (isset($_GET["parkedby"])) {$parkedby=$_GET["parkedby"];} + elseif (isset($_POST["parkedby"])) {$parkedby=$_POST["parkedby"];} +if (isset($_GET["extrachannel"])) {$extrachannel=$_GET["extrachannel"];} + elseif (isset($_POST["extrachannel"])) {$extrachannel=$_POST["extrachannel"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} +if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} + elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["secondS"])) {$secondS=$_GET["secondS"];} + elseif (isset($_POST["secondS"])) {$secondS=$_POST["secondS"];} +if (isset($_GET["outbound_cid"])) {$outbound_cid=$_GET["outbound_cid"];} + elseif (isset($_POST["outbound_cid"])) {$outbound_cid=$_POST["outbound_cid"];} +if (isset($_GET["agent_log_id"])) {$agent_log_id=$_GET["agent_log_id"];} + elseif (isset($_POST["agent_log_id"])) {$agent_log_id=$_POST["agent_log_id"];} +if (isset($_GET["call_server_ip"])) {$call_server_ip=$_GET["call_server_ip"];} + elseif (isset($_POST["call_server_ip"])) {$call_server_ip=$_POST["call_server_ip"];} +if (isset($_GET["CalLCID"])) {$CalLCID=$_GET["CalLCID"];} + elseif (isset($_POST["CalLCID"])) {$CalLCID=$_POST["CalLCID"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} +if (isset($_GET["phone_ip"])) {$phone_ip=$_GET["phone_ip"];} + elseif (isset($_POST["phone_ip"])) {$phone_ip=$_POST["phone_ip"];} +if (isset($_GET["enable_sipsak_messages"])) {$enable_sipsak_messages=$_GET["enable_sipsak_messages"];} + elseif (isset($_POST["enable_sipsak_messages"])) {$enable_sipsak_messages=$_POST["enable_sipsak_messages"];} +if (isset($_GET["allow_sipsak_messages"])) {$allow_sipsak_messages=$_GET["allow_sipsak_messages"];} + elseif (isset($_POST["allow_sipsak_messages"])) {$allow_sipsak_messages=$_POST["allow_sipsak_messages"];} +if (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];} + elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];} +if (isset($_GET["FROMvdc"])) {$FROMvdc=$_GET["FROMvdc"];} + elseif (isset($_POST["FROMvdc"])) {$FROMvdc=$_POST["FROMvdc"];} +if (isset($_GET["agentchannel"])) {$agentchannel=$_GET["agentchannel"];} + elseif (isset($_POST["agentchannel"])) {$agentchannel=$_POST["agentchannel"];} +if (isset($_GET["usegroupalias"])) {$usegroupalias=$_GET["usegroupalias"];} + elseif (isset($_POST["usegroupalias"])) {$usegroupalias=$_POST["usegroupalias"];} +if (isset($_GET["account"])) {$account=$_GET["account"];} + elseif (isset($_POST["account"])) {$account=$_POST["account"];} +if (isset($_GET["agent_dialed_number"])) {$agent_dialed_number=$_GET["agent_dialed_number"];} + elseif (isset($_POST["agent_dialed_number"])) {$agent_dialed_number=$_POST["agent_dialed_number"];} +if (isset($_GET["agent_dialed_type"])) {$agent_dialed_type=$_GET["agent_dialed_type"];} + elseif (isset($_POST["agent_dialed_type"])) {$agent_dialed_type=$_POST["agent_dialed_type"];} +if (isset($_GET["nodeletevdac"])) {$nodeletevdac=$_GET["nodeletevdac"];} + elseif (isset($_POST["nodeletevdac"])) {$nodeletevdac=$_POST["nodeletevdac"];} + +header ("Content-type: text/html; charset=utf-8"); +header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header ("Pragma: no-cache"); // HTTP/1.0 + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin FROM system_settings;"; +$rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02001',$user,$server_ip,$session_name,$one_mysql_log);} +if ($DB) {echo "$stmt\n";} +$qm_conf_ct = mysql_num_rows($rslt); +if ($qm_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $non_latin = $row[0]; + } +##### END SETTINGS LOOKUP ##### +########################################### + +if ($non_latin < 1) + { + $user=ereg_replace("[^-_0-9a-zA-Z]","",$user); + $pass=ereg_replace("[^-_0-9a-zA-Z]","",$pass); + $secondS = ereg_replace("[^0-9]","",$secondS); + } +else + { + $user = ereg_replace("'|\"|\\\\|;","",$user); + $pass = ereg_replace("'|\"|\\\\|;","",$pass); + } + + +# default optional vars if not set +if (!isset($ACTION)) {$ACTION="Originate";} +if (!isset($format)) {$format="alert";} +if (!isset($ext_priority)) {$ext_priority="1";} + +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$NOWnum = date("YmdHis"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + +$stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; +if ($DB) {echo "|$stmt|\n";} +if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");} +$rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02002',$user,$server_ip,$session_name,$one_mysql_log);} +$row=mysql_fetch_row($rslt); +$auth=$row[0]; + +if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Felaktig Användarnamn/Lösenord: |$user|$pass|\n"; + exit; + } +else + { + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Felaktig server_ip: |$server_ip| or Felaktig session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02003',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Felaktig session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') + { + echo "\n"; + echo "\n"; + echo "\n"; + echo "Skicka till manager: "; + if ($ACTION=="Originate") {echo "Originate";} + if ($ACTION=="Redirect") {echo "Redirect";} + if ($ACTION=="RedirectName") {echo "RedirectName";} + if ($ACTION=="Hangup") {echo "Hangup";} + if ($ACTION=="Command") {echo "Command";} + if ($ACTION==99999) {echo "HJÄLP";} + echo "\n"; + echo "\n"; + echo "\n"; + } + + + + + +###################### +# ACTION=SysCIDOriginate - insert Originate Manager statement allowing small CIDs for system calls +###################### +if ($ACTION=="SysCIDOriginate") + { + if ( (strlen($exten)<1) or (strlen($channel)<1) or (strlen($ext_context)<1) or (strlen($queryCID)<1) ) + { + echo "Exten $exten är ej giltig or queryCID $queryCID är ej giltig, Originate kommandot skrevs ej\n"; + } + else + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02004',$user,$server_ip,$session_name,$one_mysql_log);} + echo "Originate kommandot skickat till Exten $exten Kanal $channel på $server_ip\n"; + } + } + + + +###################### +# ACTION=Originate, OriginateName, OriginateNameVmail - insert Originate Manager statement +###################### +if ($ACTION=="OriginateName") + { + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "En av dessa variabler är ej giltig:\n"; + echo "Channel $channel måste vara mer än 2 tecken\n"; + echo "queryCID $queryCID måste vara mer än 14 tecken\n"; + echo "extenName $extenName måste väljas\n"; + echo "ext_context $ext_context måste väljas\n"; + echo "ext_priority $ext_priority måste väljas\n"; + echo "\nOriginateName Action ej skickat\n"; + } + else + { + $stmt="SELECT dialplan_number FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02005',$user,$server_ip,$session_name,$one_mysql_log);} + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = $row[0]; + $ACTION="Originate"; + } + } + } + +if ($ACTION=="OriginateNameVmail") + { + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "En av dessa variabler är ej giltig:\n"; + echo "Channel $channel måste vara mer än 2 tecken\n"; + echo "queryCID $queryCID måste vara mer än 14 tecken\n"; + echo "extenName $extenName måste väljas\n"; + echo "exten $exten måste väljas\n"; + echo "ext_context $ext_context måste väljas\n"; + echo "ext_priority $ext_priority måste väljas\n"; + echo "\nOriginateNameVmail Action ej skickat\n"; + } + else + { + $stmt="SELECT voicemail_id FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02006',$user,$server_ip,$session_name,$one_mysql_log);} + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = "$exten$row[0]"; + $ACTION="Originate"; + } + } + } + +if ($ACTION=="OriginateVDRelogin") + { + if ( ($enable_sipsak_messages > 0) and ($allow_sipsak_messages > 0) and (eregi("SIP",$protocol)) ) + { + $CIDdate = date("ymdHis"); + $DS='-'; + $SIPSAK_prefix = 'LIN-'; + print "\n"; + passthru("/usr/local/bin/sipsak -M -O desktop -B \"$SIPSAK_prefix$campaign\" -r 5060 -s sip:$extension@$phone_ip > /dev/null"); + $queryCID = "$SIPSAK_prefix$campaign$DS$CIDdate"; + + } + $ACTION="Originate"; + } + +if ($ACTION=="Originate") + { + if ( (strlen($exten)<1) or (strlen($channel)<1) or (strlen($ext_context)<1) or (strlen($queryCID)<10) ) + { + echo "ERROR Exten $exten är ej giltig or queryCID $queryCID är ej giltig, Originate kommandot skrevs ej\n"; + } + else + { + if ( (eregi('MANUAL',$agent_dialed_type)) and ( (preg_match("/^\d860\d\d\d\d$/i",$exten)) or (preg_match("/^860\d\d\d\d$/i",$exten)) ) ) + { + echo "ERROR Du har inte behörighet att logga in på andra agenters sessions $exten\n"; + exit; + } + + if (strlen($outbound_cid)>1) + {$outCID = "\"$queryCID\" <$outbound_cid>";} + else + {$outCID = "$queryCID";} + if ( ($usegroupalias > 0) and (strlen($account)>1) ) + { + $RAWaccount = $account; + $account = "Account: $account"; + $variable = "Variable: usegroupalias=1"; + } + else + {$account=''; $variable='';} + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $outCID','$account','$variable','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02007',$user,$server_ip,$session_name,$one_mysql_log);} + echo "Originate kommandot skickat till Exten $exten Kanal $channel på $server_ip |$account|$variable|\n"; + + if ($agent_dialed_number > 0) + { + $stmt = "INSERT INTO user_call_log (user,call_date,call_type,server_ip,phone_number,number_dialed,lead_id,callerid,group_alias_id) values('$user','$NOW_TIME','$agent_dialed_type','$server_ip','$exten','$channel','0','$outbound_cid','$RAWaccount')"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00192',$user,$server_ip,$session_name,$one_mysql_log);} + } + } + } + + + +###################### +# ACTION=HangupConfDial - find the Local channel that is in the conference and needs to be hung up +###################### +if ($ACTION=="HangupConfDial") + { + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<3) or (strlen($queryCID)<15) or (strlen($ext_context)<1) ) + { + $channel_live=0; + echo "conference $exten är ej giltig or ext_context $ext_context or queryCID $queryCID är ej giltig, Hangup kommandot skrevs ej\n"; + } + else + { + $local_DEF = 'Local/'; + $local_AMP = '@'; + $hangup_channel_prefix = "$local_DEF$exten$local_AMP$ext_context"; + + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$hangup_channel_prefix%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02008',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + if ($row > 0) + { + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$hangup_channel_prefix%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02009',$user,$server_ip,$session_name,$one_mysql_log);} + $rowx=mysql_fetch_row($rslt); + $channel=$rowx[0]; + $ACTION="Hangup"; + $queryCID = eregi_replace("^.","G",$queryCID); # GTvdcW... + } + } + } + + + +###################### +# ACTION=Hangup - insert Hangup Manager statement +###################### +if ($ACTION=="Hangup") + { + $stmt="UPDATE vicidial_live_agents SET external_hangup='0' where user='$user';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02010',$user,$server_ip,$session_name,$one_mysql_log);} + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) ) + { + $channel_live=0; + echo "Channel $channel är ej giltig or queryCID $queryCID är ej giltig, Hangup kommandot skrevs ej\n"; + } + else + { + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + +# $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel';"; +# if ($format=='debug') {echo "\n";} +# $rslt=mysql_query($stmt, $link); +# $row=mysql_fetch_row($rslt); +# if ($row[0]==0) +# { +# $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$call_server_ip' and channel='$channel';"; +# if ($format=='debug') {echo "\n";} +# $rslt=mysql_query($stmt, $link); +# $rowx=mysql_fetch_row($rslt); +# if ($rowx[0]==0) +# { +# $channel_live=0; +# echo "Channel $channel is not live on $call_server_ip, Hangup command not inserted\n"; +# } +# } + if ( ($auto_dial_level > 0) and (strlen($CalLCID)>2) and (strlen($exten)>2) and ($secondS > 0)) + { + $stmt="SELECT count(*) FROM vicidial_auto_calls where channel='$channel' and callerid='$CalLCID';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02011',$user,$server_ip,$session_name,$one_mysql_log);} + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + echo "Call $CalLCID $channel är inte aktivt på $call_server_ip, Checking Live Kanal...\n"; + + $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel' and extension LIKE \"%$exten\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02012',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $channel_live=0; + echo "Channel $channel är inte aktivt på $call_server_ip, Hangup kommandot skrevs ej $rowx[0]\n$stmt\n"; + } + else + { + echo "$stmt\n"; + } + } + } + if ( ($auto_dial_level < 1) and (strlen($stage)>2) and (strlen($channel)>2) and (strlen($exten)>2) ) + { + $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel' and extension NOT LIKE \"%$exten%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02083',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + { + $channel_live=0; + echo "Channel $channel in use by another agent på $call_server_ip, Hangup kommandot skrevs ej $rowx[0]\n$stmt\n"; + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./vicidial_debug.txt", "a"); + fwrite ($fp, "$NOW_TIME|MDCHU|$user|$channel|$call_server_ip|$exten|\n"); + fclose($fp); + } + } + else + { + echo "$stmt\n"; + } + } + + if ($channel_live==1) + { + if ( (strlen($CalLCID)>15) and ($secondS > 0)) + { + $stmt="SELECT count(*) FROM vicidial_auto_calls where callerid='$CalLCID';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02013',$user,$server_ip,$session_name,$one_mysql_log);} + $rowx=mysql_fetch_row($rslt); + if ($format=='debug') {echo "\n";} + if ($rowx[0] > 0) + { + ############################################# + ##### START QUEUEMETRICS LOGGING LOOKUP ##### + $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02014',$user,$server_ip,$session_name,$one_mysql_log);} + if ($format=='debug') {echo "\n";} + $qm_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $qm_conf_ct) + { + $row=mysql_fetch_row($rslt); + $enable_queuemetrics_logging = $row[0]; + $queuemetrics_server_ip = $row[1]; + $queuemetrics_dbname = $row[2]; + $queuemetrics_login = $row[3]; + $queuemetrics_pass = $row[4]; + $queuemetrics_log_id = $row[5]; + $i++; + } + ##### END QUEUEMETRICS LOGGING LOOKUP ##### + ########################################### + if ($enable_queuemetrics_logging > 0) + { + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); + mysql_select_db("$queuemetrics_dbname", $linkB); + + $stmt="SELECT count(*) from queue_log where call_id='$CalLCID' and verb='CONNECT';"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'02015',$user,$server_ip,$session_name,$one_mysql_log);} + $VAC_cn_ct = mysql_num_rows($rslt); + if ($VAC_cn_ct > 0) + { + $row=mysql_fetch_row($rslt); + $caller_connect = $row[0]; + } + if ($format=='debug') {echo "\n";} + if ($caller_connect > 0) + { + $CLqueue_position='1'; + ### grab call lead information needed for QM logging + $stmt="SELECT auto_call_id,lead_id,phone_number,status,campaign_id,phone_code,alt_dial,stage,callerid,uniqueid,queue_position from vicidial_auto_calls where callerid='$CalLCID' order by call_time limit 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02016',$user,$server_ip,$session_name,$one_mysql_log);} + $VAC_qm_ct = mysql_num_rows($rslt); + if ($VAC_qm_ct > 0) + { + $row=mysql_fetch_row($rslt); + $auto_call_id = $row[0]; + $CLlead_id = $row[1]; + $CLphone_number = $row[2]; + $CLstatus = $row[3]; + $CLcampaign_id = $row[4]; + $CLphone_code = $row[5]; + $CLalt_dial = $row[6]; + $CLstage = $row[7]; + $CLcallerid = $row[8]; + $CLuniqueid = $row[9]; + $CLqueue_position = $row[10]; + } + if ($format=='debug') {echo "\n";} + + $CLstage = preg_replace("/.*-/",'',$CLstage); + if (strlen($CLstage) < 1) {$CLstage=0;} + + $stmt="SELECT count(*) from queue_log where call_id='$CalLCID' and verb='COMPLETECALLER' and queue='$CLcampaign_id';"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'02017',$user,$server_ip,$session_name,$one_mysql_log);} + $VAC_cc_ct = mysql_num_rows($rslt); + if ($VAC_cc_ct > 0) + { + $row=mysql_fetch_row($rslt); + $caller_complete = $row[0]; + } + if ($format=='debug') {echo "\n";} + + if ($caller_complete < 1) + { + $time_id=0; + $stmt="SELECT time_id from queue_log where call_id='$CalLCID' and verb IN('ENTERQUEUE','CALLOUTBOUND') and queue='$CLcampaign_id';"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'02018',$user,$server_ip,$session_name,$one_mysql_log);} + $VAC_eq_ct = mysql_num_rows($rslt); + if ($VAC_eq_ct > 0) + { + $row=mysql_fetch_row($rslt); + $time_id = $row[0]; + } + $StarTtime = date("U"); + if ($time_id > 100000) + {$secondS = ($StarTtime - $time_id);} + + if ($format=='debug') {echo "\n";} + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$CalLCID',queue='$CLcampaign_id',agent='Agent/$user',verb='COMPLETEAGENT',data1='$CLstage',data2='$secondS',data3='$CLqueue_position',serverid='$queuemetrics_log_id';"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'02019',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + if ($format=='debug') {echo "\n";} + } + } + } + } + } + + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$call_server_ip','','Hangup','$queryCID','Channel: $channel','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02020',$user,$server_ip,$session_name,$one_mysql_log);} + echo "Hangup kommandot skickat till Kanal $channel på $call_server_ip\n"; + } + } + } + + + +###################### +# ACTION=Redirect, RedirectName, RedirectNameVmail, RedirectToPark, RedirectFromPark, RedirectVD, RedirectXtra, RedirectXtraCX +# - insert Redirect Manager statement using extensions name +###################### +if ($ACTION=="RedirectVD") + { + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($campaign)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($uniqueid)<2) or (strlen($lead_id)<1) ) + { + $channel_live=0; + echo "En av dessa variabler är ej giltig:\n"; + echo "Channel $channel måste vara mer än 2 tecken\n"; + echo "queryCID $queryCID måste vara mer än 14 tecken\n"; + echo "exten $exten måste väljas\n"; + echo "ext_context $ext_context måste väljas\n"; + echo "ext_priority $ext_priority måste väljas\n"; + echo "auto_dial_level $auto_dial_level måste väljas\n"; + echo "campaign $campaign måste väljas\n"; + echo "uniqueid $uniqueid måste väljas\n"; + echo "lead_id $lead_id måste väljas\n"; + echo "\nRedirectVD Action ej skickat\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + $stmt = "select count(*) from vicidial_campaigns where campaign_id='$campaign' and campaign_allow_inbound='Y';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02021',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + { + $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);} + } + + $stmt = "UPDATE vicidial_log set end_epoch='$StarTtime', length_in_sec='$secondS',status='XFER' where uniqueid='$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02023',$user,$server_ip,$session_name,$one_mysql_log);} + + if ($nodeletevdac < 1) + { + $stmt = "DELETE from vicidial_auto_calls where uniqueid='$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02024',$user,$server_ip,$session_name,$one_mysql_log);} + } + $ACTION="Redirect"; + } + } + +if ($ACTION=="RedirectToPark") + { + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($extenName)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($parkedby)<1) ) + { + $channel_live=0; + echo "En av dessa variabler är ej giltig:\n"; + echo "Channel $channel måste vara mer än 2 tecken\n"; + echo "queryCID $queryCID måste vara mer än 14 tecken\n"; + echo "exten $exten måste väljas\n"; + echo "extenName $extenName måste väljas\n"; + echo "ext_context $ext_context måste väljas\n"; + echo "ext_priority $ext_priority måste väljas\n"; + echo "parkedby $parkedby måste väljas\n"; + echo "\nRedirectToPark Action ej skickat\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + $stmt = "INSERT INTO parked_channels values('$channel','$server_ip','$CalLCID','$extenName','$parkedby','$NOW_TIME');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02025',$user,$server_ip,$session_name,$one_mysql_log);} + $ACTION="Redirect"; + + # $fp = fopen ("./vicidial_debug.txt", "a"); + # fwrite ($fp, "$NOW_TIME|MS_LOG_0|$queryCID|$stmt|\n"); + # fclose($fp); + } + } + +if ($ACTION=="RedirectFromPark") + { + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "En av dessa variabler är ej giltig:\n"; + echo "Channel $channel måste vara mer än 2 tecken\n"; + echo "queryCID $queryCID måste vara mer än 14 tecken\n"; + echo "exten $exten måste väljas\n"; + echo "ext_context $ext_context måste väljas\n"; + echo "ext_priority $ext_priority måste väljas\n"; + echo "\nRedirectFromPark Action ej skickat\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + $stmt = "DELETE FROM parked_channels where server_ip='$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02026',$user,$server_ip,$session_name,$one_mysql_log);} + $ACTION="Redirect"; + } + } + +if ($ACTION=="RedirectName") + { + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "En av dessa variabler är ej giltig:\n"; + echo "Channel $channel måste vara mer än 2 tecken\n"; + echo "queryCID $queryCID måste vara mer än 14 tecken\n"; + echo "extenName $extenName måste väljas\n"; + echo "ext_context $ext_context måste väljas\n"; + echo "ext_priority $ext_priority måste väljas\n"; + echo "\nRedirectName Action ej skickat\n"; + } + else + { + $stmt="SELECT dialplan_number FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02027',$user,$server_ip,$session_name,$one_mysql_log);} + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = $row[0]; + $ACTION="Redirect"; + } + } + } + +if ($ACTION=="RedirectNameVmail") + { + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "En av dessa variabler är ej giltig:\n"; + echo "Channel $channel måste vara mer än 2 tecken\n"; + echo "queryCID $queryCID måste vara mer än 14 tecken\n"; + echo "extenName $extenName måste väljas\n"; + echo "exten $exten måste väljas\n"; + echo "ext_context $ext_context måste väljas\n"; + echo "ext_priority $ext_priority måste väljas\n"; + echo "\nRedirectNameVmail Action ej skickat\n"; + } + else + { + $stmt="SELECT voicemail_id FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02028',$user,$server_ip,$session_name,$one_mysql_log);} + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = "$exten$row[0]"; + $ACTION="Redirect"; + } + } + } + + + + + + +if ($ACTION=="RedirectXtraCXNeW") + { + $DBout=''; + $row=''; $rowx=''; + $channel_liveX=1; + $channel_liveY=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($session_id)<3) or ( ( (strlen($extrachannel)<3) or (strlen($exten)<1) ) and (!ereg("NEXTAVAILABLE",$exten)) ) ) + { + $channel_liveX=0; + $channel_liveY=0; + echo "En av dessa variabler är ej giltig:\n"; + echo "Channel $channel måste vara mer än 2 tecken\n"; + echo "ExtraChannel $extrachannel måste vara mer än 2 tecken\n"; + echo "queryCID $queryCID måste vara mer än 14 tecken\n"; + echo "exten $exten måste väljas\n"; + echo "ext_context $ext_context måste väljas\n"; + echo "ext_priority $ext_priority måste väljas\n"; + echo "\nRedirect Action ej skickat\n"; + if (ereg("SECOND|FIRST|DEBUG",$filename)) + { + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./vicidial_debug.txt", "a"); + fwrite ($fp, "$NOW_TIME|RDCXC|$filename|$user|$campaign|$channel|$extrachannel|$queryCID|$exten|$ext_context|ext_priority|\n"); + fclose($fp); + } + } + } + else + { + if (ereg("NEXTAVAILABLE",$exten)) + { + $stmtA="SELECT count(*) FROM vicidial_conferences where server_ip='$server_ip' and ((extension='') or (extension is null)) and conf_exten != '$session_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmtA, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtA,'02029',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + if ($row[0] > 1) + { + $stmtB="UPDATE vicidial_conferences set extension='$protocol/$extension$NOWnum', leave_3way='0' where server_ip='$server_ip' and ((extension='') or (extension is null)) and conf_exten != '$session_id' limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmtB, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtB,'02030',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmtC="SELECT conf_exten from vicidial_conferences where server_ip='$server_ip' and extension='$protocol/$extension$NOWnum' and conf_exten != '$session_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmtC, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtC,'02031',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $exten = $row[0]; + + if ( (ereg("^8300",$extension)) and ($protocol == 'Local') ) + { + $extension = "$extension$user"; + } + + $stmtD="UPDATE vicidial_conferences set extension='$protocol/$extension' where server_ip='$server_ip' and conf_exten='$exten' limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmtD, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtD,'02032',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmtE="UPDATE vicidial_conferences set leave_3way='1', leave_3way_datetime='$NOW_TIME', extension='3WAY_$user' where server_ip='$server_ip' and conf_exten='$session_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmtE, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtE,'02033',$user,$server_ip,$session_name,$one_mysql_log);} + + $queryCID = "CXAR24$NOWnum"; + $stmtF="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $agentchannel','Context: $ext_context','Exten: $exten','Priority: 1','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmtF, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtF,'02034',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmtG="UPDATE vicidial_live_agents set conf_exten='$exten' where server_ip='$server_ip' and user='$user';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmtG, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtG,'02035',$user,$server_ip,$session_name,$one_mysql_log);} + + if ($auto_dial_level < 1) + { + $stmtH = "DELETE from vicidial_auto_calls where lead_id='$lead_id' and callerid LIKE \"M%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmtH, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtH,'02036',$user,$server_ip,$session_name,$one_mysql_log);} + } + + // $fp = fopen ("./vicidial_debug_3way.txt", "a"); + // fwrite ($fp, "$NOW_TIME|$filename|\n|$stmtA|\n|$stmtB|\n|$stmtC|\n|$stmtD|\n|$stmtE|\n|$stmtF|\n|$stmtG|\n|$stmtH|\n\n"); + // fclose($fp); + + echo "NeWSessioN|$exten|\n"; + echo "|$stmtG|\n"; + + exit; + } + else + { + $channel_liveX=0; + echo "Cannot find empty vicidial_conference på $server_ip, Redirect kommandot skrevs ej\n|$stmt|"; + if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "Hittar ingen tom konferens på $server_ip";} + } + } + + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + + $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02037',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$call_server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02038',$user,$server_ip,$session_name,$one_mysql_log);} + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_liveX=0; + echo "Channel $channel är inte aktivt på $call_server_ip, Redirect kommandot skrevs ej\n"; + if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "$channel är inte aktivt på $call_server_ip";} + } + } + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$extrachannel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02039',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$extrachannel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02040',$user,$server_ip,$session_name,$one_mysql_log);} + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_liveY=0; + echo "Channel $channel är inte aktivt på $server_ip, Redirect kommandot skrevs ej\n"; + if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "$channel är inte aktivt på $server_ip";} + } + } + if ( ($channel_liveX==1) && ($channel_liveY==1) ) + { + $stmt="SELECT count(*) FROM vicidial_live_agents where lead_id='$lead_id' and user!='$user';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02041',$user,$server_ip,$session_name,$one_mysql_log);} + $rowx=mysql_fetch_row($rslt); + if ($rowx[0] < 1) + { + $channel_liveY=0; + echo "No Local agent to send call to, Redirect kommandot skrevs ej\n"; + if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "No Local agent to send call to";} + } + else + { + $stmt="SELECT server_ip,conf_exten,user FROM vicidial_live_agents where lead_id='$lead_id' and user!='$user';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02042',$user,$server_ip,$session_name,$one_mysql_log);} + $rowx=mysql_fetch_row($rslt); + $dest_server_ip = $rowx[0]; + $dest_session_id = $rowx[1]; + $dest_user = $rowx[2]; + $S='*'; + + $D_s_ip = explode('.', $dest_server_ip); + if (strlen($D_s_ip[0])<2) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[0])<3) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[1])<2) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[1])<3) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[2])<2) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[2])<3) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[3])<2) {$D_s_ip[3] = "0$D_s_ip[3]";} + if (strlen($D_s_ip[3])<3) {$D_s_ip[3] = "0$D_s_ip[3]";} + $dest_dialstring = "$D_s_ip[0]$S$D_s_ip[1]$S$D_s_ip[2]$S$D_s_ip[3]$S$dest_session_id$S$lead_id$S$dest_user$S$phone_code$S$phone_number$S$campaign$S"; + + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$call_server_ip','','Redirect','$queryCID','Channel: $channel','Context: $ext_context','Exten: $dest_dialstring','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02043',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','$queryCID','Channel: $extrachannel','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02044',$user,$server_ip,$session_name,$one_mysql_log);} + + echo "RedirectXtraCX kommandot skickat till Kanal $channel på $call_server_ip and \nHungup $extrachannel på $server_ip\n"; + if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "$channel på $call_server_ip, Hungup $extrachannel på $server_ip";} + } + } + else + { + if ($channel_liveX==1) + {$ACTION="Redirect"; $server_ip = $call_server_ip;} + if ($channel_liveY==1) + {$ACTION="Redirect"; $channel=$extrachannel;} + if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "Changed to Redirect: $channel på $server_ip";} + } + + if (ereg("SECOND|FIRST|DEBUG",$filename)) + { + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./vicidial_debug.txt", "a"); + fwrite ($fp, "$NOW_TIME|RDCXC|$filename|$user|$campaign|$DBout|\n"); + fclose($fp); + } + } + } + } + + + + + + + + + + +if ($ACTION=="RedirectXtraNeW") + { + if ($channel=="$extrachannel") + {$ACTION="Redirect";} + else + { + $row=''; $rowx=''; + $channel_liveX=1; + $channel_liveY=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($session_id)<3) or ( ( (strlen($extrachannel)<3) or (strlen($exten)<1) ) and (!ereg("NEXTAVAILABLE",$exten)) ) ) + { + $channel_liveX=0; + $channel_liveY=0; + echo "En av dessa variabler är ej giltig:\n"; + echo "Channel $channel måste vara mer än 2 tecken\n"; + echo "ExtraChannel $extrachannel måste vara mer än 2 tecken\n"; + echo "queryCID $queryCID måste vara mer än 14 tecken\n"; + echo "exten $exten måste väljas\n"; + echo "ext_context $ext_context måste väljas\n"; + echo "ext_priority $ext_priority måste väljas\n"; + echo "session_id $session_id måste väljas\n"; + echo "\nRedirect Action ej skickat\n"; + if (ereg("SECOND|FIRST|DEBUG",$filename)) + { + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./vicidial_debug.txt", "a"); + fwrite ($fp, "$NOW_TIME|RDX|$filename|$user|$campaign|$$channel|$extrachannel|$queryCID|$exten|$ext_context|ext_priority|$session_id|\n"); + fclose($fp); + } + } + } + else + { + if (ereg("NEXTAVAILABLE",$exten)) + { + $stmt="SELECT count(*) FROM vicidial_conferences where server_ip='$server_ip' and ((extension='') or (extension is null)) and conf_exten != '$session_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02045',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + if ($row[0] > 1) + { + $stmt="UPDATE vicidial_conferences set extension='$protocol/$extension$NOWnum', leave_3way='0' where server_ip='$server_ip' and ((extension='') or (extension is null)) and conf_exten != '$session_id' limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02046',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt="SELECT conf_exten from vicidial_conferences where server_ip='$server_ip' and extension='$protocol/$extension$NOWnum' and conf_exten != '$session_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02047',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $exten = $row[0]; + + $stmt="UPDATE vicidial_conferences set extension='$protocol/$extension' where server_ip='$server_ip' and conf_exten='$exten' limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02048',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt="UPDATE vicidial_conferences set leave_3way='1', leave_3way_datetime='$NOW_TIME', extension='3WAY_$user' where server_ip='$server_ip' and conf_exten='$session_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02049',$user,$server_ip,$session_name,$one_mysql_log);} + + $queryCID = "CXAR23$NOWnum"; + $stmtB="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $agentchannel','Context: $ext_context','Exten: $exten','Priority: 1','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmtB, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02050',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt="UPDATE vicidial_live_agents set conf_exten='$exten' where server_ip='$server_ip' and user='$user';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02051',$user,$server_ip,$session_name,$one_mysql_log);} + + if ($auto_dial_level < 1) + { + $stmt = "DELETE from vicidial_auto_calls where lead_id='$lead_id' and callerid LIKE \"M%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02052',$user,$server_ip,$session_name,$one_mysql_log);} + } + + echo "NeWSessioN|$exten|\n"; + echo "|$stmtB|\n"; + + exit; + } + else + { + $channel_liveX=0; + echo "Cannot find empty vicidial_conference på $server_ip, Redirect kommandot skrevs ej\n|$stmt|"; + if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "Hittar ingen tom konferens på $server_ip";} + } + } + + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + + $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02053',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + if ( ($row[0]==0) && (!ereg("SECOND",$filename)) ) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$call_server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02054',$user,$server_ip,$session_name,$one_mysql_log);} + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_liveX=0; + echo "Channel $channel är inte aktivt på $call_server_ip, Redirect kommandot skrevs ej\n"; + if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "$channel är inte aktivt på $call_server_ip";} + } + } + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$extrachannel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02055',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + if ( ($row[0]==0) && (!ereg("SECOND",$filename)) ) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$extrachannel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02056',$user,$server_ip,$session_name,$one_mysql_log);} + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_liveY=0; + echo "Channel $channel är inte aktivt på $server_ip, Redirect kommandot skrevs ej\n"; + if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "$channel är inte aktivt på $server_ip";} + } + } + if ( ($channel_liveX==1) && ($channel_liveY==1) ) + { + if ( ($server_ip=="$call_server_ip") or (strlen($call_server_ip)<7) ) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $channel','ExtraChannel: $extrachannel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02057',$user,$server_ip,$session_name,$one_mysql_log);} + + echo "RedirectXtra kommandot skickat till Kanal $channel and \nExtraChannel $extrachannel\n to $exten på $server_ip\n"; + if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "$channel and $extrachannel to $exten på $server_ip";} + } + else + { + $S='*'; + $D_s_ip = explode('.', $server_ip); + if (strlen($D_s_ip[0])<2) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[0])<3) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[1])<2) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[1])<3) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[2])<2) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[2])<3) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[3])<2) {$D_s_ip[3] = "0$D_s_ip[3]";} + if (strlen($D_s_ip[3])<3) {$D_s_ip[3] = "0$D_s_ip[3]";} + $dest_dialstring = "$D_s_ip[0]$S$D_s_ip[1]$S$D_s_ip[2]$S$D_s_ip[3]$S$exten"; + + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$call_server_ip','','Redirect','$queryCID','Channel: $channel','Context: $ext_context','Exten: $dest_dialstring','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02058',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $extrachannel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02059',$user,$server_ip,$session_name,$one_mysql_log);} + + echo "RedirectXtra kommandot skickat till Kanal $channel på $call_server_ip and \nExtraChannel $extrachannel\n to $exten på $server_ip\n"; + if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "$channel/$call_server_ip and $extrachannel/$server_ip to $exten";} + } + } + else + { + if ($channel_liveX==1) + {$ACTION="Redirect"; $server_ip = $call_server_ip;} + if ($channel_liveY==1) + {$ACTION="Redirect"; $channel=$extrachannel;} + } + + if (ereg("SECOND|FIRST|DEBUG",$filename)) + { + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./vicidial_debug.txt", "a"); + fwrite ($fp, "$NOW_TIME|RDX|$filename|$user|$campaign|$DBout|\n"); + fclose($fp); + } + } + } + } + } + + + + + +if ($ACTION=="Redirect") + { + ### for manual dial VICIDIAL calls send the second attempt to transfer the call + if ($stage=="2NDXfeR") + { + $local_DEF = 'Local/'; + $local_AMP = '@'; + $hangup_channel_prefix = "$local_DEF$session_id$local_AMP$ext_context"; + + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$hangup_channel_prefix%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02060',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + if ($row > 0) + { + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$hangup_channel_prefix%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02061',$user,$server_ip,$session_name,$one_mysql_log);} + $rowx=mysql_fetch_row($rslt); + $channel=$rowx[0]; + $channel = eregi_replace("1$","2",$channel); + $queryCID = eregi_replace("^.","Q",$queryCID); + } + } + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "En av dessa variabler är ej giltig:\n"; + echo "Channel $channel måste vara mer än 2 tecken\n"; + echo "queryCID $queryCID måste vara mer än 14 tecken\n"; + echo "exten $exten måste väljas\n"; + echo "ext_context $ext_context måste väljas\n"; + echo "ext_priority $ext_priority måste väljas\n"; + echo "\nRedirect Action ej skickat\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02062',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02063',$user,$server_ip,$session_name,$one_mysql_log);} + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_live=0; + echo "Channel $channel är inte aktivt på $server_ip, Redirect kommandot skrevs ej\n"; + } + } + if ($channel_live==1) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02064',$user,$server_ip,$session_name,$one_mysql_log);} + + echo "Redirect kommandot skickat till Kanal $channel på $server_ip\n"; + } + } + } + + + +###################### +# ACTION=Monitor or Stop Monitor - insert Monitor/StopMonitor Manager statement to start recording on a channel +###################### +if ( ($ACTION=="Monitor") || ($ACTION=="StopMonitor") ) + { + if ($ACTION=="StopMonitor") + {$SQLfile = "";} + else + {$SQLfile = "File: $filename";} + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($filename)<8) ) + { + $channel_live=0; + echo "Channel $channel är ej giltig or queryCID $queryCID är ej giltig or filename: $filename är ej giltig, $ACTION kommandot skrevs ej\n"; + } + else + { + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02065',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02066',$user,$server_ip,$session_name,$one_mysql_log);} + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_live=0; + echo "Channel $channel är inte aktivt på $server_ip, $ACTION kommandot skrevs ej\n"; + } + } + if ($channel_live==1) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','$ACTION','$queryCID','Channel: $channel','$SQLfile','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02067',$user,$server_ip,$session_name,$one_mysql_log);} + + if ($ACTION=="Monitor") + { + $stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename,lead_id,user) values('$channel','$server_ip','$exten','$NOW_TIME','$StarTtime','$filename','$lead_id','$user')"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02068',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt="SELECT recording_id FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02069',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + } + else + { + $stmt="SELECT recording_id,start_epoch FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02070',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $rec_count = mysql_num_rows($rslt); + if ($rec_count>0) + { + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + $start_time = $row[1]; + $length_in_sec = ($StarTtime - $start_time); + $length_in_min = ($length_in_sec / 60); + $length_in_min = sprintf("%8.2f", $length_in_min); + + $stmt = "UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' where filename='$filename'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02071',$user,$server_ip,$session_name,$one_mysql_log);} + } + } + echo "$ACTION kommandot skickat till Kanal $channel på $server_ip\nFilename: $filename\nRecorDing_ID: $recording_id\n"; + } + } + } + + + + + + +###################### +# ACTION=MonitorConf or StopMonitorConf - insert Monitor/StopMonitor Manager statement to start recording on a conference +###################### +if ( ($ACTION=="MonitorConf") || ($ACTION=="StopMonitorConf") ) + { + $row=''; $rowx=''; + $channel_live=1; + $uniqueidSQL=''; + + if ( (strlen($exten)<3) or (strlen($channel)<4) or (strlen($filename)<8) ) + { + $channel_live=0; + echo "Channel $channel är ej giltig or exten $exten är ej giltig or filename: $filename är ej giltig, $ACTION kommandot skrevs ej\n"; + } + else + { + $VDvicidial_id=''; + + if ($ACTION=="MonitorConf") + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$filename','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $filename','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02072',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename,lead_id,user) values('$channel','$server_ip','$exten','$NOW_TIME','$StarTtime','$filename','$lead_id','$user')"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02073',$user,$server_ip,$session_name,$one_mysql_log);} + $RLaffected_rows = mysql_affected_rows($link); + if ($RLaffected_rows > 0) + { + $recording_id = mysql_insert_id($link); + } + + if ($FROMvdc=='YES') + { + ##### get call type from vicidial_live_agents table + $VLA_inOUT='NONE'; + $stmt="SELECT comments FROM vicidial_live_agents where user='$user' order by last_update_time desc limit 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02074',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VLA_inOUT_ct = mysql_num_rows($rslt); + if ($VLA_inOUT_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VLA_inOUT = $row[0]; + } + if ($VLA_inOUT == 'INBOUND') + { + $four_hours_ago = date("Y-m-d H:i:s", mktime(date("H")-4,date("i"),date("s"),date("m"),date("d"),date("Y"))); + + ##### look for the vicidial ID in the vicidial_closer_log table + $stmt="SELECT closecallid FROM vicidial_closer_log where lead_id='$lead_id' and user='$user' and call_date > \"$four_hours_ago\" order by closecallid desc limit 1;"; + } + else + { + ##### look for the vicidial ID in the vicidial_log table + $stmt="SELECT uniqueid FROM vicidial_log where uniqueid='$uniqueid' and lead_id='$lead_id';"; + } + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02075',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VM_mancall_ct = mysql_num_rows($rslt); + if ($VM_mancall_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDvicidial_id = $row[0]; + + $stmt = "UPDATE recording_log SET vicidial_id='$VDvicidial_id' where recording_id='$recording_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02076',$user,$server_ip,$session_name,$one_mysql_log);} + } + } + } + + ##### StopMonitorConf steps ##### + else + { + if ($uniqueid=='IN') + { + $four_hours_ago = date("Y-m-d H:i:s", mktime(date("H")-4,date("i"),date("s"),date("m"),date("d"),date("Y"))); + + ### find the value to put in the vicidial_id field if this was an inbound call + $stmt="SELECT closecallid from vicidial_closer_log where lead_id='$lead_id' and call_date > \"$four_hours_ago\" order by call_date desc limit 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02077',$user,$server_ip,$session_name,$one_mysql_log);} + $VAC_qm_ct = mysql_num_rows($rslt); + if ($VAC_qm_ct > 0) + { + $row=mysql_fetch_row($rslt); + $uniqueidSQL = ",vicidial_id='$row[0]'"; + } + } + else + { + if (strlen($uniqueid) > 8) + {$uniqueidSQL = ",vicidial_id='$uniqueid'";} + } + + $stmt="SELECT recording_id,start_epoch FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02078',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $rec_count = mysql_num_rows($rslt); + if ($rec_count>0) + { + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + $start_time = $row[1]; + $length_in_sec = ($StarTtime - $start_time); + $length_in_min = ($length_in_sec / 60); + $length_in_min = sprintf("%8.2f", $length_in_min); + + $stmt = "UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' $uniqueidSQL where filename='$filename'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02079',$user,$server_ip,$session_name,$one_mysql_log);} + } + + # find and hang up all recordings going på in this conference # and extension = '$exten' + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$channel%\" and channel LIKE \"%,1\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02080',$user,$server_ip,$session_name,$one_mysql_log);} + # $rec_count = intval(mysql_num_rows($rslt) / 2); + $rec_count = mysql_num_rows($rslt); + $h=0; + while ($rec_count>$h) + { + $rowx=mysql_fetch_row($rslt); + $HUchannel[$h] = $rowx[0]; + $h++; + } + $i=0; + while ($h>$i) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','RH12345$StarTtime$i','Channel: $HUchannel[$i]','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02081',$user,$server_ip,$session_name,$one_mysql_log);} + $i++; + } + } + echo "$ACTION kommandot skickat till Kanal $channel på $server_ip\nFilename: $filename\nRecorDing_ID: $recording_id\n INSPELNINGEN KAN MAX VAAR 60 MINUTER\n"; + } + } + + + + + +###################### +# ACTION=VolumeControl - raise or lower the volume of a meetme participant +###################### +if ($ACTION=="VolumeControl") + { + if ( (strlen($exten)<1) or (strlen($channel)<1) or (strlen($stage)<1) or (strlen($queryCID)<1) ) + { + echo "Konferens $exten, Stage $stage är ej giltig or queryCID $queryCID är ej giltig, Originate kommandot skrevs ej\n"; + } + else + { + $participant_number='XXYYXXYYXXYYXX'; + if (eregi('UP',$stage)) {$vol_prefix='4';} + if (eregi('DOWN',$stage)) {$vol_prefix='3';} + if (eregi('UNMUTE',$stage)) {$vol_prefix='2';} + if (eregi('MUTING',$stage)) {$vol_prefix='1';} + $local_DEF = 'Local/'; + $local_AMP = '@'; + $volume_local_channel = "$local_DEF$participant_number$vol_prefix$exten$local_AMP$ext_context"; + + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$queryCID','Channel: $volume_local_channel','Context: $ext_context','Exten: 8300','Priority: 1','Callerid: $queryCID','','','','$channel','$exten');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02082',$user,$server_ip,$session_name,$one_mysql_log);} + echo "Volume kommandot skickat till Konferens $exten, Stage $stage Kanal $channel på $server_ip\n"; + } + } + + + + + + + + + + + + +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $StarTtime); +if ($format=='debug') {echo "\n";} +if ($format=='debug') {echo "\n\n\n";} + +exit; + + +##### MySQL Error Logging ##### +function mysql_error_logging($NOW_TIME,$link,$mel,$stmt,$query_id,$user,$server_ip,$session_name,$one_mysql_log) + { + $NOW_TIME = date("Y-m-d H:i:s"); + # mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00001',$user,$server_ip,$session_name,$one_mysql_log); + $errno=''; $error=''; + if ( ($mel > 0) or ($one_mysql_log > 0) ) + { + $errno = mysql_errno($link); + if ( ($errno > 0) or ($mel > 1) or ($one_mysql_log > 0) ) + { + $error = mysql_error($link); + $efp = fopen ("./vicidial_mysql_errors.txt", "a"); + fwrite ($efp, "$NOW_TIME|manager_send|$query_id|$errno|$error|$stmt|$user|$server_ip|$session_name|\n"); + fclose($efp); + } + } + $one_mysql_log=0; + return $errno; + } + +?> diff --git a/LANG_www/agc_se/park_calls_display.php b/LANG_www/agc_se/park_calls_display.php new file mode 100644 index 00000000..a738b7b6 --- /dev/null +++ b/LANG_www/agc_se/park_calls_display.php @@ -0,0 +1,147 @@ + LICENSE: AGPLv2 +# +# This script is designed purely to send the details on the parked calls on the server +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $format - ('text','debug') +# - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +# - $protocol - ('SIP','Zap','IAX2',...) +# +# +# changes +# 50524-1515 - First build of script +# 50711-1208 - removed HTTP authentication in favor of user/pass vars +# 60421-1111 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60619-1205 - Added variable filters to close security holes for login form +# 90508-0727 - Changed to PHP long tags +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} + +$user=ereg_replace("[^0-9a-zA-Z]","",$user); +$pass=ereg_replace("[^0-9a-zA-Z]","",$pass); + +# default optional vars if not set +if (!isset($format)) {$format="text";} +if (!isset($park_limit)) {$park_limit="1000";} + +$version = '0.0.4'; +$build = '60619-1205'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0) ) + { + echo "Felaktig Användarnamn/Lösenord: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) { + echo "Felaktig server_ip: |$server_ip| or Felaktig session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Felaktig session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "visa parkerade samtal"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<1) or (strlen($protocol)<3) ) + { + $channel_live=0; + echo "Exten $exten är ej giltig eller protokoll $protocol är ej giltig\n"; + exit; + } + else + { + ##### print parked calls from the parked_channels table + $stmt="SELECT channel,server_ip,channel_group,extension,parked_by,parked_time from parked_channels where server_ip = '$server_ip' order by parked_time limit $park_limit;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $park_calls_count = mysql_num_rows($rslt); + echo "$park_calls_count\n"; + $loop_count=0; + while ($park_calls_count>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + echo "$row[0] ~$row[2] ~$row[3] ~$row[4] ~$row[5]|"; + } + echo "\n"; + } + + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/LANG_www/agc_se/timeclock.php b/LANG_www/agc_se/timeclock.php new file mode 100644 index 00000000..5a090a84 --- /dev/null +++ b/LANG_www/agc_se/timeclock.php @@ -0,0 +1,456 @@ + LICENSE: AGPLv2 +# +# CHANGELOG +# 80523-0134 - First Build +# 80524-0225 - Changed event_date to DATETIME, added timestamp field and tcid_link field +# 80525-2351 - Added an audit log that is not to be editable +# 80602-0641 - Fixed status update bug +# 90508-0727 - Changed to PHP long tags +# + +$version = '2.2.0-5'; +$build = '90508-0727'; + +$StarTtimE = date("U"); +$NOW_TIME = date("Y-m-d H:i:s"); + $last_action_date = $NOW_TIME; + +$US='_'; +$CL=':'; +$AT='@'; +$DS='-'; +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +if (($server_port == '80') or ($server_port == '443') ) {$server_port='';} +else {$server_port = "$CL$server_port";} +$agcPAGE = "$HTTPprotocol$server_name$server_port$script_name"; +$agcDIR = eregi_replace('timeclock.php','',$agcPAGE); + + +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];} + elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];} +if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];} + elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];} +if (isset($_GET["VD_login"])) {$VD_login=$_GET["VD_login"];} + elseif (isset($_POST["VD_login"])) {$VD_login=$_POST["VD_login"];} +if (isset($_GET["VD_pass"])) {$VD_pass=$_GET["VD_pass"];} + elseif (isset($_POST["VD_pass"])) {$VD_pass=$_POST["VD_pass"];} +if (isset($_GET["VD_campaign"])) {$VD_campaign=$_GET["VD_campaign"];} + elseif (isset($_POST["VD_campaign"])) {$VD_campaign=$_POST["VD_campaign"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["commit"])) {$commit=$_GET["commit"];} + elseif (isset($_POST["commit"])) {$commit=$_POST["commit"];} +if (isset($_GET["referrer"])) {$referrer=$_GET["referrer"];} + elseif (isset($_POST["referrer"])) {$referrer=$_POST["referrer"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} + +if (!isset($phone_login)) + { + if (isset($_GET["pl"])) {$phone_login=$_GET["pl"];} + elseif (isset($_POST["pl"])) {$phone_login=$_POST["pl"];} + } +if (!isset($phone_pass)) + { + if (isset($_GET["pp"])) {$phone_pass=$_GET["pp"];} + elseif (isset($_POST["pp"])) {$phone_pass=$_POST["pp"];} + } + +### security strip all non-alphanumeric characters out of the variables ### + $DB=ereg_replace("[^0-9a-z]","",$DB); + $phone_login=ereg_replace("[^\,0-9a-zA-Z]","",$phone_login); + $phone_pass=ereg_replace("[^0-9a-zA-Z]","",$phone_pass); + $VD_login=ereg_replace("[^0-9a-zA-Z]","",$VD_login); + $VD_pass=ereg_replace("[^0-9a-zA-Z]","",$VD_pass); + $VD_campaign=ereg_replace("[^0-9a-zA-Z_]","",$VD_campaign); + $user=ereg_replace("[^0-9a-zA-Z]","",$user); + $pass=ereg_replace("[^0-9a-zA-Z]","",$pass); + $stage=ereg_replace("[^0-9a-zA-Z]","",$stage); + $commit=ereg_replace("[^0-9a-zA-Z]","",$commit); + $referrer=ereg_replace("[^0-9a-zA-Z]","",$referrer); + +require("dbconnect.php"); + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin,admin_home_url 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]; + $welcomeURL = $row[1]; + $i++; + } +##### END SETTINGS LOOKUP ##### +########################################### + + +header ("Content-type: text/html; charset=utf-8"); +header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header ("Pragma: no-cache"); // HTTP/1.0 + +if ( ($stage == 'login') or ($stage == 'logout') ) + { + ### see if user/pass exist for this user in vicidial_users table + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $valid_user=$row[0]; + print "\n"; + + if ($valid_user < 1) + { + ### NOT A VALID USER/PASS + $VDdisplayMESSAGE = "Användaren och lösenordet du har skrivit in är inte aktivt i systemet
Vänligen försök igen:"; + + echo"\n"; + echo"AgentStämpelklocka\n"; + echo"\n"; + echo"\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "

$VDdisplayMESSAGE

"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Stämpelklocka
 
Användare:
Lösenord:
 

VERSION: $version       SKAPA: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + + exit; + } + else + { + ### VALID USER/PASS, CONTINUE + + ### get name and group for this user + $stmt="SELECT full_name,user_group from vicidial_users where user='$user' and pass='$pass';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $full_name = $row[0]; + $user_group = $row[1]; + print "\n"; + + ### get vicidial_timeclock_status record count for this user + $stmt="SELECT count(*) from vicidial_timeclock_status where user='$user';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $vts_count = $row[0]; + + $last_action_sec=99; + + if ($vts_count > 0) + { + ### vicidial_timeclock_status record found, grab status and date of last activity + $stmt="SELECT status,event_epoch from vicidial_timeclock_status where user='$user';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $status = $row[0]; + $event_epoch = $row[1]; + $last_action_date = date("Y-m-d H:i:s", $event_epoch); + $last_action_sec = ($StarTtimE - $event_epoch); + if ($last_action_sec > 0) + { + $totTIME_H = ($last_action_sec / 3600); + $totTIME_H_int = round($totTIME_H, 2); + $totTIME_H_int = intval("$totTIME_H"); + $totTIME_M = ($totTIME_H - $totTIME_H_int); + $totTIME_M = ($totTIME_M * 60); + $totTIME_M_int = round($totTIME_M, 2); + $totTIME_M_int = intval("$totTIME_M"); + $totTIME_S = ($totTIME_M - $totTIME_M_int); + $totTIME_S = ($totTIME_S * 60); + $totTIME_S = round($totTIME_S, 0); + if (strlen($totTIME_H_int) < 1) {$totTIME_H_int = "0";} + if ($totTIME_M_int < 10) {$totTIME_M_int = "0$totTIME_M_int";} + if ($totTIME_S < 10) {$totTIME_S = "0$totTIME_S";} + $totTIME_HMS = "$totTIME_H_int:$totTIME_M_int:$totTIME_S"; + } + else + { + $totTIME_HMS='0:00:00'; + } + + print "\n"; + } + else + { + ### No vicidial_timeclock_status record found, insert one + $stmt="INSERT INTO vicidial_timeclock_status set status='START', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $status='START'; + $totTIME_HMS='0:00:00'; + $affected_rows = mysql_affected_rows($link); + print "\n"; + } + if ( ($last_action_sec < 30) and ($status != 'START') ) + { + ### You cannot log in or out within 30 sekunder of your last login/logout + $VDdisplayMESSAGE = "Du kan inte logga in eller ut på 30 sekunder efter ditt senaste försök"; + + echo"\n"; + echo"AgentStämpelklocka\n"; + echo"\n"; + echo"\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "

$VDdisplayMESSAGE

"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Stämpelklocka
 
Användare:
Lösenord:
 

VERSION: $version       SKAPA: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + + exit; + } + + if ($commit == 'YES') + { + if ( ( ($status=='AUTOLOGOUT') or ($status=='START') or ($status=='LOGOUT') ) and ($stage=='login') ) + { + $VDdisplayMESSAGE = "You have now logged-in"; + $LOGtimeMESSAGE = "You logged in at $NOW_TIME"; + + ### Add a record to the timeclock log + $stmt="INSERT INTO vicidial_timeclock_log set event='LOGIN', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip', event_date='$NOW_TIME';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $timeclock_id = mysql_insert_id($link); + print "\n"; + + ### Update the user's timeclock status record + $stmt="UPDATE vicidial_timeclock_status set status='LOGIN', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip' where user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + ### Add a record to the timeclock audit log + $stmt="INSERT INTO vicidial_timeclock_audit_log set timeclock_id='$timeclock_id', event='LOGIN', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip', event_date='$NOW_TIME';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + } + + if ( ($status=='LOGIN') and ($stage=='logout') ) + { + $VDdisplayMESSAGE = "Du har nu loggats ur"; + $LOGtimeMESSAGE = "Du loggade ur kl$NOW_TIME
Inloggad tid:$totTIME_HMS"; + + ### Add a record to the timeclock log + $stmt="INSERT INTO vicidial_timeclock_log set event='LOGOUT', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip', login_sec='$last_action_sec', event_date='$NOW_TIME';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $timeclock_id = mysql_insert_id($link); + print "\n"; + + ### Update last login record in the timeclock log + $stmt="UPDATE vicidial_timeclock_log set login_sec='$last_action_sec',tcid_link='$timeclock_id' where event='LOGIN' and user='$user' order by timeclock_id desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + ### Update the user's timeclock status record + $stmt="UPDATE vicidial_timeclock_status set status='LOGOUT', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip' where user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + ### Add a record to the timeclock audit log + $stmt="INSERT INTO vicidial_timeclock_audit_log set timeclock_id='$timeclock_id', event='LOGOUT', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip', login_sec='$last_action_sec', event_date='$NOW_TIME';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + ### Update last login record in the timeclock audit log + $stmt="UPDATE vicidial_timeclock_audit_log set login_sec='$last_action_sec',tcid_link='$timeclock_id' where event='LOGIN' and user='$user' order by timeclock_id desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + } + + if ( ( ( ($status=='AUTOLOGOUT') or ($status=='START') or ($status=='LOGOUT') ) and ($stage=='logout') ) or ( ($status=='LOGIN') and ($stage=='login') ) ) + {echo "ERROR: stämpelklockan har redan använts:$status|$stage"; exit;} + + if ($referrer=='agent') + {$BACKlink = "TILLBAKA till inloggningssidan";} + if ($referrer=='admin') + {$BACKlink = "TILLBAKA till administration";} + if ($referrer=='welcome') + {$BACKlink = "TILLBAKA till välkomstssidan";} + + echo"\n"; + echo"AgentStämpelklocka\n"; + echo"\n"; + echo"\n"; + echo "\n"; + echo "

$VDdisplayMESSAGE

"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Stämpelklocka
 
$LOGtimeMESSAGE
 
$BACKlink
 

VERSION: $version       SKAPA: $build
\n"; + echo "\n\n"; + echo "\n\n"; + + exit; + } + + + + + if ( ($status=='AUTOLOGOUT') or ($status=='START') or ($status=='LOGOUT') ) + { + $VDdisplayMESSAGE = "Tid sen du senast loggade in:$totTIME_HMS"; + $log_action = 'login'; + $button_name = 'LOGIN'; + $LOGtimeMESSAGE = "Du loggade senast ur kl:$last_action_date

Klicka på LOGIN nedan för att logga in"; + } + if ($status=='LOGIN') + { + $VDdisplayMESSAGE = "Hur lång tid du varit inloggad:$totTIME_HMS"; + $log_action = 'logout'; + $button_name = 'LOGOUT'; + $LOGtimeMESSAGE = "Du loggade in kl: $last_action_date
Hur lång tid du varit inloggad:$totTIME_HMS

Klicka på LOGOUT nedan för att logga ut"; + } + + echo"\n"; + echo"AgentStämpelklocka\n"; + echo"\n"; + echo"\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "

$VDdisplayMESSAGE

"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Stämpelklocka
 
$LOGtimeMESSAGE
 
 

VERSION: $version       SKAPA: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + + exit; + } + + + + } + +else + { + echo"\n"; + echo"AgentStämpelklocka\n"; + echo"\n"; + echo"\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "

$VDdisplayMESSAGE

"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Stämpelklocka
 
Användare:
Lösenord:
 

VERSION: $version       SKAPA: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + } + +exit; + +?> diff --git a/LANG_www/agc_se/vdc_db_query.php b/LANG_www/agc_se/vdc_db_query.php new file mode 100644 index 00000000..f4db3a5d --- /dev/null +++ b/LANG_www/agc_se/vdc_db_query.php @@ -0,0 +1,6890 @@ + LICENSE: AGPLv2 +# +# This script is designed to exchange information between vicidial.php and the database server for various actions +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $format - ('text','debug') +# - $ACTION - ('regCLOSER','regTERRITORY','manDiaLnextCALL','manDiaLskip','manDiaLonly','manDiaLlookCaLL','manDiaLlogCALL','userLOGout','updateDISPO','updateLEAD','VDADpause','VDADready','VDADcheckINCOMING','UpdatEFavoritEs','CalLBacKLisT','CalLBacKCounT','PauseCodeSubmit','LogiNCamPaigns','alt_phone_change','AlertControl','AGENTSview','CALLSINQUEUEview','CALLSINQUEUEgrab','DiaLableLeaDsCounT','UpdateFields') +# - $stage - ('start','finish','lookup','new') +# - $closer_choice - ('CL_TESTCAMP_L CL_OUT123_L -') +# - $conf_exten - ('8600011',...) +# - $exten - ('123test',...) +# - $ext_context - ('default','demo',...) +# - $ext_priority - ('1','2',...) +# - $campaign - ('testcamp',...) +# - $dial_timeout - ('60','26',...) +# - $dial_prefix - ('9','8',...) +# - $campaign_cid - ('3125551212','0000000000',...) +# - $MDnextCID - ('M06301413000000002',...) +# - $uniqueid - ('1120232758.2406800',...) +# - $lead_id - ('36524',...) +# - $list_id - ('101','123456',...) +# - $length_in_sec - ('12',...) +# - $phone_code - ('1',...) +# - $phone_number - ('3125551212',...) +# - $channel - ('Zap/12-1',...) +# - $start_epoch - ('1120236911',...) +# - $vendor_lead_code - ('1234test',...) +# - $title - ('Mr.',...) +# - $first_name - ('Bob',...) +# - $middle_initial - ('L',...) +# - $last_name - ('Wilson',...) +# - $address1 - ('1324 Main St.',...) +# - $address2 - ('Apt. 12',...) +# - $address3 - ('co Robert Wilson',...) +# - $city - ('Chicago',...) +# - $state - ('IL',...) +# - $province - ('NA',...) +# - $postal_code - ('60054',...) +# - $country_code - ('USA',...) +# - $gender - ('M',...) +# - $date_of_birth - ('1970-01-01',...) +# - $alt_phone - ('3125551213',...) +# - $email - ('bob@bob.com',...) +# - $security_phrase - ('Hello',...) +# - $comments - ('Good Customer',...) +# - $auto_dial_level - ('0','1','1.2',...) +# - $VDstop_rec_after_each_call - ('0','1') +# - $conf_silent_prefix - ('7','8','5',...) +# - $extension - ('123','user123','25-1',...) +# - $protocol - ('Zap','SIP','IAX2',...) +# - $user_abb - ('1234','6666',...) +# - $preview - ('YES','NO',...) +# - $called_count - ('0','1','2',...) +# - $agent_log_id - ('123456',...) +# - $agent_log - ('NO',...) +# - $favorites_list - (",'cc160','cc100'",...) +# - $CallBackDatETimE - ('2006-04-21 14:30:00',...) +# - $recipient - ('ANYONE,'USERONLY') +# - $callback_id - ('12345','12346',...) +# - $use_internal_dnc - ('Y','N') +# - $use_campaign_dnc - ('Y','N') +# - $omit_phone_code - ('Y','N') +# - $no_delete_sessions - ('0','1') +# - $LogouTKicKAlL - ('0','1'); +# - $closer_blended = ('0','1'); +# - $inOUT = ('IN','OUT'); +# - $manual_dial_filter = ('NONE','CAMPLISTS','DNC','CAMPLISTS_DNC') +# - $agentchannel = ('Zap/1-1','SIP/testing-6ry4i3',...) +# - $conf_dialed = ('0','1') +# - $leaving_threeway = ('0','1') +# - $blind_transfer = ('0','1') +# - $usegroupalias - ('0','1') +# - $account - ('DEFAULT',...) +# - $agent_dialed_number - ('1','') +# - $agent_dialed_type - ('MANUAL_OVERRIDE','MANUAL_DIALNOW','MANUAL_PREVIEW',...) +# - $wrapup - ('WRAPUP','') +# - $vtiger_callback_id - ('16534'...) +# - $nodeletevdac - ('0','1') +# - $agent_territories - ('ABC001','ABC002'...) +# - $alt_num_status - ('0','1') +# - $DiaL_SecondS - ('0','1','2',...) +# +# CHANGELOG: +# 50629-1044 - First build of script +# 50630-1422 - Added manual dial action and MD channel lookup +# 50701-1451 - Added dial log for start and end of vicidial calls +# 50705-1239 - Added call disposition update +# 50804-1627 - Fixed updateDispo to update vicidial_log entry +# 50816-1605 - Added VDADpause/ready for auto dialing +# 50816-1811 - Added basic autodial call pickup functions +# 50817-1005 - Altered logging functions to accomodate auto_dialing +# 50818-1305 - Added stop-all-recordings-after-each-vicidial-call option +# 50818-1411 - Added hangup of agent phone after Logout +# 50901-1315 - Fixed CLOSER IN-GROUP Web Form bug +# 50902-1507 - Fixed CLOSER log length_in_sec bug +# 50902-1730 - Added functions for manual preview dialing and revert +# 50913-1214 - Added agent random update to leadupdate +# 51020-1421 - Added agent_log_id framework for detailed agent activity logging +# 51021-1717 - Allows for multi-line comments (changes \n to !N in database) +# 51111-1046 - Added vicidial_agent_log lead_id earlier for manual dial +# 51121-1445 - Altered echo statements for several small PHP speed optimizations +# 51122-1328 - Fixed UserLogout issue not removing conference reservation +# 51129-1012 - Added ability to accept calls from other VICIDIAL servers +# 51129-1729 - Changed manual dial to use the '/n' flag for calls +# 51221-1154 - Added SCRIPT id lookup and sending to vicidial.php for display +# 60105-1059 - Added Updating of astguiclient favorites in the DB +# 60208-1617 - Added dtmf buttons output per call +# 60213-1521 - Added closer_campaigns update to vicidial_users +# 60215-1036 - Added Callback date-time entry into vicidial_callbacks table +# 60413-1541 - Added USERONLY Callback listings output - CalLBacKLisT +# - Added USERONLY Callback count output - CalLBacKCounT +# 60414-1140 - Added Callback lead lookup for manual dialing +# 60419-1517 - After CALLBK is sent to agent, update callback record to INACTIVE +# 60421-1419 - Check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60427-1236 - Fixed closer_choice error for CLOSER campaigns +# 60609-1148 - Added ability to check for manual dial numbers in DNC +# 60619-1117 - Added variable filters to close security holes for login form +# 60623-1414 - Fixed variable filter for phone_code and fixed manual dial logic +# 60821-1600 - Added ability to omit the phone code on vicidial lead dialing +# 60821-1647 - Added ability to not delete sessions at logout +# 60906-1124 - Added lookup and sending of callback data for CALLBK calls +# 61128-2229 - Added vicidial_live_agents and vicidial_auto_calls manual dial entries +# 70111-1600 - Added ability to use BLEND/INBND/*_C/*_B/*_I as closer campaigns +# 70115-1733 - Added alt_dial functionality in auto-dial modes +# 70118-1501 - Added user_group to vicidial_log,_agent_log,_closer_log,_callbacks +# 70123-1357 - Fixed bug that would not update vicidial_closer_log status to dispo +# 70202-1438 - Added pause code submit function +# 70203-0930 - Added dialed_number to lead info output +# 70203-1030 - Added dialed_label to lead info output +# 70206-1126 - Added INBOUND status for inbound/closer calls in vicidial_live_agents +# 70212-1253 - Fixed small issue with CXFER +# 70213-1431 - Added QueueMetrics PAUSE/UNPAUSE/AGENTLOGIN/AGENTLOGOFF actions +# 70214-1231 - Added queuemetrics_log_id field for server_id in queue_log +# 70215-1210 - Added queuemetrics COMPLETEAGENT action +# 70216-1051 - Fixed double call complete queuemetrics logging +# 70222-1616 - Changed queue_log PAUSE/UNPAUSE to PAUSEALL/UNPAUSEALL +# 70309-1034 - Allow amphersands and questions marks in comments to pass through +# 70313-1052 - Allow pound signs(hash) in comments to pass through +# 70319-1544 - Added agent disable update customer data function +# 70322-1545 - Added sipsak display ability +# 70413-1253 - Fixed bug for outbound call time in CLOSER-type blended campaigns +# 70424-1100 - Fixed bug for fronter/closer calls that would delete vdac records +# 70802-1729 - Fixed bugs with pause_sec and wait_sec under certain call handling +# 70828-1443 - Added source_id to output of SCRIPTtab-IFRAME and WEBFORM +# 71029-1855 - removed campaign_id naming restrictions for CLOSER-type campaigns +# 71030-2047 - added hopper priority for auto alt dial entries +# 71116-1011 - added calls_today count updating of the vicidial_live_agents upon INCALL +# 71120-1520 - added LogiNCamPaigns to show only allowed campaigns for agents upon login +# 71125-1751 - Added inbound-group default inbound group sending to vicidial.php +# 71129-2025 - restricted callbacks count and list to campaign only +# 71223-0318 - changed logging of closer calls +# 71226-1117 - added option to kick all calls from conference upon logout +# 80116-1032 - added user_closer_log logging in regCLOSER +# 80125-1213 - fixed vicidial_log bug when call is from closer +# 80317-2051 - Added in-group recording settings +# 80402-0121 - Fixes for manual dial transfers on some systems, removed /n persist flag +# 80424-0442 - Added non_latin lookup from system_settings +# 80430-1006 - Added term_reason for vicidial_log and vicidial_closer_log +# 80430-1957 - Changed to leave lead_id in vicidial_live_agents record until after dispo +# 80630-2153 - Added queue_log logging for Manual dial calls +# 80703-0139 - Added alter customer phone permissions +# 80707-2325 - Added vicidial_id to recording_log for tracking of vicidial or closer log to recording +# 80713-0624 - Added vicidial_list.last_local_call_time field +# 80717-1604 - Modified logging function to use inOUT to determine call direction and place to log +# 80719-1147 - Changed recording conf prefix +# 80815-1019 - Added manual dial list restriction option +# 80831-0545 - Added extended alt dial number info display support +# 80909-1710 - Added support for campaign-specific DNC lists +# 81010-1048 - Added support for hangup of all channels except for agent channel after attempting a 3way call +# 81011-1404 - Fixed bugs in leave3way when transferring a manual dial call +# 81020-1459 - Fixed bugs in queue_log logging +# 81104-0134 - Added mysql error logging capability +# 81104-1617 - Added multi-retry for some vicidial_live_agents table MySQL queries +# 81106-0410 - Added force_timeclock_login option to LoginCampaigns function +# 81107-0424 - Added carryover of script and presets for in-group calls from campaign settings +# 81110-0058 - Changed Pause time to start new vicidial_agent_log on every pause +# 81110-1512 - Added hangup_all_non_reserved to fix non-Hangup bug +# 81111-1630 - Added another hangup fix for non-hangup +# 81114-0126 - More vicidial_agent_log bug fixes +# 81119-1809 - webform backslash fix +# 81124-2212 - Fixes blind transfer bug +# 81126-1522 - Fixed callback comments bug +# 81211-0420 - Fixed Manual dial agent_log bug +# 90120-1718 - Added external pause and dial option +# 90126-1759 - Fixed QM section that wasn't qualified and added agent alert option +# 90128-0231 - Added vendor_lead_code to manual dial lead lookup +# 90304-1335 - Added support for group aliases and agent-specific variables for campaigns and in-groups +# 90305-1041 - Added agent_dialed_number and type for user_call_log feature +# 90307-1735 - Added Shift enforcement and manager override features +# 90320-0306 - Fixed agent log bug when using wrapup time +# 90323-2013 - Added function to put phone numbers in the DNC lists if they were set to status type dnc=Y +# 90324-1316 - Added functions to log calls to Vtiger accounts and update status to siccode +# 90327-1348 - Changed Vtiger status populate to use status name +# 90408-0021 - Added API vtiger specific callback activity record ability +# 90508-0726 - Changed to PHP long tags +# 90511-0923 - Added agentonly_callback_campaign_lock option +# 90519-0634 - Fixed manual dial status and logging bug +# 90611-1423 - Fixed agent log and vicidial log bugs +# 90705-2008 - Added AGENTSview function +# 90706-1431 - Added Agent view transfer selection +# 90712-2303 - Added view calls in queue, grab call from queue +# 90717-0638 - Fixed alt dial on overflow in-group calls +# 90722-1542 - Added no hopper dialing +# 90729-0637 - Added DiaLableLeaDsCounT +# 90808-0221 - Added last_state_change to vicidial_live_agents +# 90904-1622 - Added timezone sort options for no hopper dialing +# 90908-1037 - Added DEAD call logging +# 90916-1839 - Added nodeletevdac +# 90917-2246 - Fixed auto-alt-dial DNC check bug +# 90924-1544 - Added List callerid override option +# 90930-1638 - Added agent_territories feature +# 91012-0535 - Fixed User territory no-hopper dial bug +# 91019-1224 - Fixed auto-alt-dial DNC issues +# 91026-1101 - Added AREACODE DNC option +# 91108-2120 - Fixed QM log issue with PAUSEREASON entries +# 91112-1107 - Changed ENTERQUEUE to CALLOUTBOUND for QM logging +# 91123-1801 - Added outbound_autodial field +# 91204-1937 - Added logging of agent grab calls +# 91213-0946 - Added queue_position to queue_log COMPLETE... records +# 91228-1340 - Added API fields update functions +# 100103-1254 - Added 3 more conf-presets, list ID override presets and call start/dispo URLs +# 100104-1509 - Fixed vicidial_log duplicate check to allow update if dup and logging update +# 100109-0745 - Added alt_num_status for ALTNUM dialing status +# 100109-1336 - Fixed Manual dial live call detection +# 100113-1949 - Fixed dispo_choice bug and added dispo_status to dispo URL call +# 100202-2306 - Fixed logging issues related to INBOUND_MAN dial_method +# 100207-1110 - Changed Pause Codes function to allow for multiple pause codes per pause period +# 100301-1342 - Changed Available agents output for AGENTDIRECT selection +# 100413-1342 - Fixes for extended alt-dial +# + +$version = '2.2.0-143'; +$build = '100413-1342'; +$mel=1; # Mysql Error Log enabled = 1 +$mysql_log_count=310; +$one_mysql_log=0; + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];} + elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["closer_choice"])) {$closer_choice=$_GET["closer_choice"];} + elseif (isset($_POST["closer_choice"])) {$closer_choice=$_POST["closer_choice"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];} + elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];} +if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} +if (isset($_GET["dial_timeout"])) {$dial_timeout=$_GET["dial_timeout"];} + elseif (isset($_POST["dial_timeout"])) {$dial_timeout=$_POST["dial_timeout"];} +if (isset($_GET["dial_prefix"])) {$dial_prefix=$_GET["dial_prefix"];} + elseif (isset($_POST["dial_prefix"])) {$dial_prefix=$_POST["dial_prefix"];} +if (isset($_GET["campaign_cid"])) {$campaign_cid=$_GET["campaign_cid"];} + elseif (isset($_POST["campaign_cid"])) {$campaign_cid=$_POST["campaign_cid"];} +if (isset($_GET["MDnextCID"])) {$MDnextCID=$_GET["MDnextCID"];} + elseif (isset($_POST["MDnextCID"])) {$MDnextCID=$_POST["MDnextCID"];} +if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} + elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["length_in_sec"])) {$length_in_sec=$_GET["length_in_sec"];} + elseif (isset($_POST["length_in_sec"])) {$length_in_sec=$_POST["length_in_sec"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["start_epoch"])) {$start_epoch=$_GET["start_epoch"];} + elseif (isset($_POST["start_epoch"])) {$start_epoch=$_POST["start_epoch"];} +if (isset($_GET["dispo_choice"])) {$dispo_choice=$_GET["dispo_choice"];} + elseif (isset($_POST["dispo_choice"])) {$dispo_choice=$_POST["dispo_choice"];} +if (isset($_GET["vendor_lead_code"])) {$vendor_lead_code=$_GET["vendor_lead_code"];} + elseif (isset($_POST["vendor_lead_code"])) {$vendor_lead_code=$_POST["vendor_lead_code"];} +if (isset($_GET["title"])) {$title=$_GET["title"];} + elseif (isset($_POST["title"])) {$title=$_POST["title"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["middle_initial"])) {$middle_initial=$_GET["middle_initial"];} + elseif (isset($_POST["middle_initial"])) {$middle_initial=$_POST["middle_initial"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["gender"])) {$gender=$_GET["gender"];} + elseif (isset($_POST["gender"])) {$gender=$_POST["gender"];} +if (isset($_GET["date_of_birth"])) {$date_of_birth=$_GET["date_of_birth"];} + elseif (isset($_POST["date_of_birth"])) {$date_of_birth=$_POST["date_of_birth"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["security_phrase"])) {$security_phrase=$_GET["security_phrase"];} + elseif (isset($_POST["security_phrase"])) {$security_phrase=$_POST["security_phrase"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["VDstop_rec_after_each_call"])) {$VDstop_rec_after_each_call=$_GET["VDstop_rec_after_each_call"];} + elseif (isset($_POST["VDstop_rec_after_each_call"])) {$VDstop_rec_after_each_call=$_POST["VDstop_rec_after_each_call"];} +if (isset($_GET["conf_silent_prefix"])) {$conf_silent_prefix=$_GET["conf_silent_prefix"];} + elseif (isset($_POST["conf_silent_prefix"])) {$conf_silent_prefix=$_POST["conf_silent_prefix"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} +if (isset($_GET["user_abb"])) {$user_abb=$_GET["user_abb"];} + elseif (isset($_POST["user_abb"])) {$user_abb=$_POST["user_abb"];} +if (isset($_GET["preview"])) {$preview=$_GET["preview"];} + elseif (isset($_POST["preview"])) {$preview=$_POST["preview"];} +if (isset($_GET["called_count"])) {$called_count=$_GET["called_count"];} + elseif (isset($_POST["called_count"])) {$called_count=$_POST["called_count"];} +if (isset($_GET["agent_log_id"])) {$agent_log_id=$_GET["agent_log_id"];} + elseif (isset($_POST["agent_log_id"])) {$agent_log_id=$_POST["agent_log_id"];} +if (isset($_GET["agent_log"])) {$agent_log=$_GET["agent_log"];} + elseif (isset($_POST["agent_log"])) {$agent_log=$_POST["agent_log"];} +if (isset($_GET["favorites_list"])) {$favorites_list=$_GET["favorites_list"];} + elseif (isset($_POST["favorites_list"])) {$favorites_list=$_POST["favorites_list"];} +if (isset($_GET["CallBackDatETimE"])) {$CallBackDatETimE=$_GET["CallBackDatETimE"];} + elseif (isset($_POST["CallBackDatETimE"])) {$CallBackDatETimE=$_POST["CallBackDatETimE"];} +if (isset($_GET["recipient"])) {$recipient=$_GET["recipient"];} + elseif (isset($_POST["recipient"])) {$recipient=$_POST["recipient"];} +if (isset($_GET["callback_id"])) {$callback_id=$_GET["callback_id"];} + elseif (isset($_POST["callback_id"])) {$callback_id=$_POST["callback_id"];} +if (isset($_GET["use_internal_dnc"])) {$use_internal_dnc=$_GET["use_internal_dnc"];} + elseif (isset($_POST["use_internal_dnc"])) {$use_internal_dnc=$_POST["use_internal_dnc"];} +if (isset($_GET["use_campaign_dnc"])) {$use_campaign_dnc=$_GET["use_campaign_dnc"];} + elseif (isset($_POST["use_campaign_dnc"])) {$use_campaign_dnc=$_POST["use_campaign_dnc"];} +if (isset($_GET["omit_phone_code"])) {$omit_phone_code=$_GET["omit_phone_code"];} + elseif (isset($_POST["omit_phone_code"])) {$omit_phone_code=$_POST["omit_phone_code"];} +if (isset($_GET["phone_ip"])) {$phone_ip=$_GET["phone_ip"];} + elseif (isset($_POST["phone_ip"])) {$phone_ip=$_POST["phone_ip"];} +if (isset($_GET["enable_sipsak_messages"])) {$enable_sipsak_messages=$_GET["enable_sipsak_messages"];} + elseif (isset($_POST["enable_sipsak_messages"])) {$enable_sipsak_messages=$_POST["enable_sipsak_messages"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["LogouTKicKAlL"])) {$LogouTKicKAlL=$_GET["LogouTKicKAlL"];} + elseif (isset($_POST["LogouTKicKAlL"])) {$LogouTKicKAlL=$_POST["LogouTKicKAlL"];} +if (isset($_GET["closer_blended"])) {$closer_blended=$_GET["closer_blended"];} + elseif (isset($_POST["closer_blended"])) {$closer_blended=$_POST["closer_blended"];} +if (isset($_GET["inOUT"])) {$inOUT=$_GET["inOUT"];} + elseif (isset($_POST["inOUT"])) {$inOUT=$_POST["inOUT"];} +if (isset($_GET["manual_dial_filter"])) {$manual_dial_filter=$_GET["manual_dial_filter"];} + elseif (isset($_POST["manual_dial_filter"])) {$manual_dial_filter=$_POST["manual_dial_filter"];} +if (isset($_GET["alt_dial"])) {$alt_dial=$_GET["alt_dial"];} + elseif (isset($_POST["alt_dial"])) {$alt_dial=$_POST["alt_dial"];} +if (isset($_GET["agentchannel"])) {$agentchannel=$_GET["agentchannel"];} + elseif (isset($_POST["agentchannel"])) {$agentchannel=$_POST["agentchannel"];} +if (isset($_GET["conf_dialed"])) {$conf_dialed=$_GET["conf_dialed"];} + elseif (isset($_POST["conf_dialed"])) {$conf_dialed=$_POST["conf_dialed"];} +if (isset($_GET["leaving_threeway"])) {$leaving_threeway=$_GET["leaving_threeway"];} + elseif (isset($_POST["leaving_threeway"])) {$leaving_threeway=$_POST["leaving_threeway"];} +if (isset($_GET["hangup_all_non_reserved"])) {$hangup_all_non_reserved=$_GET["hangup_all_non_reserved"];} + elseif (isset($_POST["hangup_all_non_reserved"])) {$hangup_all_non_reserved=$_POST["hangup_all_non_reserved"];} +if (isset($_GET["blind_transfer"])) {$blind_transfer=$_GET["blind_transfer"];} + elseif (isset($_POST["blind_transfer"])) {$blind_transfer=$_POST["blind_transfer"];} +if (isset($_GET["usegroupalias"])) {$usegroupalias=$_GET["usegroupalias"];} + elseif (isset($_POST["usegroupalias"])) {$usegroupalias=$_POST["usegroupalias"];} +if (isset($_GET["account"])) {$account=$_GET["account"];} + elseif (isset($_POST["account"])) {$account=$_POST["account"];} +if (isset($_GET["agent_dialed_number"])) {$agent_dialed_number=$_GET["agent_dialed_number"];} + elseif (isset($_POST["agent_dialed_number"])) {$agent_dialed_number=$_POST["agent_dialed_number"];} +if (isset($_GET["agent_dialed_type"])) {$agent_dialed_type=$_GET["agent_dialed_type"];} + elseif (isset($_POST["agent_dialed_type"])) {$agent_dialed_type=$_POST["agent_dialed_type"];} +if (isset($_GET["wrapup"])) {$wrapup=$_GET["wrapup"];} + elseif (isset($_POST["wrapup"])) {$wrapup=$_POST["wrapup"];} +if (isset($_GET["vtiger_callback_id"])) {$vtiger_callback_id=$_GET["vtiger_callback_id"];} + elseif (isset($_POST["vtiger_callback_id"])) {$vtiger_callback_id=$_POST["vtiger_callback_id"];} +if (isset($_GET["dial_method"])) {$dial_method=$_GET["dial_method"];} + elseif (isset($_POST["dial_method"])) {$dial_method=$_POST["dial_method"];} +if (isset($_GET["no_delete_sessions"])) {$no_delete_sessions=$_GET["no_delete_sessions"];} + elseif (isset($_POST["no_delete_sessions"])) {$no_delete_sessions=$_POST["no_delete_sessions"];} +if (isset($_GET["nodeletevdac"])) {$nodeletevdac=$_GET["nodeletevdac"];} + elseif (isset($_POST["nodeletevdac"])) {$nodeletevdac=$_POST["nodeletevdac"];} +if (isset($_GET["agent_territories"])) {$agent_territories=$_GET["agent_territories"];} + elseif (isset($_POST["agent_territories"])) {$agent_territories=$_POST["agent_territories"];} +if (isset($_GET["alt_num_status"])) {$alt_num_status=$_GET["alt_num_status"];} + elseif (isset($_POST["alt_num_status"])) {$alt_num_status=$_POST["alt_num_status"];} +if (isset($_GET["DiaL_SecondS"])) {$DiaL_SecondS=$_GET["DiaL_SecondS"];} + elseif (isset($_POST["DiaL_SecondS"])) {$DiaL_SecondS=$_POST["DiaL_SecondS"];} + + +header ("Content-type: text/html; charset=utf-8"); +header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header ("Pragma: no-cache"); // HTTP/1.0 + +$txt = '.txt'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$CIDdate = date("mdHis"); +$ENTRYdate = date("YmdHis"); +$MT[0]=''; +$agents='@agents'; +$US='_'; + + +##### Hangup Cause Dictionary ##### +$hangup_cause_dictionary = array( +0 => "Unspecified. No other cause codes applicable.", +1 => "Unallocated (unassigned) number.", +2 => "No route to specified transit network (national use).", +3 => "No route to destination.", +6 => "Channel unacceptable.", +7 => "Call awarded, being delivered in an established channel.", +16 => "Normal call clearing.", +17 => "Användare busy.", +18 => "No user responding.", +19 => "No answer from user (user alerted).", +20 => "Subscriber absent.", +21 => "Call rejected.", +22 => "Number changed.", +23 => "Redirection to new destination.", +25 => "Exchange routing error.", +27 => "Destination out of order.", +28 => "Felaktig number format (address incomplete).", +29 => "Facilities rejected.", +30 => "Response to STATUS INQUIRY.", +31 => "Normal, unspecified.", +34 => "No circuit/channel available.", +38 => "Network out of order.", +41 => "Temporary failure.", +42 => "Switching equipment congestion.", +43 => "Access information discarded.", +44 => "Requested circuit/channel not available.", +50 => "Requested facility not subscribed.", +52 => "Outgoing calls barred.", +54 => "Inkommande calls barred.", +57 => "Bearer capability not authorized.", +58 => "Bearer capability not presently available.", +63 => "Service or option not available, unspecified.", +65 => "Bearer capability not implemented.", +66 => "Channel type not implemented.", +69 => "Requested facility not implemented.", +79 => "Service or option not implemented, unspecified.", +81 => "Felaktig call reference value.", +88 => "Incompatible destination.", +95 => "Felaktig message, unspecified.", +96 => "Mandatory information element is missing.", +97 => "Message type non-existent or not implemented.", +98 => "Message not compatible with call state or message type non-existent or not implemented.", +99 => "Information element / parameter non-existent or not implemented.", +100 => "Felaktig information element contents.", +101 => "Message not compatible with call state.", +102 => "Recovery på timer expiry.", +103 => "Parameter non-existent or not implemented - passed på (national use).", +111 => "Protocol error, unspecified.", +127 => "Interworking, unspecified." +); + + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin,timeclock_end_of_day,agentonly_callback_campaign_lock FROM system_settings;"; +$rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00001',$user,$server_ip,$session_name,$one_mysql_log);} +if ($DB) {echo "$stmt\n";} +$qm_conf_ct = mysql_num_rows($rslt); +if ($qm_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $non_latin = $row[0]; + $timeclock_end_of_day = $row[1]; + $agentonly_callback_campaign_lock = $row[2]; + } +##### END SETTINGS LOOKUP ##### +########################################### + +if ($non_latin < 1) + { + $user=ereg_replace("[^-_0-9a-zA-Z]","",$user); + $pass=ereg_replace("[^-_0-9a-zA-Z]","",$pass); + $length_in_sec = ereg_replace("[^0-9]","",$length_in_sec); + $phone_code = ereg_replace("[^0-9]","",$phone_code); + $phone_number = ereg_replace("[^0-9]","",$phone_number); + } +else + { + $user = ereg_replace("'|\"|\\\\|;","",$user); + $pass = ereg_replace("'|\"|\\\\|;","",$pass); + } + + +# default optional vars if not set +if (!isset($format)) {$format="text";} + if ($format == 'debug') {$DB=1;} +if (!isset($ACTION)) {$ACTION="refresh";} +if (!isset($query_date)) {$query_date = $NOW_DATE;} + +if ($ACTION == 'LogiNCamPaigns') + { + $skip_user_validation=1; + } +else + { + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00002',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Felaktig Användarnamn/Lösenord: |$user|$pass|\n"; + exit; + } + else + { + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Felaktig server_ip: |$server_ip| or Felaktig session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00003',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Felaktig session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + } + +if ($format=='debug') + { + echo "\n"; + echo "\n"; + echo "\n"; + echo "VICIDiaL Databas frågeskript"; + echo "\n"; + echo "\n"; + echo "\n"; + } + + + +################################################################################ +### LogiNCamPaigns - generates an HTML SELECT list of allowed campaigns for a +### specific agent on the login screen +################################################################################ +if ($ACTION == 'LogiNCamPaigns') + { + if ( (strlen($user)<1) ) + { + echo "\n"; + exit; + } + else + { + $stmt="SELECT user_group,user_level,agent_shift_enforcement_override,shift_override_flag from vicidial_users where user='$user' and pass='$pass'"; + if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00004',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $VU_user_group = $row[0]; + $VU_user_level = $row[1]; + $VU_agent_shift_enforcement_override = $row[2]; + $VU_shift_override_flag = $row[3]; + + $LOGallowed_campaignsSQL=''; + + $stmt="SELECT allowed_campaigns,forced_timeclock_login,shift_enforcement,group_shifts from vicidial_user_groups where user_group='$VU_user_group';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00005',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $forced_timeclock_login = $row[1]; + $shift_enforcement = $row[2]; + $LOGgroup_shiftsSQL = eregi_replace(' ','',$row[3]); + $LOGgroup_shiftsSQL = eregi_replace(' ',"','",$LOGgroup_shiftsSQL); + $LOGgroup_shiftsSQL = "shift_id IN('$LOGgroup_shiftsSQL')"; + if ( (!eregi("ALL-CAMPAIGNS",$row[0])) ) + { + $LOGallowed_campaignsSQL = eregi_replace(' -','',$row[0]); + $LOGallowed_campaignsSQL = eregi_replace(' ',"','",$LOGallowed_campaignsSQL); + $LOGallowed_campaignsSQL = "and campaign_id IN('$LOGallowed_campaignsSQL')"; + } + + $show_campaign_list=1; + ### CHECK TO SEE IF AGENT IS LOGGED IN TO TIMECLOCK, IF NOT, OUTPUT ERROR + if ( (ereg('Y',$forced_timeclock_login)) or ( (ereg('ADMIN_EXEMPT',$forced_timeclock_login)) and ($VU_user_level < 8) ) ) + { + $last_agent_event=''; + $HHMM = date("Hi"); + $HHteod = substr($timeclock_end_of_day,0,2); + $MMteod = substr($timeclock_end_of_day,2,2); + + if ($HHMM < $timeclock_end_of_day) + {$EoD = mktime($HHteod, $MMteod, 10, date("m"), date("d")-1, date("Y"));} + else + {$EoD = mktime($HHteod, $MMteod, 10, date("m"), date("d"), date("Y"));} + + $EoDdate = date("Y-m-d H:i:s", $EoD); + + ##### grab timeclock logged-in time for each user ##### + $stmt="SELECT event from vicidial_timeclock_log where user='$user' and event_epoch >= '$EoD' order by timeclock_id desc limit 1;"; + if ($DB>0) {echo "|$stmt|";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00184',$user,$server_ip,$session_name,$one_mysql_log);} + $events_to_parse = mysql_num_rows($rslt); + if ($events_to_parse > 0) + { + $rowx=mysql_fetch_row($rslt); + $last_agent_event = $rowx[0]; + } + if ( (strlen($last_agent_event)<2) or (ereg('LOGOUT',$last_agent_event)) ) + {$show_campaign_list=0;} + } + } + + ### CHECK TO SEE IF AGENT IS WITHIN THEIR SHIFT IF RESTRICTED, IF NOT, OUTPUT ERROR + if ( ( (ereg("START|ALL",$shift_enforcement)) and (!ereg("OFF",$VU_agent_shift_enforcement_override)) ) or (ereg("START|ALL",$VU_agent_shift_enforcement_override)) ) + { + $shift_ok=0; + if ( (strlen($LOGgroup_shiftsSQL) < 3) and ($VU_shift_override_flag < 1) ) + { + $VDdisplayMESSAGE = "ERROR: Det finns inga skift definierade för din användargrupp\n"; + $VDloginDISPLAY=1; + } + else + { + $HHMM = date("Hi"); + $wday = date("w"); + + $stmt="SELECT shift_id,shift_start_time,shift_length,shift_weekdays from vicidial_shifts where $LOGgroup_shiftsSQL order by shift_id"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00193',$user,$server_ip,$session_name,$one_mysql_log);} + $shifts_to_print = mysql_num_rows($rslt); + + $o=0; + while ( ($shifts_to_print > $o) and ($shift_ok < 1) ) + { + $rowx=mysql_fetch_row($rslt); + $shift_id = $rowx[0]; + $shift_start_time = $rowx[1]; + $shift_length = $rowx[2]; + $shift_weekdays = $rowx[3]; + + if (eregi("$wday",$shift_weekdays)) + { + $HHshift_length = substr($shift_length,0,2); + $MMshift_length = substr($shift_length,3,2); + $HHshift_start_time = substr($shift_start_time,0,2); + $MMshift_start_time = substr($shift_start_time,2,2); + $HHshift_end_time = ($HHshift_length + $HHshift_start_time); + $MMshift_end_time = ($MMshift_length + $MMshift_start_time); + if ($MMshift_end_time > 59) + { + $MMshift_end_time = ($MMshift_end_time - 60); + $HHshift_end_time++; + } + if ($HHshift_end_time > 23) + {$HHshift_end_time = ($HHshift_end_time - 24);} + $HHshift_end_time = sprintf("%02s", $HHshift_end_time); + $MMshift_end_time = sprintf("%02s", $MMshift_end_time); + $shift_end_time = "$HHshift_end_time$MMshift_end_time"; + + if ( + ( ($HHMM >= $shift_start_time) and ($HHMM < $shift_end_time) ) or + ( ($HHMM < $shift_start_time) and ($HHMM < $shift_end_time) and ($shift_end_time <= $shift_start_time) ) or + ( ($HHMM >= $shift_start_time) and ($HHMM >= $shift_end_time) and ($shift_end_time <= $shift_start_time) ) + ) + {$shift_ok++;} + } + $o++; + } + + if ( ($shift_ok < 1) and ($VU_shift_override_flag < 1) ) + { + $VDdisplayMESSAGE = "ERROR: Du har inte behörighet att logga in utanför ditt skift\n"; + $VDloginDISPLAY=1; + } + } + if ($VDloginDISPLAY > 0) + { + $loginDATE = date("Ymd"); + $VDdisplayMESSAGE.= "

MANAGER OVERRIDE:
\n"; + $VDdisplayMESSAGE.= "
\n"; + $VDdisplayMESSAGE.= "\n"; + $VDdisplayMESSAGE.= "\n"; + $VDdisplayMESSAGE.= "\n"; + $VDdisplayMESSAGE.= "\n"; + $VDdisplayMESSAGE.= "ManagerLogga in:
\n"; + $VDdisplayMESSAGE.= "ManagerLösenord:
\n"; + $VDdisplayMESSAGE.= "




\n"; + echo "$VDdisplayMESSAGE"; + exit; + } + } + + if ($show_campaign_list > 0) + { + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns where active='Y' $LOGallowed_campaignsSQL order by campaign_id"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00006',$user,$server_ip,$session_name,$one_mysql_log);} + $camps_to_print = mysql_num_rows($rslt); + + echo "\n"; + } + else + { + echo "\n"; + } + exit; + } + + + +################################################################################ +### regCLOSER - update the vicidial_live_agents table to reflect the closer +### inbound choices made upon login +################################################################################ +if ($ACTION == 'regCLOSER') + { + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($closer_choice)<1) || (strlen($user)<1) ) + { + $channel_live=0; + echo "Gruppval $closer_choice är ej giltig\n"; + exit; + } + else + { + if ($closer_blended > 0) + {$vla_autodial = 'Y';} + else + {$vla_autodial = 'N';} + if (preg_match('/INBOUND_MAN|MANUAL/',$dial_method)) + {$vla_autodial = 'N';} + + if ($closer_choice == "MGRLOCK-") + { + $stmt="SELECT closer_campaigns FROM vicidial_users where user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00007',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $closer_choice =$row[0]; + + $stmt="UPDATE vicidial_live_agents set closer_campaigns='$closer_choice',last_state_change='$NOW_TIME',outbound_autodial='$vla_autodial' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00008',$user,$server_ip,$session_name,$one_mysql_log);} + } + else + { + $stmt="UPDATE vicidial_live_agents set closer_campaigns='$closer_choice',last_state_change='$NOW_TIME',outbound_autodial='$vla_autodial' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00009',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt="UPDATE vicidial_users set closer_campaigns='$closer_choice' where user='$user';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00010',$user,$server_ip,$session_name,$one_mysql_log);} + } + + $stmt="INSERT INTO vicidial_user_closer_log set user='$user',campaign_id='$campaign',event_date='$NOW_TIME',blended='$closer_blended',closer_campaigns='$closer_choice';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00011',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt="DELETE FROM vicidial_live_inbound_agents where user='$user';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00012',$user,$server_ip,$session_name,$one_mysql_log);} + + $in_groups_pre = preg_replace('/-$/','',$closer_choice); + $in_groups = explode(" ",$in_groups_pre); + $in_groups_ct = count($in_groups); + $k=1; + while ($k < $in_groups_ct) + { + if (strlen($in_groups[$k])>1) + { + $stmt="SELECT group_weight,calls_today FROM vicidial_inbound_group_agents where user='$user' and group_id='$in_groups[$k]';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00013',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $viga_ct = mysql_num_rows($rslt); + if ($viga_ct > 0) + { + $row=mysql_fetch_row($rslt); + $group_weight = $row[0]; + $calls_today = $row[1]; + } + else + { + $group_weight = 0; + $calls_today = 0; + } + $stmt="INSERT INTO vicidial_live_inbound_agents set user='$user',group_id='$in_groups[$k]',group_weight='$group_weight',calls_today='$calls_today',last_call_time='$NOW_TIME',last_call_finish='$NOW_TIME';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00014',$user,$server_ip,$session_name,$one_mysql_log);} + } + $k++; + } + + } + echo "Closer In Gruppval $closer_choice har blivit registrerad till användare $user\n"; + } + + + + + +################################################################################# +### regTERRITORY - update the vicidial_live_agents table to reflect the territory +### choices made upon login or while paused (agent_territories) +################################################################################# +if ($ACTION == 'regTERRITORY') + { + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($agent_territories)<1) || (strlen($user)<1) ) + { + $channel_live=0; + echo "Territory Choice $agent_territories är ej giltig\n"; + exit; + } + else + { + if (preg_match("/^MGRLOCK/",$agent_territories)) + { + $stmt="SELECT territory FROM vicidial_user_territories where user='$user';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00253',$user,$server_ip,$session_name,$one_mysql_log);} + $territories_ct = mysql_num_rows($rslt); + if ($DB) {echo "$territories_ct|$stmt\n";} + $k=0; + $agent_territories=''; + while ($territories_ct > $k) + { + $row=mysql_fetch_row($rslt); + $agent_territories .= " $row[0]"; + $k++; + } + $agent_territories .= " -"; + + $stmt="UPDATE vicidial_live_agents set agent_territories='$agent_territories',last_state_change='$NOW_TIME' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00254',$user,$server_ip,$session_name,$one_mysql_log);} + } + else + { + $stmt="UPDATE vicidial_live_agents set agent_territories='$agent_territories',last_state_change='$NOW_TIME' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00255',$user,$server_ip,$session_name,$one_mysql_log);} + } + + $stmt="INSERT INTO vicidial_user_territory_log set user='$user',campaign_id='$campaign',event_date='$NOW_TIME',agent_territories='$agent_territories';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00256',$user,$server_ip,$session_name,$one_mysql_log);} + } + echo "Territory Choice $agent_territories har blivit registrerad till användare $user\n"; + } + + + + + +################################################################################ +### For every process below, lookup the current agent_log_id for the user +################################################################################ +$stmt="SELECT agent_log_id from vicidial_live_agents where user='$user';"; +$rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00222',$user,$server_ip,$session_name,$one_mysql_log);} +$users_to_parse = mysql_num_rows($rslt); +if ($users_to_parse > 0) + { + $rowx=mysql_fetch_row($rslt); + if ($rowx[0] > 0) {$agent_log_id = $rowx[0];} + } + + + +################################################################################ +### UpdateFields - sends current vicidial_list values for fields +################################################################################ +if ($ACTION == 'UpdateFields') + { + $stmt="UPDATE vicidial_live_agents set external_update_fields='0',external_update_fields_data='' where user='$user';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00276',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt="SELECT lead_id from vicidial_live_agents where user='$user';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00274',$user,$server_ip,$session_name,$one_mysql_log);} + $vla_records = mysql_num_rows($rslt); + if ($vla_records > 0) + { + $rowx=mysql_fetch_row($rslt); + if ($rowx[0] > 0) {$lead_id = $rowx[0];} + ##### grab the data from vicidial_list for the lead_id + $stmt="SELECT vendor_lead_code,source_id,gmt_offset_now,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,rank,owner FROM vicidial_list where lead_id='$lead_id' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00275',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $list_lead_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + $vendor_id = trim("$row[0]"); + $source_id = trim("$row[1]"); + $gmt_offset_now = trim("$row[2]"); + $phone_code = trim("$row[3]"); + $phone_number = trim("$row[4]"); + $title = trim("$row[5]"); + $first_name = trim("$row[6]"); + $middle_initial = trim("$row[7]"); + $last_name = trim("$row[8]"); + $address1 = trim("$row[9]"); + $address2 = trim("$row[10]"); + $address3 = trim("$row[11]"); + $city = trim("$row[12]"); + $state = trim("$row[13]"); + $province = trim("$row[14]"); + $postal_code = trim("$row[15]"); + $country_code = trim("$row[16]"); + $gender = trim("$row[17]"); + $date_of_birth = trim("$row[18]"); + $alt_phone = trim("$row[19]"); + $email = trim("$row[20]"); + $security = trim("$row[21]"); + $comments = stripslashes(trim("$row[22]")); + $rank = trim("$row[23]"); + $owner = trim("$row[24]"); + + $comments = eregi_replace("\r",'',$comments); + $comments = eregi_replace("\n",'!N',$comments); + + $LeaD_InfO = "GOOD\n"; + $LeaD_InfO .= $vendor_id . "\n"; + $LeaD_InfO .= $source_id . "\n"; + $LeaD_InfO .= $gmt_offset_now . "\n"; + $LeaD_InfO .= $phone_code . "\n"; + $LeaD_InfO .= $phone_number . "\n"; + $LeaD_InfO .= $title . "\n"; + $LeaD_InfO .= $first_name . "\n"; + $LeaD_InfO .= $middle_initial . "\n"; + $LeaD_InfO .= $last_name . "\n"; + $LeaD_InfO .= $address1 . "\n"; + $LeaD_InfO .= $address2 . "\n"; + $LeaD_InfO .= $address3 . "\n"; + $LeaD_InfO .= $city . "\n"; + $LeaD_InfO .= $state . "\n"; + $LeaD_InfO .= $province . "\n"; + $LeaD_InfO .= $postal_code . "\n"; + $LeaD_InfO .= $country_code . "\n"; + $LeaD_InfO .= $gender . "\n"; + $LeaD_InfO .= $date_of_birth . "\n"; + $LeaD_InfO .= $alt_phone . "\n"; + $LeaD_InfO .= $email . "\n"; + $LeaD_InfO .= $security . "\n"; + $LeaD_InfO .= $comments . "\n"; + $LeaD_InfO .= $rank . "\n"; + $LeaD_InfO .= $owner . "\n"; + $LeaD_InfO .= "\n"; + + echo $LeaD_InfO; + } + else + { + echo "ERROR: no lead info in system: $lead_id\n"; + } + } + else + { + echo "ERROR: no lead active for this agent\n"; + } + } + + +################################################################################ +### manDiaLnextCaLL - for manual VICIDiaL dialing this will grab the next lead +### in the campaign, reserve it, send data back to client and +### place the call by inserting into vicidial_manager +################################################################################ +if ($ACTION == 'manDiaLnextCaLL') + { + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($conf_exten)<1) || (strlen($campaign)<1) || (strlen($ext_context)<1) ) + { + $channel_live=0; + echo "HOPPERN ÄR TOM!\n"; + echo "Conf Exten $conf_exten or campaign $campaign or ext_context $ext_context är ej giltig\n"; + exit; + } + else + { + ##### grab number of calls today in this campaign and increment + $stmt="SELECT calls_today FROM vicidial_live_agents WHERE user='$user' and campaign_id='$campaign';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00015',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $vla_cc_ct = mysql_num_rows($rslt); + if ($vla_cc_ct > 0) + { + $row=mysql_fetch_row($rslt); + $calls_today = $row[0]; + } + else + {$calls_today ='0';} + $calls_today++; + + $script_recording_delay=0; + ##### find if script contains recording fields + $stmt="SELECT count(*) FROM vicidial_scripts vs,vicidial_campaigns vc WHERE campaign_id='$campaign' and vs.script_id=vc.campaign_script and script_text LIKE \"%--A--recording_%\";"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00257',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $vs_vc_ct = mysql_num_rows($rslt); + if ($vs_vc_ct > 0) + { + $row=mysql_fetch_row($rslt); + $script_recording_delay = $row[0]; + } + + ### check if this is a callback, if it is, skip the grabbing of a new lead and mark the callback as INACTIVE + if ( (strlen($callback_id)>0) and (strlen($lead_id)>0) ) + { + $affected_rows=1; + $CBleadIDset=1; + + $stmt = "UPDATE vicidial_callbacks set status='INACTIVE' where callback_id='$callback_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00016',$user,$server_ip,$session_name,$one_mysql_log);} + } + else + { + if (strlen($phone_number)>3) + { + if (ereg("DNC",$manual_dial_filter)) + { + $stmt="SELECT count(*) FROM vicidial_dnc where phone_number='$phone_number';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00017',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + + if ($row[0] > 0) + { + echo "DNC NUNNER\n"; + exit; + } + $stmt="SELECT count(*) FROM vicidial_campaign_dnc where phone_number='$phone_number' and campaign_id='$campaign';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00018',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + + if ($row[0] > 0) + { + echo "DNC NUNNER\n"; + exit; + } + } + if (ereg("CAMPLISTS",$manual_dial_filter)) + { + $stmt="SELECT list_id,active from vicidial_lists where campaign_id='$campaign'"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00019',$user,$server_ip,$session_name,$one_mysql_log);} + $lists_to_parse = mysql_num_rows($rslt); + $camp_lists=''; + $o=0; + while ($lists_to_parse > $o) + { + $rowx=mysql_fetch_row($rslt); + if (ereg("Y", $rowx[1])) {$active_lists++; $camp_lists .= "'$rowx[0]',";} + if (ereg("N", $rowx[1])) {$inactive_lists++;} + $o++; + } + $camp_lists = eregi_replace(".$","",$camp_lists); + + $stmt="SELECT count(*) FROM vicidial_list where phone_number='$phone_number' and list_id IN($camp_lists);"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00020',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + + if ($row[0] < 1) + { + echo "NUNNER NOT IN CAMPLISTS\n"; + exit; + } + } + if ($stage=='lookup') + { + if (strlen($vendor_lead_code)>0) + { + $stmt="SELECT lead_id FROM vicidial_list where vendor_lead_code='$vendor_lead_code' order by modify_date desc LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00021',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $man_leadID_ct = mysql_num_rows($rslt); + if ( ($man_leadID_ct > 0) and (strlen($phone_number) > 5) ) + {$override_phone++;} + } + else + { + $stmt="SELECT lead_id FROM vicidial_list where phone_number='$phone_number' order by modify_date desc LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00021',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $man_leadID_ct = mysql_num_rows($rslt); + } + if ($man_leadID_ct > 0) + { + $row=mysql_fetch_row($rslt); + $affected_rows=1; + $lead_id =$row[0]; + $CBleadIDset=1; + } + else + { + ### insert a new lead in the system with this phone number + $stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='QUEUE',user='$user',called_since_last_reset='Y',entry_date='$ENTRYdate',last_local_call_time='$NOW_TIME',vendor_lead_code='$vendor_lead_code';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00022',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + $lead_id = mysql_insert_id($link); + $CBleadIDset=1; + } + } + else + { + ### insert a new lead in the system with this phone number + $stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='QUEUE',user='$user',called_since_last_reset='Y',entry_date='$ENTRYdate',last_local_call_time='$NOW_TIME';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00023',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + $lead_id = mysql_insert_id($link); + $CBleadIDset=1; + } + } + else + { + ##### gather no hopper dialing settings from campaign + $stmt="SELECT no_hopper_dialing,agent_dial_owner_only,local_call_time,dial_statuses,drop_lockout_time,lead_filter_id,lead_order FROM vicidial_campaigns where campaign_id='$campaign';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00236',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $camp_nohopper_ct = mysql_num_rows($rslt); + if ($camp_nohopper_ct > 0) + { + $row=mysql_fetch_row($rslt); + $no_hopper_dialing = $row[0]; + $agent_dial_owner_only = $row[1]; + $local_call_time = $row[2]; + $dial_statuses = $row[3]; + $drop_lockout_time = $row[4]; + $lead_filter_id = $row[5]; + $lead_order = $row[6]; + } + if (eregi("N",$no_hopper_dialing)) + { + ### grab the next lead in the hopper for this campaign and reserve it for the user + $stmt = "UPDATE vicidial_hopper set status='QUEUE', user='$user' where campaign_id='$campaign' and status='READY' order by priority desc,hopper_id LIMIT 1"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00024',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + } + else + { + ### figure out what the next lead that should be dialed is + + ########################################################## + ### BEGIN find the next lead to dial without looking in the hopper + ########################################################## + # $DB=1; + if (strlen($dial_statuses)>2) + { + $g=0; + $p='13'; + $GMT_gmt[0] = ''; + $GMT_hour[0] = ''; + $GMT_day[0] = ''; + while ($p > -13) + { + $pzone=3600 * $p; + $pmin=(gmdate("i", time() + $pzone)); + $phour=( (gmdate("G", time() + $pzone)) * 100); + $pday=gmdate("w", time() + $pzone); + $tz = sprintf("%.2f", $p); + $GMT_gmt[$g] = "$tz"; + $GMT_day[$g] = "$pday"; + $GMT_hour[$g] = ($phour + $pmin); + $p = ($p - 0.25); + $g++; + } + + $stmt="SELECT call_time_id,call_time_name,call_time_comments,ct_default_start,ct_default_stop,ct_sunday_start,ct_sunday_stop,ct_monday_start,ct_monday_stop,ct_tuesday_start,ct_tuesday_stop,ct_wednesday_start,ct_wednesday_stop,ct_thursday_start,ct_thursday_stop,ct_friday_start,ct_friday_stop,ct_saturday_start,ct_saturday_stop,ct_state_call_times FROM vicidial_call_times where call_time_id='$local_call_time';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00237',$user,$server_ip,$session_name,$one_mysql_log);} + $rowx=mysql_fetch_row($rslt); + $Gct_default_start = "$rowx[3]"; + $Gct_default_stop = "$rowx[4]"; + $Gct_sunday_start = "$rowx[5]"; + $Gct_sunday_stop = "$rowx[6]"; + $Gct_monday_start = "$rowx[7]"; + $Gct_monday_stop = "$rowx[8]"; + $Gct_tuesday_start = "$rowx[9]"; + $Gct_tuesday_stop = "$rowx[10]"; + $Gct_wednesday_start = "$rowx[11]"; + $Gct_wednesday_stop = "$rowx[12]"; + $Gct_thursday_start = "$rowx[13]"; + $Gct_thursday_stop = "$rowx[14]"; + $Gct_friday_start = "$rowx[15]"; + $Gct_friday_stop = "$rowx[16]"; + $Gct_saturday_start = "$rowx[17]"; + $Gct_saturday_stop = "$rowx[18]"; + $Gct_state_call_times = "$rowx[19]"; + + $ct_states = ''; + $ct_state_gmt_SQL = ''; + $ct_srs=0; + $b=0; + if (strlen($Gct_state_call_times)>2) + { + $state_rules = explode('|',$Gct_state_call_times); + $ct_srs = ((count($state_rules)) - 2); + } + while($ct_srs >= $b) + { + if (strlen($state_rules[$b])>1) + { + $stmt="SELECT state_call_time_id,state_call_time_state,state_call_time_name,state_call_time_comments,sct_default_start,sct_default_stop,sct_sunday_start,sct_sunday_stop,sct_monday_start,sct_monday_stop,sct_tuesday_start,sct_tuesday_stop,sct_wednesday_start,sct_wednesday_stop,sct_thursday_start,sct_thursday_stop,sct_friday_start,sct_friday_stop,sct_saturday_start,sct_saturday_stop from vicidial_state_call_times where state_call_time_id='$state_rules[$b]';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00238',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $Gstate_call_time_id = "$row[0]"; + $Gstate_call_time_state = "$row[1]"; + $Gsct_default_start = "$row[4]"; + $Gsct_default_stop = "$row[5]"; + $Gsct_sunday_start = "$row[6]"; + $Gsct_sunday_stop = "$row[7]"; + $Gsct_monday_start = "$row[8]"; + $Gsct_monday_stop = "$row[9]"; + $Gsct_tuesday_start = "$row[10]"; + $Gsct_tuesday_stop = "$row[11]"; + $Gsct_wednesday_start = "$row[12]"; + $Gsct_wednesday_stop = "$row[13]"; + $Gsct_thursday_start = "$row[14]"; + $Gsct_thursday_stop = "$row[15]"; + $Gsct_friday_start = "$row[16]"; + $Gsct_friday_stop = "$row[17]"; + $Gsct_saturday_start = "$row[18]"; + $Gsct_saturday_stop = "$row[19]"; + + $ct_states .="'$Gstate_call_time_state',"; + + $r=0; + $state_gmt=''; + while($r < $g) + { + if ($GMT_day[$r]==0) #### Sunday local time + { + if (($Gsct_sunday_start==0) and ($Gsct_sunday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_sunday_start) and ($GMT_hour[$r]<$Gsct_sunday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==1) #### Monday local time + { + if (($Gsct_monday_start==0) and ($Gsct_monday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_monday_start) and ($GMT_hour[$r]<$Gsct_monday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==2) #### Tuesday local time + { + if (($Gsct_tuesday_start==0) and ($Gsct_tuesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_tuesday_start) and ($GMT_hour[$r]<$Gsct_tuesday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==3) #### Wednesday local time + { + if (($Gsct_wednesday_start==0) and ($Gsct_wednesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_wednesday_start) and ($GMT_hour[$r]<$Gsct_wednesday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==4) #### Thursday local time + { + if (($Gsct_thursday_start==0) and ($Gsct_thursday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_thursday_start) and ($GMT_hour[$r]<$Gsct_thursday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==5) #### Friday local time + { + if (($Gsct_friday_start==0) and ($Gsct_friday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_friday_start) and ($GMT_hour[$r]<$Gsct_friday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==6) #### Saturday local time + { + if (($Gsct_saturday_start==0) and ($Gsct_saturday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_saturday_start) and ($GMT_hour[$r]<$Gsct_saturday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + $r++; + } + $state_gmt = "$state_gmt'99'"; + $ct_state_gmt_SQL .= "or (state='$Gstate_call_time_state' and gmt_offset_now IN($state_gmt)) "; + } + + $b++; + } + if (strlen($ct_states)>2) + { + $ct_states = eregi_replace(",$",'',$ct_states); + $ct_statesSQL = "and state NOT IN($ct_states)"; + } + else + { + $ct_statesSQL = ""; + } + + $r=0; + $default_gmt=''; + while($r < $g) + { + if ($GMT_day[$r]==0) #### Sunday local time + { + if (($Gct_sunday_start==0) and ($Gct_sunday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_sunday_start) and ($GMT_hour[$r]<$Gct_sunday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==1) #### Monday local time + { + if (($Gct_monday_start==0) and ($Gct_monday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_monday_start) and ($GMT_hour[$r]<$Gct_monday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==2) #### Tuesday local time + { + if (($Gct_tuesday_start==0) and ($Gct_tuesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_tuesday_start) and ($GMT_hour[$r]<$Gct_tuesday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==3) #### Wednesday local time + { + if (($Gct_wednesday_start==0) and ($Gct_wednesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_wednesday_start) and ($GMT_hour[$r]<$Gct_wednesday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==4) #### Thursday local time + { + if (($Gct_thursday_start==0) and ($Gct_thursday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_thursday_start) and ($GMT_hour[$r]<$Gct_thursday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==5) #### Friday local time + { + if (($Gct_friday_start==0) and ($Gct_friday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_friday_start) and ($GMT_hour[$r]<$Gct_friday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==6) #### Saturday local time + { + if (($Gct_saturday_start==0) and ($Gct_saturday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_saturday_start) and ($GMT_hour[$r]<$Gct_saturday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + $r++; + } + + $default_gmt = "$default_gmt'99'"; + $all_gmtSQL = "(gmt_offset_now IN($default_gmt) $ct_statesSQL) $ct_state_gmt_SQL"; + + $dial_statuses = preg_replace("/ -$/","",$dial_statuses); + $Dstatuses = explode(" ", $dial_statuses); + $Ds_to_print = (count($Dstatuses) - 0); + $Dsql = ''; + $o=0; + while ($Ds_to_print > $o) + { + $o++; + $Dsql .= "'$Dstatuses[$o]',"; + } + $Dsql = preg_replace("/,$/","",$Dsql); + if (strlen($Dsql) < 2) {$Dsql = "''";} + + $DLTsql=''; + if ($drop_lockout_time > 0) + { + $DLseconds = ($drop_lockout_time * 3600); + $DLseconds = floor($DLseconds); + $DLseconds = intval("$DLseconds"); + $DLTsql = "and ( ( (status IN('DROP','XDROP')) and (last_local_call_time < CONCAT(DATE_ADD(NOW(), INTERVAL -$DLseconds SECOND),' ',CURTIME()) ) ) or (status NOT IN('DROP','XDROP')) )"; + } + + $stmt="SELECT lead_filter_sql FROM vicidial_lead_filters where lead_filter_id='$lead_filter_id';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00239',$user,$server_ip,$session_name,$one_mysql_log);} + $filtersql_ct = mysql_num_rows($rslt); + if ($DB) {echo "$filtersql_ct|$stmt\n";} + if ($filtersql_ct > 0) + { + $row=mysql_fetch_row($rslt); + $fSQL = $row[0]; + } + + $stmt="SELECT list_id FROM vicidial_lists where campaign_id='$campaign' and active='Y';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00240',$user,$server_ip,$session_name,$one_mysql_log);} + $camplists_ct = mysql_num_rows($rslt); + if ($DB) {echo "$camplists_ct|$stmt\n";} + $k=0; + $camp_lists=''; + while ($camplists_ct > $k) + { + $row=mysql_fetch_row($rslt); + $camp_lists .= "'$row[0]',"; + $k++; + } + $camp_lists = eregi_replace(".$","",$camp_lists); + if (strlen($camp_lists) < 4) {$camp_lists="''";} + + $stmt="SELECT user_group,territory FROM vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00241',$user,$server_ip,$session_name,$one_mysql_log);} + $userterr_ct = mysql_num_rows($rslt); + if ($DB) {echo "$userterr_ct|$stmt\n";} + if ($userterr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $user_group = $row[0]; + $territory = $row[1]; + } + + $agent_territories=''; + $stmt="SELECT agent_territories FROM vicidial_live_agents where user='$user';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00258',$user,$server_ip,$session_name,$one_mysql_log);} + $userterrVLA_ct = mysql_num_rows($rslt); + if ($DB) {echo "$userterrVLA_ct|$stmt\n";} + if ($userterrVLA_ct > 0) + { + $row=mysql_fetch_row($rslt); + $agent_territories = $row[0]; + } + if (strlen($agent_territories) > 3) + { + $agent_territoriesSQL = preg_replace('/-$/','',$agent_territories); + $agent_territoriesSQL = preg_replace('/ $|^ /','',$agent_territoriesSQL); + $territory = preg_replace('/ /',"','",$agent_territoriesSQL); + } + + $adooSQL = ''; + if (eregi("USER",$agent_dial_owner_only)) {$adooSQL = "and owner='$user'";} + if (eregi("TERRITORY",$agent_dial_owner_only)) {$adooSQL = "and owner IN('$territory')";} + if (eregi("USER_GROUP",$agent_dial_owner_only)) {$adooSQL = "and owner='$user_group'";} + + $order_stmt = ''; + if (eregi("DOWN",$lead_order)){$order_stmt = 'order by lead_id asc';} + if (eregi("UP",$lead_order)){$order_stmt = 'order by lead_id desc';} + if (eregi("UP LAST NAME",$lead_order)){$order_stmt = 'order by last_name desc, lead_id asc';} + if (eregi("DOWN LAST NAME",$lead_order)){$order_stmt = 'order by last_name, lead_id asc';} + if (eregi("UP PHONE",$lead_order)){$order_stmt = 'order by phone_number desc, lead_id asc';} + if (eregi("DOWN PHONE",$lead_order)){$order_stmt = 'order by phone_number, lead_id asc';} + if (eregi("UP COUNT",$lead_order)){$order_stmt = 'order by called_count desc, lead_id asc';} + if (eregi("DOWN COUNT",$lead_order)){$order_stmt = 'order by called_count, lead_id asc';} + if (eregi("UP LAST SAMTAL TIME",$lead_order)){$order_stmt = 'order by last_local_call_time desc, lead_id asc';} + if (eregi("DOWN LAST SAMTAL TIME",$lead_order)){$order_stmt = 'order by last_local_call_time, lead_id asc';} + if (eregi("RANDOM",$lead_order)){$order_stmt = 'order by RAND()';} + if (eregi("UP RANK",$lead_order)){$order_stmt = 'order by rank desc, lead_id asc';} + if (eregi("DOWN RANK",$lead_order)){$order_stmt = 'order by rank, lead_id asc';} + if (eregi("UP OWNER",$lead_order)){$order_stmt = 'order by owner desc, lead_id asc';} + if (eregi("DOWN OWNER",$lead_order)){$order_stmt = 'order by owner, lead_id asc';} + if (eregi("UP TIMEZONE",$lead_order)){$order_stmt = 'order by gmt_offset_now desc, lead_id asc';} + if (eregi("DOWN TIMEZONE",$lead_order)){$order_stmt = 'order by gmt_offset_now, lead_id asc';} + + $stmt="UPDATE vicidial_list SET status='QUEUE',user='$user' where called_since_last_reset='N' and status IN($Dsql) and list_id IN($camp_lists) and ($all_gmtSQL) $DLTsql $fSQL $adooSQL $order_stmt LIMIT 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00242',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + + if ($affected_rows > 0) + { + $stmt="SELECT lead_id,list_id,gmt_offset_now,state FROM vicidial_list where status='QUEUE' and user='$user' order by modify_date desc LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00243',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $leadpick_ct = mysql_num_rows($rslt); + if ($leadpick_ct > 0) + { + $row=mysql_fetch_row($rslt); + $lead_id = $row[0]; + $list_id = $row[1]; + $gmt_offset_now = $row[2]; + $state = $row[3]; + + $stmt = "INSERT INTO vicidial_hopper SET lead_id='$lead_id',campaign_id='$campaign',status='QUEUE',list_id='$list_id',gmt_offset_now='$gmt_offset_now',state='$state',alt_dial='MAIN',user='$user',priority='0';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00244',$user,$server_ip,$session_name,$one_mysql_log);} + } + } + } + ########################################################## + ### END find the next lead to dial without looking in the hopper + ########################################################## + # $DB=0; + } + } + } + + if ($affected_rows > 0) + { + if (!$CBleadIDset) + { + ##### grab the lead_id of the reserved user in vicidial_hopper + $stmt="SELECT lead_id FROM vicidial_hopper where campaign_id='$campaign' and status='QUEUE' and user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00025',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $hopper_leadID_ct = mysql_num_rows($rslt); + if ($hopper_leadID_ct > 0) + { + $row=mysql_fetch_row($rslt); + $lead_id =$row[0]; + } + } + + ##### grab the data from vicidial_list for the lead_id + $stmt="SELECT lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner FROM vicidial_list where lead_id='$lead_id' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00026',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $list_lead_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + # $lead_id = trim("$row[0]"); + $dispo = trim("$row[3]"); + $tsr = trim("$row[4]"); + $vendor_id = trim("$row[5]"); + $source_id = trim("$row[6]"); + $list_id = trim("$row[7]"); + $gmt_offset_now = trim("$row[8]"); + $called_since_last_reset = trim("$row[9]"); + $phone_code = trim("$row[10]"); + if ($override_phone < 1) + {$phone_number = trim("$row[11]");} + $title = trim("$row[12]"); + $first_name = trim("$row[13]"); + $middle_initial = trim("$row[14]"); + $last_name = trim("$row[15]"); + $address1 = trim("$row[16]"); + $address2 = trim("$row[17]"); + $address3 = trim("$row[18]"); + $city = trim("$row[19]"); + $state = trim("$row[20]"); + $province = trim("$row[21]"); + $postal_code = trim("$row[22]"); + $country_code = trim("$row[23]"); + $gender = trim("$row[24]"); + $date_of_birth = trim("$row[25]"); + $alt_phone = trim("$row[26]"); + $email = trim("$row[27]"); + $security = trim("$row[28]"); + $comments = stripslashes(trim("$row[29]")); + $called_count = trim("$row[30]"); + $rank = trim("$row[32]"); + $owner = trim("$row[33]"); + } + + $called_count++; + + ##### check if system is set to generate logfile for transfers + $stmt="SELECT enable_agc_xfer_log FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00027',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $enable_agc_xfer_log_ct = mysql_num_rows($rslt); + if ($enable_agc_xfer_log_ct > 0) + { + $row=mysql_fetch_row($rslt); + $enable_agc_xfer_log =$row[0]; + } + + if ( ($WeBRooTWritablE > 0) and ($enable_agc_xfer_log > 0) ) + { + # generate callerID for unique identifier in xfer_log file + $PADlead_id = sprintf("%09s", $lead_id); + while (strlen($PADlead_id) > 9) {$PADlead_id = substr("$PADlead_id", 0, -1);} + # Create unique calleridname to track the call: MmmddhhmmssLLLLLLLLL + $MqueryCID = "M$CIDdate$PADlead_id"; + + # DATETIME|campaign|lead_id|phone_number|user|type + # 2007-08-22 11:11:11|TESTCAMP|65432|3125551212|1234|M + $fp = fopen ("./xfer_log.txt", "a"); + fwrite ($fp, "$NOW_TIME|$campaign|$lead_id|$phone_number|$user|M|$MqueryCID||$province\n"); + fclose($fp); + } + + ##### if lead is a callback, grab the callback comments + $CBentry_time = ''; + $CBcallback_time = ''; + $CBuser = ''; + $CBcomments = ''; + if (ereg("CALLBK",$dispo)) + { + $stmt="SELECT entry_time,callback_time,user,comments FROM vicidial_callbacks where lead_id='$lead_id' order by callback_id desc LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00028',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cb_record_ct = mysql_num_rows($rslt); + if ($cb_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $CBentry_time = trim("$row[0]"); + $CBcallback_time = trim("$row[1]"); + $CBuser = trim("$row[2]"); + $CBcomments = trim("$row[3]"); + } + } + + $stmt = "SELECT local_gmt FROM servers where active='Y' limit 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00029',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $server_ct = mysql_num_rows($rslt); + if ($server_ct > 0) + { + $row=mysql_fetch_row($rslt); + $local_gmt = $row[0]; + } + $LLCT_DATE_offset = ($local_gmt - $gmt_offset_now); + $LLCT_DATE = date("Y-m-d H:i:s", mktime(date("H")-$LLCT_DATE_offset,date("i"),date("s"),date("m"),date("d"),date("Y"))); + + if (ereg('Y',$called_since_last_reset)) + { + $called_since_last_reset = ereg_replace('Y','',$called_since_last_reset); + if (strlen($called_since_last_reset) < 1) {$called_since_last_reset = 0;} + $called_since_last_reset++; + $called_since_last_reset = "Y$called_since_last_reset"; + } + else {$called_since_last_reset = 'Y';} + ### flag the lead as called and change it's status to INCALL + $stmt = "UPDATE vicidial_list set status='INCALL', called_since_last_reset='$called_since_last_reset', called_count='$called_count',user='$user',last_local_call_time='$LLCT_DATE' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00030',$user,$server_ip,$session_name,$one_mysql_log);} + + if (!$CBleadIDset) + { + ### delete the lead from the hopper + $stmt = "DELETE FROM vicidial_hopper where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00031',$user,$server_ip,$session_name,$one_mysql_log);} + } + + $stmt="UPDATE vicidial_agent_log set lead_id='$lead_id',comments='MANUAL' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00032',$user,$server_ip,$session_name,$one_mysql_log);} + + ### if preview dialing, do not send the call + if ( (strlen($preview)<1) || ($preview == 'NO') ) + { + ### prepare variables to place manual call from VICIDiaL + $CCID_on=0; $CCID=''; + $local_DEF = 'Local/'; + $local_AMP = '@'; + $Local_out_prefix = '9'; + $Local_dial_timeout = '60'; + # $Local_persist = '/n'; + $Local_persist = ''; + if ($dial_timeout > 4) {$Local_dial_timeout = $dial_timeout;} + $Local_dial_timeout = ($Local_dial_timeout * 1000); + if (strlen($dial_prefix) > 0) {$Local_out_prefix = "$dial_prefix";} + if (strlen($campaign_cid) > 6) {$CCID = "$campaign_cid"; $CCID_on++;} + $campaign_cid_override=''; + ### check if there is a list_id override + if (strlen($list_id) > 1) + { + $stmt = "SELECT campaign_cid_override FROM vicidial_lists where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00245',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $lio_ct = mysql_num_rows($rslt); + if ($lio_ct > 0) + { + $row=mysql_fetch_row($rslt); + $campaign_cid_override = $row[0]; + } + } + if (strlen($campaign_cid_override) > 6) {$CCID = "$campaign_cid_override"; $CCID_on++;} + if (eregi("x",$dial_prefix)) {$Local_out_prefix = '';} + + $PADlead_id = sprintf("%09s", $lead_id); + while (strlen($PADlead_id) > 9) {$PADlead_id = substr("$PADlead_id", 0, -1);} + + # Create unique calleridname to track the call: MmmddhhmmssLLLLLLLLL + $MqueryCID = "M$CIDdate$PADlead_id"; + if ($CCID_on) {$CIDstring = "\"$MqueryCID\" <$CCID>";} + else {$CIDstring = "$MqueryCID";} + + ### whether to omit phone_code or not + if (eregi('Y',$omit_phone_code)) + {$Ndialstring = "$Local_out_prefix$phone_number";} + else + {$Ndialstring = "$Local_out_prefix$phone_code$phone_number";} + + if ( ($usegroupalias > 0) and (strlen($account)>1) ) + { + $RAWaccount = $account; + $account = "Account: $account"; + $variable = "Variable: usegroupalias=1"; + } + else + {$account=''; $variable='';} + + ### insert the call action into the vicidial_manager table to initiate the call + # $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $conf_exten','Context: $ext_context','Channel: $local_DEF$Local_out_prefix$phone_code$phone_number$local_AMP$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $Ndialstring','Context: $ext_context','Channel: $local_DEF$conf_exten$local_AMP$ext_context$Local_persist','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','$account','$variable','','');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00033',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt = "INSERT INTO vicidial_auto_calls (server_ip,campaign_id,status,lead_id,callerid,phone_code,phone_number,call_time,call_type) values('$server_ip','$campaign','XFER','$lead_id','$MqueryCID','$phone_code','$phone_number','$NOW_TIME','OUT')"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00034',$user,$server_ip,$session_name,$one_mysql_log);} + + ### update the agent status to INCALL in vicidial_live_agents + $stmt = "UPDATE vicidial_live_agents set status='INCALL',last_call_time='$NOW_TIME',callerid='$MqueryCID',lead_id='$lead_id',comments='MANUAL',calls_today='$calls_today',external_hangup=0,external_status='',external_pause='',external_dial='',last_state_change='$NOW_TIME' where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00035',$user,$server_ip,$session_name,$one_mysql_log);} + + ### update calls_today count in vicidial_campaign_agents + $stmt = "UPDATE vicidial_campaign_agents set calls_today='$calls_today' where user='$user' and campaign_id='$campaign';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00036',$user,$server_ip,$session_name,$one_mysql_log);} + + # #### update vicidial_agent_log if not MANUAL dial_method + # if ($dial_method != 'MANUAL') + # { + # $pause_sec=0; + # $stmt = "select pause_epoch,pause_sec,wait_epoch,talk_epoch,dispo_epoch,agent_log_id from vicidial_agent_log where agent_log_id >= '$agent_log_id' and user='$user' order by agent_log_id desc limit 1;"; + # if ($DB) {echo "$stmt\n";} + # $rslt=mysql_query($stmt, $link); + # if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00302',$user,$server_ip,$session_name,$one_mysql_log);} + # $VDpr_ct = mysql_num_rows($rslt); + # if ( ($VDpr_ct > 0) and (strlen($row[3]<5)) and (strlen($row[4]<5)) ) + # { + # $row=mysql_fetch_row($rslt); + # $agent_log_id = $row[5]; + # $pause_sec = (($StarTtime - $row[0]) + $row[1]); + # + # $stmt="UPDATE vicidial_agent_log set pause_sec='$pause_sec',wait_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; + # if ($format=='debug') {echo "\n";} + # $rslt=mysql_query($stmt, $link); + # if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00303',$user,$server_ip,$session_name,$one_mysql_log);} + # } + # } + + + $val_pause_epoch=0; + $val_pause_sec=0; + $stmt = "SELECT pause_epoch FROM vicidial_agent_log where agent_log_id='$agent_log_id';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $vald_ct = mysql_num_rows($rslt); + if ($vald_ct > 0) + { + $row=mysql_fetch_row($rslt); + $val_pause_epoch = $row[0]; + $val_pause_sec = ($StarTtime - $val_pause_epoch); + } + + $stmt="UPDATE vicidial_agent_log set pause_sec='$val_pause_sec',wait_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + + + if ($agent_dialed_number > 0) + { + $stmt = "INSERT INTO user_call_log (user,call_date,call_type,server_ip,phone_number,number_dialed,lead_id,callerid,group_alias_id) values('$user','$NOW_TIME','$agent_dialed_type','$server_ip','$phone_number','$Ndialstring','$lead_id','$CCID','$RAWaccount')"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00191',$user,$server_ip,$session_name,$one_mysql_log);} + } + + ############################################# + ##### START QUEUEMETRICS LOGGING LOOKUP ##### + $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00037',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $qm_conf_ct = mysql_num_rows($rslt); + if ($qm_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $enable_queuemetrics_logging = $row[0]; + $queuemetrics_server_ip = $row[1]; + $queuemetrics_dbname = $row[2]; + $queuemetrics_login = $row[3]; + $queuemetrics_pass = $row[4]; + $queuemetrics_log_id = $row[5]; + } + ##### END QUEUEMETRICS LOGGING LOOKUP ##### + ########################################### + if ($enable_queuemetrics_logging > 0) + { + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); + mysql_select_db("$queuemetrics_dbname", $linkB); + + # UNPAUSEALL + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='UNPAUSEALL',serverid='$queuemetrics_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00038',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + + # SAMTALOUTBOUND (formerly ENTERQUEUE) + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MqueryCID',queue='$campaign',agent='NONE',verb='CALLOUTBOUND',data2='$phone_number',serverid='$queuemetrics_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00039',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + + # CONNECT + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MqueryCID',queue='$campaign',agent='Agent/$user',verb='CONNECT',data1='0',serverid='$queuemetrics_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00040',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + + mysql_close($linkB); + } + + } + + ##### find if script contains recording fields + $stmt="SELECT count(*) FROM vicidial_lists WHERE list_id='$list_id' and agent_script_override!='' and agent_script_override IS NOT NULL and agent_script_override!='NONE';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00259',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $vls_vc_ct = mysql_num_rows($rslt); + if ($vls_vc_ct > 0) + { + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + { + $script_recording_delay=0; + ##### find if script contains recording fields + $stmt="SELECT count(*) FROM vicidial_scripts vs,vicidial_lists vls WHERE list_id='$list_id' and vs.script_id=vls.agent_script_override and script_text LIKE \"%--A--recording_%\";"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00260',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $vs_vc_ct = mysql_num_rows($rslt); + if ($vs_vc_ct > 0) + { + $row=mysql_fetch_row($rslt); + $script_recording_delay = $row[0]; + } + } + } + + ### Check for List ID override settings + $VDCL_xferconf_a_number=''; + $VDCL_xferconf_b_number=''; + $VDCL_xferconf_c_number=''; + $VDCL_xferconf_d_number=''; + $VDCL_xferconf_e_number=''; + $stmt = "select xferconf_a_number,xferconf_b_number,xferconf_c_number,xferconf_d_number,xferconf_e_number from vicidial_campaigns where campaign_id='$campaign';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00277',$user,$server_ip,$session_name,$one_mysql_log);} + $VC_preset_ct = mysql_num_rows($rslt); + if ($VC_preset_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_xferconf_a_number = $row[0]; + $VDCL_xferconf_b_number = $row[1]; + $VDCL_xferconf_c_number = $row[2]; + $VDCL_xferconf_d_number = $row[3]; + $VDCL_xferconf_e_number = $row[4]; + } + + if (strlen($list_id)>0) + { + $stmt = "select xferconf_a_number,xferconf_b_number,xferconf_c_number,xferconf_d_number,xferconf_e_number from vicidial_lists where list_id='$list_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00278',$user,$server_ip,$session_name,$one_mysql_log);} + $VDIG_preset_ct = mysql_num_rows($rslt); + if ($VDIG_preset_ct > 0) + { + $row=mysql_fetch_row($rslt); + if (strlen($row[0]) > 0) + {$VDCL_xferconf_a_number = $row[0];} + if (strlen($row[1]) > 0) + {$VDCL_xferconf_b_number = $row[1];} + if (strlen($row[2]) > 0) + {$VDCL_xferconf_c_number = $row[2];} + if (strlen($row[3]) > 0) + {$VDCL_xferconf_d_number = $row[3];} + if (strlen($row[4]) > 0) + {$VDCL_xferconf_e_number = $row[4];} + } + } + + + $comments = eregi_replace("\r",'',$comments); + $comments = eregi_replace("\n",'!N',$comments); + + $LeaD_InfO = $MqueryCID . "\n"; + $LeaD_InfO .= $lead_id . "\n"; + $LeaD_InfO .= $dispo . "\n"; + $LeaD_InfO .= $tsr . "\n"; + $LeaD_InfO .= $vendor_id . "\n"; + $LeaD_InfO .= $list_id . "\n"; + $LeaD_InfO .= $gmt_offset_now . "\n"; + $LeaD_InfO .= $phone_code . "\n"; + $LeaD_InfO .= $phone_number . "\n"; + $LeaD_InfO .= $title . "\n"; + $LeaD_InfO .= $first_name . "\n"; + $LeaD_InfO .= $middle_initial . "\n"; + $LeaD_InfO .= $last_name . "\n"; + $LeaD_InfO .= $address1 . "\n"; + $LeaD_InfO .= $address2 . "\n"; + $LeaD_InfO .= $address3 . "\n"; + $LeaD_InfO .= $city . "\n"; + $LeaD_InfO .= $state . "\n"; + $LeaD_InfO .= $province . "\n"; + $LeaD_InfO .= $postal_code . "\n"; + $LeaD_InfO .= $country_code . "\n"; + $LeaD_InfO .= $gender . "\n"; + $LeaD_InfO .= $date_of_birth . "\n"; + $LeaD_InfO .= $alt_phone . "\n"; + $LeaD_InfO .= $email . "\n"; + $LeaD_InfO .= $security . "\n"; + $LeaD_InfO .= $comments . "\n"; + $LeaD_InfO .= $called_count . "\n"; + $LeaD_InfO .= $CBentry_time . "\n"; + $LeaD_InfO .= $CBcallback_time . "\n"; + $LeaD_InfO .= $CBuser . "\n"; + $LeaD_InfO .= $CBcomments . "\n"; + $LeaD_InfO .= $phone_number . "\n"; + $LeaD_InfO .= "MAIN\n"; + $LeaD_InfO .= $source_id . "\n"; + $LeaD_InfO .= $rank . "\n"; + $LeaD_InfO .= $owner . "\n"; + $LeaD_InfO .= "\n"; + $LeaD_InfO .= $script_recording_delay . "\n"; + $LeaD_InfO .= $VDCL_xferconf_a_number . "\n"; + $LeaD_InfO .= $VDCL_xferconf_b_number . "\n"; + $LeaD_InfO .= $VDCL_xferconf_c_number . "\n"; + $LeaD_InfO .= $VDCL_xferconf_d_number . "\n"; + $LeaD_InfO .= $VDCL_xferconf_e_number . "\n"; + + echo $LeaD_InfO; + } + else + { + echo "HOPPERN ÄR TOM!\n"; + } + } + } + + +################################################################################ +### alt_phone_change - change alt phone numbers to active and inactive +### +################################################################################ +if ($ACTION == 'alt_phone_change') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($stage)<1) || (strlen($called_count)<1) || (strlen($lead_id)<1) || (strlen($phone_number)<1) ) + { + $channel_live=0; + echo "ALTERNATIVT NUMMER NUNNER STATUS NOT CHANGED\n"; + echo "$phone_number $stage $lead_id or $called_count är ej giltig\n"; + exit; + } + else + { + $stmt = "UPDATE vicidial_list_alt_phones set active='$stage' where lead_id='$lead_id' and phone_number='$phone_number' and alt_phone_count='$called_count';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00041',$user,$server_ip,$session_name,$one_mysql_log);} + + echo "ALTERNATIVT NUMMER NUNNER STATUS CHANGED\n"; + } +} + + +################################################################################ +### AlertControl - change the agent alert setting in vicidial_users +### +################################################################################ +if ($ACTION == 'AlertControl') +{ + if (strlen($stage)<1) + { + $channel_live=0; + echo "AGENT ALERT SETTING NOT CHANGED\n"; + echo "$stage är ej giltig\n"; + exit; + } + else + { + if (ereg('ON',$stage)) {$stage = '1';} + else {$stage = '0';} + + $stmt = "UPDATE vicidial_users set alert_enabled='$stage' where user='$user' and pass='$pass';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'000185',$user,$server_ip,$session_name,$one_mysql_log);} + + echo "AGENT ALERT SETTING CHANGED $stage\n"; + } +} + + +################################################################################ +### manDiaLskip - for manual VICIDiaL dialing this skips the lead that was +### previewed in the step above and puts it back in orig status +################################################################################ +if ($ACTION == 'manDiaLskip') + { + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($stage)<1) || (strlen($called_count)<1) || (strlen($lead_id)<1) ) + { + $channel_live=0; + echo "LEAD NOT REVERTED\n"; + echo "Conf Exten $conf_exten or campaign $campaign or ext_context $ext_context är ej giltig\n"; + exit; + } + else + { + $called_count = ($called_count - 1); + ### flag the lead as called and change it's status to INCALL + $stmt = "UPDATE vicidial_list set status='$stage', called_count='$called_count',user='$user' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00042',$user,$server_ip,$session_name,$one_mysql_log);} + + + echo "LEAD REVERTED\n"; + } + } + + +################################################################################ +### manDiaLonly - for manual VICIDiaL dialing this sends the call that was +### previewed in the step above +################################################################################ +if ($ACTION == 'manDiaLonly') + { + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($conf_exten)<1) || (strlen($campaign)<1) || (strlen($ext_context)<1) || (strlen($phone_number)<1) || (strlen($lead_id)<1) ) + { + $channel_live=0; + echo " SAMTAL NOT PLACED\n"; + echo "Conf Exten $conf_exten or campaign $campaign or ext_context $ext_context är ej giltig\n"; + exit; + } + else + { + ##### grab number of calls today in this campaign and increment + $stmt="SELECT calls_today FROM vicidial_live_agents WHERE user='$user' and campaign_id='$campaign';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00043',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $vla_cc_ct = mysql_num_rows($rslt); + if ($vla_cc_ct > 0) + { + $row=mysql_fetch_row($rslt); + $calls_today =$row[0]; + } + else + {$calls_today ='0';} + $calls_today++; + + ### prepare variables to place manual call from VICIDiaL + $CCID_on=0; $CCID=''; + $local_DEF = 'Local/'; + $local_AMP = '@'; + $Local_out_prefix = '9'; + $Local_dial_timeout = '60'; + $Local_persist = '/n'; + if ($dial_timeout > 4) {$Local_dial_timeout = $dial_timeout;} + $Local_dial_timeout = ($Local_dial_timeout * 1000); + if (strlen($dial_prefix) > 0) {$Local_out_prefix = "$dial_prefix";} + if (strlen($campaign_cid) > 6) {$CCID = "$campaign_cid"; $CCID_on++;} + if (eregi("x",$dial_prefix)) {$Local_out_prefix = '';} + $campaign_cid_override=''; + ### check if there is a list_id override + if (strlen($lead_id) > 1) + { + $list_id=''; + $stmt = "SELECT list_id FROM vicidial_list where lead_id='$lead_id';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00246',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $lio_ct = mysql_num_rows($rslt); + if ($lio_ct > 0) + { + $row=mysql_fetch_row($rslt); + $list_id = $row[0]; + + if (strlen($list_id) > 1) + { + $stmt = "SELECT campaign_cid_override FROM vicidial_lists where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00247',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $lio_ct = mysql_num_rows($rslt); + if ($lio_ct > 0) + { + $row=mysql_fetch_row($rslt); + $campaign_cid_override = $row[0]; + } + } + } + } + if (strlen($campaign_cid_override) > 6) {$CCID = "$campaign_cid_override"; $CCID_on++;} + + $PADlead_id = sprintf("%09s", $lead_id); + while (strlen($PADlead_id) > 9) {$PADlead_id = substr("$PADlead_id", 0, -1);} + + # Create unique calleridname to track the call: MmmddhhmmssLLLLLLLLL + $MqueryCID = "M$CIDdate$PADlead_id"; + if ($CCID_on) {$CIDstring = "\"$MqueryCID\" <$CCID>";} + else {$CIDstring = "$MqueryCID";} + + if ( ($usegroupalias > 0) and (strlen($account)>1) ) + { + $RAWaccount = $account; + $account = "Account: $account"; + $variable = "Variable: usegroupalias=1"; + } + else + {$account=''; $variable='';} + + ### whether to omit phone_code or not + if (eregi('Y',$omit_phone_code)) + {$Ndialstring = "$Local_out_prefix$phone_number";} + else + {$Ndialstring = "$Local_out_prefix$phone_code$phone_number";} + ### insert the call action into the vicidial_manager table to initiate the call + # $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $conf_exten','Context: $ext_context','Channel: $local_DEF$Local_out_prefix$phone_code$phone_number$local_AMP$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $Ndialstring','Context: $ext_context','Channel: $local_DEF$conf_exten$local_AMP$ext_context$Local_persist','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','$account','$variable','','');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00044',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt = "INSERT INTO vicidial_auto_calls (server_ip,campaign_id,status,lead_id,callerid,phone_code,phone_number,call_time,call_type) values('$server_ip','$campaign','XFER','$lead_id','$MqueryCID','$phone_code','$phone_number','$NOW_TIME','OUT')"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00045',$user,$server_ip,$session_name,$one_mysql_log);} + + ### update the agent status to INCALL in vicidial_live_agents + $stmt = "UPDATE vicidial_live_agents set status='INCALL',last_call_time='$NOW_TIME',callerid='$MqueryCID',lead_id='$lead_id',comments='MANUAL',calls_today='$calls_today',external_hangup=0,external_status='',external_pause='',external_dial='',last_state_change='$NOW_TIME' where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00046',$user,$server_ip,$session_name,$one_mysql_log);} + $retry_count=0; + while ( ($errno > 0) and ($retry_count < 9) ) + { + $rslt=mysql_query($stmt, $link); + $one_mysql_log=1; + $errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9046$retry_count",$user,$server_ip,$session_name,$one_mysql_log); + $one_mysql_log=0; + $retry_count++; + } + + $stmt = "UPDATE vicidial_campaign_agents set calls_today='$calls_today' where user='$user' and campaign_id='$campaign';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00047',$user,$server_ip,$session_name,$one_mysql_log);} + + echo "$MqueryCID\n"; + +# #### update vicidial_agent_log if not MANUAL dial_method +# if ($dial_method != 'MANUAL') +# { +# $pause_sec=0; +# $stmt = "SELECT pause_epoch,pause_sec,wait_epoch,talk_epoch,dispo_epoch,agent_log_id from vicidial_agent_log where agent_log_id >= '$agent_log_id' and user='$user' order by agent_log_id desc limit 1;"; +# if ($DB) {echo "$stmt\n";} +# $rslt=mysql_query($stmt, $link); +# if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00304',$user,$server_ip,$session_name,$one_mysql_log);} +# $VDpr_ct = mysql_num_rows($rslt); +# if ( ($VDpr_ct > 0) and (strlen($row[3]<5)) and (strlen($row[4]<5)) ) +# { +# $row=mysql_fetch_row($rslt); +# $agent_log_id = $row[5]; +# $pause_sec = (($StarTtime - $row[0]) + $row[1]); +# +# $stmt="UPDATE vicidial_agent_log set pause_sec='$pause_sec',wait_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; +# if ($format=='debug') {echo "\n";} +# $rslt=mysql_query($stmt, $link); +# if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00305',$user,$server_ip,$session_name,$one_mysql_log);} +# } +# } + + $val_pause_epoch=0; + $val_pause_sec=0; + $val_dispo_epoch=0; + $val_dispo_sec=0; + $val_wait_epoch=0; + $val_wait_sec=0; + $stmt = "SELECT dispo_epoch,wait_epoch,pause_epoch FROM vicidial_agent_log where agent_log_id='$agent_log_id';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $vald_ct = mysql_num_rows($rslt); + if ($vald_ct > 0) + { + $row=mysql_fetch_row($rslt); + $val_dispo_epoch = $row[0]; + $val_wait_epoch = $row[1]; + $val_pause_epoch = $row[2]; + $val_dispo_sec = ($StarTtime - $val_dispo_epoch); + $val_wait_sec = ($StarTtime - $val_wait_epoch); + $val_pause_sec = ($StarTtime - $val_pause_epoch); + } + if ($val_dispo_epoch > 1000) + { + $stmt="UPDATE vicidial_agent_log set status='ALTNUM',dispo_sec='$val_dispo_sec' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + + $user_group=''; + $stmt="SELECT user_group FROM vicidial_users where user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $ug_record_ct = mysql_num_rows($rslt); + if ($ug_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $user_group = trim("$row[0]"); + } + + $stmt="INSERT INTO vicidial_agent_log (user,server_ip,event_time,campaign_id,pause_epoch,pause_sec,wait_epoch,user_group,sub_status) values('$user','$server_ip','$NOW_TIME','$campaign','$StarTtime','0','$StarTtime','$user_group','ANDIAL');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + $agent_log_id = mysql_insert_id($link); + + $stmt="UPDATE vicidial_live_agents SET agent_log_id='$agent_log_id',last_state_change='$NOW_TIME' where user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $VLAaffected_rows_update = mysql_affected_rows($link); + } + else + { + $stmt="UPDATE vicidial_agent_log set pause_sec='$val_pause_sec',wait_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + } + + echo "$agent_log_id\n"; + + + if ($agent_dialed_number > 0) + { + $stmt = "INSERT INTO user_call_log (user,call_date,call_type,server_ip,phone_number,number_dialed,lead_id,callerid,group_alias_id) values('$user','$NOW_TIME','$agent_dialed_type','$server_ip','$phone_number','$Ndialstring','$lead_id','$CCID','$RAWaccount')"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00192',$user,$server_ip,$session_name,$one_mysql_log);} + } + + + ############################################# + ##### START QUEUEMETRICS LOGGING LOOKUP ##### + $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00048',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $qm_conf_ct = mysql_num_rows($rslt); + if ($qm_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $enable_queuemetrics_logging = $row[0]; + $queuemetrics_server_ip = $row[1]; + $queuemetrics_dbname = $row[2]; + $queuemetrics_login = $row[3]; + $queuemetrics_pass = $row[4]; + $queuemetrics_log_id = $row[5]; + } + ##### END QUEUEMETRICS LOGGING LOOKUP ##### + ########################################### + if ($enable_queuemetrics_logging > 0) + { + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); + mysql_select_db("$queuemetrics_dbname", $linkB); + + # UNPAUSEALL + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='UNPAUSEALL',serverid='$queuemetrics_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00049',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + + # SAMTALOUTBOUND (formerly ENTERQUEUE) + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MqueryCID',queue='$campaign',agent='NONE',verb='CALLOUTBOUND',data2='$phone_number',serverid='$queuemetrics_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00050',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + + # CONNECT + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MqueryCID',queue='$campaign',agent='Agent/$user',verb='CONNECT',data1='0',serverid='$queuemetrics_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00051',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + + mysql_close($linkB); + } + + } + } + + +################################################################################ +### manDiaLlookCaLL - for manual VICIDiaL dialing this will attempt to look up +### the trunk channel that the call was placed on +################################################################################ +if ($ACTION == 'manDiaLlookCaLL') + { + $MT[0]=''; + $row=''; $rowx=''; + $call_good=0; + if (strlen($MDnextCID)<18) + { + echo "NO\n"; + echo "MDnextCID $MDnextCID är ej giltig\n"; + exit; + } + else + { + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="SELECT uniqueid,channel FROM vicidial_manager where callerid='$MDnextCID' and server_ip='$server_ip' and status IN('UPDATED','DEAD') LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00052',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VM_mancall_ct = mysql_num_rows($rslt); + if ($VM_mancall_ct > 0) + { + $row=mysql_fetch_row($rslt); + $uniqueid =$row[0]; + $channel =$row[1]; + $call_output = "$uniqueid\n$channel\n"; + $call_good++; + } + else + { + ### after 10 sekunder, start checking for call termination in the carrier log + if ( ($DiaL_SecondS > 0) and (preg_match("/0$/",$DiaL_SecondS)) ) + { + $stmt="SELECT uniqueid,channel,end_epoch FROM call_log where caller_code='$MDnextCID' and server_ip='$server_ip' order by start_time desc LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00291',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VM_mancallX_ct = mysql_num_rows($rslt); + if ($VM_mancallX_ct > 0) + { + $row=mysql_fetch_row($rslt); + $uniqueid = $row[0]; + $channel = $row[1]; + $end_epoch = $row[2]; + + ### Check carrier log for error + $stmt="SELECT dialstatus,hangup_cause FROM vicidial_carrier_log where uniqueid='$uniqueid' and server_ip='$server_ip' and channel='$channel' and dialstatus IN('BUSY','CHANUNAVAIL','CONGESTION') LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00292',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $CL_mancall_ct = mysql_num_rows($rslt); + if ($CL_mancall_ct > 0) + { + $row=mysql_fetch_row($rslt); + $dialstatus =$row[0]; + $hangup_cause =$row[1]; + + $channel = $dialstatus; + $hangup_cause_msg = "Cause: " . $hangup_cause . " - " . hangup_cause_description($hangup_cause); + + $call_output = "$uniqueid\n$channel\nERROR\n" . $hangup_cause_msg; + $call_good++; + + ### Delete call record + $stmt="DELETE from vicidial_auto_calls where callerid='$MDnextCID';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00293',$user,$server_ip,$session_name,$one_mysql_log);} + } + } + } + } + + if ($call_good > 0) + { + $wait_sec=0; + $dead_epochSQL = ''; + $stmt = "select wait_epoch,wait_sec,dead_epoch from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00053',$user,$server_ip,$session_name,$one_mysql_log);} + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $wait_sec = (($StarTtime - $row[0]) + $row[1]); + $now_dead_epoch = $row[2]; + if ( ($now_dead_epoch > 1000) and ($now_dead_epoch < $StarTtime) ) + {$dead_epochSQL = ",dead_epoch='$StarTtime'";} + } + $stmt="UPDATE vicidial_agent_log set wait_sec='$wait_sec',talk_epoch='$StarTtime',lead_id='$lead_id' $dead_epochSQL where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00054',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt="UPDATE vicidial_auto_calls set uniqueid='$uniqueid',channel='$channel' where callerid='$MDnextCID';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00055',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt="UPDATE call_log set uniqueid='$uniqueid',channel='$channel' where caller_code='$MDnextCID';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00300',$user,$server_ip,$session_name,$one_mysql_log);} + + echo "$call_output"; + } + else + {echo "NO\n$DiaL_SecondS\n";} + } + } + + + +################################################################################ +### manDiaLlogCALL - for manual VICIDiaL logging of calls places record in +### vicidial_log and then sends process to call_log entry +################################################################################ +if ($ACTION == 'manDiaLlogCaLL') +{ + $MT[0]=''; + $row=''; $rowx=''; + $vidSQL=''; + $VDterm_reason=''; + +if ($stage == "start") + { + if ( (strlen($uniqueid)<1) || (strlen($lead_id)<1) || (strlen($list_id)<1) || (strlen($phone_number)<1) || (strlen($campaign)<1) ) + { + $fp = fopen ("./vicidial_debug.txt", "a"); + fwrite ($fp, "$NOW_TIME|VL_LOG_0|$uniqueid|$lead_id|$user|$list_id|$campaign|$start_epoch|$phone_number|$agent_log_id|\n"); + fclose($fp); + + echo "LOGG SKREVS EJ\n"; + echo "uniqueid $uniqueid or lead_id: $lead_id or list_id: $list_id or phone_number: $phone_number or campaign: $campaign är ej giltig\n"; + exit; + } + else + { + $user_group=''; + $stmt="SELECT user_group FROM vicidial_users where user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00056',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $ug_record_ct = mysql_num_rows($rslt); + if ($ug_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $user_group = trim("$row[0]"); + } + + $manualVLexists=0; + $beginUNIQUEID = preg_replace("/\..*/","",$uniqueid); + $stmt="SELECT count(*) from vicidial_log where lead_id='$lead_id' and user='$user' and phone_number='$phone_number' and uniqueid LIKE \"$beginUNIQUEID%\";"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00223',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VL_exists_ct = mysql_num_rows($rslt); + if ($VL_exists_ct > 0) + { + $row=mysql_fetch_row($rslt); + $manualVLexists = $row[0]; + } + + $manualVLexistsDUP=0; + if ($manualVLexists < 1) + { + ##### insert log into vicidial_log for manual VICIDiaL call + $stmt="INSERT INTO vicidial_log (uniqueid,lead_id,list_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,comments,processed,user_group,alt_dial) values('$uniqueid','$lead_id','$list_id','$campaign','$NOW_TIME','$StarTtime','INCALL','$phone_code','$phone_number','$user','MANUAL','N','$user_group','$alt_dial');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00279',$user,$server_ip,$session_name,$one_mysql_log);} + $DUPerrno = mysql_errno($link); + if ($DUPerrno > 0) + {$manualVLexistsDUP=1;} + $affected_rows = mysql_affected_rows($link); + } + if ( ($manualVLexists > 0) or ($manualVLexistsDUP > 0) ) + { + ##### insert log into vicidial_log for manual VICIDiaL call + $stmt="UPDATE vicidial_log SET list_id='$list_id',comments='MANUAL',user_group='$user_group',alt_dial='$alt_dial' where lead_id='$lead_id' and user='$user' and phone_number='$phone_number' and uniqueid LIKE \"$beginUNIQUEID%\";"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00224',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + } + + if ($affected_rows > 0) + { + echo "VICIDiaL_LOG Tillagd: $uniqueid|$channel|$NOW_TIME\n"; + echo "$StarTtime\n"; + } + else + { + echo "LOGG SKREVS EJ\n"; + } + + $stmt = "UPDATE vicidial_auto_calls SET uniqueid='$uniqueid' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00058',$user,$server_ip,$session_name,$one_mysql_log);} + + # ##### insert log into call_log for manual VICIDiaL call + # $stmt = "INSERT INTO call_log (uniqueid,channel,server_ip,extension,number_dialed,caller_code,start_time,start_epoch) values('$uniqueid','$channel','$server_ip','$exten','$phone_code$phone_number','MD $user $lead_id','$NOW_TIME','$StarTtime')"; + # if ($DB) {echo "$stmt\n";} + # $rslt=mysql_query($stmt, $link); + # $affected_rows = mysql_affected_rows($link); + + # if ($affected_rows > 0) + # { + # echo "CALL_LOG Tillagd: $uniqueid|$channel|$NOW_TIME"; + # } + # else + # { + # echo "LOGG SKREVS EJ\n"; + # } + } + } + +if ($stage == "end") + { + $status_dispo = 'DISPO'; + if ($alt_num_status > 0) + {$status_dispo = 'ALTNUM';} + ##### get call type from vicidial_live_agents table + $VLA_inOUT='NONE'; + $stmt="SELECT comments FROM vicidial_live_agents where user='$user' order by last_update_time desc limit 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00059',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VLA_inOUT_ct = mysql_num_rows($rslt); + if ($VLA_inOUT_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VLA_inOUT = $row[0]; + } + + if ( (strlen($uniqueid)<1) and ($VLA_inOUT == 'INBOUND') ) + { + $fp = fopen ("./vicidial_debug.txt", "a"); + fwrite ($fp, "$NOW_TIME|INBND_LOG_0|$uniqueid|$lead_id|$user|$inOUT|$VLA_inOUT|$start_epoch|$phone_number|$agent_log_id|\n"); + fclose($fp); + $uniqueid='6666.1'; + } + if ( (strlen($uniqueid)<1) or (strlen($lead_id)<1) ) + { + echo "LOGG SKREVS EJ\n"; + echo "uniqueid $uniqueid or lead_id: $lead_id är ej giltig\n"; + exit; + } + else + { + $term_reason='NONE'; + if ($start_epoch < 1000) + { + if ($VLA_inOUT == 'INBOUND') + { + $four_hours_ago = date("Y-m-d H:i:s", mktime(date("H")-4,date("i"),date("s"),date("m"),date("d"),date("Y"))); + + ##### look for the start epoch in the vicidial_closer_log table + $stmt="SELECT start_epoch,term_reason,closecallid,campaign_id FROM vicidial_closer_log where phone_number='$phone_number' and lead_id='$lead_id' and user='$user' and call_date > \"$four_hours_ago\" order by closecallid desc limit 1;"; + $VDIDselect = "VDCL_LID $lead_id $phone_number $user $four_hours_ago"; + } + else + { + ##### look for the start epoch in the vicidial_log table + $stmt="SELECT start_epoch,term_reason,uniqueid,campaign_id FROM vicidial_log where uniqueid='$uniqueid' and lead_id='$lead_id' order by call_date desc limit 1;"; + $VDIDselect = "VDL_UIDLID $uniqueid $lead_id"; + } + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00060',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VM_mancall_ct = mysql_num_rows($rslt); + if ($VM_mancall_ct > 0) + { + $row=mysql_fetch_row($rslt); + $start_epoch = $row[0]; + $VDterm_reason = $row[1]; + $VDvicidial_id = $row[2]; + $VDcampaign_id = $row[3]; + $length_in_sec = ($StarTtime - $start_epoch); + } + else + { + $length_in_sec = 0; + } + + if ( ($length_in_sec < 1) and ($VLA_inOUT == 'INBOUND') ) + { + $fp = fopen ("./vicidial_debug.txt", "a"); + fwrite ($fp, "$NOW_TIME|INBND_LOG_1|$uniqueid|$lead_id|$user|$inOUT|$length_in_sec|$VDterm_reason|$VDvicidial_id|$start_epoch|\n"); + fclose($fp); + + ##### start epoch in the vicidial_log table, couldn't find one in vicidial_closer_log + $stmt="SELECT start_epoch,term_reason,campaign_id FROM vicidial_log where uniqueid='$uniqueid' and lead_id='$lead_id' order by call_date desc limit 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00061',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VM_mancall_ct = mysql_num_rows($rslt); + if ($VM_mancall_ct > 0) + { + $row=mysql_fetch_row($rslt); + $start_epoch = $row[0]; + $VDterm_reason = $row[1]; + $VDcampaign_id = $row[2]; + $length_in_sec = ($StarTtime - $start_epoch); + } + else + { + $length_in_sec = 0; + } + } + } + else {$length_in_sec = ($StarTtime - $start_epoch);} + + if (strlen($VDcampaign_id)<1) {$VDcampaign_id = $campaign;} + + $four_hours_ago = date("Y-m-d H:i:s", mktime(date("H")-4,date("i"),date("s"),date("m"),date("d"),date("Y"))); + + if ($VLA_inOUT == 'INBOUND') + { + $stmt = "UPDATE vicidial_closer_log set end_epoch='$StarTtime', length_in_sec='$length_in_sec', status='$status_dispo' where lead_id='$lead_id' and user='$user' and call_date > \"$four_hours_ago\" order by call_date desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00062',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + if ($affected_rows > 0) + { + echo "$uniqueid\n$channel\n"; + } + else + { + $fp = fopen ("./vicidial_debug.txt", "a"); + fwrite ($fp, "$NOW_TIME|INBND_LOG_2|$uniqueid|$lead_id|$user|$inOUT|$length_in_sec|$VDterm_reason|$VDvicidial_id|$start_epoch|\n"); + fclose($fp); + } + } + + ############################################# + ##### START QUEUEMETRICS LOGGING LOOKUP ##### + $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00063',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $qm_conf_ct = mysql_num_rows($rslt); + $i=0; + if ($qm_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $enable_queuemetrics_logging = $row[0]; + $queuemetrics_server_ip = $row[1]; + $queuemetrics_dbname = $row[2]; + $queuemetrics_login = $row[3]; + $queuemetrics_pass = $row[4]; + $queuemetrics_log_id = $row[5]; + + if ($enable_queuemetrics_logging > 0) + { + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); + mysql_select_db("$queuemetrics_dbname", $linkB); + } + } + ##### END QUEUEMETRICS LOGGING LOOKUP ##### + ########################################### + + if ($auto_dial_level > 0) + { + ### check to see if campaign has alt_dial enabled + $stmt="SELECT auto_alt_dial,use_internal_dnc,use_campaign_dnc FROM vicidial_campaigns where campaign_id='$campaign';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00064',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VAC_mancall_ct = mysql_num_rows($rslt); + if ($VAC_mancall_ct > 0) + { + $row=mysql_fetch_row($rslt); + $auto_alt_dial = $row[0]; + $use_internal_dnc = $row[1]; + $use_campaign_dnc = $row[2]; + } + else {$auto_alt_dial = 'NONE';} + if (eregi("(ALT_ONLY|ADDR3_ONLY|ALT_AND_ADDR3|ALT_AND_EXTENDED|ALT_AND_ADDR3_AND_EXTENDED|EXTENDED_ONLY)",$auto_alt_dial)) + { + ### check to see if lead should be alt_dialed + if (strlen($alt_dial)<2) {$alt_dial = 'NONE';} + + ### check if inbound call, if so find a recent outbound call to pull alt_dial value from + if ($VLA_inOUT == 'INBOUND') + { + $one_hour_ago = date("Y-m-d H:i:s", mktime(date("H")-1,date("i"),date("s"),date("m"),date("d"),date("Y"))); + ##### find a recent outbound call associated with this inbound call + $stmt="SELECT alt_dial FROM vicidial_log where lead_id='$lead_id' and status IN('DROP','XDROP') and call_date > \"$one_hour_ago\" order by call_date desc limit 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00235',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VL_alt_ct = mysql_num_rows($rslt); + if ($VL_alt_ct > 0) + { + $row=mysql_fetch_row($rslt); + $alt_dial = $row[0]; + } + } + + if ( (eregi("(NONE|MAIN)",$alt_dial)) and (eregi("(ALT_ONLY|ALT_AND_ADDR3|ALT_AND_EXTENDED)",$auto_alt_dial)) ) + { + $alt_dial_skip=0; + $stmt="SELECT alt_phone,gmt_offset_now,state FROM vicidial_list where lead_id='$lead_id';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00065',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VAC_mancall_ct = mysql_num_rows($rslt); + if ($VAC_mancall_ct > 0) + { + $row=mysql_fetch_row($rslt); + $alt_phone = $row[0]; + $alt_phone = eregi_replace("[^0-9]","",$alt_phone); + $gmt_offset_now = $row[1]; + $state = $row[2]; + } + else {$alt_phone = '';} + if (strlen($alt_phone)>5) + { + if ( (ereg("Y",$use_internal_dnc)) or (ereg("AREACODE",$use_internal_dnc)) ) + { + if (ereg("AREACODE",$use_internal_dnc)) + { + $alt_phone_areacode = substr($alt_phone, 0, 3); + $alt_phone_areacode .= "XXXXXXX"; + $stmtA="SELECT count(*) from vicidial_dnc where phone_number IN('$alt_phone','$alt_phone_areacode');"; + } + else + {$stmtA="SELECT count(*) FROM vicidial_dnc where phone_number='$alt_phone';";} + $rslt=mysql_query($stmtA, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtA,'00066',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VLAP_dnc_ct = mysql_num_rows($rslt); + if ($VLAP_dnc_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VD_alt_dnc_count = $row[0]; + } + } + else {$VD_alt_dnc_count=0;} + if ( (ereg("Y",$use_campaign_dnc)) or (ereg("AREACODE",$use_campaign_dnc)) ) + { + if (ereg("AREACODE",$use_campaign_dnc)) + { + $alt_phone_areacode = substr($alt_phone, 0, 3); + $alt_phone_areacode .= "XXXXXXX"; + $stmtA="SELECT count(*) from vicidial_campaign_dnc where phone_number IN('$alt_phone','$alt_phone_areacode') and campaign_id='$campaign';"; + } + else + {$stmtA="SELECT count(*) FROM vicidial_campaign_dnc where phone_number='$alt_phone' and campaign_id='$campaign';";} + $rslt=mysql_query($stmtA, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtA,'00067',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VLAP_cdnc_ct = mysql_num_rows($rslt); + if ($VLAP_cdnc_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VD_alt_dnc_count = ($VD_alt_dnc_count + $row[0]); + } + } + if ($VD_alt_dnc_count < 1) + { + ### insert record into vicidial_hopper for alt_phone call attempt + $stmt = "INSERT INTO vicidial_hopper SET lead_id='$lead_id',campaign_id='$campaign',status='HOLD',list_id='$list_id',gmt_offset_now='$gmt_offset_now',state='$state',alt_dial='ALT',user='',priority='25';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00068',$user,$server_ip,$session_name,$one_mysql_log);} + } + else + {$alt_dial_skip=1;} + } + else + {$alt_dial_skip=1;} + if ($alt_dial_skip > 0) + {$alt_dial='ALT';} + } + + if ( ( (eregi("(ALT)",$alt_dial)) and (eregi("ALT_AND_ADDR3",$auto_alt_dial)) ) or ( (eregi("(NONE|MAIN)",$alt_dial)) and (eregi("ADDR3_ONLY",$auto_alt_dial)) ) ) + { + $addr3_dial_skip=0; + $stmt="SELECT address3,gmt_offset_now,state FROM vicidial_list where lead_id='$lead_id';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00069',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VAC_mancall_ct = mysql_num_rows($rslt); + if ($VAC_mancall_ct > 0) + { + $row=mysql_fetch_row($rslt); + $address3 = $row[0]; + $address3 = eregi_replace("[^0-9]","",$address3); + $gmt_offset_now = $row[1]; + $state = $row[2]; + } + else {$address3 = '';} + if (strlen($address3)>5) + { + if ( (ereg("Y",$use_internal_dnc)) or (ereg("AREACODE",$use_internal_dnc)) ) + { + if (ereg("AREACODE",$use_internal_dnc)) + { + $addr3_phone_areacode = substr($address3, 0, 3); + $addr3_phone_areacode .= "XXXXXXX"; + $stmtA="SELECT count(*) from vicidial_dnc where phone_number IN('$address3','$addr3_phone_areacode');"; + } + else + {$stmtA="SELECT count(*) FROM vicidial_dnc where phone_number='$address3';";} + $rslt=mysql_query($stmtA, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtA,'00070',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VLAP_dnc_ct = mysql_num_rows($rslt); + if ($VLAP_dnc_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VD_alt_dnc_count = $row[0]; + } + } + else {$VD_alt_dnc_count=0;} + if ( (ereg("Y",$use_campaign_dnc)) or (ereg("AREACODE",$use_campaign_dnc)) ) + { + if (ereg("AREACODE",$use_campaign_dnc)) + { + $addr3_phone_areacode = substr($address3, 0, 3); + $addr3_phone_areacode .= "XXXXXXX"; + $stmtA="SELECT count(*) from vicidial_campaign_dnc where phone_number IN('$address3','$addr3_phone_areacode') and campaign_id='$campaign';"; + } + else + {$stmtA="SELECT count(*) FROM vicidial_campaign_dnc where phone_number='$address3' and campaign_id='$campaign';";} + $rslt=mysql_query($stmtA, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtA,'00071',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VLAP_cdnc_ct = mysql_num_rows($rslt); + if ($VLAP_cdnc_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VD_alt_dnc_count = ($VD_alt_dnc_count + $row[0]); + } + } + if ($VD_alt_dnc_count < 1) + { + ### insert record into vicidial_hopper for address3 call attempt + $stmt = "INSERT INTO vicidial_hopper SET lead_id='$lead_id',campaign_id='$campaign',status='HOLD',list_id='$list_id',gmt_offset_now='$gmt_offset_now',state='$state',alt_dial='ADDR3',user='',priority='20';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00072',$user,$server_ip,$session_name,$one_mysql_log);} + } + else + {$addr3_dial_skip=1;} + } + else + {$addr3_dial_skip=1;} + if ($addr3_dial_skip > 0) + {$alt_dial='ADDR3';} + } + + # $fp = fopen ("./alt_multi_log.txt", "a"); + # fwrite ($fp, "$NOW_TIME|PRE-X|$campaign|$lead_id|$phone_number|$user|$Ctype|$callerid|$uniqueid|$stmt|$auto_alt_dial|$alt_dial\n"); + # fclose($fp); + + if ( ( ( (eregi("(NONE|MAIN)",$alt_dial)) and (eregi("EXTENDED_ONLY",$auto_alt_dial)) ) or ( (eregi("(ALT)",$alt_dial)) and (eregi("(ALT_AND_EXTENDED)",$auto_alt_dial)) ) or ( (eregi("(ADDR3)",$alt_dial)) and (eregi("(ADDR3_AND_EXTENDED|ALT_AND_ADDR3_AND_EXTENDED)",$auto_alt_dial)) ) or ( (eregi("(X)",$alt_dial)) and (eregi("EXTENDED",$auto_alt_dial)) ) ) and (!eregi("LAST",$alt_dial)) ) + { + if (eregi("(ADDR3)",$alt_dial)) {$Xlast=0;} + else + {$Xlast = ereg_replace("[^0-9]","",$alt_dial);} + if (strlen($Xlast)<1) + {$Xlast=0;} + $VD_altdialx=''; + + $stmt="SELECT gmt_offset_now,state,list_id FROM vicidial_list where lead_id='$lead_id';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00073',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VL_deailts_ct = mysql_num_rows($rslt); + if ($VL_deailts_ct > 0) + { + $row=mysql_fetch_row($rslt); + $EA_gmt_offset_now = $row[0]; + $EA_state = $row[1]; + $EA_list_id = $row[2]; + } + $alt_dial_phones_count=0; + $stmt="SELECT count(*) FROM vicidial_list_alt_phones where lead_id='$lead_id';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00074',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VLAP_ct = mysql_num_rows($rslt); + if ($VLAP_ct > 0) + { + $row=mysql_fetch_row($rslt); + $alt_dial_phones_count = $row[0]; + } + while ( ($alt_dial_phones_count > 0) and ($alt_dial_phones_count > $Xlast) ) + { + $Xlast++; + $stmt="SELECT alt_phone_id,phone_number,active FROM vicidial_list_alt_phones where lead_id='$lead_id' and alt_phone_count='$Xlast';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00075',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VLAP_detail_ct = mysql_num_rows($rslt); + if ($VLAP_detail_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VD_altdial_id = $row[0]; + $VD_altdial_phone = $row[1]; + $VD_altdial_active = $row[2]; + } + else + {$Xlast=9999999999;} + + if (ereg("Y",$VD_altdial_active)) + { + if ( (ereg("Y",$use_internal_dnc)) or (ereg("AREACODE",$use_internal_dnc)) ) + { + if (ereg("AREACODE",$use_internal_dnc)) + { + $vdap_phone_areacode = substr($VD_altdial_phone, 0, 3); + $vdap_phone_areacode .= "XXXXXXX"; + $stmtA="SELECT count(*) from vicidial_dnc where phone_number IN('$VD_altdial_phone','$vdap_phone_areacode');"; + } + else + {$stmtA="SELECT count(*) FROM vicidial_dnc where phone_number='$VD_altdial_phone';";} + $rslt=mysql_query($stmtA, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtA,'00076',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VLAP_dnc_ct = mysql_num_rows($rslt); + if ($VLAP_dnc_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VD_alt_dnc_count = $row[0]; + } + } + else {$VD_alt_dnc_count=0;} + if ( (ereg("Y",$use_campaign_dnc)) or (ereg("AREACODE",$use_campaign_dnc)) ) + { + if (ereg("AREACODE",$use_campaign_dnc)) + { + $vdap_phone_areacode = substr($VD_altdial_phone, 0, 3); + $vdap_phone_areacode .= "XXXXXXX"; + $stmtA="SELECT count(*) from vicidial_campaign_dnc where phone_number IN('$VD_altdial_phone','$vdap_phone_areacode') and campaign_id='$campaign';"; + } + else + {$stmtA="SELECT count(*) FROM vicidial_campaign_dnc where phone_number='$VD_altdial_phone' and campaign_id='$campaign';";} + $rslt=mysql_query($stmtA, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtA,'00077',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VLAP_cdnc_ct = mysql_num_rows($rslt); + if ($VLAP_cdnc_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VD_alt_dnc_count = ($VD_alt_dnc_count + $row[0]); + } + } + if ($VD_alt_dnc_count < 1) + { + if ($alt_dial_phones_count == $Xlast) + {$Xlast = 'LAST';} + $stmt = "INSERT INTO vicidial_hopper SET lead_id='$lead_id',campaign_id='$campaign',status='HOLD',list_id='$EA_list_id',gmt_offset_now='$EA_gmt_offset_now',state='$EA_state',alt_dial='X$Xlast',user='',priority='15';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00078',$user,$server_ip,$session_name,$one_mysql_log);} + $Xlast=9999999999; + } + } + } + } + } + + if ($enable_queuemetrics_logging > 0) + { + ### grab call lead information needed for QM logging + $stmt="SELECT auto_call_id,lead_id,phone_number,status,campaign_id,phone_code,alt_dial,stage,callerid,uniqueid from vicidial_auto_calls where lead_id='$lead_id' order by call_time limit 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00079',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VAC_qm_ct = mysql_num_rows($rslt); + if ($VAC_qm_ct > 0) + { + $row=mysql_fetch_row($rslt); + $auto_call_id = $row[0]; + $CLlead_id = $row[1]; + $CLphone_number = $row[2]; + $CLstatus = $row[3]; + $CLcampaign_id = $row[4]; + $CLphone_code = $row[5]; + $CLalt_dial = $row[6]; + $CLstage = $row[7]; + $CLcallerid = $row[8]; + $CLuniqueid = $row[9]; + } + + $CLstage = preg_replace("/.*-/",'',$CLstage); + if (strlen($CLstage) < 1) {$CLstage=0;} + + $stmt="SELECT count(*) from queue_log where call_id='$MDnextCID' and verb='COMPLETECALLER' and queue='$VDcampaign_id';"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00080',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VAC_cc_ct = mysql_num_rows($rslt); + if ($VAC_cc_ct > 0) + { + $row=mysql_fetch_row($rslt); + $caller_complete = $row[0]; + } + + if ($caller_complete < 1) + { + $term_reason='AGENT'; + } + else + { + $term_reason='CALLER'; + } + + } + + if ($nodeletevdac < 1) + { + ### delete call record from vicidial_auto_calls + $stmt = "DELETE from vicidial_auto_calls where lead_id='$lead_id' and campaign_id='$VDcampaign_id' and uniqueid='$uniqueid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00081',$user,$server_ip,$session_name,$one_mysql_log);} + } + + $stmt = "UPDATE vicidial_live_agents set status='PAUSED',uniqueid=0,callerid='',channel='',call_server_ip='',last_call_finish='$NOW_TIME',comments='',last_state_change='$NOW_TIME' where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00082',$user,$server_ip,$session_name,$one_mysql_log);} + $retry_count=0; + while ( ($errno > 0) and ($retry_count < 9) ) + { + $rslt=mysql_query($stmt, $link); + $one_mysql_log=1; + $errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9082$retry_count",$user,$server_ip,$session_name,$one_mysql_log); + $one_mysql_log=0; + $retry_count++; + } + + $affected_rows = mysql_affected_rows($link); + if ($affected_rows > 0) + { + if ($enable_queuemetrics_logging > 0) + { + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='PAUSEALL',serverid='$queuemetrics_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00083',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + } + } + } + else + { + if ($enable_queuemetrics_logging > 0) + { + $CLqueue_position=1; + ### check to see if lead should be alt_dialed + $stmt="SELECT auto_call_id,lead_id,phone_number,status,campaign_id,phone_code,alt_dial,stage,callerid,uniqueid,queue_position from vicidial_auto_calls where lead_id='$lead_id' order by call_time desc limit 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00084',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VAC_qm_ct = mysql_num_rows($rslt); + if ($VAC_qm_ct > 0) + { + $row=mysql_fetch_row($rslt); + $auto_call_id = $row[0]; + $CLlead_id = $row[1]; + $CLphone_number = $row[2]; + $CLstatus = $row[3]; + $CLcampaign_id = $row[4]; + $CLphone_code = $row[5]; + $CLalt_dial = $row[6]; + $CLstage = $row[7]; + $CLcallerid = $row[8]; + $CLuniqueid = $row[9]; + $CLqueue_position = $row[10]; + } + + $CLstage = preg_replace("/XFER|CLOSER|-/",'',$CLstage); + if ($CLstage < 0.25) {$CLstage=0;} + + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MDnextCID',queue='$VDcampaign_id',agent='Agent/$user',verb='COMPLETEAGENT',data1='$CLstage',data2='$length_in_sec',data3='$CLqueue_position',serverid='$queuemetrics_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00085',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + } + + if ($nodeletevdac < 1) + { + # $stmt = "DELETE from vicidial_auto_calls where lead_id='$lead_id' and campaign_id='$campaign' and uniqueid='$uniqueid';"; + $stmt = "DELETE from vicidial_auto_calls where lead_id='$lead_id' and campaign_id='$VDcampaign_id' and callerid LIKE \"M%\";"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00086',$user,$server_ip,$session_name,$one_mysql_log);} + } + + $stmt = "UPDATE vicidial_live_agents set status='PAUSED',uniqueid=0,callerid='',channel='',call_server_ip='',last_call_finish='$NOW_TIME',comments='',last_state_change='$NOW_TIME' where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00087',$user,$server_ip,$session_name,$one_mysql_log);} + $retry_count=0; + while ( ($errno > 0) and ($retry_count < 9) ) + { + $rslt=mysql_query($stmt, $link); + $one_mysql_log=1; + $errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9087$retry_count",$user,$server_ip,$session_name,$one_mysql_log); + $one_mysql_log=0; + $retry_count++; + } + + $affected_rows = mysql_affected_rows($link); + if ($affected_rows > 0) + { + if ($enable_queuemetrics_logging > 0) + { + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='PAUSEALL',serverid='$queuemetrics_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00088',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + } + } + } + + if ( ($VLA_inOUT == 'AUTO') or ($VLA_inOUT == 'MANUAL') ) + { + $SQLterm = "term_reason='$term_reason',"; + + if ( (ereg("NONE",$term_reason)) or (ereg("NONE",$VDterm_reason)) or (strlen($VDterm_reason) < 1) ) + { + ### check to see if lead should be alt_dialed + $stmt="SELECT term_reason,uniqueid from vicidial_log where uniqueid='$uniqueid' and lead_id='$lead_id' order by call_date desc limit 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00089',$user,$server_ip,$session_name,$one_mysql_log);} + $VAC_qm_ct = mysql_num_rows($rslt); + if ($VAC_qm_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDterm_reason = $row[0]; + $VDvicidial_id = $row[1]; + $VDIDselect = "VDL_UIDLID $uniqueid $lead_id"; + } + if (ereg("CALLER",$VDterm_reason)) + { + $SQLterm = ""; + } + else + { + $SQLterm = "term_reason='AGENT',"; + } + } + + ### check to see if the vicidial_log record exists, if not, insert it + $manualVLexists=0; + $beginUNIQUEID = preg_replace("/\..*/","",$uniqueid); + $stmt="SELECT count(*) from vicidial_log where lead_id='$lead_id' and user='$user' and phone_number='$phone_number' and uniqueid LIKE \"$beginUNIQUEID%\";"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00223',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VL_exists_ct = mysql_num_rows($rslt); + if ($VL_exists_ct > 0) + { + $row=mysql_fetch_row($rslt); + $manualVLexists = $row[0]; + } + + if ($manualVLexists < 1) + { + ##### insert log into vicidial_log for manual VICIDiaL call + $stmt="INSERT INTO vicidial_log (uniqueid,lead_id,list_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,comments,processed,user_group,alt_dial) values('$uniqueid','$lead_id','$list_id','$campaign','$NOW_TIME','$StarTtime','DONEM','$phone_code','$phone_number','$user','MANUAL','N','$user_group','$alt_dial');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00280',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + + if ($affected_rows > 0) + { + echo "VICIDiaL_LOG Tillagd: $uniqueid|$channel|$NOW_TIME\n"; + echo "$StarTtime\n"; + } + else + { + echo "LOGG SKREVS EJ\n"; + } + } + else + { + $stmt="UPDATE vicidial_log SET uniqueid='$uniqueid' where lead_id='$lead_id' and user='$user' and phone_number='$phone_number' and uniqueid LIKE \"$beginUNIQUEID%\";"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00057',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + } + + ##### update the duration and end time in the vicidial_log table + $stmt="UPDATE vicidial_log set $SQLterm end_epoch='$StarTtime', length_in_sec='$length_in_sec', status='$status_dispo' where uniqueid='$uniqueid' and lead_id='$lead_id' and user='$user' order by call_date desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00090',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + + if ($affected_rows > 0) + { + echo "$uniqueid\n$channel\n"; + } + else + { + echo "LOGG SKREVS EJ\n\n"; + } + } + else + { + $SQLterm = "term_reason='$term_reason'"; + $QL_term=''; + + if ( (ereg("NONE",$term_reason)) or (ereg("NONE",$VDterm_reason)) or (strlen($VDterm_reason) < 1) ) + { + ### find out who hung up the call + $stmt="SELECT term_reason,closecallid,queue_position from vicidial_closer_log where lead_id='$lead_id' and call_date > \"$four_hours_ago\" order by call_date desc limit 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00091',$user,$server_ip,$session_name,$one_mysql_log);} + $VAC_qm_ct = mysql_num_rows($rslt); + if ($VAC_qm_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDterm_reason = $row[0]; + $VDvicidial_id = $row[1]; + $VDqueue_position = $row[2]; + $VDIDselect = "VDCL_LID4HOUR $lead_id $four_hours_ago"; + } + if (ereg("CALLER",$VDterm_reason)) + { + $SQLterm = ""; + } + else + { + $SQLterm = "term_reason='AGENT'"; + $QL_term = 'COMPLETEAGENT'; + } + } + + if (strlen($SQLterm) > 0) + { + ##### update the duration and end time in the vicidial_log table + $stmt="UPDATE vicidial_closer_log set $SQLterm, status='$status_dispo' where lead_id='$lead_id' and call_date > \"$four_hours_ago\" order by call_date desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00092',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + } + + if ($enable_queuemetrics_logging > 0) + { + if ( (strlen($QL_term) > 0) and ($leaving_threeway > 0) ) + { + $stmt="SELECT count(*) from queue_log where call_id='$MDnextCID' and verb='COMPLETEAGENT' and queue='$VDcampaign_id';"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00093',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VAC_cc_ct = mysql_num_rows($rslt); + if ($VAC_cc_ct > 0) + { + $row=mysql_fetch_row($rslt); + $agent_complete = $row[0]; + } + if ($agent_complete < 1) + { + if (strlen($VDqueue_position) < 1) + { + ### find out who hung up the call + $stmt="SELECT queue_position from vicidial_closer_log where lead_id='$lead_id' and call_date > \"$four_hours_ago\" order by call_date desc limit 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00273',$user,$server_ip,$session_name,$one_mysql_log);} + $VAC_qm_ct = mysql_num_rows($rslt); + if ($VAC_qm_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDqueue_position = $row[0]; + } + } + if (strlen($VDqueue_position) < 1) + {$VDqueue_position=1;} + + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MDnextCID',queue='$VDcampaign_id',agent='Agent/$user',verb='COMPLETEAGENT',data1='$CLstage',data2='$length_in_sec',data3='$VDqueue_position',serverid='$queuemetrics_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00094',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + } + } + } + } + } + + echo $VDstop_rec_after_each_call . '|' . $extension . '|' . $conf_silent_prefix . '|' . $conf_exten . '|' . $user_abb . "|\n"; + + ##### if VICIDiaL call and hangup_after_each_call activated, find all recording + ##### channels and hang them up while entering info into recording_log and + ##### returning filename/recordingID + if ($VDstop_rec_after_each_call == 1) + { + $local_DEF = 'Local/'; + $local_AMP = '@'; + $total_rec=0; + $total_hangup=0; + $loop_count=0; + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = '$conf_exten' order by channel desc;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00095',$user,$server_ip,$session_name,$one_mysql_log);} + if ($rslt) {$rec_list = mysql_num_rows($rslt);} + while ($rec_list>$loop_count) + { + $row=mysql_fetch_row($rslt); + if (preg_match("/Local\/$conf_silent_prefix$conf_exten\@/i",$row[0])) + { + $rec_channels[$total_rec] = "$row[0]"; + $total_rec++; + } + else + { + # if (preg_match("/$agentchannel/i",$row[0])) + if ( ($agentchannel == "$row[0]") or (ereg('ASTblind',$row[0])) ) + { + $donothing=1; + } + else + { + $hangup_channels[$total_hangup] = "$row[0]"; + $total_hangup++; + } + } + if ($format=='debug') {echo "\n";} + $loop_count++; + } + + $loop_count=0; + $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and extension = '$conf_exten' order by channel desc;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00184',$user,$server_ip,$session_name,$one_mysql_log);} + if ($rslt) {$rec_list = mysql_num_rows($rslt);} + while ($rec_list>$loop_count) + { + $row=mysql_fetch_row($rslt); + if (preg_match("/Local\/$conf_silent_prefix$conf_exten\@/i",$row[0])) + { + $rec_channels[$total_rec] = "$row[0]"; + $total_rec++; + } + else + { + # if (preg_match("/$agentchannel/i",$row[0])) + if ( ($agentchannel == "$row[0]") or (ereg('ASTblind',$row[0])) ) + { + $donothing=1; + } + else + { + $hangup_channels[$total_hangup] = "$row[0]"; + $total_hangup++; + } + } + if ($format=='debug') {echo "\n";} + $loop_count++; + } + + + ### if a conference call or 3way call was attempted, then hangup all channels except for the agentchannel + if ( ( ($conf_dialed > 0) or ($hangup_all_non_reserved > 0) ) and ($leaving_threeway < 1) and ($blind_transfer < 1) ) + { + $loop_count=0; + while($loop_count < $total_hangup) + { + if (strlen($hangup_channels[$loop_count])>5) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','CH12346$StarTtime$loop_count','Channel: $hangup_channels[$loop_count]','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00096',$user,$server_ip,$session_name,$one_mysql_log);} + } + $loop_count++; + } + } + + $total_recFN=0; + $loop_count=0; + $filename=$MT; # not necessary : and cmd_line_f LIKE \"%_$user_abb\" + $stmt="SELECT cmd_line_f FROM vicidial_manager where server_ip='$server_ip' and action='Originate' and cmd_line_b = 'Channel: $local_DEF$conf_silent_prefix$conf_exten$local_AMP$ext_context' order by entry_date desc limit $total_rec;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00097',$user,$server_ip,$session_name,$one_mysql_log);} + if ($rslt) {$recFN_list = mysql_num_rows($rslt);} + while ($recFN_list>$loop_count) + { + $row=mysql_fetch_row($rslt); + $filename[$total_recFN] = preg_replace("/Callerid: /i","",$row[0]); + if ($format=='debug') {echo "\n";} + $total_recFN++; + $loop_count++; + } + + $loop_count=0; + while($loop_count < $total_rec) + { + if (strlen($rec_channels[$loop_count])>5) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','RH12345$StarTtime$loop_count','Channel: $rec_channels[$loop_count]','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00098',$user,$server_ip,$session_name,$one_mysql_log);} + + echo "REC_STOP|$rec_channels[$loop_count]|$filename[$loop_count]|"; + if (strlen($filename)>2) + { + $stmt="SELECT recording_id,start_epoch,vicidial_id,lead_id FROM recording_log where filename='$filename[$loop_count]'"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00099',$user,$server_ip,$session_name,$one_mysql_log);} + if ($rslt) {$fn_count = mysql_num_rows($rslt);} + if ($fn_count) + { + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + $start_time = $row[1]; + $vicidial_id = $row[2]; + $RClead_id = $row[3]; + + if ( (strlen($RClead_id)<1) or ($RClead_id < 1) or ($RClead_id=='NULL') ) + {$lidSQL = ",lead_id='$lead_id'";} + if (strlen($vicidial_id)<1) + {$vidSQL = ",vicidial_id='$VDvicidial_id'";} + else + { + if ( (ereg('.',$vicidial_id)) and ($VLA_inOUT == 'INBOUND') ) + { + if (!ereg('.',$VDvicidial_id)) + {$vidSQL = ",vicidial_id='$VDvicidial_id'";} + + $fp = fopen ("./vicidial_debug.txt", "a"); + fwrite ($fp, "$NOW_TIME|INBND_LOG_3|$uniqueid|$lead_id|$user|$inOUT|$VLA_inOUT|$length_in_sec|$VDterm_reason|$VDvicidial_id|$vicidial_id|$start_epoch|$recording_id|\n"); + fclose($fp); + } + } + $length_in_sec = ($StarTtime - $start_time); + $length_in_min = ($length_in_sec / 60); + $length_in_min = sprintf("%8.2f", $length_in_min); + + $stmt="UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' $vidSQL $lidSQL where filename='$filename[$loop_count]' and end_epoch is NULL;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00100',$user,$server_ip,$session_name,$one_mysql_log);} + + echo "$recording_id|$length_in_min|"; + + # $fp = fopen ("./recording_debug_$NOW_DATE$txt", "a"); + # fwrite ($fp, "$NOW_TIME|RECORD_LOG|$filename[$loop_count]|$uniqueid|$lead_id|$user|$inOUT|$VLA_inOUT|$length_in_sec|$VDterm_reason|$VDvicidial_id|$VDvicidial_id|$vicidial_id|$start_epoch|$recording_id|$VDIDselect|\n"); + # fclose($fp); + } + else {echo "||";} + } + else {echo "||";} + echo "\n"; + } + $loop_count++; + } + } + + + $talk_sec=0; + $talk_epochSQL=''; + $dead_secSQL=''; + $lead_id_commentsSQL=''; + $StarTtime = date("U"); + $stmt = "select talk_epoch,talk_sec,wait_sec,wait_epoch,lead_id,comments,dead_epoch from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00101',$user,$server_ip,$session_name,$one_mysql_log);} + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + if ( (eregi("NULL",$row[0])) or ($row[0] < 1000) ) + { + $talk_epochSQL=",talk_epoch='$StarTtime'"; + $row[0]=$row[3]; + } + if ( (!eregi("NULL",$row[6])) and ($row[6] > 1000) ) + { + $dead_sec = ($StarTtime - $row[6]); + if ($dead_sec < 0) {$dead_sec=0;} + $dead_secSQL=",dead_sec='$dead_sec'"; + } + $talk_sec = (($StarTtime - $row[0]) + $row[1]); + if ( ( ($auto_dial_level < 1) or (preg_match('/^M/',$MDnextCID)) ) and (preg_match('/INBOUND_MAN/',$dial_method)) ) + { + if ( (eregi("NULL",$row[5])) or (strlen($row[5]) < 1) ) + { + $lead_id_commentsSQL .= ",comments='MANUAL'"; + } + if ( (eregi("NULL",$row[4])) or ($row[4] < 1) or (strlen($row[4]) < 1) ) + { + $lead_id_commentsSQL .= ",lead_id='$lead_id'"; + } + } + } + $stmt="UPDATE vicidial_agent_log set talk_sec='$talk_sec',dispo_epoch='$StarTtime' $talk_epochSQL $dead_secSQL $lead_id_commentsSQL where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00102',$user,$server_ip,$session_name,$one_mysql_log);} + + ### update vicidial_carrier_log to match uniqueIDs + $beginUNIQUEID = preg_replace("/\..*/","",$uniqueid); + $stmt="UPDATE vicidial_carrier_log set uniqueid='$uniqueid' where lead_id='$lead_id' and uniqueid LIKE \"$beginUNIQUEID%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00299',$user,$server_ip,$session_name,$one_mysql_log);} + } +} + + +################################################################################ +### VDADREcheckINCOMING - for auto-dial VICIDiaL dialing this will recheck for +### calls to see if the channel has updated +################################################################################ +if ($ACTION == 'VDADREcheckINCOMING') + { + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($campaign)<1) || (strlen($server_ip)<1) || (strlen($lead_id)<1) ) + { + $channel_live=0; + echo "0\n"; + echo "Kampanj $campaign är ej giltig\n"; + echo "lead_id $lead_id är ej giltig\n"; + exit; + } + else + { + ### grab the call and lead info from the vicidial_live_agents table + $stmt = "SELECT lead_id,uniqueid,callerid,channel,call_server_ip FROM vicidial_live_agents where server_ip = '$server_ip' and user='$user' and campaign_id='$campaign' and lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00103',$user,$server_ip,$session_name,$one_mysql_log);} + $queue_leadID_ct = mysql_num_rows($rslt); + + if ($queue_leadID_ct > 0) + { + $row=mysql_fetch_row($rslt); + $lead_id =$row[0]; + $uniqueid =$row[1]; + $callerid =$row[2]; + $channel =$row[3]; + $call_server_ip =$row[4]; + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + echo "1\n" . $lead_id . '|' . $uniqueid . '|' . $callerid . '|' . $channel . '|' . $call_server_ip . "|\n"; + } + } + } + + +################################################################################ +### VDADcheckINCOMING - for auto-dial VICIDiaL dialing this will check for calls +### in the vicidial_live_agents table in QUEUE status, then +### lookup the lead info and pass it back to vicidial.php +################################################################################ +if ($ACTION == 'VDADcheckINCOMING') + { + $VDCL_ingroup_recording_override = ''; + $VDCL_ingroup_rec_filename = ''; + $Ctype = 'A'; + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + $alt_phone_code=''; + $alt_phone_number=''; + $alt_phone_note=''; + $alt_phone_active=''; + $alt_phone_count=''; + + if ( (strlen($campaign)<1) || (strlen($server_ip)<1) ) + { + $channel_live=0; + echo "0\n"; + echo "Kampanj $campaign är ej giltig\n"; + exit; + } + else + { + ### grab the call and lead info from the vicidial_live_agents table + $stmt = "SELECT lead_id,uniqueid,callerid,channel,call_server_ip,comments FROM vicidial_live_agents where server_ip = '$server_ip' and user='$user' and campaign_id='$campaign' and status='QUEUE';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00104',$user,$server_ip,$session_name,$one_mysql_log);} + $queue_leadID_ct = mysql_num_rows($rslt); + + if ($queue_leadID_ct > 0) + { + $row=mysql_fetch_row($rslt); + $lead_id =$row[0]; + $uniqueid =$row[1]; + $callerid =$row[2]; + $channel =$row[3]; + $call_server_ip =$row[4]; + $VLAcomments=$row[5]; + + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + echo "1\n" . $lead_id . '|' . $uniqueid . '|' . $callerid . '|' . $channel . '|' . $call_server_ip . "|\n"; + + ##### grab number of calls today in this campaign and increment + $stmt="SELECT calls_today FROM vicidial_live_agents WHERE user='$user' and campaign_id='$campaign';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00105',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $vla_cc_ct = mysql_num_rows($rslt); + if ($vla_cc_ct > 0) + { + $row=mysql_fetch_row($rslt); + $calls_today =$row[0]; + } + else + {$calls_today ='0';} + $calls_today++; + + ### update the agent status to INCALL in vicidial_live_agents + $stmt = "UPDATE vicidial_live_agents set status='INCALL',last_call_time='$NOW_TIME',calls_today='$calls_today',external_hangup=0,external_status='',external_pause='',external_dial='',last_state_change='$NOW_TIME' where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00106',$user,$server_ip,$session_name,$one_mysql_log);} + $retry_count=0; + while ( ($errno > 0) and ($retry_count < 9) ) + { + $rslt=mysql_query($stmt, $link); + $one_mysql_log=1; + $errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9106$retry_count",$user,$server_ip,$session_name,$one_mysql_log); + $one_mysql_log=0; + $retry_count++; + } + + $stmt = "UPDATE vicidial_campaign_agents set calls_today='$calls_today' where user='$user' and campaign_id='$campaign';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00107',$user,$server_ip,$session_name,$one_mysql_log);} + + ##### grab the data from vicidial_list for the lead_id + $stmt="SELECT lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner FROM vicidial_list where lead_id='$lead_id' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00108',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $list_lead_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + # $lead_id = trim("$row[0]"); + $dispo = trim("$row[3]"); + $tsr = trim("$row[4]"); + $vendor_id = trim("$row[5]"); + $source_id = trim("$row[6]"); + $list_id = trim("$row[7]"); + $gmt_offset_now = trim("$row[8]"); + $phone_code = trim("$row[10]"); + $phone_number = trim("$row[11]"); + $title = trim("$row[12]"); + $first_name = trim("$row[13]"); + $middle_initial = trim("$row[14]"); + $last_name = trim("$row[15]"); + $address1 = trim("$row[16]"); + $address2 = trim("$row[17]"); + $address3 = trim("$row[18]"); + $city = trim("$row[19]"); + $state = trim("$row[20]"); + $province = trim("$row[21]"); + $postal_code = trim("$row[22]"); + $country_code = trim("$row[23]"); + $gender = trim("$row[24]"); + $date_of_birth = trim("$row[25]"); + $alt_phone = trim("$row[26]"); + $email = trim("$row[27]"); + $security = trim("$row[28]"); + $comments = stripslashes(trim("$row[29]")); + $called_count = trim("$row[30]"); + $rank = trim("$row[32]"); + $owner = trim("$row[33]"); + } + + ##### if lead is a callback, grab the callback comments + $CBentry_time = ''; + $CBcallback_time = ''; + $CBuser = ''; + $CBcomments = ''; + if (ereg("CALLBK",$dispo)) + { + $stmt="SELECT entry_time,callback_time,user,comments FROM vicidial_callbacks where lead_id='$lead_id' order by callback_id desc LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00109',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cb_record_ct = mysql_num_rows($rslt); + if ($cb_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $CBentry_time = trim("$row[0]"); + $CBcallback_time = trim("$row[1]"); + $CBuser = trim("$row[2]"); + $CBcomments = trim("$row[3]"); + } + } + + ### update the lead status to INCALL + $stmt = "UPDATE vicidial_list set status='INCALL', user='$user' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00110',$user,$server_ip,$session_name,$one_mysql_log);} + + ### update the log status to INCALL + $user_group=''; + $stmt="SELECT user_group FROM vicidial_users where user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00111',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $ug_record_ct = mysql_num_rows($rslt); + if ($ug_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $user_group = trim("$row[0]"); + } + + + $stmt = "SELECT campaign_id,phone_number,alt_dial,call_type from vicidial_auto_calls where callerid = '$callerid' order by call_time desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00112',$user,$server_ip,$session_name,$one_mysql_log);} + $VDAC_cid_ct = mysql_num_rows($rslt); + if ($VDAC_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDADchannel_group =$row[0]; + $dialed_number =$row[1]; + $dialed_label =$row[2]; + $call_type =$row[3]; + if ( ($dialed_number != $phone_number) and (strlen($dialed_label) < 3) ) + { + if ($dialed_number != $alt_phone) + { + if ($dialed_number != $address3) + { + $dialed_label = 'X1'; + $stmt = "SELECT alt_phone_count from vicidial_list_alt_phones where lead_id='$lead_id' and phone_number = '$dialed_number' order by alt_phone_count limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00248',$user,$server_ip,$session_name,$one_mysql_log);} + $VDAP_cid_ct = mysql_num_rows($rslt); + if ($VDAP_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $Xalt_phone_count =$row[0]; + + $stmt = "SELECT count(*) from vicidial_list_alt_phones where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00249',$user,$server_ip,$session_name,$one_mysql_log);} + $VDAPct_cid_ct = mysql_num_rows($rslt); + if ($VDAPct_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $COUNTalt_phone_count =$row[0]; + + if ($COUNTalt_phone_count <= $Xalt_phone_count) + {$dialed_label = 'XLAST';} + else + {$dialed_label = "X$Xalt_phone_count";} + } + + } + } + else + {$dialed_label = 'ADDR3';} + } + else + {$dialed_label = 'ALT';} + } + } + else + { + $dialed_number = $phone_number; + $dialed_label = 'MAIN'; + if (preg_match('/^M|^V/',$callerid)) + { + $call_type = 'OUT'; + $VDADchannel_group = $campaign; + } + else + { + $call_type = 'IN'; + $stmt = "SELECT campaign_id from vicidial_closer_log where lead_id = '$lead_id' order by call_date desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00183',$user,$server_ip,$session_name,$one_mysql_log);} + $VDCL_mvac_ct = mysql_num_rows($rslt); + if ($VDCL_mvac_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDADchannel_group =$row[0]; + } + } + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./vicidial_debug.txt", "a"); + fwrite ($fp, "$NOW_TIME|INBND|$callerid|$user|$user_group|$list_id|$lead_id|$phone_number|$uniqueid|$VDADchannel_group|$call_type|$dialed_number|$dialed_label\n"); + fclose($fp); + } + } + + if ( ($call_type=='OUT') or ($call_type=='OUTBALANCE') ) + { + $stmt = "UPDATE vicidial_log set user='$user', comments='AUTO', list_id='$list_id', status='INCALL', user_group='$user_group' where lead_id='$lead_id' and uniqueid='$uniqueid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00113',$user,$server_ip,$session_name,$one_mysql_log);} + + $script_recording_delay=0; + ##### grab number of calls today in this campaign and increment + $stmt="SELECT count(*) FROM vicidial_scripts vs,vicidial_campaigns vc WHERE campaign_id='$campaign' and vs.script_id=vc.campaign_script and script_text LIKE \"%--A--recording_%\";"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00261',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $vs_vc_ct = mysql_num_rows($rslt); + if ($vs_vc_ct > 0) + { + $row=mysql_fetch_row($rslt); + $script_recording_delay = $row[0]; + } + + $stmt = "SELECT campaign_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,default_xfer_group,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number from vicidial_campaigns where campaign_id='$campaign';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00114',$user,$server_ip,$session_name,$one_mysql_log);} + $VDIG_cid_ct = mysql_num_rows($rslt); + if ($VDIG_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_campaign_script = $row[0]; + $VDCL_get_call_launch = $row[1]; + $VDCL_xferconf_a_dtmf = $row[2]; + $VDCL_xferconf_a_number = $row[3]; + $VDCL_xferconf_b_dtmf = $row[4]; + $VDCL_xferconf_b_number = $row[5]; + $VDCL_default_xfer_group = $row[6]; + if (strlen($VDCL_default_xfer_group)<2) {$VDCL_default_xfer_group='X';} + $VDCL_start_call_url = $row[7]; + $VDCL_dispo_call_url = $row[8]; + $VDCL_xferconf_c_number = $row[9]; + $VDCL_xferconf_d_number = $row[10]; + $VDCL_xferconf_e_number = $row[11]; + } + + ### Check for List ID override settings + if (strlen($list_id)>0) + { + $stmt = "select xferconf_a_number,xferconf_b_number,xferconf_c_number,xferconf_d_number,xferconf_e_number from vicidial_lists where list_id='$list_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00281',$user,$server_ip,$session_name,$one_mysql_log);} + $VDIG_xferOR_ct = mysql_num_rows($rslt); + if ($VDIG_xferOR_ct > 0) + { + $row=mysql_fetch_row($rslt); + if (strlen($row[0]) > 0) + {$VDCL_xferconf_a_number = $row[0];} + if (strlen($row[1]) > 0) + {$VDCL_xferconf_b_number = $row[1];} + if (strlen($row[2]) > 0) + {$VDCL_xferconf_c_number = $row[2];} + if (strlen($row[3]) > 0) + {$VDCL_xferconf_d_number = $row[3];} + if (strlen($row[4]) > 0) + {$VDCL_xferconf_e_number = $row[4];} + } + } + + echo "|||||$VDCL_campaign_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|$VDCL_default_xfer_group|X|X|||||$VDCL_xferconf_c_number|$VDCL_xferconf_d_number|$VDCL_xferconf_e_number\n|\n"; + + if (ereg('X',$dialed_label)) + { + if (ereg('LAST',$dialed_label)) + { + $stmt = "SELECT phone_code,phone_number,alt_phone_note,active,alt_phone_count FROM vicidial_list_alt_phones where lead_id='$lead_id' order by alt_phone_count desc limit 1;"; + } + else + { + $Talt_dial = ereg_replace("[^0-9]","",$dialed_label); + $stmt = "SELECT phone_code,phone_number,alt_phone_note,active,alt_phone_count FROM vicidial_list_alt_phones where lead_id='$lead_id' and alt_phone_count='$Talt_dial';"; + } + + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00116',$user,$server_ip,$session_name,$one_mysql_log);} + $VLAP_ct = mysql_num_rows($rslt); + if ($VLAP_ct > 0) + { + $row=mysql_fetch_row($rslt); + $alt_phone_code = $row[0]; + $alt_phone_number = $row[1]; + $alt_phone_note = $row[2]; + $alt_phone_active = $row[3]; + $alt_phone_count = $row[4]; + } + } + } + else + { + ### update the vicidial_closer_log user to INCALL + $stmt = "UPDATE vicidial_closer_log set user='$user', comments='AUTO', list_id='$list_id', status='INCALL', user_group='$user_group' where lead_id='$lead_id' order by closecallid desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00117',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt = "select count(*) from vicidial_log where lead_id='$lead_id' and uniqueid='$uniqueid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00118',$user,$server_ip,$session_name,$one_mysql_log);} + $VDL_cid_ct = mysql_num_rows($rslt); + if ($VDL_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_front_VDlog =$row[0]; + } + + $script_recording_delay=0; + ##### find if script contains recording fields + $stmt="SELECT count(*) FROM vicidial_scripts vs,vicidial_inbound_groups vig WHERE group_id='$VDADchannel_group' and vs.script_id=vig.ingroup_script and script_text LIKE \"%--A--recording_%\";"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00262',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $vs_vc_ct = mysql_num_rows($rslt); + if ($vs_vc_ct > 0) + { + $row=mysql_fetch_row($rslt); + $script_recording_delay = $row[0]; + } + + $stmt = "select group_name,group_color,web_form_address,fronter_display,ingroup_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,default_xfer_group,ingroup_recording_override,ingroup_rec_filename,default_group_alias,web_form_address_two,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number from vicidial_inbound_groups where group_id='$VDADchannel_group';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00119',$user,$server_ip,$session_name,$one_mysql_log);} + $VDIG_cid_ct = mysql_num_rows($rslt); + if ($VDIG_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_group_name = $row[0]; + $VDCL_group_color = $row[1]; + $VDCL_group_web = stripslashes($row[2]); + $VDCL_fronter_display = $row[3]; + $VDCL_ingroup_script = $row[4]; + $VDCL_get_call_launch = $row[5]; + $VDCL_xferconf_a_dtmf = $row[6]; + $VDCL_xferconf_a_number = $row[7]; + $VDCL_xferconf_b_dtmf = $row[8]; + $VDCL_xferconf_b_number = $row[9]; + $VDCL_default_xfer_group = $row[10]; + $VDCL_ingroup_recording_override = $row[11]; + $VDCL_ingroup_rec_filename = $row[12]; + $VDCL_default_group_alias = $row[13]; + $VDCL_group_web_two = stripslashes($row[14]); + $VDCL_timer_action = $row[15]; + $VDCL_timer_action_message = $row[16]; + $VDCL_timer_action_seconds = $row[17]; + $VDCL_start_call_url = $row[18]; + $VDCL_dispo_call_url = $row[19]; + $VDCL_xferconf_c_number = $row[20]; + $VDCL_xferconf_d_number = $row[21]; + $VDCL_xferconf_e_number = $row[22]; + + $stmt = "select campaign_script,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,default_group_alias,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number from vicidial_campaigns where campaign_id='$campaign';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00181',$user,$server_ip,$session_name,$one_mysql_log);} + $VDIG_cidOR_ct = mysql_num_rows($rslt); + if ($VDIG_cidOR_ct > 0) + { + $row=mysql_fetch_row($rslt); + if (strlen($VDCL_xferconf_a_dtmf) < 1) + {$VDCL_xferconf_a_dtmf = $row[1];} + if (strlen($VDCL_xferconf_a_number) < 1) + {$VDCL_xferconf_a_number = $row[2];} + if (strlen($VDCL_xferconf_b_dtmf) < 1) + {$VDCL_xferconf_b_dtmf = $row[3];} + if (strlen($VDCL_xferconf_b_number) < 1) + {$VDCL_xferconf_b_number = $row[4];} + if (strlen($VDCL_default_group_alias) < 1) + {$VDCL_default_group_alias = $row[5];} + if (strlen($VDCL_timer_action) < 1) + {$VDCL_timer_action = $row[6];} + if (strlen($VDCL_timer_action_message) < 1) + {$VDCL_timer_action_message = $row[7];} + if (strlen($VDCL_timer_action_seconds) < 1) + {$VDCL_timer_action_seconds = $row[8];} + if (strlen($VDCL_start_call_url) < 1) + {$VDCL_start_call_url = $row[9];} + if (strlen($VDCL_dispo_call_url) < 1) + {$VDCL_dispo_call_url = $row[10];} + if (strlen($VDCL_xferconf_c_number) < 1) + {$VDCL_xferconf_c_number = $row[11];} + if (strlen($VDCL_xferconf_d_number) < 1) + {$VDCL_xferconf_d_number = $row[12];} + if (strlen($VDCL_xferconf_e_number) < 1) + {$VDCL_xferconf_e_number = $row[13];} + + if ( ( (ereg('NONE',$VDCL_ingroup_script)) and (strlen($VDCL_ingroup_script) < 5) ) or (strlen($VDCL_ingroup_script) < 1) ) + { + $VDCL_ingroup_script = $row[0]; + $script_recording_delay=0; + ##### find if script contains recording fields + $stmt="SELECT count(*) FROM vicidial_scripts vs,vicidial_campaigns vc WHERE campaign_id='$campaign' and vs.script_id=vc.campaign_script and script_text LIKE \"%--A--recording_%\";"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00263',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $vs_vc_ct = mysql_num_rows($rslt); + if ($vs_vc_ct > 0) + { + $row=mysql_fetch_row($rslt); + $script_recording_delay = $row[0]; + } + } + } + + $stmt = "select group_web_vars from vicidial_inbound_group_agents where group_id='$VDADchannel_group' and user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00188',$user,$server_ip,$session_name,$one_mysql_log);} + $VDIG_cidgwv_ct = mysql_num_rows($rslt); + if ($VDIG_cidgwv_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_group_web_vars = $row[0]; + } + + if (strlen($VDCL_group_web_vars) < 1) + { + $stmt = "select group_web_vars from vicidial_campaign_agents where campaign_id='$campaign' and user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00189',$user,$server_ip,$session_name,$one_mysql_log);} + $VDIG_cidogwv = mysql_num_rows($rslt); + if ($VDIG_cidogwv > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_group_web_vars = $row[0]; + } + } + + ### update the comments in vicidial_live_agents record + $stmt = "UPDATE vicidial_live_agents set comments='INBOUND' where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00120',$user,$server_ip,$session_name,$one_mysql_log);} + + $Ctype = 'I'; + } + else + { + $stmt = "select campaign_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,default_group_alias,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number from vicidial_campaigns where campaign_id='$VDADchannel_group';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00121',$user,$server_ip,$session_name,$one_mysql_log);} + $VDIG_cid_ct = mysql_num_rows($rslt); + if ($VDIG_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_ingroup_script = $row[0]; + $VDCL_get_call_launch = $row[1]; + $VDCL_xferconf_a_dtmf = $row[2]; + $VDCL_xferconf_a_number = $row[3]; + $VDCL_xferconf_b_dtmf = $row[4]; + $VDCL_xferconf_b_number = $row[5]; + $VDCL_default_group_alias = $row[6]; + $VDCL_timer_action = $row[7]; + $VDCL_timer_action_message = $row[8]; + $VDCL_timer_action_seconds = $row[9]; + $VDCL_start_call_url = $row[10]; + $VDCL_dispo_call_url = $row[11]; + $VDCL_xferconf_c_number = $row[12]; + $VDCL_xferconf_d_number = $row[13]; + $VDCL_xferconf_e_number = $row[14]; + } + + $script_recording_delay=0; + ##### find if script contains recording fields + $stmt="SELECT count(*) FROM vicidial_scripts vs,vicidial_campaigns vc WHERE campaign_id='$VDADchannel_group' and vs.script_id=vc.campaign_script and script_text LIKE \"%--A--recording_%\";"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00264',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $vs_vc_ct = mysql_num_rows($rslt); + if ($vs_vc_ct > 0) + { + $row=mysql_fetch_row($rslt); + $script_recording_delay = $row[0]; + } + + $stmt = "select group_web_vars from vicidial_campaign_agents where campaign_id='$VDADchannel_group' and user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00190',$user,$server_ip,$session_name,$one_mysql_log);} + $VDIG_cidogwv = mysql_num_rows($rslt); + if ($VDIG_cidogwv > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_group_web_vars = $row[0]; + } + } + + $VDCL_caller_id_number=''; + if (strlen($VDCL_default_group_alias)>1) + { + $stmt = "select caller_id_number from groups_alias where group_alias_id='$VDCL_default_group_alias';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00187',$user,$server_ip,$session_name,$one_mysql_log);} + $VDIG_cidnum_ct = mysql_num_rows($rslt); + if ($VDIG_cidnum_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_caller_id_number = $row[0]; + } + } + + ### Check for List ID override settings + if (strlen($list_id)>0) + { + $stmt = "select xferconf_a_number,xferconf_b_number,xferconf_c_number,xferconf_d_number,xferconf_e_number from vicidial_lists where list_id='$list_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00282',$user,$server_ip,$session_name,$one_mysql_log);} + $VDIG_cidOR_ct = mysql_num_rows($rslt); + if ($VDIG_cidOR_ct > 0) + { + $row=mysql_fetch_row($rslt); + if (strlen($row[0]) > 0) + {$VDCL_xferconf_a_number = $row[0];} + if (strlen($row[1]) > 0) + {$VDCL_xferconf_b_number = $row[1];} + if (strlen($row[2]) > 0) + {$VDCL_xferconf_c_number = $row[2];} + if (strlen($row[3]) > 0) + {$VDCL_xferconf_d_number = $row[3];} + if (strlen($row[4]) > 0) + {$VDCL_xferconf_e_number = $row[4];} + } + } + + ### if web form is set then send på to vicidial.php for override of WEB_FORM address + if ( (strlen($VDCL_group_web)>5) or (strlen($VDCL_group_name)>0) ) {echo "$VDCL_group_web|$VDCL_group_name|$VDCL_group_color|$VDCL_fronter_display|$VDADchannel_group|$VDCL_ingroup_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|$VDCL_default_xfer_group|$VDCL_ingroup_recording_override|$VDCL_ingroup_rec_filename|$VDCL_default_group_alias|$VDCL_caller_id_number|$VDCL_group_web_vars|$VDCL_group_web_two|$VDCL_timer_action|$VDCL_timer_action_message|$VDCL_timer_action_seconds|$VDCL_xferconf_c_number|$VDCL_xferconf_d_number|$VDCL_xferconf_e_number|\n";} + else {echo "X|$VDCL_group_name|$VDCL_group_color|$VDCL_fronter_display|$VDADchannel_group|$VDCL_ingroup_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|$VDCL_default_xfer_group|$VDCL_ingroup_recording_override|$VDCL_ingroup_rec_filename|$VDCL_default_group_alias|$VDCL_caller_id_number|$VDCL_group_web_vars|$VDCL_group_web_two|$VDCL_timer_action|$VDCL_timer_action_message|$VDCL_timer_action_seconds|$VDCL_xferconf_c_number|$VDCL_xferconf_d_number|$VDCL_xferconf_e_number|\n";} + + $stmt = "SELECT full_name from vicidial_users where user='$tsr';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00122',$user,$server_ip,$session_name,$one_mysql_log);} + $VDU_cid_ct = mysql_num_rows($rslt); + if ($VDU_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $fronter_full_name = $row[0]; + echo $fronter_full_name . '|' . $tsr . "\n"; + } + else {echo '|' . $tsr . "\n";} + } + + ##### find if script contains recording fields + $stmt="SELECT count(*) FROM vicidial_lists WHERE list_id='$list_id' and agent_script_override!='' and agent_script_override IS NOT NULL and agent_script_override!='NONE';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00265',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $vls_vc_ct = mysql_num_rows($rslt); + if ($vls_vc_ct > 0) + { + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + { + $script_recording_delay=0; + ##### find if script contains recording fields + $stmt="SELECT count(*) FROM vicidial_scripts vs,vicidial_lists vls WHERE list_id='$list_id' and vs.script_id=vls.agent_script_override and script_text LIKE \"%--A--recording_%\";"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00266',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $vs_vc_ct = mysql_num_rows($rslt); + if ($vs_vc_ct > 0) + { + $row=mysql_fetch_row($rslt); + $script_recording_delay = $row[0]; + } + } + } + + $comments = eregi_replace("\r",'',$comments); + $comments = eregi_replace("\n",'!N',$comments); + + $LeaD_InfO = $callerid . "\n"; + $LeaD_InfO .= $lead_id . "\n"; + $LeaD_InfO .= $dispo . "\n"; + $LeaD_InfO .= $tsr . "\n"; + $LeaD_InfO .= $vendor_id . "\n"; + $LeaD_InfO .= $list_id . "\n"; + $LeaD_InfO .= $gmt_offset_now . "\n"; + $LeaD_InfO .= $phone_code . "\n"; + $LeaD_InfO .= $phone_number . "\n"; + $LeaD_InfO .= $title . "\n"; + $LeaD_InfO .= $first_name . "\n"; + $LeaD_InfO .= $middle_initial . "\n"; + $LeaD_InfO .= $last_name . "\n"; + $LeaD_InfO .= $address1 . "\n"; + $LeaD_InfO .= $address2 . "\n"; + $LeaD_InfO .= $address3 . "\n"; + $LeaD_InfO .= $city . "\n"; + $LeaD_InfO .= $state . "\n"; + $LeaD_InfO .= $province . "\n"; + $LeaD_InfO .= $postal_code . "\n"; + $LeaD_InfO .= $country_code . "\n"; + $LeaD_InfO .= $gender . "\n"; + $LeaD_InfO .= $date_of_birth . "\n"; + $LeaD_InfO .= $alt_phone . "\n"; + $LeaD_InfO .= $email . "\n"; + $LeaD_InfO .= $security . "\n"; + $LeaD_InfO .= $comments . "\n"; + $LeaD_InfO .= $called_count . "\n"; + $LeaD_InfO .= $CBentry_time . "\n"; + $LeaD_InfO .= $CBcallback_time . "\n"; + $LeaD_InfO .= $CBuser . "\n"; + $LeaD_InfO .= $CBcomments . "\n"; + $LeaD_InfO .= $dialed_number . "\n"; + $LeaD_InfO .= $dialed_label . "\n"; + $LeaD_InfO .= $source_id . "\n"; + $LeaD_InfO .= $alt_phone_code . "\n"; + $LeaD_InfO .= $alt_phone_number . "\n"; + $LeaD_InfO .= $alt_phone_note . "\n"; + $LeaD_InfO .= $alt_phone_active . "\n"; + $LeaD_InfO .= $alt_phone_count . "\n"; + $LeaD_InfO .= $rank . "\n"; + $LeaD_InfO .= $owner . "\n"; + $LeaD_InfO .= $script_recording_delay . "\n"; + + echo $LeaD_InfO; + + + + $wait_sec=0; + $StarTtime = date("U"); + $stmt = "select wait_epoch,wait_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00123',$user,$server_ip,$session_name,$one_mysql_log);} + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $wait_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set wait_sec='$wait_sec',talk_epoch='$StarTtime',lead_id='$lead_id' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00124',$user,$server_ip,$session_name,$one_mysql_log);} + + ### If SAMTALBK, change vicidial_callback record to INACTIVE + if (eregi("CALLBK|CBHOLD", $dispo)) + { + $stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='$lead_id' and status NOT IN('INACTIVE','DEAD','ARCHIVE');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00125',$user,$server_ip,$session_name,$one_mysql_log);} + } + + ##### check if system is set to generate logfile for transfers + $stmt="SELECT enable_agc_xfer_log FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00126',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $enable_agc_xfer_log_ct = mysql_num_rows($rslt); + if ($enable_agc_xfer_log_ct > 0) + { + $row=mysql_fetch_row($rslt); + $enable_agc_xfer_log =$row[0]; + } + + if ( ($WeBRooTWritablE > 0) and ($enable_agc_xfer_log > 0) ) + { + # DATETIME|campaign|lead_id|phone_number|user|type + # 2007-08-22 11:11:11|TESTCAMP|65432|3125551212|1234|A + $fp = fopen ("./xfer_log.txt", "a"); + fwrite ($fp, "$NOW_TIME|$campaign|$lead_id|$phone_number|$user|$Ctype|$callerid|$uniqueid|$province\n"); + fclose($fp); + } + + ### Issue Start Call URL if defined + if (strlen($VDCL_start_call_url) > 7) + { + if (eregi('--A--user_custom_',$VDCL_start_call_url)) + { + $stmt = "select custom_one,custom_two,custom_three,custom_four,custom_five from vicidial_users where user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00283',$user,$server_ip,$session_name,$one_mysql_log);} + $VUC_ct = mysql_num_rows($rslt); + if ($VUC_ct > 0) + { + $row=mysql_fetch_row($rslt); + $user_custom_one = urlencode(trim($row[0])); + $user_custom_two = urlencode(trim($row[1])); + $user_custom_three = urlencode(trim($row[2])); + $user_custom_four = urlencode(trim($row[3])); + $user_custom_five = urlencode(trim($row[4])); + } + } + $VDCL_start_call_url = preg_replace('/^VAR/','',$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--lead_id--B--',urlencode(trim($lead_id)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--vendor_id--B--',urlencode(trim($vendor_id)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--vendor_lead_code--B--',urlencode(trim($vendor_id)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--list_id--B--',urlencode(trim($list_id)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--gmt_offset_now--B--',urlencode(trim($gmt_offset_now)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--phone_code--B--',urlencode(trim($phone_code)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--phone_number--B--',urlencode(trim($phone_number)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--title--B--',urlencode(trim($title)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--first_name--B--',urlencode(trim($first_name)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--middle_initial--B--',urlencode(trim($middle_initial)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--last_name--B--',urlencode(trim($last_name)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--address1--B--',urlencode(trim($address1)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--address2--B--',urlencode(trim($address2)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--address3--B--',urlencode(trim($address3)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--city--B--',urlencode(trim($city)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--state--B--',urlencode(trim($state)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--province--B--',urlencode(trim($province)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--postal_code--B--',urlencode(trim($postal_code)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--country_code--B--',urlencode(trim($country_code)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--gender--B--',urlencode(trim($gender)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--date_of_birth--B--',urlencode(trim($date_of_birth)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--alt_phone--B--',urlencode(trim($alt_phone)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--email--B--',urlencode(trim($email)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--security_phrase--B--',urlencode(trim($security_phrase)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--comments--B--',urlencode(trim($comments)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--user--B--',urlencode(trim($user)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--pass--B--',urlencode(trim($pass)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--campaign--B--',urlencode(trim($campaign)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--phone_login--B--',urlencode(trim($phone_login)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--original_phone_login--B--',urlencode(trim($original_phone_login)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--phone_pass--B--',urlencode(trim($phone_pass)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--fronter--B--',urlencode(trim($fronter)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--closer--B--',urlencode(trim($closer)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--group--B--',urlencode(trim($group)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--channel_group--B--',urlencode(trim($channel_group)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--SQLdate--B--',urlencode(trim($SQLdate)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--epoch--B--',urlencode(trim($epoch)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--uniqueid--B--',urlencode(trim($uniqueid)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--customer_zap_channel--B--',urlencode(trim($customer_zap_channel)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--customer_server_ip--B--',urlencode(trim($customer_server_ip)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--server_ip--B--',urlencode(trim($server_ip)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--SIPexten--B--',urlencode(trim($SIPexten)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--session_id--B--',urlencode(trim($session_id)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--phone--B--',urlencode(trim($phone)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--parked_by--B--',urlencode(trim($parked_by)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--dispo--B--',urlencode(trim($dispo)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--dialed_number--B--',urlencode(trim($dialed_number)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--dialed_label--B--',urlencode(trim($dialed_label)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--source_id--B--',urlencode(trim($source_id)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--rank--B--',urlencode(trim($rank)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--owner--B--',urlencode(trim($owner)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--camp_script--B--',urlencode(trim($camp_script)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--in_script--B--',urlencode(trim($in_script)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--fullname--B--',urlencode(trim($fullname)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--user_custom_one--B--',urlencode(trim($user_custom_one)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--user_custom_two--B--',urlencode(trim($user_custom_two)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--user_custom_three--B--',urlencode(trim($user_custom_three)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--user_custom_four--B--',urlencode(trim($user_custom_four)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--user_custom_five--B--',urlencode(trim($user_custom_five)),$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--talk_time--B--',"0",$VDCL_start_call_url); + $VDCL_start_call_url = eregi_replace('--A--talk_time_min--B--',"0",$VDCL_start_call_url); + if ($DB > 0) {echo "$VDCL_start_call_url
\n";} + $SCUfile = file("$VDCL_start_call_url"); + if ($DB > 0) {echo "$SCUfile[0]
\n";} + + ##### BEGIN special filtering and response for Vtiger account balance function ##### + $stmt = "SELECT enable_vtiger_integration FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00294',$user,$server_ip,$session_name,$one_mysql_log);} + $ss_conf_ct = mysql_num_rows($rslt); + if ($ss_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $enable_vtiger_integration = $row[0]; + } + if ( ($enable_vtiger_integration > 0) and (ereg('callxfer',$VDCL_start_call_url)) and (ereg('contactwsid',$VDCL_start_call_url)) ) + { + $SCUoutput=''; + foreach ($SCUfile as $SCUline) + {$SCUoutput .= "$SCUline";} + # {"result":true,"durationLimit":3071} + if (strlen($SCUoutput) > 4) + { + $SCUresponse = explode('durationLimit',$SCUoutput); + $durationLimit = preg_replace('/\D/','',$SCUresponse[1]); + $durationLimitSEC = ( ( ($durationLimit + 0) - 3) * 60); # minutes - 3 for 3-minute-warning + if ($durationLimitSEC < 5) {$durationLimitSEC = 5;} + + $stmt="UPDATE vicidial_live_agents set external_timer_action='D1_DIAL',external_timer_action_message='3 minute warning for customer',external_timer_action_seconds='$durationLimitSEC' where user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00295',$user,$server_ip,$session_name,$one_mysql_log);} + $vla_update_timer = mysql_affected_rows($link); + + $fp = fopen ("./call_url_log.txt", "a"); + fwrite ($fp, "$VDCL_start_call_url\n$SCUoutput\n$durationLimit|$durationLimitSEC|$vla_update_timer\n"); + fclose($fp); + } + } + ##### END special filtering and response for Vtiger account balance function ##### + } + } + else + { + echo "0\n"; + # echo "No calls in QUEUE for $user på $server_ip\n"; + exit; + } + } + } + + +################################################################################ +### userLOGout - Logs the user out of VICIDiaL client, deleting db records and +### inserting into vicidial_user_log +################################################################################ +if ($ACTION == 'userLOGout') + { + $MT[0]=''; + $row=''; $rowx=''; + if ( (strlen($campaign)<1) || (strlen($conf_exten)<1) ) + { + echo "NO\n"; + echo "campaign $campaign or conf_exten $conf_exten är ej giltig\n"; + exit; + } + else + { + $user_group=''; + $stmt="SELECT user_group FROM vicidial_users where user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00127',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $ug_record_ct = mysql_num_rows($rslt); + if ($ug_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $user_group = trim("$row[0]"); + } + ##### Insert a LOGOUT record into the user log + $stmt="INSERT INTO vicidial_user_log (user,event,campaign_id,event_date,event_epoch,user_group) values('$user','LOGOUT','$campaign','$NOW_TIME','$StarTtime','$user_group');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00128',$user,$server_ip,$session_name,$one_mysql_log);} + $vul_insert = mysql_affected_rows($link); + + if ($no_delete_sessions < 1) + { + ##### Remove the reservation på the vicidial_conferences meetme room + $stmt="UPDATE vicidial_conferences set extension='' where server_ip='$server_ip' and conf_exten='$conf_exten';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00129',$user,$server_ip,$session_name,$one_mysql_log);} + $vc_remove = mysql_affected_rows($link); + } + + ##### Delete the web_client_sessions + $stmt="DELETE from web_client_sessions where server_ip='$server_ip' and session_name ='$session_name';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00132',$user,$server_ip,$session_name,$one_mysql_log);} + $wcs_delete = mysql_affected_rows($link); + + ##### Hangup the client phone + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$protocol/$extension%\" order by channel desc;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00133',$user,$server_ip,$session_name,$one_mysql_log);} + if ($rslt) + { + $row=mysql_fetch_row($rslt); + $agent_channel = "$row[0]"; + if ($format=='debug') {echo "\n";} + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','ULGH3459$StarTtime','Channel: $agent_channel','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00134',$user,$server_ip,$session_name,$one_mysql_log);} + } + + if ($LogouTKicKAlL > 0) + { + $local_DEF = 'Local/5555'; + $local_AMP = '@'; + $kick_local_channel = "$local_DEF$conf_exten$local_AMP$ext_context"; + $queryCID = "ULGH3458$StarTtime"; + + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$queryCID','Channel: $kick_local_channel','Context: $ext_context','Exten: 8300','Priority: 1','Callerid: $queryCID','','','','$channel','$exten');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00135',$user,$server_ip,$session_name,$one_mysql_log);} + } + + sleep(1); + + ##### Delete the vicidial_live_agents record for this session + $stmt="DELETE from vicidial_live_agents where server_ip='$server_ip' and user ='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00130',$user,$server_ip,$session_name,$one_mysql_log);} + $retry_count=0; + while ( ($errno > 0) and ($retry_count < 9) ) + { + $rslt=mysql_query($stmt, $link); + $one_mysql_log=1; + $errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9130$retry_count",$user,$server_ip,$session_name,$one_mysql_log); + $one_mysql_log=0; + $retry_count++; + } + $vla_delete = mysql_affected_rows($link); + + ##### Delete the vicidial_live_inbound_agents records for this session + $stmt="DELETE from vicidial_live_inbound_agents where user ='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00131',$user,$server_ip,$session_name,$one_mysql_log);} + $vlia_delete = mysql_affected_rows($link); + + $pause_sec=0; + $stmt = "select pause_epoch,pause_sec,wait_epoch,talk_epoch,dispo_epoch,agent_log_id from vicidial_agent_log where agent_log_id >= '$agent_log_id' and user='$user' order by agent_log_id desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00136',$user,$server_ip,$session_name,$one_mysql_log);} + $VDpr_ct = mysql_num_rows($rslt); + if ( ($VDpr_ct > 0) and (strlen($row[3]<5)) and (strlen($row[4]<5)) ) + { + $row=mysql_fetch_row($rslt); + $agent_log_id = $row[5]; + $pause_sec = (($StarTtime - $row[0]) + $row[1]); + + $stmt="UPDATE vicidial_agent_log set pause_sec='$pause_sec',wait_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00137',$user,$server_ip,$session_name,$one_mysql_log);} + } + + if ($vla_delete > 0) + { + ############################################# + ##### START QUEUEMETRICS LOGGING LOOKUP ##### + $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id,allow_sipsak_messages FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00138',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $qm_conf_ct = mysql_num_rows($rslt); + if ($qm_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $enable_queuemetrics_logging = $row[0]; + $queuemetrics_server_ip = $row[1]; + $queuemetrics_dbname = $row[2]; + $queuemetrics_login = $row[3]; + $queuemetrics_pass = $row[4]; + $queuemetrics_log_id = $row[5]; + $allow_sipsak_messages = $row[6]; + } + ##### END QUEUEMETRICS LOGGING LOOKUP ##### + ########################################### + if ( ($enable_sipsak_messages > 0) and ($allow_sipsak_messages > 0) and (eregi("SIP",$protocol)) ) + { + $SIPSAK_message = 'LOGGED OUT'; + passthru("/usr/local/bin/sipsak -M -O desktop -B \"$SIPSAK_message\" -r 5060 -s sip:$extension@$phone_ip > /dev/null"); + } + + if ($enable_queuemetrics_logging > 0) + { + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); + mysql_select_db("$queuemetrics_dbname", $linkB); + + # $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='$campaign',agent='Agent/$user',verb='PAUSE',serverid='1';"; + # if ($DB) {echo "$stmt\n";} + # + # $rslt=mysql_query($stmt, $linkB); + # $affected_rows = mysql_affected_rows($linkB); + + $stmt = "SELECT time_id FROM queue_log where agent='Agent/$user' and verb='AGENTLOGIN' order by time_id desc limit 1;"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00139',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + echo "$stmt\n"; + $li_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $li_conf_ct) + { + $row=mysql_fetch_row($rslt); + $logintime = $row[0]; + $i++; + } + + $time_logged_in = ($StarTtime - $logintime); + if ($time_logged_in > 1000000) {$time_logged_in=1;} + + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='AGENTLOGOFF',data1='$user$agents',data2='$time_logged_in',serverid='$queuemetrics_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00140',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + + mysql_close($linkB); + } + } + + echo "$vul_insert|$vc_remove|$vla_delete|$wcs_delete|$agent_channel|$vlia_delete\n"; + } + } + + +################################################################################ +### updateDISPO - update the vicidial_list table to reflect the agent choice of +### call disposition for that lead +################################################################################ +if ($ACTION == 'updateDISPO') + { + $MT[0]=''; + $row=''; $rowx=''; + $MAN_vl_insert=0; + if ( (strlen($dispo_choice)<1) || (strlen($lead_id)<1) ) + { + echo "Dispo Choice $dispo or lead_id $lead_id är ej giltig\n"; + exit; + } + else + { + $stmt = "SELECT dispo_call_url from vicidial_campaigns where campaign_id='$campaign';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00284',$user,$server_ip,$session_name,$one_mysql_log);} + $VC_dcu_ct = mysql_num_rows($rslt); + if ($VC_dcu_ct > 0) + { + $row=mysql_fetch_row($rslt); + $dispo_call_url =$row[0]; + } + + ### reset the API fields in vicidial_live_agents record + $stmt = "UPDATE vicidial_live_agents set lead_id=0,external_hangup=0,external_status='',external_update_fields='0',external_update_fields_data='',external_timer_action_seconds='-1',last_state_change='$NOW_TIME' where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00141',$user,$server_ip,$session_name,$one_mysql_log);} + $retry_count=0; + while ( ($errno > 0) and ($retry_count < 9) ) + { + $rslt=mysql_query($stmt, $link); + $one_mysql_log=1; + $errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9141$retry_count",$user,$server_ip,$session_name,$one_mysql_log); + $one_mysql_log=0; + $retry_count++; + } + + if ($auto_dial_level < 1) + { + $stmt = "UPDATE vicidial_live_agents set status='PAUSED',callerid='' where user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00285',$user,$server_ip,$session_name,$one_mysql_log);} + } + + $stmt="UPDATE vicidial_list set status='$dispo_choice', user='$user' where lead_id='$lead_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt = "SELECT count(*) from vicidial_inbound_groups where group_id='$stage';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00143',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + { + $stmt = "UPDATE vicidial_closer_log set status='$dispo_choice' where lead_id='$lead_id' and user='$user' order by closecallid desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00144',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt = "UPDATE vicidial_live_inbound_agents set last_call_finish=NOW() where group_id='$stage' and user='$user' limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00310',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt = "SELECT dispo_call_url from vicidial_inbound_groups where group_id='$stage';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00286',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $dispo_call_url = $row[0]; + } + else + { + $four_hours_ago = date("Y-m-d H:i:s", mktime(date("H")-4,date("i"),date("s"),date("m"),date("d"),date("Y"))); + + if ( ($auto_dial_level < 1) or (preg_match('/^M/',$MDnextCID)) ) + { + $stmt = "SELECT count(*) from vicidial_log where lead_id='$lead_id' and user='$user' and call_date > \"$four_hours_ago\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00213',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + { + $stmt="UPDATE vicidial_log set status='$dispo_choice' where lead_id='$lead_id' and user='$user' and call_date > \"$four_hours_ago\" order by uniqueid desc limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00145',$user,$server_ip,$session_name,$one_mysql_log);} + } + else + { + $VLlist_id = ''; $VLphone_number = ''; $VLphone_code = ''; $user_group=''; + $stmt = "SELECT user_group FROM vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00217',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VUinfo_ct = mysql_num_rows($rslt); + if ($VUinfo_ct > 0) + { + $row=mysql_fetch_row($rslt); + $user_group = "$row[0]"; + } + + $stmt = "SELECT list_id,phone_number,phone_code,alt_phone,address3 FROM vicidial_list where lead_id='$lead_id';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00216',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VLinfo_ct = mysql_num_rows($rslt); + if ($VLinfo_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VLlist_id = "$row[0]"; + if (strlen($phone_number)<6) + { + $VLphone_number = "$row[1]"; + $VLalt = 'MAIN'; + $VLalt_phone = "$row[3]"; + $VLaddress3 = "$row[4]"; + } + else + { + $VLphone_number = "$phone_number"; + if ($phone_number == "$row[1]") + {$VLalt = 'MAIN';} + else + { + if ($phone_number != $VLalt_phone) + { + if ($phone_number != $VLaddress3) + { + $VLalt = 'X1'; + $stmt = "SELECT alt_phone_count from vicidial_list_alt_phones where lead_id='$lead_id' and phone_number = '$dialed_number' order by alt_phone_count limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00250',$user,$server_ip,$session_name,$one_mysql_log);} + $VDAP_cid_ct = mysql_num_rows($rslt); + if ($VDAP_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $Xalt_phone_count =$row[0]; + + $stmt = "SELECT count(*) from vicidial_list_alt_phones where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00251',$user,$server_ip,$session_name,$one_mysql_log);} + $VDAPct_cid_ct = mysql_num_rows($rslt); + if ($VDAPct_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $COUNTalt_phone_count =$row[0]; + + if ($COUNTalt_phone_count <= $Xalt_phone_count) + {$VLalt = 'XLAST';} + else + {$VLalt = "X$Xalt_phone_count";} + } + + } + } + else + {$VLalt = 'ADDR3';} + } + else + {$VLalt = 'ALT';} + } + } + if (strlen($phone_code)<1) + {$VLphone_code = "$row[2]";} + else + {$VLphone_code = "$phone_code";} + } + + $PADlead_id = sprintf("%09s", $lead_id); + while (strlen($PADlead_id) > 9) {$PADlead_id = substr("$PADlead_id", 0, -1);} + $FAKEcall_id = "$StarTtime.$PADlead_id"; + $stmt = "INSERT INTO vicidial_log set uniqueid='$FAKEcall_id',lead_id='$lead_id',list_id='$VLlist_id',campaign_id='$campaign',call_date='$NOW_TIME',start_epoch='$StarTtime',end_epoch='$StarTtime',length_in_sec='0',status='$dispo_choice',phone_code='$VLphone_code',phone_number='$VLphone_number',user='$user',comments='MANUAL',processed='N',user_group='$user_group',term_reason='AGENT',alt_dial='$VLalt';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00215',$user,$server_ip,$session_name,$one_mysql_log);} + + $MAN_vl_insert++; + } + + $stmt="DELETE FROM vicidial_auto_calls where callerid='$MDnextCID';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00219',$user,$server_ip,$session_name,$one_mysql_log);} + } + else + { + $stmt="UPDATE vicidial_log set status='$dispo_choice' where lead_id='$lead_id' and user='$user' and call_date > \"$four_hours_ago\" order by uniqueid desc limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00145',$user,$server_ip,$session_name,$one_mysql_log);} + } + } + + ### find all DNC-type statuses in the system + if ( ($use_internal_dnc=='Y') or ($use_campaign_dnc=='Y') ) + { + $DNC_string_check = '|'; + $stmt = "SELECT status FROM vicidial_statuses where dnc='Y';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00195',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $dncvs_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $dncvs_ct) + { + $row=mysql_fetch_row($rslt); + $DNC_string_check .= "$row[0]|"; + $i++; + } + + $stmt = "SELECT status FROM vicidial_campaign_statuses where dnc='Y';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00196',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $dncvcs_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $dncvcs_ct) + { + $row=mysql_fetch_row($rslt); + $DNC_string_check .= "$row[0]|"; + $i++; + } + + # echo "$DNC_string_check"; + } + + $insert_into_dnc=0; + if ( ($use_internal_dnc=='Y') and (eregi("\|$dispo_choice\|", $DNC_string_check) ) ) + { + $stmt = "select phone_number from vicidial_list where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00146',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $stmt="INSERT INTO vicidial_dnc (phone_number) values('$row[0]');"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00147',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $insert_into_dnc++; + } + if ( ($use_campaign_dnc=='Y') and (eregi("\|$dispo_choice\|", $DNC_string_check) ) ) + { + $stmt = "select phone_number from vicidial_list where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00148',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $stmt="INSERT INTO vicidial_campaign_dnc (phone_number,campaign_id) values('$row[0]','$campaign');"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00149',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $insert_into_dnc++; + } + } + + $dispo_sec=0; + $dispo_epochSQL=''; + $lead_id_commentsSQL=''; + $StarTtime = date("U"); + $stmt = "select dispo_epoch,dispo_sec,talk_epoch,wait_epoch,lead_id,comments,agent_log_id from vicidial_agent_log where agent_log_id <='$agent_log_id' and lead_id='$lead_id' order by agent_log_id desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00150',$user,$server_ip,$session_name,$one_mysql_log);} + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $agent_log_id = $row[6]; + if ( (eregi("NULL",$row[2])) or ($row[2] < 1000) ) + { + $row[2]=$StarTtime; + $wait_sec=($row[2] - $row[3]); + $dispo_epochSQL = ",talk_epoch='$row[2]',wait_sec='$wait_sec'"; + } + if ( (eregi("NULL",$row[0])) or ($row[0] < 1000) ) + { + $dispo_epochSQL .= ",dispo_epoch='$StarTtime'"; + $row[0]=$row[2]; + } + $dispo_sec = (($StarTtime - $row[0]) + $row[1]); + if ( (preg_match('/^M/',$MDnextCID)) and (preg_match('/INBOUND_MAN/',$dial_method)) ) + { + if ( (eregi("NULL",$row[5])) or (strlen($row[5]) < 1) ) + { + $lead_id_commentsSQL .= ",comments='MANUAL'"; + } + if ( (eregi("NULL",$row[4])) or ($row[4] < 1) or (strlen($row[4]) < 1) ) + { + $lead_id_commentsSQL .= ",lead_id='$lead_id'"; + } + } + } + $stmt="UPDATE vicidial_agent_log set dispo_sec='$dispo_sec',status='$dispo_choice' $dispo_epochSQL $lead_id_commentsSQL where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00151',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt="UPDATE vicidial_campaigns set campaign_calldate='$NOW_TIME' where campaign_id='$campaign';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00272',$user,$server_ip,$session_name,$one_mysql_log);} + + $user_group=''; + $stmt="SELECT user_group FROM vicidial_users where user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00152',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $ug_record_ct = mysql_num_rows($rslt); + if ($ug_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $user_group = trim("$row[0]"); + } + $CALL_agent_log_id = $agent_log_id; + + if ($auto_dial_level < 1) + { + $MAN_insert_leadIDsql=''; + if ($MAN_vl_insert > 0) + {$MAN_insert_leadIDsql = ",lead_id='$lead_id'";} + $stmt="INSERT INTO vicidial_agent_log SET user='$user',server_ip='$server_ip',event_time='$NOW_TIME',campaign_id='$campaign',pause_epoch='$StarTtime',pause_sec='0',wait_epoch='$StarTtime',user_group='$user_group'$MAN_insert_leadIDsql;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00153',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + $agent_log_id = mysql_insert_id($link); + + $stmt="UPDATE vicidial_live_agents SET agent_log_id='$agent_log_id' where user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00220',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $VLAaffected_rows_update = mysql_affected_rows($link); + } + + ### SAMTALBACK ENTRY + if ( ($dispo_choice == 'CBHOLD') and (strlen($CallBackDatETimE)>10) ) + { + $comments = eregi_replace('"','',$comments); + $comments = eregi_replace("'",'',$comments); + $comments = eregi_replace(';','',$comments); + $comments = eregi_replace("\\\\",' ',$comments); + $stmt="INSERT INTO vicidial_callbacks (lead_id,list_id,campaign_id,status,entry_time,callback_time,user,recipient,comments,user_group) values('$lead_id','$list_id','$campaign','ACTIVE','$NOW_TIME','$CallBackDatETimE','$user','$recipient','$comments','$user_group');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00154',$user,$server_ip,$session_name,$one_mysql_log);} + } + + $stmt="SELECT auto_alt_dial_statuses,use_internal_dnc,use_campaign_dnc from vicidial_campaigns where campaign_id='$campaign';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00155',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $VC_auto_alt_dial_statuses = $row[0]; + $use_internal_dnc = $row[1]; + $use_campaign_dnc = $row[2]; + + if ( ($auto_dial_level > 0) and (ereg(" $dispo_choice ",$VC_auto_alt_dial_statuses)) ) + { + $stmt = "select count(*) from vicidial_hopper where lead_id='$lead_id' and status='HOLD';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00156',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + + if ($row[0] > 0) + { + ##### Check for alt phone number in DNC list if applicable + $UD_DNC_campaign=0; + $UD_DNC_internal=0; + $vh_phone=''; + $stmt="SELECT phone_number FROM vicidial_list where lead_id='$lead_id';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00267',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $ud_record_ct = mysql_num_rows($rslt); + if ($ud_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $vh_phone = $row[0]; + } + + if ( (ereg("Y",$use_internal_dnc)) or (ereg("AREACODE",$use_internal_dnc)) ) + { + if (ereg("AREACODE",$use_internal_dnc)) + { + $vhp_phone_areacode = substr($vh_phone, 0, 3); + $vhp_phone_areacode .= "XXXXXXX"; + $stmtA="SELECT count(*) from vicidial_dnc where phone_number IN('$vh_phone','$vhp_phone_areacode');"; + } + else + {$stmtA="SELECT count(*) FROM vicidial_dnc where phone_number='$vh_phone';";} + $rslt=mysql_query($stmtA, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtA,'00268',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $ud_record_ct = mysql_num_rows($rslt); + if ($ud_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $UD_DNC_internal = $row[0]; + } + } + + if ( (ereg("Y",$use_campaign_dnc)) or (ereg("AREACODE",$use_campaign_dnc)) ) + { + if (ereg("AREACODE",$use_campaign_dnc)) + { + $vhp_phone_areacode = substr($vh_phone, 0, 3); + $vhp_phone_areacode .= "XXXXXXX"; + $stmtA="SELECT count(*) from vicidial_campaign_dnc where phone_number IN('$vh_phone','$vhp_phone_areacode') and campaign_id='$campaign';"; + } + else + {$stmtA="SELECT count(*) FROM vicidial_campaign_dnc where phone_number='$vh_phone' and campaign_id='$campaign';";} + $rslt=mysql_query($stmtA, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtA,'00269',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $ud_record_ct = mysql_num_rows($rslt); + if ($ud_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $UD_DNC_campaign = $row[0]; + } + } + + if ( ($UD_DNC_campaign > 0) or ($UD_DNC_internal > 0) ) + { + if ( ( (ereg(" DNCC ",$VC_auto_alt_dial_statuses)) and ($UD_DNC_campaign > 0) ) or ( (ereg(" DNCL ",$VC_auto_alt_dial_statuses)) and ($UD_DNC_internal > 0) ) ) + { + $stmt="UPDATE vicidial_hopper set status='DNC' where lead_id='$lead_id' and status='HOLD' limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00157',$user,$server_ip,$session_name,$one_mysql_log);} + } + } + else + { + $stmt="UPDATE vicidial_hopper set status='READY' where lead_id='$lead_id' and status='HOLD' limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00157',$user,$server_ip,$session_name,$one_mysql_log);} + } + } + } + else + { + $stmt="DELETE from vicidial_hopper where lead_id='$lead_id' and status='HOLD';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00158',$user,$server_ip,$session_name,$one_mysql_log);} + } + + ####### START Vtiger Call Logging ####### + $stmt = "SELECT enable_vtiger_integration,vtiger_server_ip,vtiger_dbname,vtiger_login,vtiger_pass,vtiger_url FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00197',$user,$server_ip,$session_name,$one_mysql_log);} + $ss_conf_ct = mysql_num_rows($rslt); + if ($ss_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $enable_vtiger_integration = $row[0]; + $vtiger_server_ip = $row[1]; + $vtiger_dbname = $row[2]; + $vtiger_login = $row[3]; + $vtiger_pass = $row[4]; + $vtiger_url = $row[5]; + } + + if ($enable_vtiger_integration > 0) + { + $stmt = "SELECT vtiger_search_category,vtiger_create_call_record,vtiger_create_lead_record,vtiger_search_dead,vtiger_status_call FROM vicidial_campaigns where campaign_id='$campaign';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00198',$user,$server_ip,$session_name,$one_mysql_log);} + $vtc_conf_ct = mysql_num_rows($rslt); + if ($vtc_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $vtiger_search_category = $row[0]; + $vtiger_create_call_record = $row[1]; + $vtiger_create_lead_record = $row[2]; + $vtiger_search_dead = $row[3]; + $vtiger_status_call = $row[4]; + } + if ( (ereg('ACCTID',$vtiger_search_category)) or (ereg('ACCOUNT',$vtiger_search_category)) ) + { + ### find the full status name for this status + $stmt = "select status_name from vicidial_statuses where status='$dispo_choice';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00211',$user,$server_ip,$session_name,$one_mysql_log);} + $vs_ct = mysql_num_rows($rslt); + if ($vs_ct > 0) + { + $row=mysql_fetch_row($rslt); + $status_name = $row[0]; + } + else + { + $stmt = "select status_name from vicidial_campaign_statuses where status='$dispo_choice' and campaign_id='$campaign';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00212',$user,$server_ip,$session_name,$one_mysql_log);} + $vs_ct = mysql_num_rows($rslt); + if ($vs_ct > 0) + { + $row=mysql_fetch_row($rslt); + $status_name = $row[0]; + } + } + if (strlen($status_name) < 1) {$status_name = $dispo_choice;} + + ### connect to your vtiger database + $linkV=mysql_connect("$vtiger_server_ip", "$vtiger_login","$vtiger_pass"); + if (!$linkV) {die("Could not connect: $vtiger_server_ip|$vtiger_dbname|$vtiger_login|$vtiger_pass" . mysql_error());} + mysql_select_db("$vtiger_dbname", $linkV); + + $stmt = "SELECT vendor_lead_code FROM vicidial_list where lead_id='$lead_id';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00210',$user,$server_ip,$session_name,$one_mysql_log);} + $vlc_ct = mysql_num_rows($rslt); + if ($vlc_ct > 0) + { + $row=mysql_fetch_row($rslt); + $vendor_id = $row[0]; + } + + # make sure the ID is present in Vtiger database as an account + $stmt="SELECT count(*) from vtiger_account where accountid='$vendor_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00199',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $VIDcount = $row[0]; + if ($VIDcount > 0) + { + ### create a call record in vtiger linked to the account + if (ereg('DISPO',$vtiger_create_call_record)) + { + $TODAY = date("Y-m-d"); + $HHMMnow = date("H:i"); + $minute_old = mktime(date("H"), date("i")+5, date("s"), date("m"), date("d"), date("Y")); + $HHMMend = date("H:i",$minute_old); + + #Get logged in user ID + $stmt="SELECT id from vtiger_users where user_name='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00200',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $user_id = $row[0]; + + ## if numbered callback activity record, alter existing record + $vtiger_callback_modified=0; + if ($vtiger_callback_id > 0) + { + # make sure the ID is present in Vtiger database as an account + $stmt="SELECT count(*) from vtiger_seactivityrel where activityid='$vtiger_callback_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00213',$user,$server_ip,$session_name,$one_mysql_log);} + $vt_act_ct = mysql_num_rows($rslt); + if ($vt_act_ct > 0) + { + $row=mysql_fetch_row($rslt); + $activity_check = $row[0]; + } + if ($activity_check > 0) + { + $act_description=''; + $stmt="SELECT description from vtiger_crmentity where crmid='$vtiger_callback_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00214',$user,$server_ip,$session_name,$one_mysql_log);} + $vt_actd_ct = mysql_num_rows($rslt); + if ($vt_actd_ct > 0) + { + $row=mysql_fetch_row($rslt); + $act_description = $row[0]; + } + $act_subject=''; + $stmt="SELECT subject from vtiger_activity where activityid='$vtiger_callback_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00215',$user,$server_ip,$session_name,$one_mysql_log);} + $vt_actd_ct = mysql_num_rows($rslt); + if ($vt_actd_ct > 0) + { + $row=mysql_fetch_row($rslt); + $act_subject = $row[0]; + } + + $stmt = "UPDATE vtiger_crmentity SET modifiedby='$user_id', description='$act_description - VICIDIAL Call user $user',modifiedtime='$NOW_TIME',viewedtime='$NOW_TIME' where crmid='$vtiger_callback_id';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00216',$user,$server_ip,$session_name,$one_mysql_log);} + $stmt = "UPDATE vtiger_activity SET subject='VC Call: $status_name - $act_subject',date_start='$TODAY',time_start='$HHMMnow',time_end='$HHMMend',eventstatus='Held' where activityid='$vtiger_callback_id';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00217',$user,$server_ip,$session_name,$one_mysql_log);} + $vtiger_callback_modified=1; + } + } + + ## create new activity record + if ($vtiger_callback_modified < 1) + { + # Get next aviable id from vtiger_crmentity_seq to use as activityid in vtiger_crmentity + $stmt="SELECT id from vtiger_crmentity_seq ;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00201',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $activityid = ($row[0] + 1); + + # Increase next aviable crmid with 1 so next record gets proper id + $stmt="UPDATE vtiger_crmentity_seq SET id = '$activityid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00202',$user,$server_ip,$session_name,$one_mysql_log);} + + #Insert values into vtiger_salesmanactivityrel + $stmt = "INSERT INTO vtiger_salesmanactivityrel SET smid='$user_id',activityid='$activityid';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00203',$user,$server_ip,$session_name,$one_mysql_log);} + + #Insert values into vtiger_seactivityrel + $stmt = "INSERT INTO vtiger_seactivityrel SET crmid='$vendor_id',activityid='$activityid';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00204',$user,$server_ip,$session_name,$one_mysql_log);} + + #Insert values into vtiger_crmentity + $stmt = "INSERT INTO vtiger_crmentity (crmid, smcreatorid, smownerid, modifiedby, setype, description, createdtime, modifiedtime, viewedtime, status, version, presence, deleted) VALUES ('$activityid', '$user_id', '$user_id','$user_id', 'Calendar', 'VICIDIAL Call user $user', '$NOW_TIME', '$NOW_TIME', '$NOW_TIME', NULL, '0', '1', '0');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00205',$user,$server_ip,$session_name,$one_mysql_log);} + + #Insert values into vtiger_activity + $stmt = "INSERT INTO vtiger_activity SET activityid='$activityid',subject='VC Call: $status_name',activitytype='Call',date_start='$TODAY',due_date='$TODAY',time_start='$HHMMnow',time_end='$HHMMend',sendnotification='0',duration_hours='0',duration_minutes='1',status='',eventstatus='Held',priority='Medium',location='VICIDIAL Användare $user',notime='0',visibility='Public',recurringtype='--None--';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00206',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "|$leadid|\n";} + } + } + ### update the status of the record in vtiger + if (ereg('Y',$vtiger_status_call)) + { + #Get logged in user ID + $stmt="SELECT id from vtiger_users where user_name='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00207',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $user_id = $row[0]; + + #Update vtiger_crmentity + $stmt = "UPDATE vtiger_crmentity SET modifiedby='$user_id', modifiedtime='$NOW_TIME' where crmid='$vendor_id';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00208',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "|$leadid|\n";} + + if ($insert_into_dnc > 0) {$emailoptoutSQL = ", emailoptout='1'";} + #Update vtiger_account dnc=emailoptout + $stmt = "UPDATE vtiger_account SET siccode='$status_name' $emailoptoutSQL where accountid='$vendor_id';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00209',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "|$leadid|\n";} + + + ### check and see if the custom date fields exist, if they do then update them if necessary + # Date of Efternamn Attempt, Date of Efternamn Non-Contact, Date of Efternamn Contact, Date of Efternamn Sale + + # first find the sale statuses that are in the system + $SALE_string_check = '|'; + $stmt = "SELECT status FROM vicidial_statuses where sale='Y';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00211',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $salevs_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $salevs_ct) + { + $row=mysql_fetch_row($rslt); + $SALE_string_check .= "$row[0]|"; + $i++; + } + $stmt = "SELECT status FROM vicidial_campaign_statuses where sale='Y';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00212',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $salevcs_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $salevcs_ct) + { + $row=mysql_fetch_row($rslt); + $SALE_string_check .= "$row[0]|"; + $i++; + } + + # second find the customer contact statuses that are in the system + $CC_string_check = '|'; + $stmt = "SELECT status FROM vicidial_statuses where customer_contact='Y';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00213',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cc_vs_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $cc_vs_ct) + { + $row=mysql_fetch_row($rslt); + $CC_string_check .= "$row[0]|"; + $i++; + } + $stmt = "SELECT status FROM vicidial_campaign_statuses where customer_contact='Y';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00287',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cc_vcs_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $cc_vcs_ct) + { + $row=mysql_fetch_row($rslt); + $CC_string_check .= "$row[0]|"; + $i++; + } + + # third calculate what custom date fields need their date updated + $VT_last_noncontact_update=0; $VT_last_noncontact_ct=0; + $VT_last_contact_update=0; $VT_last_contact_ct=0; + $VT_last_sale_update=0; $VT_last_sale_ct=0; + if (eregi("\|$dispo_choice\|", $SALE_string_check) ) + {$VT_last_sale_update++;} + if (eregi("\|$dispo_choice\|", $CC_string_check) ) + {$VT_last_contact_update++;} + else + {$VT_last_noncontact_update++;} + + # fourth see if the vtiger database has the custom date fields in it + $stmt="SELECT count(*) from vtiger_field where fieldlabel='Date of Last Attempt';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00215',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $VT_last_attempt_ct = $row[0]; + + if ($VT_last_noncontact_update > 0) + { + $stmt="SELECT count(*) from vtiger_field where fieldlabel='Date of Last Non-Contact';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00216',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $VT_last_noncontact_ct = $row[0]; + } + if ($VT_last_contact_update > 0) + { + $stmt="SELECT count(*) from vtiger_field where fieldlabel='Date of Last Contact';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00217',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $VT_last_contact_ct = $row[0]; + } + if ($VT_last_sale_update > 0) + { + $stmt="SELECT count(*) from vtiger_field where fieldlabel='Date of Last Sale';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00218',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $VT_last_sale_ct = $row[0]; + } + + # fifth find the fieldnames if they exist and update the dates + if ($VT_last_attempt_ct > 0) + { + $stmt="SELECT fieldname from vtiger_field where fieldlabel='Date of Last Attempt';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00219',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $VT_last_attempt_field = $row[0]; + + $stmt = "UPDATE vtiger_accountscf SET $VT_last_attempt_field='$TODAY' where accountid='$vendor_id';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00223',$user,$server_ip,$session_name,$one_mysql_log);} + } + if ($VT_last_noncontact_ct > 0) + { + $stmt="SELECT fieldname from vtiger_field where fieldlabel='Date of Last Non-Contact';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00220',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $VT_last_noncontact_field = $row[0]; + + $stmt = "UPDATE vtiger_accountscf SET $VT_last_noncontact_field='$TODAY' where accountid='$vendor_id';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00224',$user,$server_ip,$session_name,$one_mysql_log);} + } + if ($VT_last_contact_ct > 0) + { + $stmt="SELECT fieldname from vtiger_field where fieldlabel='Date of Last Contact';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00221',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $VT_last_contact_field = $row[0]; + + $stmt = "UPDATE vtiger_accountscf SET $VT_last_contact_field='$TODAY' where accountid='$vendor_id';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00225',$user,$server_ip,$session_name,$one_mysql_log);} + } + if ($VT_last_sale_ct > 0) + { + $stmt="SELECT fieldname from vtiger_field where fieldlabel='Date of Last Sale';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00222',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $VT_last_sale_field = $row[0]; + + $stmt = "UPDATE vtiger_accountscf SET $VT_last_sale_field='$TODAY' where accountid='$vendor_id';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkV,$mel,$stmt,'00226',$user,$server_ip,$session_name,$one_mysql_log);} + } + } + } + } + } + ####### END Vtiger Call Logging ####### + + ############################################# + ##### START QUEUEMETRICS LOGGING LOOKUP ##### + $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00159',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $qm_conf_ct = mysql_num_rows($rslt); + if ($qm_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $enable_queuemetrics_logging = $row[0]; + $queuemetrics_server_ip = $row[1]; + $queuemetrics_dbname = $row[2]; + $queuemetrics_login = $row[3]; + $queuemetrics_pass = $row[4]; + $queuemetrics_log_id = $row[5]; + } + ##### END QUEUEMETRICS LOGGING LOOKUP ##### + ########################################### + if ($enable_queuemetrics_logging > 0) + { + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); + mysql_select_db("$queuemetrics_dbname", $linkB); + + if (strlen($stage) < 2) + {$stage = $campaign;} + + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MDnextCID',queue='$stage',agent='Agent/$user',verb='CALLSTATUS',data1='$dispo_choice',serverid='$queuemetrics_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00160',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + + mysql_close($linkB); + } + + ### Issue Dispo Call URL if defined + if (strlen($dispo_call_url) > 7) + { + $talk_time=0; + $talk_time_ms=0; + $talk_time_min=0; + if (eregi('--A--user_custom_',$dispo_call_url)) + { + $stmt = "select custom_one,custom_two,custom_three,custom_four,custom_five from vicidial_users where user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00288',$user,$server_ip,$session_name,$one_mysql_log);} + $VUC_ct = mysql_num_rows($rslt); + if ($VUC_ct > 0) + { + $row=mysql_fetch_row($rslt); + $user_custom_one = urlencode(trim($row[0])); + $user_custom_two = urlencode(trim($row[1])); + $user_custom_three = urlencode(trim($row[2])); + $user_custom_four = urlencode(trim($row[3])); + $user_custom_five = urlencode(trim($row[4])); + } + } + + if (eregi('--A--talk_time',$dispo_call_url)) + { + $stmt = "select talk_sec,dead_sec from vicidial_agent_log where lead_id='$lead_id' and agent_log_id='$CALL_agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00289',$user,$server_ip,$session_name,$one_mysql_log);} + $VAL_talk_ct = mysql_num_rows($rslt); + if ($VAL_talk_ct > 0) + { + $row=mysql_fetch_row($rslt); + $talk_sec = $row[0]; + $dead_sec = $row[1]; + $talk_time = ($talk_sec - $dead_sec); + if ($talk_time < 1) + { + $talk_time = 0; + $talk_time_ms = 0; + } + else + { + $talk_time_ms = ($talk_time * 1000); + $talk_time_min = ceil($talk_time / 60); + } + } + } + + if (eregi('--A--dispo_name--B--',$dispo_call_url)) + { + ### find the full status name for this status + $stmt = "select status_name from vicidial_statuses where status='$dispo_choice';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00297',$user,$server_ip,$session_name,$one_mysql_log);} + $vs_name_ct = mysql_num_rows($rslt); + if ($vs_name_ct > 0) + { + $row=mysql_fetch_row($rslt); + $status_name = $row[0]; + } + else + { + $stmt = "select status_name from vicidial_campaign_statuses where status='$dispo_choice' and campaign_id='$campaign';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00298',$user,$server_ip,$session_name,$one_mysql_log);} + $vcs_name_ct = mysql_num_rows($rslt); + if ($vcs_name_ct > 0) + { + $row=mysql_fetch_row($rslt); + $status_name = $row[0]; + } + } + if (strlen($status_name) < 1) {$status_name = $dispo_choice;} + } + $dispo_name = urlencode(trim($status_name)); + + + + ##### grab the data from vicidial_list for the lead_id + $stmt="SELECT lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner FROM vicidial_list where lead_id='$lead_id' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00290',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $list_lead_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + $dispo = urlencode(trim($row[3])); + $tsr = urlencode(trim($row[4])); + $vendor_id = urlencode(trim($row[5])); + $vendor_lead_code = urlencode(trim($row[5])); + $source_id = urlencode(trim($row[6])); + $list_id = urlencode(trim($row[7])); + $gmt_offset_now = urlencode(trim($row[8])); + $phone_code = urlencode(trim($row[10])); + $phone_number = urlencode(trim($row[11])); + $title = urlencode(trim($row[12])); + $first_name = urlencode(trim($row[13])); + $middle_initial = urlencode(trim($row[14])); + $last_name = urlencode(trim($row[15])); + $address1 = urlencode(trim($row[16])); + $address2 = urlencode(trim($row[17])); + $address3 = urlencode(trim($row[18])); + $city = urlencode(trim($row[19])); + $state = urlencode(trim($row[20])); + $province = urlencode(trim($row[21])); + $postal_code = urlencode(trim($row[22])); + $country_code = urlencode(trim($row[23])); + $gender = urlencode(trim($row[24])); + $date_of_birth = urlencode(trim($row[25])); + $alt_phone = urlencode(trim($row[26])); + $email = urlencode(trim($row[27])); + $security = urlencode(trim($row[28])); + $comments = urlencode(trim($row[29])); + $called_count = urlencode(trim($row[30])); + $rank = urlencode(trim($row[32])); + $owner = urlencode(trim($row[33])); + } + + $dispo_call_url = preg_replace('/^VAR/','',$dispo_call_url); + $dispo_call_url = eregi_replace('--A--lead_id--B--',"$lead_id",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--vendor_id--B--',"$vendor_id",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--vendor_lead_code--B--',"$vendor_lead_code",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--list_id--B--',"$list_id",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--gmt_offset_now--B--',"$gmt_offset_now",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--phone_code--B--',"$phone_code",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--phone_number--B--',"$phone_number",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--title--B--',"$title",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--first_name--B--',"$first_name",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--middle_initial--B--',"$middle_initial",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--last_name--B--',"$last_name",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--address1--B--',"$address1",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--address2--B--',"$address2",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--address3--B--',"$address3",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--city--B--',"$city",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--state--B--',"$state",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--province--B--',"$province",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--postal_code--B--',"$postal_code",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--country_code--B--',"$country_code",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--gender--B--',"$gender",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--date_of_birth--B--',"$date_of_birth",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--alt_phone--B--',"$alt_phone",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--email--B--',"$email",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--security_phrase--B--',"$security_phrase",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--comments--B--',"$comments",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--user--B--',"$user",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--pass--B--',"$pass",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--campaign--B--',"$campaign",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--phone_login--B--',"$phone_login",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--original_phone_login--B--',"$original_phone_login",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--phone_pass--B--',"$phone_pass",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--fronter--B--',"$fronter",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--closer--B--',"$closer",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--group--B--',"$group",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--channel_group--B--',"$channel_group",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--SQLdate--B--',"$SQLdate",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--epoch--B--',"$epoch",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--uniqueid--B--',"$uniqueid",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--customer_zap_channel--B--',"$customer_zap_channel",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--customer_server_ip--B--',"$customer_server_ip",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--server_ip--B--',"$server_ip",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--SIPexten--B--',"$SIPexten",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--session_id--B--',"$session_id",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--phone--B--',"$phone",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--parked_by--B--',"$parked_by",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--dispo--B--',"$dispo",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--dispo_name--B--',"$dispo_name",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--dialed_number--B--',"$dialed_number",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--dialed_label--B--',"$dialed_label",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--source_id--B--',"$source_id",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--rank--B--',"$rank",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--owner--B--',"$owner",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--camp_script--B--',"$camp_script",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--in_script--B--',"$in_script",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--fullname--B--',"$fullname",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--user_custom_one--B--',"$user_custom_one",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--user_custom_two--B--',"$user_custom_two",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--user_custom_three--B--',"$user_custom_three",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--user_custom_four--B--',"$user_custom_four",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--user_custom_five--B--',"$user_custom_five",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--talk_time--B--',"$talk_time",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--talk_time_ms--B--',"$talk_time_ms",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--talk_time_min--B--',"$talk_time_min",$dispo_call_url); + $dispo_call_url = eregi_replace('--A--agent_log_id--B--',"$CALL_agent_log_id",$dispo_call_url); + if ($DB > 0) {echo "$dispo_call_url
\n";} + $SCUfile = file("$dispo_call_url"); + if ($DB > 0) {echo "$SCUfile[0]
\n";} + + $stmt = "SELECT enable_vtiger_integration FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00296',$user,$server_ip,$session_name,$one_mysql_log);} + $ss_conf_ct = mysql_num_rows($rslt); + if ($ss_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $enable_vtiger_integration = $row[0]; + } + if ( ($enable_vtiger_integration > 0) and (ereg('mode=callend',$dispo_call_url)) and (ereg('contactwsid',$dispo_call_url)) ) + { + $SCUoutput=''; + foreach ($SCUfile as $SCUline) + {$SCUoutput .= "$SCUline";} + $fp = fopen ("./call_url_log.txt", "a"); + fwrite ($fp, "$dispo_call_url\n$SCUoutput\n"); + fclose($fp); + } + } + echo 'Lead ' . $lead_id . ' har blivit ändrad till ' . $dispo_choice . " Status\nNext agent_log_id:\n" . $agent_log_id . "\n"; + } + +################################################################################ +### updateLEAD - update the vicidial_list table to reflect the values that are +### in the agents screen at time of call hangup +################################################################################ +if ($ACTION == 'updateLEAD') + { + $MT[0]=''; + $row=''; $rowx=''; + $DO_NOT_UPDATE=0; + $DO_NOT_UPDATE_text=''; + if ( (strlen($phone_number)<1) || (strlen($lead_id)<1) ) + { + echo "phone_number $phone_number or lead_id $lead_id är ej giltig\n"; + exit; + } + else + { + $stmt = "SELECT disable_alter_custdata,disable_alter_custphone FROM vicidial_campaigns where campaign_id='$campaign'"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00161',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $dac_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $dac_conf_ct) + { + $row=mysql_fetch_row($rslt); + $disable_alter_custdata = $row[0]; + $disable_alter_custphone = $row[1]; + $i++; + } + if ( (ereg('Y',$disable_alter_custdata)) or (ereg('Y',$disable_alter_custphone)) ) + { + if (ereg('Y',$disable_alter_custdata)) + { + $DO_NOT_UPDATE=1; + $DO_NOT_UPDATE_text=' NOT'; + } + if (ereg('Y',$disable_alter_custphone)) + { + $DO_NOT_UPDATEphone=1; + } + $stmt = "SELECT alter_custdata_override,alter_custphone_override FROM vicidial_users where user='$user'"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00162',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $aco_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $aco_conf_ct) + { + $row=mysql_fetch_row($rslt); + $alter_custdata_override = $row[0]; + $alter_custphone_override = $row[1]; + $i++; + } + if (ereg('ALLOW_ALTER',$alter_custdata_override)) + { + $DO_NOT_UPDATE=0; + $DO_NOT_UPDATE_text=''; + } + if (ereg('ALLOW_ALTER',$alter_custphone_override)) + { + $DO_NOT_UPDATEphone=0; + } + } + + if ($DO_NOT_UPDATE < 1) + { + $comments = eregi_replace("\r",'',$comments); + $comments = eregi_replace("\n",'!N',$comments); + $comments = eregi_replace("--AMP--",'&',$comments); + $comments = eregi_replace("--QUES--",'?',$comments); + $comments = eregi_replace("--POUND--",'#',$comments); + + $phoneSQL=''; + if ($DO_NOT_UPDATEphone < 1) + {$phoneSQL = ",phone_number='$phone_number'";} + + $stmt="UPDATE vicidial_list set vendor_lead_code='" . mysql_real_escape_string($vendor_lead_code) . "', title='" . mysql_real_escape_string($title) . "', first_name='" . mysql_real_escape_string($first_name) . "', middle_initial='" . mysql_real_escape_string($middle_initial) . "', last_name='" . mysql_real_escape_string($last_name) . "', address1='" . mysql_real_escape_string($address1) . "', address2='" . mysql_real_escape_string($address2) . "', address3='" . mysql_real_escape_string($address3) . "', city='" . mysql_real_escape_string($city) . "', state='" . mysql_real_escape_string($state) . "', province='" . mysql_real_escape_string($province) . "', postal_code='" . mysql_real_escape_string($postal_code) . "', country_code='" . mysql_real_escape_string($country_code) . "', gender='" . mysql_real_escape_string($gender) . "', date_of_birth='" . mysql_real_escape_string($date_of_birth) . "', alt_phone='" . mysql_real_escape_string($alt_phone) . "', email='" . mysql_real_escape_string($email) . "', security_phrase='" . mysql_real_escape_string($security_phrase) . "', comments='" . mysql_real_escape_string($comments) . "' $phoneSQL where lead_id='$lead_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00163',$user,$server_ip,$session_name,$one_mysql_log);} + } + + $random = (rand(1000000, 9999999) + 10000000); + $stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00164',$user,$server_ip,$session_name,$one_mysql_log);} + $retry_count=0; + while ( ($errno > 0) and ($retry_count < 9) ) + { + $rslt=mysql_query($stmt, $link); + $one_mysql_log=1; + $errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9164$retry_count",$user,$server_ip,$session_name,$one_mysql_log); + $one_mysql_log=0; + $retry_count++; + } + + } + echo "Lead $lead_id information has$DO_NOT_UPDATE_text been updated\n"; + } + + +################################################################################ +### VDADpause - update the vicidial_live_agents table to show that the agent is +### or ready now active and ready to take calls +################################################################################ +if ( ($ACTION == 'VDADpause') || ($ACTION == 'VDADready') ) + { + $MT[0]=''; + $row=''; $rowx=''; + if ( (strlen($stage)<2) || (strlen($server_ip)<1) ) + { + echo "stage $stage är ej giltig\n"; + exit; + } + else + { + $vla_autodialSQL=''; + if (preg_match('/INBOUND_MAN/',$dial_method)) + {$vla_autodialSQL = ",outbound_autodial='N'";} + $random = (rand(1000000, 9999999) + 10000000); + $stmt="UPDATE vicidial_live_agents set uniqueid=0,callerid='',channel='', random_id='$random',comments='',last_state_change='$NOW_TIME' $vla_autodialSQL where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00165',$user,$server_ip,$session_name,$one_mysql_log);} + $retry_count=0; + while ( ($errno > 0) and ($retry_count < 9) ) + { + $rslt=mysql_query($stmt, $link); + $one_mysql_log=1; + $errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9165$retry_count",$user,$server_ip,$session_name,$one_mysql_log); + $one_mysql_log=0; + $retry_count++; + } + + if ($comments != 'NO_STATUS_CHANGE') + { + $stmt="UPDATE vicidial_live_agents set status='$stage' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00166',$user,$server_ip,$session_name,$one_mysql_log);} + $retry_count=0; + while ( ($errno > 0) and ($retry_count < 9) ) + { + $rslt=mysql_query($stmt, $link); + $one_mysql_log=1; + $errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9166$retry_count",$user,$server_ip,$session_name,$one_mysql_log); + $one_mysql_log=0; + $retry_count++; + } + $affected_rows = mysql_affected_rows($link); + } + if ( ($affected_rows > 0) or ($comments == 'NO_STATUS_CHANGE') ) + { + ############################################# + ##### START QUEUEMETRICS LOGGING LOOKUP ##### + $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00167',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $qm_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $qm_conf_ct) + { + $row=mysql_fetch_row($rslt); + $enable_queuemetrics_logging = $row[0]; + $queuemetrics_server_ip = $row[1]; + $queuemetrics_dbname = $row[2]; + $queuemetrics_login = $row[3]; + $queuemetrics_pass = $row[4]; + $queuemetrics_log_id = $row[5]; + $i++; + } + ##### END QUEUEMETRICS LOGGING LOOKUP ##### + ########################################### + if ($enable_queuemetrics_logging > 0) + { + if ( (ereg('READY',$stage)) or (ereg('CLOSER',$stage)) ) {$QMstatus='UNPAUSEALL';} + if (ereg('PAUSE',$stage)) {$QMstatus='PAUSEALL';} + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); + mysql_select_db("$queuemetrics_dbname", $linkB); + + $user_group=''; + $stmt="SELECT user_group FROM vicidial_users where user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00182',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $ug_record_ct = mysql_num_rows($rslt); + if ($ug_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $user_group = trim("$row[0]"); + } + + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='$QMstatus',serverid='$queuemetrics_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00168',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + + mysql_close($linkB); + } + } + + $pause_sec=0; + $stmt = "select pause_epoch,pause_sec,wait_epoch,wait_sec,dispo_epoch from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00169',$user,$server_ip,$session_name,$one_mysql_log);} + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $dispo_epoch = $row[4]; + $wait_sec=0; + if ($row[2] > 0) + { + $wait_sec = (($StarTtime - $row[2]) + $row[3]); + } + if ( (eregi("NULL",$row[4])) or ($row[4] < 1000) ) + {$pause_sec = (($StarTtime - $row[0]) + $row[1]);} + else + {$pause_sec = (($row[4] - $row[0]) + $row[1]);} + + } + if ($ACTION == 'VDADready') + { + if ( (eregi("NULL",$dispo_epoch)) or ($dispo_epoch < 1000) ) + { + $stmt="UPDATE vicidial_agent_log set pause_sec='$pause_sec',wait_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00170',$user,$server_ip,$session_name,$one_mysql_log);} + } + } + if ($ACTION == 'VDADpause') + { + if ( (eregi("NULL",$dispo_epoch)) or ($dispo_epoch < 1000) ) + { + $stmt="UPDATE vicidial_agent_log set wait_sec='$wait_sec' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00171',$user,$server_ip,$session_name,$one_mysql_log);} + } + + $agent_log = 'NEW_ID'; + } + + if ($wrapup == 'WRAPUP') + { + if ( (eregi("NULL",$dispo_epoch)) or ($dispo_epoch < 1000) ) + { + $stmt="UPDATE vicidial_agent_log set dispo_epoch='$StarTtime', dispo_sec='0' where agent_log_id='$agent_log_id';"; + } + else + { + $dispo_sec = ($StarTtime - $dispo_epoch); + $stmt="UPDATE vicidial_agent_log set dispo_sec='$dispo_sec' where agent_log_id='$agent_log_id';"; + } + + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00194',$user,$server_ip,$session_name,$one_mysql_log);} + } + + if ($agent_log == 'NEW_ID') + { + $user_group=''; + $stmt="SELECT user_group FROM vicidial_users where user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00182',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $ug_record_ct = mysql_num_rows($rslt); + if ($ug_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $user_group = trim("$row[0]"); + } + + $stmt="INSERT INTO vicidial_agent_log (user,server_ip,event_time,campaign_id,pause_epoch,pause_sec,wait_epoch,user_group) values('$user','$server_ip','$NOW_TIME','$campaign','$StarTtime','0','$StarTtime','$user_group');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00153',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + $agent_log_id = mysql_insert_id($link); + + $stmt="UPDATE vicidial_live_agents SET agent_log_id='$agent_log_id' where user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00221',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $VLAaffected_rows_update = mysql_affected_rows($link); + } + } + echo 'Agent ' . $user . ' har nu status ' . $stage . "\nNext agent_log_id:\n$agent_log_id\n"; + } + + +################################################################################ +### UpdatEFavoritEs - update the astguiclient favorites list for this extension +################################################################################ +if ($ACTION == 'UpdatEFavoritEs') + { + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($favorites_list)<1) || (strlen($user)<1) || (strlen($exten)<1) ) + { + echo "favorites list $favorites_list är ej giltig\n"; + exit; + } + else + { + $stmt = "select count(*) from phone_favorites where extension='$exten' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00172',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + + if ($row[0] > 0) + { + $stmt="UPDATE phone_favorites set extensions_list=\"$favorites_list\" where extension='$exten' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00173',$user,$server_ip,$session_name,$one_mysql_log);} + } + else + { + $stmt="INSERT INTO phone_favorites values('$exten','$server_ip',\"$favorites_list\");"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00174',$user,$server_ip,$session_name,$one_mysql_log);} + } + } + echo "Favorites list has been updated to $favorites_list for $exten\n"; + } + + +################################################################################ +### PauseCodeSubmit - Update vicidial_agent_log with pause code +################################################################################ +if ($ACTION == 'PauseCodeSubmit') + { + $row=''; $rowx=''; + if ( (strlen($status)<1) || (strlen($agent_log_id)<1) ) + { + echo "agent_log_id $agent_log_id or pause_code $status är ej giltig\n"; + exit; + } + else + { + ### if this is the first pause code entry in a pause session, simply update and log to queue_log + if ($stage < 1) + { + $stmt="UPDATE vicidial_agent_log set sub_status=\"$status\" where agent_log_id >= '$agent_log_id' and user='$user' and ( (sub_status is NULL) or (sub_status='') )order by agent_log_id limit 2;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00175',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + } + ### this is not the first pause code entry, insert new vicidial_agent_log entry + else + { + $pause_sec=0; + $stmt = "select pause_epoch from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00305',$user,$server_ip,$session_name,$one_mysql_log);} + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $pause_sec = ($StarTtime - $row[0]); + } + $stmt="UPDATE vicidial_agent_log set pause_sec='$pause_sec' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00306',$user,$server_ip,$session_name,$one_mysql_log);} + + $user_group=''; + $stmt="SELECT user_group FROM vicidial_users where user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00309',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $ug_record_ct = mysql_num_rows($rslt); + if ($ug_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $user_group = trim("$row[0]"); + } + + $stmt="INSERT INTO vicidial_agent_log (user,server_ip,event_time,campaign_id,pause_epoch,pause_sec,wait_epoch,user_group,sub_status) values('$user','$server_ip','$NOW_TIME','$campaign','$StarTtime','0','$StarTtime','$user_group','$status');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00307',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + $agent_log_id = mysql_insert_id($link); + + $stmt="UPDATE vicidial_live_agents SET agent_log_id='$agent_log_id',last_state_change='$NOW_TIME' where user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00308',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $VLAaffected_rows_update = mysql_affected_rows($link); + } + + ### if entry accepted, add a queue_log entry if QM integration is enabled + if ($affected_rows > 0) + { + ############################################# + ##### START QUEUEMETRICS LOGGING LOOKUP ##### + $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id,allow_sipsak_messages FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00176',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $qm_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $qm_conf_ct) + { + $row=mysql_fetch_row($rslt); + $enable_queuemetrics_logging = $row[0]; + $queuemetrics_server_ip = $row[1]; + $queuemetrics_dbname = $row[2]; + $queuemetrics_login = $row[3]; + $queuemetrics_pass = $row[4]; + $queuemetrics_log_id = $row[5]; + $allow_sipsak_messages = $row[6]; + $i++; + } + ##### END QUEUEMETRICS LOGGING LOOKUP ##### + ########################################### + if ( ($enable_sipsak_messages > 0) and ($allow_sipsak_messages > 0) and (eregi("SIP",$protocol)) ) + { + $SIPSAK_prefix = 'BK-'; + passthru("/usr/local/bin/sipsak -M -O desktop -B \"$SIPSAK_prefix$status\" -r 5060 -s sip:$extension@$phone_ip > /dev/null"); + } + if ($enable_queuemetrics_logging > 0) + { + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); + mysql_select_db("$queuemetrics_dbname", $linkB); + + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='PAUSEREASON',serverid='$queuemetrics_log_id',data1='$status';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00177',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + + mysql_close($linkB); + } + } + } + echo ' Paus Code ' . $status . " has been recorded\nNext agent_log_id:\n" . $agent_log_id . "\n"; + } + + +################################################################################ +### AGENTSview - List statuses of other agents in sidebar or xfer frame +################################################################################ +if ($ACTION == 'AGENTSview') + { + $stmt="SELECT user_group from vicidial_users where user='$user' and pass='$pass'"; + if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00225',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $VU_user_group = $row[0]; + + $agent_status_viewable_groupsSQL=''; + ### Gather timeclock and shift enforcement restriction settings + $stmt="SELECT agent_status_viewable_groups,agent_status_view_time from vicidial_user_groups where user_group='$VU_user_group';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00226',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $agent_status_viewable_groups = $row[0]; + $agent_status_viewable_groupsSQL = eregi_replace(' ','',$agent_status_viewable_groups); + $agent_status_viewable_groupsSQL = eregi_replace(' ',"','",$agent_status_viewable_groupsSQL); + $agent_status_viewable_groupsSQL = "user_group IN('$agent_status_viewable_groupsSQL')"; + $agent_status_view = 0; + if (strlen($agent_status_viewable_groups) > 2) + {$agent_status_view = 1;} + $agent_status_view_time=0; + if ($row[1] == 'Y') + {$agent_status_view_time=1;} + $andSQL=''; + if (ereg("ALL-GROUPS",$agent_status_viewable_groups)) + {$AGENTviewSQL = "";} + else + { + $AGENTviewSQL = "($agent_status_viewable_groupsSQL)"; + + if (ereg("CAMPAIGN-AGENTS",$agent_status_viewable_groups)) + {$AGENTviewSQL = "($AGENTviewSQL or (campaign_id='$campaign'))";} + $AGENTviewSQL = "and $AGENTviewSQL"; + } + if ($comments=='AgentXferViewSelect') + {$AGENTviewSQL .= " and (vla.closer_campaigns LIKE \"%AGENTDIRECT%\")";} + + + echo ""; + ### Gather agents data and statuses + $stmt="SELECT vla.user,vla.status,vu.full_name,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish) from vicidial_live_agents vla,vicidial_users vu where vla.user=vu.user $AGENTviewSQL order by vu.full_name;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00227',$VD_login,$server_ip,$session_name,$one_mysql_log);} + if ($rslt) {$agents_count = mysql_num_rows($rslt);} + $loop_count=0; + while ($agents_count > $loop_count) + { + $row=mysql_fetch_row($rslt); + $user = $row[0]; + $status = $row[1]; + $full_name = $row[2]; + $call_start = $row[3]; + $call_finish = $row[4]; + + if ( ($status=='READY') or ($status=='CLOSER') ) + { + $statuscolor='#ADD8E6'; + $call_time = ($StarTtime - $call_finish); + } + if ( ($status=='QUEUE') or ($status=='INCALL') ) + { + $statuscolor='#D8BFD8'; + $call_time = ($StarTtime - $call_start); + } + if ($status=='PAUSED') + { + $statuscolor='#F0E68C'; + $call_time = ($StarTtime - $call_finish); + } + + if ($call_time < 1) + { + $call_time = "0:00"; + } + else + { + $Fminutes_M = ($call_time / 60); + $Fminutes_M_int = floor($Fminutes_M); + $Fminutes_M_int = intval("$Fminutes_M_int"); + $Fminutes_S = ($Fminutes_M - $Fminutes_M_int); + $Fminutes_S = ($Fminutes_S * 60); + $Fminutes_S = round($Fminutes_S, 0); + if ($Fminutes_S < 10) {$Fminutes_S = "0$Fminutes_S";} + $call_time = "$Fminutes_M_int:$Fminutes_S"; + } + + if ($comments=='AgentXferViewSelect') + { + echo ""; + if ($agent_status_view_time > 0) + {echo "";} + echo ""; + } + else + { + echo ""; + if ($agent_status_view_time > 0) + {echo "";} + echo ""; + } + $loop_count++; + } + echo "
  $row[0] - $row[2]   $call_time  
  "; + echo "$row[0] - $row[2]"; + echo "   $call_time  

\n"; + echo "    -READY      -INCALL      -PAUSED  \n"; + + echo "\n"; + } + + +################################################################################ +### CALLSINQUEUEview - List calls in queue for the bottombar 228 +################################################################################ +if ($ACTION == 'CALLSINQUEUEview') + { + $stmt="SELECT view_calls_in_queue,grab_calls_in_queue from vicidial_campaigns where campaign_id='$campaign'"; + if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00228',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $view_calls_in_queue = $row[0]; + $grab_calls_in_queue = $row[1]; + + if (eregi('NONE',$view_calls_in_queue)) + { + echo "Samtalskö är frånkopplad för denna kampanj\n"; + exit; + } + else + { + $view_calls_in_queue = ereg_replace('ALL','99', $view_calls_in_queue); + + ### grab the status and campaign/in-group information for this agent to display + $ADsql=''; + $stmt="SELECT status,campaign_id,closer_campaigns from vicidial_live_agents where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00229',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $Alogin=$row[0]; + $Acampaign=$row[1]; + $AccampSQL=$row[2]; + $AccampSQL = ereg_replace(' -','', $AccampSQL); + $AccampSQL = ereg_replace(' ',"','", $AccampSQL); + if (eregi('AGENTDIRECT', $AccampSQL)) + { + $AccampSQL = ereg_replace('AGENTDIRECT','', $AccampSQL); + $ADsql = "or ( (campaign_id LIKE \"%AGENTDIRECT%\") and (agent_only='$user') )"; + } + + ### grab the basic data på calls in the queue for this agent + $stmt="SELECT lead_id,campaign_id,phone_number,uniqueid,UNIX_TIMESTAMP(call_time),call_type,auto_call_id from vicidial_auto_calls where status IN('LIVE') and ( (campaign_id='$Acampaign') or (campaign_id IN('$AccampSQL')) $ADsql) order by queue_priority,call_time;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00230',$user,$server_ip,$session_name,$one_mysql_log);} + if ($rslt) {$calls_count = mysql_num_rows($rslt);} + $loop_count=0; + while ($calls_count > $loop_count) + { + $row=mysql_fetch_row($rslt); + $CQlead_id[$loop_count] = $row[0]; + $CQcampaign_id[$loop_count] = $row[1]; + $CQphone_number[$loop_count] = $row[2]; + $CQuniqueid[$loop_count] = $row[3]; + $CQcall_time[$loop_count] = $row[4]; + $CQcall_type[$loop_count] = $row[5]; + $CQauto_call_id[$loop_count] = $row[6]; + $loop_count++; + } + + ### re-order the calls to always make sure the AGENTDIRECT calls are first + $loop_count=0; + $o=0; + while ($calls_count > $loop_count) + { + if (eregi('AGENTDIRECT', $CQcampaign_id[$loop_count])) + { + $OQlead_id[$o] = $CQlead_id[$loop_count]; + $OQcampaign_id[$o] = $CQcampaign_id[$loop_count]; + $OQphone_number[$o] = $CQphone_number[$loop_count]; + $OQuniqueid[$o] = $CQuniqueid[$loop_count]; + $OQcall_time[$o] = $CQcall_time[$loop_count]; + $OQcall_type[$o] = $CQcall_type[$loop_count]; + $OQauto_call_id[$o] = $CQauto_call_id[$loop_count]; + $o++; + } + $loop_count++; + } + $loop_count=0; + while ($calls_count > $loop_count) + { + if (!eregi('AGENTDIRECT', $CQcampaign_id[$loop_count])) + { + $OQlead_id[$o] = $CQlead_id[$loop_count]; + $OQcampaign_id[$o] = $CQcampaign_id[$loop_count]; + $OQphone_number[$o] = $CQphone_number[$loop_count]; + $OQuniqueid[$o] = $CQuniqueid[$loop_count]; + $OQcall_time[$o] = $CQcall_time[$loop_count]; + $OQcall_type[$o] = $CQcall_type[$loop_count]; + $OQauto_call_id[$o] = $CQauto_call_id[$loop_count]; + $o++; + } + $loop_count++; + } + + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + ### Print call information and gather more info på the calls as they are printed + $loop_count=0; + while ( ($calls_count > $loop_count) and ($view_calls_in_queue > $loop_count) ) + { + $call_time = ($StarTtime - $OQcall_time[$loop_count]); + $Fminutes_M = ($call_time / 60); + $Fminutes_M_int = floor($Fminutes_M); + $Fminutes_M_int = intval("$Fminutes_M_int"); + $Fminutes_S = ($Fminutes_M - $Fminutes_M_int); + $Fminutes_S = ($Fminutes_S * 60); + $Fminutes_S = round($Fminutes_S, 0); + if ($Fminutes_S < 10) {$Fminutes_S = "0$Fminutes_S";} + $call_time = "$Fminutes_M_int:$Fminutes_S"; + $call_handle_method=''; + + if ($OQcall_type[$loop_count]=='IN') + { + $stmt="SELECT group_name,group_color from vicidial_inbound_groups where group_id='$OQcampaign_id[$loop_count]';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00231',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $group_name = $row[0]; + $group_color = $row[1]; + } + $stmt="SELECT comments,user,first_name,last_name from vicidial_list where lead_id='$OQlead_id[$loop_count]'"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00232',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $comments = $row[0]; + $agent = $row[1]; + $first_last_name = "$row[2] $row[3]"; + $caller_name = $first_last_name; + + $stmt="SELECT full_name from vicidial_users where user='$agent'"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00232',$user,$server_ip,$session_name,$one_mysql_log);} + if ($rslt) {$agent_name_count = mysql_num_rows($rslt);} + if ($agent_name_count > 0) + { + $row=mysql_fetch_row($rslt); + $agent_name = $row[0]; + } + else + {$agent_name='';} + + if (strlen($caller_name)<2) + {$caller_name = $comments;} + if (strlen($caller_name) > 30) {$caller_name = substr("$caller_name", 0, 30);} + + if (eregi("0$|2$|4$|6$|8$", $loop_count)) {$Qcolor='bgcolor="#FCFCFC"';} + else{$Qcolor='bgcolor="#ECECEC"';} + + if ( (eregi('Y',$grab_calls_in_queue)) and ($OQcall_type[$loop_count]=='IN') ) + { + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + else + { + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + $loop_count++; + } + echo "
    PHONE     NAME     WAIT     AGENT           SAMTAL GROUP     TYPE  
TAKE SAMTAL     $OQphone_number[$loop_count]     $caller_name     $call_time     $agent - $agent_name           $OQcampaign_id[$loop_count] - $group_name     $OQcall_type[$loop_count]  
    $OQphone_number[$loop_count]     $caller_name     $call_time     $agent - $agent_name           $OQcampaign_id[$loop_count] - $group_name     $OQcall_type[$loop_count]  

 \n"; + } + } + + +################################################################################ +### CALLSINQUEUEgrab - grab a call in queue and reserve it for that agent +################################################################################ +if ($ACTION == 'CALLSINQUEUEgrab') + { + $stmt="SELECT view_calls_in_queue,grab_calls_in_queue from vicidial_campaigns where campaign_id='$campaign'"; + if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00233',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $view_calls_in_queue = $row[0]; + $grab_calls_in_queue = $row[1]; + + if ( (eregi('NONE',$view_calls_in_queue)) or (eregi('N',$grab_calls_in_queue)) ) + { + echo "ERROR: Samtalskö är frånkopplad för denna kampanj\n"; + exit; + } + else + { + $stmt="UPDATE vicidial_auto_calls set agent_grab=\"$user\" where auto_call_id='$stage' and agent_grab='' and status='LIVE';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00234',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + if ($affected_rows > 0) + { + $stmt="SELECT call_time,campaign_id,uniqueid,phone_number,lead_id,queue_priority,call_type from vicidial_auto_calls where auto_call_id='$stage';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00270',$user,$server_ip,$session_name,$one_mysql_log);} + if ($rslt) {$vac_count = mysql_num_rows($rslt);} + if ($vac_count > 0) + { + $row=mysql_fetch_row($rslt); + $GCcall_time = $row[0]; + $GCcampaign_id = $row[1]; + $GCuniqueid = $row[2]; + $GCphone_number = $row[3]; + $GClead_id = $row[4]; + $GCqueue_priority = $row[5]; + $GCcall_type = $row[6]; + + $stmt="INSERT INTO vicidial_grab_call_log SET auto_call_id='$stage',user='$user',event_date='$NOW_TIME',call_time='$GCcall_time',campaign_id='$GCcampaign_id',uniqueid='$GCuniqueid',phone_number='$GCphone_number',lead_id='$GClead_id',queue_priority='$GCqueue_priority',call_type='$GCcall_type';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00271',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + } + + echo "SUCCESS: Call $stage grabbed for $user"; + exit; + } + else + { + echo "ERROR: Call $stage could not be grabbed for $user\n"; + exit; + } + } + } + + +################################################################################ +### CalLBacKLisT - List the USERONLY callbacks for an agent +################################################################################ +if ($ACTION == 'CalLBacKLisT') + { + if ($agentonly_callback_campaign_lock > 0) + {$campaignCBsql = "and campaign_id='$campaign'";} + else + {$campaignCBsql = '';} + $stmt = "select callback_id,lead_id,campaign_id,status,entry_time,callback_time,comments from vicidial_callbacks where recipient='USERONLY' and user='$user' $campaignCBsql and status NOT IN('INACTIVE','DEAD') order by callback_time;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00178',$user,$server_ip,$session_name,$one_mysql_log);} + if ($rslt) {$callbacks_count = mysql_num_rows($rslt);} + echo "$callbacks_count\n"; + $loop_count=0; + while ($callbacks_count>$loop_count) + { + $row=mysql_fetch_row($rslt); + $callback_id[$loop_count] = $row[0]; + $lead_id[$loop_count] = $row[1]; + $campaign_id[$loop_count] = $row[2]; + $status[$loop_count] = $row[3]; + $entry_time[$loop_count] = $row[4]; + $callback_time[$loop_count] = $row[5]; + $comments[$loop_count] = $row[6]; + $loop_count++; + } + $loop_count=0; + while ($callbacks_count>$loop_count) + { + $stmt = "select first_name,last_name,phone_number from vicidial_list where lead_id='$lead_id[$loop_count]';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00179',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + + echo "$row[0] ~$row[1] ~$row[2] ~$callback_id[$loop_count] ~$lead_id[$loop_count] ~$campaign_id[$loop_count] ~$status[$loop_count] ~$entry_time[$loop_count] ~$callback_time[$loop_count] ~$comments[$loop_count]\n"; + $loop_count++; + } + + } + + +################################################################################ +### CalLBacKCounT - send the count of the USERONLY callbacks for an agent +################################################################################ +if ($ACTION == 'CalLBacKCounT') + { + if ($agentonly_callback_campaign_lock > 0) + {$campaignCBsql = "and campaign_id='$campaign'";} + else + {$campaignCBsql = '';} + $stmt = "select count(*) from vicidial_callbacks where recipient='USERONLY' and user='$user' $campaignCBsql and status NOT IN('INACTIVE','DEAD');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00180',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $cbcount=$row[0]; + + echo "$cbcount"; + } + + + + +################################################################################ +### DiaLableLeaDsCounT - send the count of the dialable leads in this campaign +################################################################################ +if ($ACTION == 'DiaLableLeaDsCounT') + { + $stmt = "select dialable_leads from vicidial_campaign_stats where campaign_id='$campaign';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00252',$user,$server_ip,$session_name,$one_mysql_log);} + if ($rslt) {$dialable_count = mysql_num_rows($rslt);} + if ($dialable_count > 0) + { + $row=mysql_fetch_row($rslt); + $DLcount = $row[0]; + } + + echo "$DLcount"; + } + + + + +if ($format=='debug') +{ +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $StarTtime); +echo "\n"; +echo "\n\n\n"; +} + +exit; + + +##### Hangup Cause Description Map ##### +function hangup_cause_description($code) + { + global $hangup_cause_dictionary; + if ( array_key_exists($code,$hangup_cause_dictionary) ) { return $hangup_cause_dictionary[$code]; } + else { return "Unidentified Hangup Cause Code."; } + } + + +##### MySQL Error Logging ##### +function mysql_error_logging($NOW_TIME,$link,$mel,$stmt,$query_id,$user,$server_ip,$session_name,$one_mysql_log) +{ +$NOW_TIME = date("Y-m-d H:i:s"); +# mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00001',$user,$server_ip,$session_name,$one_mysql_log); +$errno=''; $error=''; +if ( ($mel > 0) or ($one_mysql_log > 0) ) + { + $errno = mysql_errno($link); + if ( ($errno > 0) or ($mel > 1) or ($one_mysql_log > 0) ) + { + $error = mysql_error($link); + $efp = fopen ("./vicidial_mysql_errors.txt", "a"); + fwrite ($efp, "$NOW_TIME|vdc_db_query|$query_id|$errno|$error|$stmt|$user|$server_ip|$session_name|\n"); + fclose($efp); + } + } +$one_mysql_log=0; +return $errno; +} + +?> diff --git a/LANG_www/agc_se/vdc_script_display.php b/LANG_www/agc_se/vdc_script_display.php new file mode 100644 index 00000000..8c9bb87d --- /dev/null +++ b/LANG_www/agc_se/vdc_script_display.php @@ -0,0 +1,435 @@ + LICENSE: AGPLv2 +# +# This script is designed display the contents of the SCRIPT tab in the agent interface +# +# CHANGELOG: +# 90824-1435 - First build of script +# 90827-1548 - Added list override script option +# 91204-1913 - Added recording_filename and recording_id variables +# 91211-1103 - Added user_custom_... variables +# 100116-0702 - Added preset variables +# + +$version = '2.2.0-5'; +$build = '100116-0702'; + +require("dbconnect.php"); + + +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} + elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} + $vendor_lead_code = $vendor_id; +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["gmt_offset_now"])) {$gmt_offset_now=$_GET["gmt_offset_now"];} + elseif (isset($_POST["gmt_offset_now"])) {$gmt_offset_now=$_POST["gmt_offset_now"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["title"])) {$title=$_GET["title"];} + elseif (isset($_POST["title"])) {$title=$_POST["title"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["middle_initial"])) {$middle_initial=$_GET["middle_initial"];} + elseif (isset($_POST["middle_initial"])) {$middle_initial=$_POST["middle_initial"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["gender"])) {$gender=$_GET["gender"];} + elseif (isset($_POST["gender"])) {$gender=$_POST["gender"];} +if (isset($_GET["date_of_birth"])) {$date_of_birth=$_GET["date_of_birth"];} + elseif (isset($_POST["date_of_birth"])) {$date_of_birth=$_POST["date_of_birth"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["security_phrase"])) {$security_phrase=$_GET["security_phrase"];} + elseif (isset($_POST["security_phrase"])) {$security_phrase=$_POST["security_phrase"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} +if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];} + elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];} +if (isset($_GET["original_phone_login"])) {$original_phone_login=$_GET["original_phone_login"];} + elseif (isset($_POST["original_phone_login"])) {$original_phone_login=$_POST["original_phone_login"];} +if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];} + elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];} +if (isset($_GET["fronter"])) {$fronter=$_GET["fronter"];} + elseif (isset($_POST["fronter"])) {$fronter=$_POST["fronter"];} +if (isset($_GET["closer"])) {$closer=$_GET["closer"];} + elseif (isset($_POST["closer"])) {$closer=$_POST["closer"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["channel_group"])) {$channel_group=$_GET["channel_group"];} + elseif (isset($_POST["channel_group"])) {$channel_group=$_POST["channel_group"];} +if (isset($_GET["SQLdate"])) {$SQLdate=$_GET["SQLdate"];} + elseif (isset($_POST["SQLdate"])) {$SQLdate=$_POST["SQLdate"];} +if (isset($_GET["epoch"])) {$epoch=$_GET["epoch"];} + elseif (isset($_POST["epoch"])) {$epoch=$_POST["epoch"];} +if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} + elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} +if (isset($_GET["customer_zap_channel"])) {$customer_zap_channel=$_GET["customer_zap_channel"];} + elseif (isset($_POST["customer_zap_channel"])) {$customer_zap_channel=$_POST["customer_zap_channel"];} +if (isset($_GET["customer_server_ip"])) {$customer_server_ip=$_GET["customer_server_ip"];} + elseif (isset($_POST["customer_server_ip"])) {$customer_server_ip=$_POST["customer_server_ip"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["SIPexten"])) {$SIPexten=$_GET["SIPexten"];} + elseif (isset($_POST["SIPexten"])) {$SIPexten=$_POST["SIPexten"];} +if (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];} + elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["parked_by"])) {$parked_by=$_GET["parked_by"];} + elseif (isset($_POST["parked_by"])) {$parked_by=$_POST["parked_by"];} +if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];} + elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];} +if (isset($_GET["dialed_number"])) {$dialed_number=$_GET["dialed_number"];} + elseif (isset($_POST["dialed_number"])) {$dialed_number=$_POST["dialed_number"];} +if (isset($_GET["dialed_label"])) {$dialed_label=$_GET["dialed_label"];} + elseif (isset($_POST["dialed_label"])) {$dialed_label=$_POST["dialed_label"];} +if (isset($_GET["source_id"])) {$source_id=$_GET["source_id"];} + elseif (isset($_POST["source_id"])) {$source_id=$_POST["source_id"];} +if (isset($_GET["rank"])) {$rank=$_GET["rank"];} + elseif (isset($_POST["rank"])) {$rank=$_POST["rank"];} +if (isset($_GET["owner"])) {$owner=$_GET["owner"];} + elseif (isset($_POST["owner"])) {$owner=$_POST["owner"];} +if (isset($_GET["camp_script"])) {$camp_script=$_GET["camp_script"];} + elseif (isset($_POST["camp_script"])) {$camp_script=$_POST["camp_script"];} +if (isset($_GET["in_script"])) {$in_script=$_GET["in_script"];} + elseif (isset($_POST["in_script"])) {$in_script=$_POST["in_script"];} +if (isset($_GET["script_width"])) {$script_width=$_GET["script_width"];} + elseif (isset($_POST["script_width"])) {$script_width=$_POST["script_width"];} +if (isset($_GET["script_height"])) {$script_height=$_GET["script_height"];} + elseif (isset($_POST["script_height"])) {$script_height=$_POST["script_height"];} +if (isset($_GET["fullname"])) {$fullname=$_GET["fullname"];} + elseif (isset($_POST["fullname"])) {$fullname=$_POST["fullname"];} +if (isset($_GET["recording_filename"])) {$recording_filename=$_GET["recording_filename"];} + elseif (isset($_POST["recording_filename"])) {$recording_filename=$_POST["recording_filename"];} +if (isset($_GET["recording_id"])) {$recording_id=$_GET["recording_id"];} + elseif (isset($_POST["recording_id"])) {$recording_id=$_POST["recording_id"];} +if (isset($_GET["user_custom_one"])) {$user_custom_one=$_GET["user_custom_one"];} + elseif (isset($_POST["user_custom_one"])) {$user_custom_one=$_POST["user_custom_one"];} +if (isset($_GET["user_custom_two"])) {$user_custom_two=$_GET["user_custom_two"];} + elseif (isset($_POST["user_custom_two"])) {$user_custom_two=$_POST["user_custom_two"];} +if (isset($_GET["user_custom_three"])) {$user_custom_three=$_GET["user_custom_three"];} + elseif (isset($_POST["user_custom_three"])) {$user_custom_three=$_POST["user_custom_three"];} +if (isset($_GET["user_custom_four"])) {$user_custom_four=$_GET["user_custom_four"];} + elseif (isset($_POST["user_custom_four"])) {$user_custom_four=$_POST["user_custom_four"];} +if (isset($_GET["user_custom_five"])) {$user_custom_five=$_GET["user_custom_five"];} + elseif (isset($_POST["user_custom_five"])) {$user_custom_five=$_POST["user_custom_five"];} +if (isset($_GET["preset_number_a"])) {$preset_number_a=$_GET["preset_number_a"];} + elseif (isset($_POST["preset_number_a"])) {$preset_number_a=$_POST["preset_number_a"];} +if (isset($_GET["preset_number_b"])) {$preset_number_b=$_GET["preset_number_b"];} + elseif (isset($_POST["preset_number_b"])) {$preset_number_b=$_POST["preset_number_b"];} +if (isset($_GET["preset_number_c"])) {$preset_number_c=$_GET["preset_number_c"];} + elseif (isset($_POST["preset_number_c"])) {$preset_number_c=$_POST["preset_number_c"];} +if (isset($_GET["preset_number_d"])) {$preset_number_d=$_GET["preset_number_d"];} + elseif (isset($_POST["preset_number_d"])) {$preset_number_d=$_POST["preset_number_d"];} +if (isset($_GET["preset_number_e"])) {$preset_number_e=$_GET["preset_number_e"];} + elseif (isset($_POST["preset_number_e"])) {$preset_number_e=$_POST["preset_number_e"];} +if (isset($_GET["preset_number_f"])) {$preset_number_f=$_GET["preset_number_f"];} + elseif (isset($_POST["preset_number_f"])) {$preset_number_f=$_POST["preset_number_f"];} +if (isset($_GET["preset_dtmf_a"])) {$preset_dtmf_a=$_GET["preset_dtmf_a"];} + elseif (isset($_POST["preset_dtmf_a"])) {$preset_dtmf_a=$_POST["preset_dtmf_a"];} +if (isset($_GET["preset_dtmf_b"])) {$preset_dtmf_b=$_GET["preset_dtmf_b"];} + elseif (isset($_POST["preset_dtmf_b"])) {$preset_dtmf_b=$_POST["preset_dtmf_b"];} +if (isset($_GET["ScrollDIV"])) {$ScrollDIV=$_GET["ScrollDIV"];} + elseif (isset($_POST["ScrollDIV"])) {$ScrollDIV=$_POST["ScrollDIV"];} +if (isset($_GET["ignore_list_script"])) {$ignore_list_script=$_GET["ignore_list_script"];} + elseif (isset($_POST["ignore_list_script"])) {$ignore_list_script=$_POST["ignore_list_script"];} + +header ("Content-type: text/html; charset=utf-8"); +header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header ("Pragma: no-cache"); // HTTP/1.0 + +$txt = '.txt'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$CIDdate = date("mdHis"); +$ENTRYdate = date("YmdHis"); +$MT[0]=''; +$agents='@agents'; + +$script_height = ($script_height - 20); + +$IFRAME=0; + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin,timeclock_end_of_day,agentonly_callback_campaign_lock FROM system_settings;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$qm_conf_ct = mysql_num_rows($rslt); +if ($qm_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $non_latin = $row[0]; + $timeclock_end_of_day = $row[1]; + $agentonly_callback_campaign_lock = $row[2]; + } +##### END SETTINGS LOOKUP ##### +########################################### + +if ($non_latin < 1) + { + $user=ereg_replace("[^-_0-9a-zA-Z]","",$user); + $pass=ereg_replace("[^-_0-9a-zA-Z]","",$pass); + $length_in_sec = ereg_replace("[^0-9]","",$length_in_sec); + $phone_code = ereg_replace("[^0-9]","",$phone_code); + $phone_number = ereg_replace("[^0-9]","",$phone_number); + } +else + { + $user = ereg_replace("'|\"|\\\\|;","",$user); + $pass = ereg_replace("'|\"|\\\\|;","",$pass); + } + + +# default optional vars if not set +if (!isset($format)) {$format="text";} + if ($format == 'debug') {$DB=1;} +if (!isset($ACTION)) {$ACTION="refresh";} +if (!isset($query_date)) {$query_date = $NOW_DATE;} + +$stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; +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($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Invalid Username/Password: |$user|$pass|\n"; + exit; + } +else + { + # do nothing for now + } + +if ($format=='debug') + { + echo "\n"; + echo "\n"; + echo "\n"; + echo "VICIDiaL Script Display Script"; + echo "\n"; + echo "\n"; + echo "\n"; + } + +if (strlen($in_script) < 1) + {$call_script = $camp_script;} +else + {$call_script = $in_script;} + +if ($ignore_list_script < 1) + { + $stmt="SELECT agent_script_override from vicidial_lists where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $agent_script_override = $row[0]; + if (strlen($agent_script_override) > 0) + {$call_script = $agent_script_override;} + } + +$stmt="SELECT script_name,script_text from vicidial_scripts where script_id='$call_script';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$script_name = $row[0]; +$script_text = stripslashes($row[1]); + +if (eregi("iframe src",$script_text)) + { + $IFRAME=1; + $lead_id = eregi_replace(' ','+',$lead_id); + $vendor_id = eregi_replace(' ','+',$vendor_id); + $vendor_lead_code = eregi_replace(' ','+',$vendor_lead_code); + $list_id = eregi_replace(' ','+',$list_id); + $gmt_offset_now = eregi_replace(' ','+',$gmt_offset_now); + $phone_code = eregi_replace(' ','+',$phone_code); + $phone_number = eregi_replace(' ','+',$phone_number); + $title = eregi_replace(' ','+',$title); + $first_name = eregi_replace(' ','+',$first_name); + $middle_initial = eregi_replace(' ','+',$middle_initial); + $last_name = eregi_replace(' ','+',$last_name); + $address1 = eregi_replace(' ','+',$address1); + $address2 = eregi_replace(' ','+',$address2); + $address3 = eregi_replace(' ','+',$address3); + $city = eregi_replace(' ','+',$city); + $state = eregi_replace(' ','+',$state); + $province = eregi_replace(' ','+',$province); + $postal_code = eregi_replace(' ','+',$postal_code); + $country_code = eregi_replace(' ','+',$country_code); + $gender = eregi_replace(' ','+',$gender); + $date_of_birth = eregi_replace(' ','+',$date_of_birth); + $alt_phone = eregi_replace(' ','+',$alt_phone); + $email = eregi_replace(' ','+',$email); + $security_phrase = eregi_replace(' ','+',$security_phrase); + $comments = eregi_replace(' ','+',$comments); + $user = eregi_replace(' ','+',$user); + $pass = eregi_replace(' ','+',$pass); + $campaign = eregi_replace(' ','+',$campaign); + $phone_login = eregi_replace(' ','+',$phone_login); + $original_phone_login = eregi_replace(' ','+',$original_phone_login); + $phone_pass = eregi_replace(' ','+',$phone_pass); + $fronter = eregi_replace(' ','+',$fronter); + $closer = eregi_replace(' ','+',$closer); + $group = eregi_replace(' ','+',$group); + $channel_group = eregi_replace(' ','+',$channel_group); + $SQLdate = eregi_replace(' ','+',$SQLdate); + $epoch = eregi_replace(' ','+',$epoch); + $uniqueid = eregi_replace(' ','+',$uniqueid); + $customer_zap_channel = eregi_replace(' ','+',$customer_zap_channel); + $customer_server_ip = eregi_replace(' ','+',$customer_server_ip); + $server_ip = eregi_replace(' ','+',$server_ip); + $SIPexten = eregi_replace(' ','+',$SIPexten); + $session_id = eregi_replace(' ','+',$session_id); + $phone = eregi_replace(' ','+',$phone); + $parked_by = eregi_replace(' ','+',$parked_by); + $dispo = eregi_replace(' ','+',$dispo); + $dialed_number = eregi_replace(' ','+',$dialed_number); + $dialed_label = eregi_replace(' ','+',$dialed_label); + $source_id = eregi_replace(' ','+',$source_id); + $rank = eregi_replace(' ','+',$rank); + $owner = eregi_replace(' ','+',$owner); + $camp_script = eregi_replace(' ','+',$camp_script); + $in_script = eregi_replace(' ','+',$in_script); + $script_width = eregi_replace(' ','+',$script_width); + $script_height = eregi_replace(' ','+',$script_height); + $fullname = eregi_replace(' ','+',$fullname); + $recording_filename = eregi_replace(' ','+',$recording_filename); + $recording_id = eregi_replace(' ','+',$recording_id); + $user_custom_one = eregi_replace(' ','+',$user_custom_one); + $user_custom_two = eregi_replace(' ','+',$user_custom_two); + $user_custom_three = eregi_replace(' ','+',$user_custom_three); + $user_custom_four = eregi_replace(' ','+',$user_custom_four); + $user_custom_five = eregi_replace(' ','+',$user_custom_five); + $preset_number_a = eregi_replace(' ','+',$preset_number_a); + $preset_number_b = eregi_replace(' ','+',$preset_number_b); + $preset_number_c = eregi_replace(' ','+',$preset_number_c); + $preset_number_d = eregi_replace(' ','+',$preset_number_d); + $preset_number_e = eregi_replace(' ','+',$preset_number_e); + $preset_number_f = eregi_replace(' ','+',$preset_number_f); + $preset_dtmf_a = eregi_replace(' ','+',$preset_dtmf_a); + $preset_dtmf_b = eregi_replace(' ','+',$preset_dtmf_b); + } + +$script_text = eregi_replace('--A--lead_id--B--',"$lead_id",$script_text); +$script_text = eregi_replace('--A--vendor_id--B--',"$vendor_id",$script_text); +$script_text = eregi_replace('--A--vendor_lead_code--B--',"$vendor_lead_code",$script_text); +$script_text = eregi_replace('--A--list_id--B--',"$list_id",$script_text); +$script_text = eregi_replace('--A--gmt_offset_now--B--',"$gmt_offset_now",$script_text); +$script_text = eregi_replace('--A--phone_code--B--',"$phone_code",$script_text); +$script_text = eregi_replace('--A--phone_number--B--',"$phone_number",$script_text); +$script_text = eregi_replace('--A--title--B--',"$title",$script_text); +$script_text = eregi_replace('--A--first_name--B--',"$first_name",$script_text); +$script_text = eregi_replace('--A--middle_initial--B--',"$middle_initial",$script_text); +$script_text = eregi_replace('--A--last_name--B--',"$last_name",$script_text); +$script_text = eregi_replace('--A--address1--B--',"$address1",$script_text); +$script_text = eregi_replace('--A--address2--B--',"$address2",$script_text); +$script_text = eregi_replace('--A--address3--B--',"$address3",$script_text); +$script_text = eregi_replace('--A--city--B--',"$city",$script_text); +$script_text = eregi_replace('--A--state--B--',"$state",$script_text); +$script_text = eregi_replace('--A--province--B--',"$province",$script_text); +$script_text = eregi_replace('--A--postal_code--B--',"$postal_code",$script_text); +$script_text = eregi_replace('--A--country_code--B--',"$country_code",$script_text); +$script_text = eregi_replace('--A--gender--B--',"$gender",$script_text); +$script_text = eregi_replace('--A--date_of_birth--B--',"$date_of_birth",$script_text); +$script_text = eregi_replace('--A--alt_phone--B--',"$alt_phone",$script_text); +$script_text = eregi_replace('--A--email--B--',"$email",$script_text); +$script_text = eregi_replace('--A--security_phrase--B--',"$security_phrase",$script_text); +$script_text = eregi_replace('--A--comments--B--',"$comments",$script_text); +$script_text = eregi_replace('--A--user--B--',"$user",$script_text); +$script_text = eregi_replace('--A--pass--B--',"$pass",$script_text); +$script_text = eregi_replace('--A--campaign--B--',"$campaign",$script_text); +$script_text = eregi_replace('--A--phone_login--B--',"$phone_login",$script_text); +$script_text = eregi_replace('--A--original_phone_login--B--',"$original_phone_login",$script_text); +$script_text = eregi_replace('--A--phone_pass--B--',"$phone_pass",$script_text); +$script_text = eregi_replace('--A--fronter--B--',"$fronter",$script_text); +$script_text = eregi_replace('--A--closer--B--',"$closer",$script_text); +$script_text = eregi_replace('--A--group--B--',"$group",$script_text); +$script_text = eregi_replace('--A--channel_group--B--',"$channel_group",$script_text); +$script_text = eregi_replace('--A--SQLdate--B--',"$SQLdate",$script_text); +$script_text = eregi_replace('--A--epoch--B--',"$epoch",$script_text); +$script_text = eregi_replace('--A--uniqueid--B--',"$uniqueid",$script_text); +$script_text = eregi_replace('--A--customer_zap_channel--B--',"$customer_zap_channel",$script_text); +$script_text = eregi_replace('--A--customer_server_ip--B--',"$customer_server_ip",$script_text); +$script_text = eregi_replace('--A--server_ip--B--',"$server_ip",$script_text); +$script_text = eregi_replace('--A--SIPexten--B--',"$SIPexten",$script_text); +$script_text = eregi_replace('--A--session_id--B--',"$session_id",$script_text); +$script_text = eregi_replace('--A--phone--B--',"$phone",$script_text); +$script_text = eregi_replace('--A--parked_by--B--',"$parked_by",$script_text); +$script_text = eregi_replace('--A--dispo--B--',"$dispo",$script_text); +$script_text = eregi_replace('--A--dialed_number--B--',"$dialed_number",$script_text); +$script_text = eregi_replace('--A--dialed_label--B--',"$dialed_label",$script_text); +$script_text = eregi_replace('--A--source_id--B--',"$source_id",$script_text); +$script_text = eregi_replace('--A--rank--B--',"$rank",$script_text); +$script_text = eregi_replace('--A--owner--B--',"$owner",$script_text); +$script_text = eregi_replace('--A--camp_script--B--',"$camp_script",$script_text); +$script_text = eregi_replace('--A--in_script--B--',"$in_script",$script_text); +$script_text = eregi_replace('--A--script_width--B--',"$script_width",$script_text); +$script_text = eregi_replace('--A--script_height--B--',"$script_height",$script_text); +$script_text = eregi_replace('--A--fullname--B--',"$fullname",$script_text); +$script_text = eregi_replace('--A--recording_filename--B--',"$recording_filename",$script_text); +$script_text = eregi_replace('--A--recording_id--B--',"$recording_id",$script_text); +$script_text = eregi_replace('--A--user_custom_one--B--',"$user_custom_one",$script_text); +$script_text = eregi_replace('--A--user_custom_two--B--',"$user_custom_two",$script_text); +$script_text = eregi_replace('--A--user_custom_three--B--',"$user_custom_three",$script_text); +$script_text = eregi_replace('--A--user_custom_four--B--',"$user_custom_four",$script_text); +$script_text = eregi_replace('--A--user_custom_five--B--',"$user_custom_five",$script_text); +$script_text = eregi_replace('--A--preset_number_a--B--',"$preset_number_a",$script_text); +$script_text = eregi_replace('--A--preset_number_b--B--',"$preset_number_b",$script_text); +$script_text = eregi_replace('--A--preset_number_c--B--',"$preset_number_c",$script_text); +$script_text = eregi_replace('--A--preset_number_d--B--',"$preset_number_d",$script_text); +$script_text = eregi_replace('--A--preset_number_e--B--',"$preset_number_e",$script_text); +$script_text = eregi_replace('--A--preset_number_f--B--',"$preset_number_f",$script_text); +$script_text = eregi_replace('--A--preset_dtmf_a--B--',"$preset_dtmf_a",$script_text); +$script_text = eregi_replace('--A--preset_dtmf_b--B--',"$preset_dtmf_b",$script_text); +$script_text = eregi_replace("\n","
",$script_text); +$script_text = stripslashes($script_text); + + +echo "\n"; +echo "\n"; +echo "
\n"; +if ( ($IFRAME < 1) and ($ScrollDIV > 0) ) + { echo "
";} +echo "
$script_name
\n"; +echo "$script_text\n"; +if ( ($IFRAME < 1) and ($ScrollDIV > 0) ) + { echo "
";} +echo "
\n"; + +exit; + +?> diff --git a/LANG_www/agc_se/vicidial.php b/LANG_www/agc_se/vicidial.php new file mode 100644 index 00000000..609d5f49 --- /dev/null +++ b/LANG_www/agc_se/vicidial.php @@ -0,0 +1,11360 @@ + LICENSE: AGPLv2 +# +# Other scripts that this application depends on: +# - vdc_db_query.php: Updates information in the database +# - manager_send.php: Sends manager actions to the DB for execution +# - conf_exten_check.php: time sync and status updater, calls in queue +# - vdc_script_display.php: displays script with variables +# +# CHANGELOG +# 50607-1426 - First Build of VICIDIAL web client basic login process finished +# 50628-1620 - Added some basic formatting and worked on process flow +# 50628-1715 - Startup variables mapped to javascript variables +# 50629-1303 - Added Login Closer in-groups selection box and vla update +# 50629-1530 - Rough layout for customer info form section and button links +# 50630-1453 - Rough Manual Dial/Hangup with customer info displayed +# 50701-1450 - Added vicidial_log entries on dial and hangup +# 50701-1634 - Added Logout function +# 50705-1259 - Added call disposition functionality +# 50705-1432 - Added lead info DB update function +# 50705-1658 - Added web form functionality +# 50706-1043 - Added call park and pickup functions +# 50706-1234 - Added Start/Stop Recording functionality +# 50706-1614 - Added conference channels display option +# 50711-1333 - Removed call check redundancy and fixed a span bug +# 50727-1424 - Added customer channel and participant present sensing/alerts +# 50804-1057 - Added SendDTMF function and reconfigured the transfer span +# 50804-1224 - Added Local and Internal Closer transfer functions +# 50804-1628 - Added Blind transfer, activated LIVE CALL image and fixed bugs +# 50804-1808 - Added button images for left buttons +# 50815-1151 - Added 3Way calling functions to Transfer-conf frame +# 50815-1602 - Added images and buttons for xfer functions +# 50816-1813 - Added basic autodial outbound call pickup functions +# 50817-1113 - Fixes to auto_dialing call receipt +# 50817-1234 - Added inbound call receipt capability +# 50817-1541 - Added customer time display +# 50818-1327 - Added stop-all-recordings-after-each-vicidial-call option +# 50818-1703 - Added pretty login section +# 50825-1200 - Modified form field lengths, added double-click dispositions +# 50831-1603 - Fixed customer time bug and fronter display bug for CLOSER +# 50901-1314 - Fixed CLOSER IN-GROUP Web Form bug +# 50903-0904 - Added preview-lead code for manual dialing +# 50904-0016 - Added ability to hangup manual dials before pickup +# 50906-1319 - Added override for filters on xfer calls, fixed login display bug +# 50909-1243 - Added hotkeys functionality for quick dispoing in auto-dial mode +# 50912-0958 - Modified hotkeys function, agent must have user_level >= 5 to use +# 50913-1212 - Added campaign_cid to 3rd party calls +# 50923-1546 - Modified to work with language translation +# 50926-1656 - Added campaign pull-down at login of active campaigns +# 50928-1633 - Added manual dial alternate number dial option +# 50930-1538 - Added session_id empty login failure and fixed 2 minor bugs +# 51004-1656 - Fixed recording filename bug and new Spanish translation +# 51020-1103 - Added campaign-specific recording control abilities +# 51020-1352 - Added Basic vicidial_agent_log framework +# 51021-1050 - Fixed custtime display and disable Enter/Return keypresses +# 51021-1718 - Allows for multi-line comments (changes \n to !N in database) +# 51110-1432 - Fixed non-standard http port issue +# 51111-1047 - Added vicidial_agent_log lead_id earlier for manual dial +# 51118-1305 - Activate multi-line comments from $multi_line_comments var +# 51118-1313 - Move Transfer DIV to a floating span to preserve 800x600 view +# 51121-1506 - Small PHP optimizations in many scripts and disabled globalize +# 51129-1010 - Added ability to accept calls from other VICIDIAL servers +# 51129-1254 - Fixed Hangups of other agents channels when customer hangs up +# 51208-1732 - Created user-first login that looks for default phone info +# 51219-1526 - Added variable framework for campaign and in-group scripts +# 51221-1200 - Added SCRIPT tab, layout and functionality +# 51221-1714 - Added auto-switch-to-SCRIPT-tab and auto-webform-popup +# 51222-1605 - Added VMail message blind transfer button to xfer-conf frame +# 51229-1028 - Added checks on web_form_address to allow for var in the DB value +# 60117-1312 - Added Transfer-conf frame toggle on button press +# 60208-1152 - Added DTMF-xfernumber preset links to xfer-conf frame +# 60213-1129 - Added vicidial_users.hotkeys_active for any user hotkeys +# 60213-1210 - Added ability to sort routing of calls by user_level +# 60214-0932 - Initial Callback calendar display framework +# 60214-1407 - Added ability to minimize the dispo screen to see info below +# 60215-1104 - Added ANYONE scheduled callbacks functionality +# 60410-1116 - Added persistant pause after dispo option and change dispo text +# - Added web form submit that opens new window with dispo on submit +# - Added PREVIOUS CALLBACK in customer info to flag callbacks +# - Added link to try to hangup the call again in the dispo screen +# - Added link noone-in-session screen to call agent phone again +# - Added link customer-hungup screen to go straight to dispo screen +# 60410-1532 - Added agent status and campaign calls dialing display option +# 60411-1547 - Add ability to set callback as USERONLY and some basic formatting +# 60413-1752 - Add basic USERONLY callback frame and listings +# 60414-1039 - Changed manual dial preview and alt dial checkboxes to spans +# - Added beta-level USERONLY callback functionality +# - Added beta-level manual dialing with lead insertion functionality +# 60415-1534 - Fixed manual dial lead preview and fixed manuald dial override bug +# 60417-1108 - Added capability to do alt-number-dialing in auto-dial mode +# - Changed several permissions to database-defined +# 60419-1529 - Prevent manual dial or callbacks when alt-dial lead not finished +# 60420-1647 - Fixed DiaLDiaLAltPhonE error, Call Agent Again DialControl error +# 60421-1229 - Check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60424-1005 - Fixed Alt phone disabled bug for callbacks and manual dials +# 60426-1058 - Added vicidial_user setting for default blended check for CLOSER +# 60501-1008 - Added option to manual dial screen to manually lookup phone number +# 60503-1653 - Fixed agentonly_callback not-defined bug in scheduled callbacks screen +# 60504-1032 - Fixed manual dial display bug and transfer dispo alert bug +# - Fixed recording filename display to not overrun 25 characters +# 60510-1051 - Added Wrapup timer and wrapup message on wrapup screen after dispo +# 60608-1453 - Added CLOSER campaign allowable in-groups limitations +# 60609-1123 - Added add-number-to-DNC-list function and manual dial check DNC +# 60619-1047 - Added variable filters to close security holes for login form +# 60804-1710 - fixed scheduled CALLBK for other languages build +# 60808-1145 - Added consultative transfers with customer data +# 60808-2232 - Added campaign name to pulldown for login screen +# 60809-1603 - Added option to locally transfer consult xfers +# 60809-1732 - Added recheck of transferred channels before customer gone mesg +# 60810-1011 - Fixed CXFER leave 3way call bugs +# 60816-1602 - Added ALLCALLS recording delay option allcalls_delay +# 60816-1716 - Fixed customer time display bug and client DST setting +# 60821-1555 - Added option to omit phone_code on dialout of leads +# 60821-1628 - Added ALLFORCE recording option +# 60821-1643 - Added no_delete_sessions option to not delete sessions +# 60822-0512 - Changed phone number fields to be maxlength of 12 +# 60829-1531 - Made compatible with WeBRooTWritablE setting in dbconnect.php +# 60906-1152 - Added Previous CallBack info display span +# 60906-1715 - Allow for Local phone extension conferences +# 61004-1729 - Add ability to control volume per channel in "calls in this session" +# 61122-1341 - Added vicidial_user_groups allowed_campaigns restrictions +# 61122-1523 - Added more SCRIPT variables +# 61128-2229 - Added vicidial_live_agents and vicidial_auto_calls manual dial entries +# 61130-1617 - Added lead_id to MonitorConf for recording_log +# 61221-1212 - Changed width to 760 to better fit 800x600 screens, widened SCRIPT +# 70109-1128 - Fixed wrapup timer bug +# 70109-1635 - Added option for HotKeys automatically dialing next number in manual mode +# - Added option for alternate number dialing with hotkeys +# 70111-1600 - Added ability to use BLEND/INBND/*_C/*_B/*_I as closer campaigns +# 70118-1517 - Added vicidial_agent_log and vicidial_user_log logging of user_group +# 70201-1249 - Added FAST DIAL option for manually dialing, added UTF8 compatible code +# 70201-1703 - Fixed cursor bug for most text input fields +# 70202-1453 - Added first portions of Agent Pause Codes +# 70203-0108 - Finished Agent Pause Codes functionality +# 70203-0930 - Added dialed_number to webform output +# 70203-1010 - Added dialed_label to webform output +# 70206-1201 - Fixed allow_closers bug +# 70206-1332 - Added vicidial_recording_override users setting function +# 70212-1252 - Fixed small issue with CXFER +# 70213-1018 - Changed CXFER and AXFER to update customer information before transfer +# 70214-1233 - Added queuemetrics_log_id field for server_id in queue_log +# 70215-1240 - Added queuemetrics_log_id field for server_id in queue_log +# 70222-1617 - Changed queue_log PAUSE/UNPAUSE to PAUSEALL/UNPAUSEALL +# 70226-1252 - Added Mute/UnMute to agent screen +# 70309-1035 - Allow amphersands and questions marks in comments to pass through +# 70313-1052 - Allow pound signs(hash) in comments to pass through +# 70316-1406 - Moved the MUTE button to be accessible during a transfer/conf +# 70319-1446 - Added agent-deactive-display and disable customer info update functions +# 70319-1626 - Added option to allow agent logins to campaigns with no leads in the hopper +# 70320-1501 - Added option to allow retry of leave-3way-call from dispo screen +# 70322-1545 - Added sipsak display ability +# 70510-1319 - Added onUnload force Logout +# 70806-1530 - Added Presets Dial links above agent mute button +# 70823-2118 - Fixed XMLHTTPRequest, HotKeys and Scheduled Callbacks issues with MSIE +# 70828-1443 - Added source_id to output of SCRIPTtab-IFRAME and WEBFORM +# 71022-1427 - Added formatting of the customer phone number in the main status bar +# 71029-1848 - Changed CLOSER-type campaign to not use campaign_id restrictions +# 71101-1204 - Fixed bug in callback calendar with DST +# 71116-0957 - Added campaign_weight and calls_today to the vla table insertion +# 71120-1719 - Added XMLHTPRequest lookup of allowable campaigns for agents during login +# 71122-0256 - Added auto-pause notification +# 71125-1751 - Changed Transfer section to allow for selection of in-groups to send calls to +# 71127-0408 - Added height and width settings for easier modification of screen size +# 71129-2025 - restricted callbacks count and list to campaign only +# 71223-0318 - changed logging of closer calls +# 71226-1117 - added option to kick all calls from conference upon logout +# 80109-1510 - added gender select list +# 80116-1032 - added option on CLOSER-type campaigns to change in-groups when paused +# 80317-2106 - added recording override options for inbound group calls +# 80331-1433 - Added second transfer try for VICIDIAL transfers/hangups on manual dial calls +# 80402-0121 - Fixes for manual dial transfers on some systems +# 80407-2112 - Work on adding phone login load balancing across servers +# 80416-0559 - Added ability to log computer_ip at login, set the $PhonESComPIP variable +# 80428-0413 - UTF8 changes and testing +# 80505-0054 - Added multi-phones load-balanced alias option +# 80507-0932 - Fixed Script display bug (+ instead of space) +# 80519-1425 - Added calls in queue display +# 80523-1630 - Added Timeclock links +# 80625-0047 - Added U option for gender, added date/phone display options +# 80630-2210 - Added queue_log entries for Manual Dial +# 80703-0139 - Added alter customer phone permissions +# 80703-1106 - Added API functionality for Hangup and Dispo, added Agent Display Queue Count +# 80707-2325 - Added vicidial_id to recording_log for tracking of vicidial or closer log to recording +# 80709-0358 - Added Default alt phone dial hard-code option +# 80719-1147 - Changed recording and senddtmf conf prefix +# 80815-1014 - Added manual dial list restriction option +# 80823-2123 - Fixed form scroll for IE, added copy to clipboard(IE-only feature) +# 80831-0548 - Added Extended alt-dial-phone display information for non-manual calls +# 80909-1717 - Added support for campaign-specific DNC lists +# 80915-1754 - Rewrote leave-3way functions for external calling +# 81002-1908 - Fixed double-login bug in some conditions +# 81007-0945 - Added three_way_call_cid option for outbound 3way calls +# 81010-1047 - Fixed conf calling prefix to use settings, other 3way improvements +# 81011-1403 - Fixed bugs in leave3way when transferring a manual dial call +# 81012-1729 - Added INBOUND_MAN dial method to allow manual list dialing and inbound calls +# 81013-1644 - Fixed bug in leave 3way for manual dial fronters +# 81015-0405 - Fixed bug related to hangups on 3way calls +# 81016-0703 - Changed leave 3way to allow function at any time transfer-conf is available +# 81020-1501 - Fixed bugs in queue_log logging +# 81023-0411 - Added compatibility for dial-in agents using AGI, bug fixes +# 81030-0403 - Added option to force Pause Codes on PAUSE +# 81103-1427 - Added 3way call dial prefix +# 81104-0140 - Added mysql error logging capability +# 81104-1618 - Changed MySQL queries logging +# 81106-0411 - Changedthe campaign login list behaviour +# 81110-0057 - Changed Pause time to start new vicidial_agent_log on every pause +# 81110-1514 - Added hangup_all_non_reserved to fix non-Hangup bug +# 81119-1811 - webform backslash fix +# 81124-2213 - Fixes blind transfer bug +# 81209-1617 - Added campaign web form target option and web form address variables +# 81211-0422 - Fixed Manual dial agent_log bug +# 90102-1402 - Added time sync check notification +# 90115-0619 - Added ability to send Local Closer to AGENTDIRECT agent_only +# 90120-1719 - Added API pause/resume and number dial functionality +# 90126-2302 - Added Vtiger login option and agent alert option +# 90128-0230 - Added vendor_lead_code to API dial and manuald dial with lookup +# 90202-0148 - Added option to disable BLENDED checkbox +# 90209-0132 - Changed tab images and color scheme +# 90303-1145 - Fixed rare manual dial live hangup bug +# 90304-1333 - Added user-specific web vars option +# 90305-0917 - Added prefix-choice and group-alias options for calls coming from API +# 90307-1736 - Added Shift enforcement and manager override features +# 90315-1009 - Changed revision for new trunk 2.2.0 +# 90320-0309 - Fixed agent log bug when using wrapup time +# 90323-1555 - Initial call to agent phone now has campaign callerIDnumber +# 90408-0104 - Added Vtiger callback record ability +# 90508-0727 - Changed to PHP long tags +# 90511-1018 - Added restriction not allowing dialing into agent sessions from manual dial +# 90519-0635 - Fixed manual dial status and logging bug +# 90525-1012 - Fixed transfer issue of auto-received call after manual dial call +# 90529-0741 - Added nophone agent phone login that will not show any empty session alerts +# 90531-0635 - Added option to hide customer phone number +# 90611-1422 - Fixed multiple logging bugs +# 90628-0655 - Added Quick Transfer button and Preset Prepopulate option +# 90705-1400 - Added Agent view sidebar option +# 90706-1432 - Added Agent view transfer selection +# 90709-1649 - Fixed alt-number transfers and dispo variable reset for webform +# 90712-2304 - Added ADD-ALL group selection, view calls in queue, grab call from queue, requeue button +# 90717-0640 - Added dialed_label and dialed_number to script variables +# 90721-1114 - Added rank and owner as vicidial_list fields +# 90726-2012 - Added allow_alerts option +# 90729-0647 - Added agent_display_dialable_leads option +# 90730-0145 - Fixed bugs in re-queue and INBOUND_MAN with blended selected +# 90808-0117 - Fixed manual dial calls today bug, added last_state_change to vicidial_live_agents +# 90812-0046 - Added no-delete-sessions = 1 as default, unused sessions cleared out at timeclock end of day +# 90814-0829 - Moved mute button next to hotkeys button +# 90827-0133 - Reworked Script display code +# 90827-1549 - Added list script override option, original_phone_login variable +# 90831-1456 - Added active_agent_login_server option for servers +# 90908-1038 - Added DEAD call display +# 90909-0921 - Fixed park issues +# 90916-1144 - Added Second web form button, Answering Machine Message change +# 90917-1325 - Fixed script loading bug with customer webform at the same time +# 90920-2108 - Changed web forms to use window.open instead of traditional links(IE7 compatibility issue) +# 90923-1310 - Rolled back last change +# 90928-1955 - Added lead update before closer transfer +# 90930-2243 - Added Territory selection functions +# 91108-2118 - Added QM pause code entry +# 91111-1433 - Fixed Gender pulldown list display for IE, remove links for recording channels in SHOW CHANNELS +# 91123-1801 - Added code for outbound_autodial field +# 91130-2021 - Added code for manager override of in-group selection +# 91204-1638 - Added recording_filename and recording_id script variables and script refresh link +# 91205-2055 - Added CONSULTATIVE checkbox in a redesigned Transfer-Conf frame +# 91206-2020 - Fixed vicidial_agent_log logging bug on logout when not paused +# 91211-1412 - Added User custom variables and CRM login popup +# 91219-0657 - Set pause code automatically on ReQueue and INBOUND_MAN Dial-Next-Number +# 91228-1339 - Added API "fields update" functions and "timer action" functions +# 100103-1250 - Added 3 more conf-presets, list ID override presets and call start/dispo URLs +# 100107-0108 - Added dynamic screen size based on login screen browser dimensions +# 100109-0801 - Added ALTNUM alt number status, fixed alt number dialing from setting +# 100109-1338 - Fixed Manual dial live call detection +# 100116-0709 - Added presets to script and web form variables +# 100203-0640 - Fixed logging issues related to INBOUND_MAN dial method +# 100207-1109 - Changed Pause Codes function to allow for multiple pause codes per pause period +# 100228-1257 - Fixed no-selected default transfer group issue on inbound calls +# 100301-1329 - Changed AGENTDIRECT user selection launching to AGENTS link next to number-to-dial field +# 100309-1709 - small fix for IE CRM popup +# 100315-1149 - fix for rare recording_log uniqueid issue on manual dial calls to same number +# 100327-0902 - fix for manual dial answering machine message +# 100413-1347 - Various fixes for logging and extended alt-dialing +# + +$version = '2.2.0-258'; +$build = '100413-1347'; +$mel=1; # Mysql Error Log enabled = 1 +$mysql_log_count=64; +$one_mysql_log=0; + +require("dbconnect.php"); + +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["JS_browser_width"])) {$JS_browser_width=$_GET["JS_browser_width"];} + elseif (isset($_POST["JS_browser_width"])) {$JS_browser_width=$_POST["JS_browser_width"];} +if (isset($_GET["JS_browser_height"])) {$JS_browser_height=$_GET["JS_browser_height"];} + elseif (isset($_POST["JS_browser_height"])) {$JS_browser_height=$_POST["JS_browser_height"];} +if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];} + elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];} +if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];} + elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];} +if (isset($_GET["VD_login"])) {$VD_login=$_GET["VD_login"];} + elseif (isset($_POST["VD_login"])) {$VD_login=$_POST["VD_login"];} +if (isset($_GET["VD_pass"])) {$VD_pass=$_GET["VD_pass"];} + elseif (isset($_POST["VD_pass"])) {$VD_pass=$_POST["VD_pass"];} +if (isset($_GET["VD_campaign"])) {$VD_campaign=$_GET["VD_campaign"];} + elseif (isset($_POST["VD_campaign"])) {$VD_campaign=$_POST["VD_campaign"];} +if (isset($_GET["relogin"])) {$relogin=$_GET["relogin"];} + elseif (isset($_POST["relogin"])) {$relogin=$_POST["relogin"];} +if (isset($_GET["MGR_override"])) {$MGR_override=$_GET["MGR_override"];} + elseif (isset($_POST["MGR_override"])) {$MGR_override=$_POST["MGR_override"];} +if (!isset($phone_login)) + { + if (isset($_GET["pl"])) {$phone_login=$_GET["pl"];} + elseif (isset($_POST["pl"])) {$phone_login=$_POST["pl"];} + } +if (!isset($phone_pass)) + { + if (isset($_GET["pp"])) {$phone_pass=$_GET["pp"];} + elseif (isset($_POST["pp"])) {$phone_pass=$_POST["pp"];} + } +if (isset($VD_campaign)) + { + $VD_campaign = strtoupper($VD_campaign); + $VD_campaign = eregi_replace(" ",'',$VD_campaign); + } +if (!isset($flag_channels)) + { + $flag_channels=0; + $flag_string=''; + } + +### security strip all non-alphanumeric characters out of the variables ### +$DB=ereg_replace("[^0-9a-z]","",$DB); +$phone_login=ereg_replace("[^\,0-9a-zA-Z]","",$phone_login); +$phone_pass=ereg_replace("[^0-9a-zA-Z]","",$phone_pass); +$VD_login=ereg_replace("[^-_0-9a-zA-Z]","",$VD_login); +$VD_pass=ereg_replace("[^-_0-9a-zA-Z]","",$VD_pass); +$VD_campaign = ereg_replace("[^-_0-9a-zA-Z]","",$VD_campaign); + + +$forever_stop=0; + +if ($force_logout) + { + echo "Du är nu utloggad ur systemet, välkommen åter! +\n"; + exit; + } + +$isdst = date("I"); +$StarTtimE = date("U"); +$NOW_TIME = date("Y-m-d H:i:s"); +$tsNOW_TIME = date("YmdHis"); +$FILE_TIME = date("Ymd-His"); +$loginDATE = date("Ymd"); +$CIDdate = date("ymdHis"); +$month_old = mktime(11, 0, 0, date("m"), date("d")-2, date("Y")); +$past_month_date = date("Y-m-d H:i:s",$month_old); +$minutes_old = mktime(date("H"), date("i")-2, date("s"), date("m"), date("d"), date("Y")); +$past_minutes_date = date("Y-m-d H:i:s",$minutes_old); + + +$random = (rand(1000000, 9999999) + 10000000); + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin,vdc_header_date_format,vdc_customer_date_format,vdc_header_phone_format,webroot_writable,timeclock_end_of_day,vtiger_url,enable_vtiger_integration,outbound_autodial_active,enable_second_webform,user_territories_active FROM system_settings;"; +$rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01001',$VD_login,$server_ip,$session_name,$one_mysql_log);} +if ($DB) {echo "$stmt\n";} +$qm_conf_ct = mysql_num_rows($rslt); +if ($qm_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $non_latin = $row[0]; + $vdc_header_date_format = $row[1]; + $vdc_customer_date_format = $row[2]; + $vdc_header_phone_format = $row[3]; + $WeBRooTWritablE = $row[4]; + $timeclock_end_of_day = $row[5]; + $vtiger_url = $row[6]; + $enable_vtiger_integration = $row[7]; + $outbound_autodial_active = $row[8]; + $enable_second_webform = $row[9]; + $user_territories_active = $row[10]; + } +##### END SETTINGS LOOKUP ##### +########################################### + + +##### DEFINABLE SETTINGS AND OPTIONS +########################################### +$conf_silent_prefix = '5'; # vicidial_conferences prefix to enter silently and muted for recording +$dtmf_silent_prefix = '7'; # vicidial_conferences prefix to enter silently +$HKuser_level = '5'; # minimum vicidial user_level for HotKeys +$campaign_login_list = '1'; # show drop-down list of campaigns at login +$manual_dial_preview = '1'; # allow preview lead option when manual dial +$multi_line_comments = '1'; # set to 1 to allow multi-line comment box +$user_login_first = '0'; # set to 1 to have the vicidial_user login before the phone login +$view_scripts = '1'; # set to 1 to show the SCRIPTS tab +$dispo_check_all_pause = '0'; # set to 1 to allow for persistent pause after dispo +$callholdstatus = '1'; # set to 1 to show calls på hold count +$agentcallsstatus = '0'; # set to 1 to show agent status and call dialed count + $campagentstatctmax = '3'; # Number of sekunder for campaign call and agent stats +$show_campname_pulldown = '1'; # set to 1 to show campaign name på login pulldown +$webform_sessionname = '1'; # set to 1 to include the session_name in webform URL +$local_consult_xfers = '1'; # set to 1 to send consultative transfers from original server +$clientDST = '1'; # set to 1 to check for DST på server for agent time +$no_delete_sessions = '1'; # set to 1 to not delete sessions at logout +$volumecontrol_active = '1'; # set to 1 to allow agents to alter volume of channels +$PreseT_DiaL_LinKs = '0'; # set to 1 to show a RING link for Dial Presets +$LogiNAJAX = '1'; # set to 1 to do lookups på campaigns for login +$HidEMonitoRSessionS = '1'; # set to 1 to hide remote monitoring channels from "session calls" +$hangup_all_non_reserved= '1'; # set to 1 to force hangup all non-reserved channels upon Lägg på kund +$LogouTKicKAlL = '1'; # set to 1 to hangup all calls in session upon agent logout +$PhonESComPIP = '1'; # set to 1 to log computer IP to phone if blank, set to 2 to force log each login +$DefaulTAlTDiaL = '0'; # set to 1 to enable ALT RING by default if enabled for the campaign +$AgentAlert_allowed = '1'; # set to 1 to allow Agent alert option +$disable_blended_checkbox='0'; # set to 1 to disable the BLENDED checkbox from the in-group chooser screen + +$TEST_all_statuses = '0'; # TEST variable allows all statuses in dispo screen + +$stretch_dimensions = '1'; # sets the vicidial screen to the size of the browser window +$BROWSER_HEIGHT = 500; # set to the minimum browser height, default=500 +$BROWSER_WIDTH = 770; # set to the minimum browser width, default=770 +$MAIN_COLOR = '#CCCCCC'; # old default is E0C2D6 +$SCRIPT_COLOR = '#E6E6E6'; # old default is FFE7D0 +$SIDEBAR_COLOR = '#F6F6F6'; + +# options now set in DB: +#$alt_phone_dialing = '1'; # allow agents to call alt phone numbers +#$scheduled_callbacks = '1'; # set to 1 to allow agent to choose scheduled callbacks +# $agentonly_callbacks = '1'; # set to 1 to allow agent to choose agent-only scheduled callbacks +#$agentcall_manual = '1'; # set to 1 to allow agent to make manual calls during autodial session + + +$US='_'; +$CL=':'; +$AT='@'; +$DS='-'; +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +if (($server_port == '80') or ($server_port == '443') ) {$server_port='';} +else {$server_port = "$CL$server_port";} +$agcPAGE = "$HTTPprotocol$server_name$server_port$script_name"; +$agcDIR = eregi_replace('vicidial.php','',$agcPAGE); + + +header ("Content-type: text/html; charset=utf-8"); +header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header ("Pragma: no-cache"); // HTTP/1.0 +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +if ($campaign_login_list > 0) + { + $camp_form_code = "\n"; + } +else + { + $camp_form_code = "\n"; + } + + +if ($LogiNAJAX > 0) + { + ?> + + + + + + + + Agent web client: Logga in på nytt\n"; +echo "\n"; +echo "\n"; +echo "Stämpelklocka
\n"; +echo "\n"; +echo "\n"; +echo "\n";echo "\n";echo "
English Svenska
\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "


"; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Logga in på nytt
 
Telefonlogin:
Telefonlösenord:
Användare:
Lösenord:
Kampanj: $camp_form_code
  \n"; +echo "

VERSION: $version       SKAPA: $build
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; +exit; +} + +if ($user_login_first == 1) +{ + if ( (strlen($VD_login)<1) or (strlen($VD_pass)<1) or (strlen($VD_campaign)<1) ) + { + echo "Agent web client: Kampanjinloggning\n"; + echo "\n"; + echo "\n"; + echo "Stämpelklocka
\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Svenska
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + #echo "\n"; + #echo "\n"; + echo "

Användare

"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Kampanjinloggning
 
Användare:
Lösenord:
Kampanj: $camp_form_code
  \n"; + echo "

VERSION: $version       SKAPA: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + else + { + if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) ) + { + $stmt="SELECT phone_login,phone_pass from vicidial_users where user='$VD_login' and pass='$VD_pass' and user_level > 0 and active='Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01005',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $phone_login=$row[0]; + $phone_pass=$row[1]; + + echo "Agent web client: Login\n"; + echo "\n"; + echo "\n"; + echo "Stämpelklocka
\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Svenska
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Logga in
 
Telefonlogin:
Telefonlösenord:
Användare:
Lösenord:
Kampanj: $camp_form_code
  \n"; + echo "

VERSION: $version       SKAPA: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + + } + } +} + +if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) ) +{ +echo "Agent web client: Telefonlogin\n"; +echo "\n"; +echo "\n"; +echo "Stämpelklocka
\n"; +echo "\n"; +echo "\n"; +echo "\n";echo "\n";echo "
English Svenska
\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "


"; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Telefonlogin
 
Telefonlogin:
Telefonlösenord:
  \n"; +echo "

VERSION: $version       SKAPA: $build
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; +exit; +} +else +{ +if ($WeBRooTWritablE > 0) + {$fp = fopen ("./vicidial_auth_entries.txt", "a");} +$VDloginDISPLAY=0; + + if ( (strlen($VD_login)<2) or (strlen($VD_pass)<2) or (strlen($VD_campaign)<2) ) + { + $VDloginDISPLAY=1; + } + else + { + $stmt="SELECT count(*) from vicidial_users where user='$VD_login' and pass='$VD_pass' and user_level > 0 and active='Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01006',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if($auth>0) + { + $login=strtoupper($VD_login); + $password=strtoupper($VD_pass); + ##### grab the full name of the agent + $stmt="SELECT full_name,user_level,hotkeys_active,agent_choose_ingroups,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,closer_default_blended,user_group,vicidial_recording_override,alter_custphone_override,alert_enabled,agent_shift_enforcement_override,shift_override_flag,allow_alerts,closer_campaigns,agent_choose_territories,custom_one,custom_two,custom_three,custom_four,custom_five from vicidial_users where user='$VD_login' and pass='$VD_pass'"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01007',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $LOGfullname = $row[0]; + $user_level = $row[1]; + $VU_hotkeys_active = $row[2]; + $VU_agent_choose_ingroups = $row[3]; + $VU_scheduled_callbacks = $row[4]; + $agentonly_callbacks = $row[5]; + $agentcall_manual = $row[6]; + $VU_vicidial_recording = $row[7]; + $VU_vicidial_transfers = $row[8]; + $VU_closer_default_blended = $row[9]; + $VU_user_group = $row[10]; + $VU_vicidial_recording_override = $row[11]; + $VU_alter_custphone_override = $row[12]; + $VU_alert_enabled = $row[13]; + $VU_agent_shift_enforcement_override = $row[14]; + $VU_shift_override_flag = $row[15]; + $VU_allow_alerts = $row[16]; + $VU_closer_campaigns = $row[17]; + $VU_agent_choose_territories = $row[18]; + $VU_custom_one = $row[19]; + $VU_custom_two = $row[20]; + $VU_custom_three = $row[21]; + $VU_custom_four = $row[22]; + $VU_custom_five = $row[23]; + + if ( ($VU_alert_enabled > 0) and ($VU_allow_alerts > 0) ) {$VU_alert_enabled = 'ON';} + else {$VU_alert_enabled = 'OFF';} + $AgentAlert_allowed = $VU_allow_alerts; + + ### Gather timeclock and shift enforcement restriction settings + $stmt="SELECT forced_timeclock_login,shift_enforcement,group_shifts,agent_status_viewable_groups,agent_status_view_time from vicidial_user_groups where user_group='$VU_user_group';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01052',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $forced_timeclock_login = $row[0]; + $shift_enforcement = $row[1]; + $LOGgroup_shiftsSQL = eregi_replace(' ','',$row[2]); + $LOGgroup_shiftsSQL = eregi_replace(' ',"','",$LOGgroup_shiftsSQL); + $LOGgroup_shiftsSQL = "shift_id IN('$LOGgroup_shiftsSQL')"; + $agent_status_viewable_groups = $row[3]; + $agent_status_viewable_groupsSQL = eregi_replace(' ','',$agent_status_viewable_groups); + $agent_status_viewable_groupsSQL = eregi_replace(' ',"','",$agent_status_viewable_groupsSQL); + $agent_status_viewable_groupsSQL = "user_group IN('$agent_status_viewable_groupsSQL')"; + $agent_status_view = 0; + if (strlen($agent_status_viewable_groups) > 2) + {$agent_status_view = 1;} + $agent_status_view_time=0; + if ($row[4] == 'Y') + {$agent_status_view_time=1;} + + ### BEGIN - CHECK TO SEE IF AGENT IS LOGGED IN TO TIMECLOCK, IF NOT, OUTPUT ERROR + if ( (ereg('Y',$forced_timeclock_login)) or ( (ereg('ADMIN_EXEMPT',$forced_timeclock_login)) and ($VU_user_level < 8) ) ) + { + $last_agent_event=''; + $HHMM = date("Hi"); + $HHteod = substr($timeclock_end_of_day,0,2); + $MMteod = substr($timeclock_end_of_day,2,2); + + if ($HHMM < $timeclock_end_of_day) + {$EoD = mktime($HHteod, $MMteod, 10, date("m"), date("d")-1, date("Y"));} + else + {$EoD = mktime($HHteod, $MMteod, 10, date("m"), date("d"), date("Y"));} + + $EoDdate = date("Y-m-d H:i:s", $EoD); + + ##### grab timeclock logged-in time for each user ##### + $stmt="SELECT event from vicidial_timeclock_log where user='$VD_login' and event_epoch >= '$EoD' order by timeclock_id desc limit 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01053',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $events_to_parse = mysql_num_rows($rslt); + if ($events_to_parse > 0) + { + $rowx=mysql_fetch_row($rslt); + $last_agent_event = $rowx[0]; + } + if ($DB>0) {echo "|$stmt|$events_to_parse|$last_agent_event|";} + if ( (strlen($last_agent_event)<2) or (ereg('LOGOUT',$last_agent_event)) ) + { + $VDloginDISPLAY=1; + $VDdisplayMESSAGE = "DU MÅSTE STÄMPLA IN FÖRST
"; + } + } + ### END - CHECK TO SEE IF AGENT IS LOGGED IN TO TIMECLOCK, IF NOT, OUTPUT ERROR + + ### BEGIN - CHECK TO SEE IF SHIFT ENFORCEMENT IS ENABLED AND AGENT IS OUTSIDE OF THEIR SHIFTS, IF SO, OUTPUT ERROR + if ( ( (ereg("START|ALL",$shift_enforcement)) and (!ereg("OFF",$VU_agent_shift_enforcement_override)) ) or (ereg("START|ALL",$VU_agent_shift_enforcement_override)) ) + { + $shift_ok=0; + if ( (strlen($LOGgroup_shiftsSQL) < 3) and ($VU_shift_override_flag < 1) ) + { + $VDloginDISPLAY=1; + $VDdisplayMESSAGE = "ERROR: Det finns inga skift definierade för din användargrupp
"; + } + else + { + $HHMM = date("Hi"); + $wday = date("w"); + + $stmt="SELECT shift_id,shift_start_time,shift_length,shift_weekdays from vicidial_shifts where $LOGgroup_shiftsSQL order by shift_id"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01056',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $shifts_to_print = mysql_num_rows($rslt); + + $o=0; + while ( ($shifts_to_print > $o) and ($shift_ok < 1) ) + { + $rowx=mysql_fetch_row($rslt); + $shift_id = $rowx[0]; + $shift_start_time = $rowx[1]; + $shift_length = $rowx[2]; + $shift_weekdays = $rowx[3]; + + if (eregi("$wday",$shift_weekdays)) + { + $HHshift_length = substr($shift_length,0,2); + $MMshift_length = substr($shift_length,3,2); + $HHshift_start_time = substr($shift_start_time,0,2); + $MMshift_start_time = substr($shift_start_time,2,2); + $HHshift_end_time = ($HHshift_length + $HHshift_start_time); + $MMshift_end_time = ($MMshift_length + $MMshift_start_time); + if ($MMshift_end_time > 59) + { + $MMshift_end_time = ($MMshift_end_time - 60); + $HHshift_end_time++; + } + if ($HHshift_end_time > 23) + {$HHshift_end_time = ($HHshift_end_time - 24);} + $HHshift_end_time = sprintf("%02s", $HHshift_end_time); + $MMshift_end_time = sprintf("%02s", $MMshift_end_time); + $shift_end_time = "$HHshift_end_time$MMshift_end_time"; + + if ( + ( ($HHMM >= $shift_start_time) and ($HHMM < $shift_end_time) ) or + ( ($HHMM < $shift_start_time) and ($HHMM < $shift_end_time) and ($shift_end_time <= $shift_start_time) ) or + ( ($HHMM >= $shift_start_time) and ($HHMM >= $shift_end_time) and ($shift_end_time <= $shift_start_time) ) + ) + {$shift_ok++;} + } + $o++; + } + + if ( ($shift_ok < 1) and ($VU_shift_override_flag < 1) ) + { + $VDloginDISPLAY=1; + $VDdisplayMESSAGE = "ERROR: Du har inte behörighet att logga in utanför ditt skift
"; + } + } + if ( ($shift_ok < 1) and ($VU_shift_override_flag < 1) and ($VDloginDISPLAY > 0) ) + { + $VDdisplayMESSAGE.= "

MANAGER OVERRIDE:
\n"; + $VDdisplayMESSAGE.= "
\n"; + $VDdisplayMESSAGE.= "\n"; + $VDdisplayMESSAGE.= "\n"; + $VDdisplayMESSAGE.= "\n"; + $VDdisplayMESSAGE.= "\n"; + $VDdisplayMESSAGE.= "\n"; + $VDdisplayMESSAGE.= "\n"; + $VDdisplayMESSAGE.= "\n"; + $VDdisplayMESSAGE.= "ManagerLogga in:
\n"; + $VDdisplayMESSAGE.= "ManagerLösenord:
\n"; + $VDdisplayMESSAGE.= "
\n"; + } + } + ### END - CHECK TO SEE IF SHIFT ENFORCEMENT IS ENABLED AND AGENT IS OUTSIDE OF THEIR SHIFTS, IF SO, OUTPUT ERROR + + + + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "vdweb|GOOD|$date|$VD_login|$VD_pass|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + $user_abb = "$VD_login$VD_login$VD_login$VD_login"; + while ( (strlen($user_abb) > 4) and ($forever_stop < 200) ) + {$user_abb = eregi_replace("^.","",$user_abb); $forever_stop++;} + + $stmt="SELECT allowed_campaigns from vicidial_user_groups where user_group='$VU_user_group';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01008',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $LOGallowed_campaigns =$row[0]; + + if ( (!eregi(" $VD_campaign ",$LOGallowed_campaigns)) and (!eregi("ALL-CAMPAIGNS",$LOGallowed_campaigns)) ) + { + echo "Agent web client: Kampanjinloggning\n"; + echo "\n"; + echo "\n"; + echo "Stämpelklocka
\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Svenska
\n"; + echo "Sorry, you are not allowed to login to this campaign: $VD_campaign\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "Logga in: \n
"; + echo "Lösenord:
\n"; + echo "Kampanj: $camp_form_code
\n"; + echo "   \n"; + echo "\n"; + echo "
\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + + ##### check to see that the campaign is active + $stmt="SELECT count(*) FROM vicidial_campaigns where campaign_id='$VD_campaign' and active='Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01009',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $CAMPactive=$row[0]; + if($CAMPactive>0) + { + if ($TEST_all_statuses > 0) {$selectableSQL = '';} + else {$selectableSQL = "selectable='Y' and";} + $VARstatuses=''; + $VARstatusnames=''; + ##### grab the statuses that can be used for dispositioning by an agent + $stmt="SELECT status,status_name FROM vicidial_statuses WHERE $selectableSQL status != 'NEW' order by status limit 50;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01010',$VD_login,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VD_statuses_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $VD_statuses_ct) + { + $row=mysql_fetch_row($rslt); + $statuses[$i] =$row[0]; + $status_names[$i] =$row[1]; + $VARstatuses = "$VARstatuses'$statuses[$i]',"; + $VARstatusnames = "$VARstatusnames'$status_names[$i]',"; + $i++; + } + + ##### grab the campaign-specific statuses that can be used for dispositioning by an agent + $stmt="SELECT status,status_name FROM vicidial_campaign_statuses WHERE $selectableSQL status != 'NEW' and campaign_id='$VD_campaign' order by status limit 80;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01011',$VD_login,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VD_statuses_camp = mysql_num_rows($rslt); + $j=0; + while ($j < $VD_statuses_camp) + { + $row=mysql_fetch_row($rslt); + $statuses[$i] =$row[0]; + $status_names[$i] =$row[1]; + $VARstatuses = "$VARstatuses'$statuses[$i]',"; + $VARstatusnames = "$VARstatusnames'$status_names[$i]',"; + $i++; + $j++; + } + $VD_statuses_ct = ($VD_statuses_ct+$VD_statuses_camp); + $VARstatuses = substr("$VARstatuses", 0, -1); + $VARstatusnames = substr("$VARstatusnames", 0, -1); + + ##### grab the campaign-specific HotKey statuses that can be used for dispositioning by an agent + $stmt="SELECT hotkey,status,status_name FROM vicidial_campaign_hotkeys WHERE selectable='Y' and status != 'NEW' and campaign_id='$VD_campaign' order by hotkey limit 9;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01012',$VD_login,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $HK_statuses_camp = mysql_num_rows($rslt); + $w=0; + $HKboxA=''; + $HKboxB=''; + $HKboxC=''; + while ($w < $HK_statuses_camp) + { + $row=mysql_fetch_row($rslt); + $HKhotkey[$w] =$row[0]; + $HKstatus[$w] =$row[1]; + $HKstatus_name[$w] =$row[2]; + $HKhotkeys = "$HKhotkeys'$HKhotkey[$w]',"; + $HKstatuses = "$HKstatuses'$HKstatus[$w]',"; + $HKstatusnames = "$HKstatusnames'$HKstatus_name[$w]',"; + if ($w < 3) + {$HKboxA = "$HKboxA $HKhotkey[$w] - $HKstatus[$w] - $HKstatus_name[$w]
";} + if ( ($w >= 3) and ($w < 6) ) + {$HKboxB = "$HKboxB $HKhotkey[$w] - $HKstatus[$w] - $HKstatus_name[$w]
";} + if ($w >= 6) + {$HKboxC = "$HKboxC $HKhotkey[$w] - $HKstatus[$w] - $HKstatus_name[$w]
";} + $w++; + } + $HKhotkeys = substr("$HKhotkeys", 0, -1); + $HKstatuses = substr("$HKstatuses", 0, -1); + $HKstatusnames = substr("$HKstatusnames", 0, -1); + + ##### grab the campaign settings + $stmt="SELECT park_ext,park_file_name,web_form_address,allow_closers,auto_dial_level,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc,allcalls_delay,omit_phone_code,agent_pause_codes_active,no_hopper_leads_logins,campaign_allow_inbound,manual_dial_list_id,default_xfer_group,xfer_groups,disable_alter_custphone,display_queue_count,manual_dial_filter,agent_clipboard_copy,use_campaign_dnc,three_way_call_cid,dial_method,three_way_dial_prefix,web_form_target,vtiger_screen_login,agent_allow_group_alias,default_group_alias,quick_transfer_button,prepopulate_transfer_preset,view_calls_in_queue,view_calls_in_queue_launch,call_requeue_button,pause_after_each_call,no_hopper_dialing,agent_dial_owner_only,agent_display_dialable_leads,web_form_address_two,agent_select_territories,crm_popup_login,crm_login_address,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number FROM vicidial_campaigns where campaign_id = '$VD_campaign';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01013',$VD_login,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $park_ext = $row[0]; + $park_file_name = $row[1]; + $web_form_address = stripslashes($row[2]); + $allow_closers = $row[3]; + $auto_dial_level = $row[4]; + $dial_timeout = $row[5]; + $dial_prefix = $row[6]; + $campaign_cid = $row[7]; + $campaign_vdad_exten = $row[8]; + $campaign_rec_exten = $row[9]; + $campaign_recording = $row[10]; + $campaign_rec_filename = $row[11]; + $campaign_script = $row[12]; + $get_call_launch = $row[13]; + $campaign_am_message_exten = '8320'; + $xferconf_a_dtmf = $row[15]; + $xferconf_a_number = $row[16]; + $xferconf_b_dtmf = $row[17]; + $xferconf_b_number = $row[18]; + $alt_number_dialing = $row[19]; + $VC_scheduled_callbacks = $row[20]; + $wrapup_seconds = $row[21]; + $wrapup_message = $row[22]; + $closer_campaigns = $row[23]; + $use_internal_dnc = $row[24]; + $allcalls_delay = $row[25]; + $omit_phone_code = $row[26]; + $agent_pause_codes_active = $row[27]; + $no_hopper_leads_logins = $row[28]; + $campaign_allow_inbound = $row[29]; + $manual_dial_list_id = $row[30]; + $default_xfer_group = $row[31]; + $xfer_groups = $row[32]; + $disable_alter_custphone = $row[33]; + $display_queue_count = $row[34]; + $manual_dial_filter = $row[35]; + $CopY_tO_ClipboarD = $row[36]; + $use_campaign_dnc = $row[37]; + $three_way_call_cid = $row[38]; + $dial_method = $row[39]; + $three_way_dial_prefix = $row[40]; + $web_form_target = $row[41]; + $vtiger_screen_login = $row[42]; + $agent_allow_group_alias = $row[43]; + $default_group_alias = $row[44]; + $quick_transfer_button = $row[45]; + $prepopulate_transfer_preset = $row[46]; + $view_calls_in_queue = $row[47]; + $view_calls_in_queue_launch = $row[48]; + $call_requeue_button = $row[49]; + $pause_after_each_call = $row[50]; + $no_hopper_dialing = $row[51]; + $agent_dial_owner_only = $row[52]; + $agent_display_dialable_leads = $row[53]; + $web_form_address_two = $row[54]; + $agent_select_territories = $row[55]; + $crm_popup_login = $row[56]; + $crm_login_address = $row[57]; + $timer_action = $row[58]; + $timer_action_message = $row[59]; + $timer_action_seconds = $row[60]; + $start_call_url = $row[61]; + $dispo_call_url = $row[62]; + $xferconf_c_number = $row[63]; + $xferconf_d_number = $row[64]; + $xferconf_e_number = $row[65]; + + if ($user_territories_active < 1) + {$agent_select_territories = 0;} + if (preg_match("/Y/",$agent_select_territories)) + {$agent_select_territories=1;} + else + {$agent_select_territories=0;} + + if (preg_match("/Y/",$agent_display_dialable_leads)) + {$agent_display_dialable_leads=1;} + else + {$agent_display_dialable_leads=0;} + + if (preg_match("/Y/",$no_hopper_dialing)) + {$no_hopper_dialing=1;} + else + {$no_hopper_dialing=0;} + + if ( (preg_match("/Y/",$call_requeue_button)) and ($auto_dial_level > 0) ) + {$call_requeue_button=1;} + else + {$call_requeue_button=0;} + + if ( (preg_match("/AUTO/",$view_calls_in_queue_launch)) and ($auto_dial_level > 0) ) + {$view_calls_in_queue_launch=1;} + else + {$view_calls_in_queue_launch=0;} + + if ( (!preg_match("/NONE/",$view_calls_in_queue)) and ($auto_dial_level > 0) ) + {$view_calls_in_queue=1;} + else + {$view_calls_in_queue=0;} + + if (preg_match("/Y/",$pause_after_each_call)) + {$dispo_check_all_pause=1;} + + $quick_transfer_button_enabled=0; + if (preg_match("/IN_GROUP|PRESET_1|PRESET_2|PRESET_3|PRESET_4|PRESET_5/",$quick_transfer_button)) + {$quick_transfer_button_enabled=1;} + + $preset_populate=''; + $prepopulate_transfer_preset_enabled=0; + if (preg_match("/PRESET_1|PRESET_2|PRESET_3|PRESET_4|PRESET_5/",$prepopulate_transfer_preset)) + { + $prepopulate_transfer_preset_enabled=1; + if (preg_match("/PRESET_1/",$prepopulate_transfer_preset)) + {$preset_populate = $xferconf_a_number;} + if (preg_match("/PRESET_2/",$prepopulate_transfer_preset)) + {$preset_populate = $xferconf_b_number;} + if (preg_match("/PRESET_3/",$prepopulate_transfer_preset)) + {$preset_populate = $xferconf_c_number;} + if (preg_match("/PRESET_4/",$prepopulate_transfer_preset)) + {$preset_populate = $xferconf_d_number;} + if (preg_match("/PRESET_5/",$prepopulate_transfer_preset)) + {$preset_populate = $xferconf_e_number;} + } + + $default_group_alias_cid=''; + if (strlen($default_group_alias)>1) + { + $stmt = "select caller_id_number from groups_alias where group_alias_id='$default_group_alias';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01055',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $VDIG_cidnum_ct = mysql_num_rows($rslt); + if ($VDIG_cidnum_ct > 0) + { + $row=mysql_fetch_row($rslt); + $default_group_alias_cid = $row[0]; + } + } + + $stmt = "select group_web_vars from vicidial_campaign_agents where campaign_id='$VD_campaign' and user='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01056',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $VDIG_cidogwv = mysql_num_rows($rslt); + if ($VDIG_cidogwv > 0) + { + $row=mysql_fetch_row($rslt); + $default_web_vars = $row[0]; + } + + if ( (!ereg('DISABLED',$VU_vicidial_recording_override)) and ($VU_vicidial_recording > 0) ) + { + $campaign_recording = $VU_vicidial_recording_override; + echo "\n"; + } + if ( ($VC_scheduled_callbacks=='Y') and ($VU_scheduled_callbacks=='1') ) + {$scheduled_callbacks='1';} + if ($VU_vicidial_recording=='0') + {$campaign_recording='NEVER';} + if ($VU_alter_custphone_override=='ALLOW_ALTER') + {$disable_alter_custphone='N';} + if (strlen($three_way_dial_prefix) < 1) + {$three_way_dial_prefix = $dial_prefix ;} + if ($alt_number_dialing=='Y') + {$alt_phone_dialing='1';} + else + { + $alt_phone_dialing='0'; + $DefaulTAlTDiaL='0'; + } + if ($display_queue_count=='N') + {$callholdstatus='0';} + if ( ($dial_method == 'INBOUND_MAN') or ($outbound_autodial_active < 1) ) + {$VU_closer_default_blended=0;} + + $closer_campaigns = preg_replace("/^ | -$/","",$closer_campaigns); + $closer_campaigns = preg_replace("/ /","','",$closer_campaigns); + $closer_campaigns = "'$closer_campaigns'"; + + if ( (ereg('Y',$agent_pause_codes_active)) or (ereg('FORCE',$agent_pause_codes_active)) ) + { + ##### grab the pause codes for this campaign + $stmt="SELECT pause_code,pause_code_name FROM vicidial_pause_codes WHERE campaign_id='$VD_campaign' order by pause_code limit 50;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01014',$VD_login,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VD_pause_codes = mysql_num_rows($rslt); + $j=0; + while ($j < $VD_pause_codes) + { + $row=mysql_fetch_row($rslt); + $pause_codes[$i] =$row[0]; + $pause_code_names[$i] =$row[1]; + $VARpause_codes = "$VARpause_codes'$pause_codes[$i]',"; + $VARpause_code_names = "$VARpause_code_names'$pause_code_names[$i]',"; + $i++; + $j++; + } + $VD_pause_codes_ct = ($VD_pause_codes_ct+$VD_pause_codes); + $VARpause_codes = substr("$VARpause_codes", 0, -1); + $VARpause_code_names = substr("$VARpause_code_names", 0, -1); + } + + ##### grab the inbound groups to choose from if campaign contains CLOSER + $VARingroups="''"; + if ( ($campaign_allow_inbound == 'Y') and ($dial_method != 'MANUAL') ) + { + $VARingroups=''; + $stmt="select group_id from vicidial_inbound_groups where active = 'Y' and group_id IN($closer_campaigns) order by group_id limit 600;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01015',$VD_login,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $closer_ct = mysql_num_rows($rslt); + $INgrpCT=0; + while ($INgrpCT < $closer_ct) + { + $row=mysql_fetch_row($rslt); + $closer_groups[$INgrpCT] =$row[0]; + $VARingroups = "$VARingroups'$closer_groups[$INgrpCT]',"; + $INgrpCT++; + } + $VARingroups = substr("$VARingroups", 0, -1); + } + else + {$closer_campaigns = "''";} + + ##### gather territory listings for this agent if select territories is enabled + $VARterritories=''; + if ($agent_select_territories > 0) + { + $stmt="SELECT territory from vicidial_user_territories where user='$VD_login';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01062',$VD_login,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $territory_ct = mysql_num_rows($rslt); + $territoryCT=0; + while ($territoryCT < $territory_ct) + { + $row=mysql_fetch_row($rslt); + $territories[$territoryCT] =$row[0]; + $VARterritories = "$VARterritories'$territories[$territoryCT]',"; + $territoryCT++; + } + $VARterritories = substr("$VARterritories", 0, -1); + echo "\n"; + } + + ##### grab the allowable inbound groups to choose from for transfer options + $xfer_groups = preg_replace("/^ | -$/","",$xfer_groups); + $xfer_groups = preg_replace("/ /","','",$xfer_groups); + $xfer_groups = "'$xfer_groups'"; + $VARxfergroups="''"; + if ($allow_closers == 'Y') + { + $VARxfergroups=''; + $stmt="select group_id,group_name from vicidial_inbound_groups where active = 'Y' and group_id IN($xfer_groups) order by group_id limit 600;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01016',$VD_login,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $xfer_ct = mysql_num_rows($rslt); + $XFgrpCT=0; + while ($XFgrpCT < $xfer_ct) + { + $row=mysql_fetch_row($rslt); + $VARxfergroups = "$VARxfergroups'$row[0]',"; + $VARxfergroupsnames = "$VARxfergroupsnames'$row[1]',"; + if ($row[0] == "$default_xfer_group") {$default_xfer_group_name = $row[1];} + $XFgrpCT++; + } + $VARxfergroups = substr("$VARxfergroups", 0, -1); + $VARxfergroupsnames = substr("$VARxfergroupsnames", 0, -1); + } + + if (ereg('Y',$agent_allow_group_alias)) + { + ##### grab the active group aliases + $stmt="SELECT group_alias_id,group_alias_name,caller_id_number FROM groups_alias WHERE active='Y' order by group_alias_id limit 1000;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01054',$VD_login,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VD_group_aliases = mysql_num_rows($rslt); + $j=0; + while ($j < $VD_group_aliases) + { + $row=mysql_fetch_row($rslt); + $group_alias_id[$i] = $row[0]; + $group_alias_name[$i] = $row[1]; + $caller_id_number[$i] = $row[2]; + $VARgroup_alias_ids = "$VARgroup_alias_ids'$group_alias_id[$i]',"; + $VARgroup_alias_names = "$VARgroup_alias_names'$group_alias_name[$i]',"; + $VARcaller_id_numbers = "$VARcaller_id_numbers'$caller_id_number[$i]',"; + $i++; + $j++; + } + $VD_group_aliases_ct = ($VD_group_aliases_ct+$VD_group_aliases); + $VARgroup_alias_ids = substr("$VARgroup_alias_ids", 0, -1); + $VARgroup_alias_names = substr("$VARgroup_alias_names", 0, -1); + $VARcaller_id_numbers = substr("$VARcaller_id_numbers", 0, -1); + } + + ##### grab the number of leads in the hopper for this campaign + $stmt="SELECT count(*) FROM vicidial_hopper where campaign_id = '$VD_campaign' and status='READY';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01017',$VD_login,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $campaign_leads_to_call = $row[0]; + echo "\n"; + + } + else + { + $VDloginDISPLAY=1; + $VDdisplayMESSAGE = "Kampanjen är ej aktiv, vänligen försök igen
"; + } + } + else + { + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "vdweb|FAIL|$date|$VD_login|$VD_pass|$ip|$browser|\n"); + fclose($fp); + } + $VDloginDISPLAY=1; + $VDdisplayMESSAGE = "Inloggningsuppgifterna är felaktiga, vänligen försök igen
"; + } + } + if ($VDloginDISPLAY) + { + echo "Agent web client: Kampanjinloggning\n"; + echo "\n"; + echo "\n"; + echo "Stämpelklocka
\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Svenska
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "

$VDdisplayMESSAGE

"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Kampanjinloggning
 
Användare:
Lösenord:
Kampanj: $camp_form_code
  \n"; + echo "

VERSION: $version       SKAPA: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + +$original_phone_login = $phone_login; + +# code for parsing load-balanced agent phone allocation where agent interface +# will send multiple phones-table logins so that the script can determine the +# server that has the fewest agents logged into it. +# login: ca101,cb101,cc101 + $alias_found=0; +$stmt="select count(*) from phones_alias where alias_id = '$phone_login';"; +$rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01018',$VD_login,$server_ip,$session_name,$one_mysql_log);} +$alias_ct = mysql_num_rows($rslt); +if ($alias_ct > 0) + { + $row=mysql_fetch_row($rslt); + $alias_found = "$row[0]"; + } +if ($alias_found > 0) + { + $stmt="select alias_name,logins_list from phones_alias where alias_id = '$phone_login' limit 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01019',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $alias_ct = mysql_num_rows($rslt); + if ($alias_ct > 0) + { + $row=mysql_fetch_row($rslt); + $alias_name = "$row[0]"; + $phone_login = "$row[1]"; + } + } + +$pa=0; +if ( (eregi(',',$phone_login)) and (strlen($phone_login) > 2) ) + { + $phoneSQL = "("; + $phones_auto = explode(',',$phone_login); + $phones_auto_ct = count($phones_auto); + while($pa < $phones_auto_ct) + { + if ($pa > 0) + {$phoneSQL .= " or ";} + $desc = ($phones_auto_ct - $pa); # traverse in reverse order + $phoneSQL .= "(login='$phones_auto[$desc]' and pass='$phone_pass')"; + $pa++; + } + $phoneSQL .= ")"; + } +else {$phoneSQL = "login='$phone_login' and pass='$phone_pass'";} + +$authphone=0; +#$stmt="SELECT count(*) from phones where $phoneSQL and active = 'Y';"; +$stmt="SELECT count(*) from phones,servers where $phoneSQL and phones.active = 'Y' and active_agent_login_server='Y' and phones.server_ip=servers.server_ip;"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01020',$VD_login,$server_ip,$session_name,$one_mysql_log);} +$row=mysql_fetch_row($rslt); +$authphone=$row[0]; +if (!$authphone) + { + echo "Agent web client: Telefonlogin Error\n"; + echo "\n"; + echo "\n"; + echo "Stämpelklocka
\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Svenska
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Logga in Error
 
Tyvärr är din telefons inloggningsuppgifter inte aktiva I detta system, vänligen försök igen:
 
Telefonlogin:
Telefonlösenord:

VERSION: $version       SKAPA: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } +else + { +### go through the entered phones to figure out which server has fewest agents +### logged in and use that phone login account + if ($pa > 0) + { + $pb=0; + $pb_login=''; + $pb_server_ip=''; + $pb_count=0; + $pb_log=''; + while($pb < $phones_auto_ct) + { + ### find the server_ip of each phone_login + $stmtx="SELECT server_ip from phones where login = '$phones_auto[$pb]';"; + if ($DB) {echo "|$stmtx|\n";} + if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");} + $rslt=mysql_query($stmtx, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01021',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $rowx=mysql_fetch_row($rslt); + + ### get number of agents logged in to each server + $stmt="SELECT count(*) from vicidial_live_agents where server_ip = '$rowx[0]';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01022',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + + ### find out whether the server is set to active + $stmt="SELECT count(*) from servers where server_ip = '$rowx[0]' and active='Y' and active_agent_login_server='Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01023',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $rowy=mysql_fetch_row($rslt); + + ### find out whether the server_updater is running + $stmt="SELECT count(*) from server_updater where server_ip = '$rowx[0]' and last_update > '$past_minutes_date';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01024',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $rowz=mysql_fetch_row($rslt); + + $pb_log .= "$phones_auto[$pb]|$rowx[0]|$row[0]|$rowy[0]|$rowz[0]| "; + + if ( ($rowy[0] > 0) && ($rowz[0] > 0) ) + { + if ( ($pb_count >= $row[0]) || (strlen($pb_server_ip) < 4) ) + { + $pb_count=$row[0]; + $pb_server_ip=$rowx[0]; + $phone_login=$phones_auto[$pb]; + } + } + $pb++; + } + echo "\n"; + } + echo "Agent web client\n"; + $stmt="SELECT extension,dialplan_number,voicemail_id,phone_ip,computer_ip,server_ip,login,pass,status,active,phone_type,fullname,company,picture,messages,old_messages,protocol,local_gmt,ASTmgrUSERNAME,ASTmgrSECRET,login_user,login_pass,login_campaign,park_on_extension,conf_on_extension,VICIDIAL_park_on_extension,VICIDIAL_park_on_filename,monitor_prefix,recording_exten,voicemail_exten,voicemail_dump_exten,ext_context,dtmf_send_extension,call_out_number_group,client_browser,install_directory,local_web_callerID_URL,VICIDIAL_web_URL,AGI_call_logging_enabled,user_switching_enabled,conferencing_enabled,admin_hangup_enabled,admin_hijack_enabled,admin_monitor_enabled,call_parking_enabled,updater_check_enabled,AFLogging_enabled,QUEUE_ACTION_enabled,CallerID_popup_enabled,voicemail_button_enabled,enable_fast_refresh,fast_refresh_rate,enable_persistant_mysql,auto_dial_next_number,VDstop_rec_after_each_call,DBX_server,DBX_database,DBX_user,DBX_pass,DBX_port,DBY_server,DBY_database,DBY_user,DBY_pass,DBY_port,outbound_cid,enable_sipsak_messages,email,template_id,conf_override,phone_context,phone_ring_timeout,conf_secret from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01025',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $extension=$row[0]; + $dialplan_number=$row[1]; + $voicemail_id=$row[2]; + $phone_ip=$row[3]; + $computer_ip=$row[4]; + $server_ip=$row[5]; + $login=$row[6]; + $pass=$row[7]; + $status=$row[8]; + $active=$row[9]; + $phone_type=$row[10]; + $fullname=$row[11]; + $company=$row[12]; + $picture=$row[13]; + $messages=$row[14]; + $old_messages=$row[15]; + $protocol=$row[16]; + $local_gmt=$row[17]; + $ASTmgrUSERNAME=$row[18]; + $ASTmgrSECRET=$row[19]; + $login_user=$row[20]; + $login_pass=$row[21]; + $login_campaign=$row[22]; + $park_on_extension=$row[23]; + $conf_on_extension=$row[24]; + $VICIDiaL_park_on_extension=$row[25]; + $VICIDiaL_park_on_filename=$row[26]; + $monitor_prefix=$row[27]; + $recording_exten=$row[28]; + $voicemail_exten=$row[29]; + $voicemail_dump_exten=$row[30]; + $ext_context=$row[31]; + $dtmf_send_extension=$row[32]; + $call_out_number_group=$row[33]; + $client_browser=$row[34]; + $install_directory=$row[35]; + $local_web_callerID_URL=$row[36]; + $VICIDiaL_web_URL=$row[37]; + $AGI_call_logging_enabled=$row[38]; + $user_switching_enabled=$row[39]; + $conferencing_enabled=$row[40]; + $admin_hangup_enabled=$row[41]; + $admin_hijack_enabled=$row[42]; + $admin_monitor_enabled=$row[43]; + $call_parking_enabled=$row[44]; + $updater_check_enabled=$row[45]; + $AFLogging_enabled=$row[46]; + $QUEUE_ACTION_enabled=$row[47]; + $CallerID_popup_enabled=$row[48]; + $voicemail_button_enabled=$row[49]; + $enable_fast_refresh=$row[50]; + $fast_refresh_rate=$row[51]; + $enable_persistant_mysql=$row[52]; + $auto_dial_next_number=$row[53]; + $VDstop_rec_after_each_call=$row[54]; + $DBX_server=$row[55]; + $DBX_database=$row[56]; + $DBX_user=$row[57]; + $DBX_pass=$row[58]; + $DBX_port=$row[59]; + $outbound_cid=$row[65]; + $enable_sipsak_messages=$row[66]; + + $no_empty_session_warnings=0; + if ($phone_login == 'nophone') + { + $no_empty_session_warnings=1; + } + if ($PhonESComPIP == '1') + { + if (strlen($computer_ip) < 4) + { + $stmt="UPDATE phones SET computer_ip='$ip' where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01026',$VD_login,$server_ip,$session_name,$one_mysql_log);} + } + } + if ($PhonESComPIP == '2') + { + $stmt="UPDATE phones SET computer_ip='$ip' where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01027',$VD_login,$server_ip,$session_name,$one_mysql_log);} + } + if ($clientDST) + { + $local_gmt = ($local_gmt + $isdst); + } + if ($protocol == 'EXTERNAL') + { + $protocol = 'Local'; + $extension = "$dialplan_number$AT$ext_context"; + } + $SIP_user = "$protocol/$extension"; + $SIP_user_DiaL = "$protocol/$extension"; + if ( (ereg('8300',$dialplan_number)) and (strlen($dialplan_number)<5) and ($protocol == 'Local') ) + { + $SIP_user = "$protocol/$extension$VD_login"; + } + + $stmt="SELECT asterisk_version from servers where server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01028',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $asterisk_version=$row[0]; + + # If a park extension is not set, use the default one + if ( (strlen($park_ext)>0) && (strlen($park_file_name)>0) ) + { + $VICIDiaL_park_on_extension = "$park_ext"; + $VICIDiaL_park_on_filename = "$park_file_name"; + echo "\n"; + } + echo "\n"; + + # If a web form address is not set, use the default one + if (strlen($web_form_address)>0) + { + $VICIDiaL_web_form_address = "$web_form_address"; + echo "\n"; + } + else + { + $VICIDiaL_web_form_address = "$VICIDiaL_web_URL"; + print "\n"; + $VICIDiaL_web_form_address_enc = rawurlencode($VICIDiaL_web_form_address); + } + $VICIDiaL_web_form_address_enc = rawurlencode($VICIDiaL_web_form_address); + + # If a web form address two is not set, use the first one + if (strlen($web_form_address_two)>0) + { + $VICIDiaL_web_form_address_two = "$web_form_address_two"; + echo "\n"; + } + else + { + $VICIDiaL_web_form_address_two = "$VICIDiaL_web_form_address"; + echo "\n"; + $VICIDiaL_web_form_address_two_enc = rawurlencode($VICIDiaL_web_form_address_two); + } + $VICIDiaL_web_form_address_two_enc = rawurlencode($VICIDiaL_web_form_address_two); + + # If closers are allowed på this campaign + if ($allow_closers=="Y") + { + $VICIDiaL_allow_closers = 1; + echo "\n"; + } + else + { + $VICIDiaL_allow_closers = 0; + echo "\n"; + } + + + $session_ext = eregi_replace("[^a-z0-9]", "", $extension); + if (strlen($session_ext) > 10) {$session_ext = substr($session_ext, 0, 10);} + $session_rand = (rand(1,9999999) + 10000000); + $session_name = "$StarTtimE$US$session_ext$session_rand"; + + if ($webform_sessionname) + {$webform_sessionname = "&session_name=$session_name";} + else + {$webform_sessionname = '';} + + $stmt="DELETE from web_client_sessions where start_time < '$past_month_date' and extension='$extension' and server_ip = '$server_ip' and program = 'vicidial';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01029',$VD_login,$server_ip,$session_name,$one_mysql_log);} + + $stmt="INSERT INTO web_client_sessions values('$extension','$server_ip','vicidial','$NOW_TIME','$session_name');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01030',$VD_login,$server_ip,$session_name,$one_mysql_log);} + + if ( ( ($campaign_allow_inbound == 'Y') and ($dial_method != 'MANUAL') ) || ($campaign_leads_to_call > 0) || (ereg('Y',$no_hopper_leads_logins)) ) + { + ### insert an entry into the user log for the login event + $stmt = "INSERT INTO vicidial_user_log (user,event,campaign_id,event_date,event_epoch,user_group) values('$VD_login','LOGIN','$VD_campaign','$NOW_TIME','$StarTtimE','$VU_user_group')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01031',$VD_login,$server_ip,$session_name,$one_mysql_log);} + + ##### check to see if the user has a conf extension already, this happens if they previously exited uncleanly + $stmt="SELECT conf_exten FROM vicidial_conferences where extension='$SIP_user' and server_ip = '$server_ip' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01032',$VD_login,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $prev_login_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $prev_login_ct) + { + $row=mysql_fetch_row($rslt); + $session_id =$row[0]; + $i++; + } + if ($prev_login_ct > 0) + {echo "\n";} + else + { + ##### grab the next available vicidial_conference room and reserve it + $stmt="SELECT count(*) FROM vicidial_conferences where server_ip='$server_ip' and ((extension='') or (extension is null));"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01033',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + { + $stmt="UPDATE vicidial_conferences set extension='$SIP_user', leave_3way='0' where server_ip='$server_ip' and ((extension='') or (extension is null)) limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01034',$VD_login,$server_ip,$session_name,$one_mysql_log);} + + $stmt="SELECT conf_exten from vicidial_conferences where server_ip='$server_ip' and ( (extension='$SIP_user') or (extension='$VD_login') );"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01035',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $session_id = $row[0]; + } + echo "\n"; + } + + ### mark leads that were not dispositioned during previous calls as ERI + $stmt="UPDATE vicidial_list set status='ERI', user='' where status IN('QUEUE','INCALL') and user ='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01036',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + echo "\n"; + + $stmt="DELETE from vicidial_hopper where status IN('QUEUE','INCALL','DONE') and user ='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01037',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + echo "\n"; + + $stmt="DELETE from vicidial_live_agents where user ='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01038',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + echo "\n"; + + $stmt="DELETE from vicidial_live_inbound_agents where user ='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01039',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + echo "\n"; + + # echo "You have logged in as user: $VD_login på phone: $SIP_user till kampanj: $VD_campaign
\n"; + $VICIDiaL_is_logged_in=1; + + ### set the callerID for manager middleware-app to connect the phone to the user + $SIqueryCID = "S$CIDdate$session_id"; + + ############################################# + ##### START SYSTEM_SETTINGS LOOKUP ##### + $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id,vicidial_agent_disable,allow_sipsak_messages FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01040',$VD_login,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $qm_conf_ct = mysql_num_rows($rslt); + if ($qm_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $enable_queuemetrics_logging = $row[0]; + $queuemetrics_server_ip = $row[1]; + $queuemetrics_dbname = $row[2]; + $queuemetrics_login = $row[3]; + $queuemetrics_pass = $row[4]; + $queuemetrics_log_id = $row[5]; + $vicidial_agent_disable = $row[6]; + $allow_sipsak_messages = $row[7]; + } + ##### END QUEUEMETRICS LOGGING LOOKUP ##### + ########################################### + + if ( ($enable_sipsak_messages > 0) and ($allow_sipsak_messages > 0) and (eregi("SIP",$protocol)) ) + { + $SIPSAK_prefix = 'LIN-'; + echo "\n"; + passthru("/usr/local/bin/sipsak -M -O desktop -B \"$SIPSAK_prefix$VD_campaign\" -r 5060 -s sip:$extension@$phone_ip > /dev/null"); + $SIqueryCID = "$SIPSAK_prefix$VD_campaign$DS$CIDdate"; + } + + ### insert a NY record to the vicidial_manager table to be processed + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$SIqueryCID','Channel: $SIP_user_DiaL','Context: $ext_context','Exten: $session_id','Priority: 1','Callerid: \"$SIqueryCID\" <$campaign_cid>','','','','','');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01041',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + echo "\n"; + + ##### grab the campaign_weight and number of calls today på that campaign for the agent + $stmt="SELECT campaign_weight,calls_today FROM vicidial_campaign_agents where user='$VD_login' and campaign_id = '$VD_campaign';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01042',$VD_login,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $vca_ct = mysql_num_rows($rslt); + if ($vca_ct > 0) + { + $row=mysql_fetch_row($rslt); + $campaign_weight = $row[0]; + $calls_today = $row[1]; + $i++; + } + else + { + $campaign_weight = '0'; + $calls_today = '0'; + $stmt="INSERT INTO vicidial_campaign_agents (user,campaign_id,campaign_rank,campaign_weight,calls_today) values('$VD_login','$VD_campaign','0','0','$calls_today');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01043',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + echo "\n"; + } + + if ($auto_dial_level > 0) + { + echo "\n"; + + + $closer_chooser_string=''; + $stmt="INSERT INTO vicidial_live_agents (user,server_ip,conf_exten,extension,status,lead_id,campaign_id,uniqueid,callerid,channel,random_id,last_call_time,last_update_time,last_call_finish,closer_campaigns,user_level,campaign_weight,calls_today,last_state_change,outbound_autodial,manager_ingroup_set) values('$VD_login','$server_ip','$session_id','$SIP_user','PAUSED','','$VD_campaign','','','','$random','$NOW_TIME','$tsNOW_TIME','$NOW_TIME','$closer_chooser_string','$user_level','$campaign_weight','$calls_today','$NOW_TIME','Y','N');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01044',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + echo "\n"; + + if ($enable_queuemetrics_logging > 0) + { + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); + mysql_select_db("$queuemetrics_dbname", $linkB); + + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtimE',call_id='NONE',queue='NONE',agent='Agent/$VD_login',verb='AGENTLOGIN',data1='$VD_login@agents',serverid='$queuemetrics_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'01045',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + echo "\n"; + + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtimE',call_id='NONE',queue='NONE',agent='Agent/$VD_login',verb='PAUSEALL',serverid='$queuemetrics_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'01046',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + echo "\n"; + + mysql_close($linkB); + mysql_select_db("$VARDB_database", $link); + } + + + if ( ($campaign_allow_inbound == 'Y') and ($dial_method != 'MANUAL') ) + { + print "\n"; + } + } + else + { + print "\n"; + + $stmt="INSERT INTO vicidial_live_agents (user,server_ip,conf_exten,extension,status,lead_id,campaign_id,uniqueid,callerid,channel,random_id,last_call_time,last_update_time,last_call_finish,user_level,campaign_weight,calls_today,last_state_change,outbound_autodial,manager_ingroup_set) values('$VD_login','$server_ip','$session_id','$SIP_user','PAUSED','','$VD_campaign','','','','$random','$NOW_TIME','$tsNOW_TIME','$NOW_TIME','$user_level', '$campaign_weight', '$calls_today','$NOW_TIME','N','N');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01047',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + echo "\n"; + + if ($enable_queuemetrics_logging > 0) + { + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); + mysql_select_db("$queuemetrics_dbname", $linkB); + + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtimE',call_id='NONE',queue='$VD_campaign',agent='Agent/$VD_login',verb='AGENTLOGIN',data1='$VD_login@agents',serverid='$queuemetrics_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'01048',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + echo "\n"; + + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtimE',call_id='NONE',queue='NONE',agent='Agent/$VD_login',verb='PAUSEALL',serverid='$queuemetrics_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'01049',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + echo "\n"; + + mysql_close($linkB); + mysql_select_db("$VARDB_database", $link); + } + } + } + else + { + echo "Agent web client: Kampanjinloggning\n"; + echo "\n"; + echo "\n"; + echo "Stämpelklocka
\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Svenska
\n"; + echo "Tyvärr finns det inga leads i hoppern för denna kampanj\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "Logga in: \n
"; + echo "Lösenord:
\n"; + echo "Kampanj: $camp_form_code
\n"; + echo "   \n"; + echo "\n"; + echo "
\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + if (strlen($session_id) < 1) + { + echo "Agent web client: Kampanjinloggning\n"; + echo "\n"; + echo "\n"; + echo "Stämpelklocka
\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Svenska
\n"; + echo "Sorry, there are no available sessions\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "Logga in: \n
"; + echo "Lösenord:
\n"; + echo "Kampanj: $camp_form_code
\n"; + echo "   \n"; + echo "\n"; + echo "
\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + + if (ereg('MSIE',$browser)) + { + $useIE=1; + echo "\n"; + } + else + { + $useIE=0; + echo "\n"; + } + + $StarTtimE = date("U"); + $NOW_TIME = date("Y-m-d H:i:s"); + ##### Agent is going to log in so insert the vicidial_agent_log entry now + $stmt="INSERT INTO vicidial_agent_log (user,server_ip,event_time,campaign_id,pause_epoch,pause_sec,wait_epoch,user_group,sub_status) values('$VD_login','$server_ip','$NOW_TIME','$VD_campaign','$StarTtimE','0','$StarTtimE','$VU_user_group','LOGIN');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01050',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + $agent_log_id = mysql_insert_id($link); + echo "\n"; + + ##### update vicidial_campaigns to show agent has logged in + $stmt="UPDATE vicidial_campaigns set campaign_logindate='$NOW_TIME' where campaign_id='$VD_campaign';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01064',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $VCaffected_rows = mysql_affected_rows($link); + echo "\n"; + + if ($enable_queuemetrics_logging > 0) + { + $StarTtimEpause = ($StarTtimE + 1); + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); + mysql_select_db("$queuemetrics_dbname", $linkB); + + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtimEpause',call_id='NONE',queue='NONE',agent='Agent/$VD_login',verb='PAUSEREASON',data1='LOGIN',serverid='$queuemetrics_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'01063',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + echo "\n"; + + mysql_close($linkB); + mysql_select_db("$VARDB_database", $link); + } + + $stmt="UPDATE vicidial_live_agents SET agent_log_id='$agent_log_id' where user='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01061',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $VLAaffected_rows_update = mysql_affected_rows($link); + + $stmt="UPDATE vicidial_users SET shift_override_flag='0' where user='$VD_login' and shift_override_flag='1';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01057',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $VUaffected_rows = mysql_affected_rows($link); + + $S='*'; + $D_s_ip = explode('.', $server_ip); + if (strlen($D_s_ip[0])<2) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[0])<3) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[1])<2) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[1])<3) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[2])<2) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[2])<3) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[3])<2) {$D_s_ip[3] = "0$D_s_ip[3]";} + if (strlen($D_s_ip[3])<3) {$D_s_ip[3] = "0$D_s_ip[3]";} + $server_ip_dialstring = "$D_s_ip[0]$S$D_s_ip[1]$S$D_s_ip[2]$S$D_s_ip[3]$S"; + + ##### grab the datails of all active scripts in the system + $stmt="SELECT script_id,script_name FROM vicidial_scripts WHERE active='Y' order by script_id limit 1000;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01051',$VD_login,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $MM_scripts = mysql_num_rows($rslt); + $e=0; + while ($e < $MM_scripts) + { + $row=mysql_fetch_row($rslt); + $MMscriptid[$e] =$row[0]; + $MMscriptname[$e] = urlencode($row[1]); + $MMscriptids = "$MMscriptids'$MMscriptid[$e]',"; + $MMscriptnames = "$MMscriptnames'$MMscriptname[$e]',"; + $e++; + } + $MMscriptids = substr("$MMscriptids", 0, -1); + $MMscriptnames = substr("$MMscriptnames", 0, -1); + } +} + + +### SCREEN WIDTH AND HEIGHT CALCULATIONS ### +### DO NOT EDIT! ### +if ($stretch_dimensions > 0) + { + if ($agent_status_view < 1) + { + if ($JS_browser_width >= 510) + {$BROWSER_WIDTH = ($JS_browser_width - 80);} + } + else + { + if ($JS_browser_width >= 730) + {$BROWSER_WIDTH = ($JS_browser_width - 300);} + } + if ($JS_browser_height >= 340) + {$BROWSER_HEIGHT = ($JS_browser_height - 40);} + } +$MASTERwidth=($BROWSER_WIDTH - 340); +$MASTERheight=($BROWSER_HEIGHT - 200); +if ($MASTERwidth < 430) {$MASTERwidth = '430';} +if ($MASTERheight < 300) {$MASTERheight = '300';} + +$CAwidth = ($MASTERwidth + 340); # 770 - cover all (none-in-session, customer hunngup, etc...) +$SBwidth = ($MASTERwidth + 331); # 761 - SideBar starting point +$MNwidth = ($MASTERwidth + 330); # 760 - main frame +$XFwidth = ($MASTERwidth + 320); # 750 - transfer/conference +$HCwidth = ($MASTERwidth + 310); # 740 - hotkeys and callbacks +$CQwidth = ($MASTERwidth + 300); # 730 - calls in queue listings +$AMwidth = ($MASTERwidth + 270); # 700 - preset-dial links +$SCwidth = ($MASTERwidth + 230); # 670 - live call sekunder counter, sidebar link +$MUwidth = ($MASTERwidth + 180); # 610 - agent mute +$SSwidth = ($MASTERwidth + 176); # 606 - scroll script +$SDwidth = ($MASTERwidth + 170); # 600 - scroll script, customer data and calls-in-session +$HKwidth = ($MASTERwidth + 20); # 450 - Hotkeys button +$HSwidth = ($MASTERwidth + 1); # 431 - Header spacer +$CLwidth = ($MASTERwidth - 160); # 270 - Calls in queue link + +$WRheight = ($MASTERheight + 160); # 460 - Warning boxes +$CQheight = ($MASTERheight + 140); # 440 - Calls in queue section +$SLheight = ($MASTERheight + 122); # 422 - SideBar link, Calls in queue link +$HKheight = ($MASTERheight + 105); # 405 - HotKey active Button +$AMheight = ($MASTERheight + 100); # 400 - Agent mute and preset dial links +$MBheight = ($MASTERheight + 65); # 365 - Manual Dial Buttons +$CBheight = ($MASTERheight + 50); # 350 - Agent Callback, pause code, volume control Buttons and agent status +$SSheight = ($MASTERheight + 31); # 331 - script content +$HTheight = ($MASTERheight + 10); # 310 - transfer frame, callback comments and hotkey +$BPheight = ($MASTERheight - 250); # 50 - bottom buffer, Agent Xfer Span + + +################################################################ +### BEGIN - build the callback calendar (12 months) ### +################################################################ +define ('ADAY', (60*60*24)); +$CdayARY = getdate(); +$Cmon = $CdayARY['mon']; +$Cyear = $CdayARY['year']; +$CTODAY = date("Y-m"); +$CTODAYmday = date("j"); +$CINC=0; + +$Cmonths = Array('Januari','February','Mars','April','Maj','Juni', + 'Juli','Augusti','September','Oktober','November','December'); +$Cdays = Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat'); + +$CCAL_OUT = ''; + +$CCAL_OUT .= ""; + +while ($CINC < 12) +{ +if ( ($CINC == 0) || ($CINC == 4) ||($CINC == 8) ) + {$CCAL_OUT .= "";} + +$CCAL_OUT .= ""; + +if ( ($CINC == 3) || ($CINC == 7) ||($CINC == 11) ) + {$CCAL_OUT .= "";} +$CINC++; +} + +$CCAL_OUT .= "
"; + +$CYyear = $Cyear; +$Cmonth= ($Cmon + $CINC); +if ($Cmonth > 12) + { + $Cmonth = ($Cmonth - 12); + $CYyear++; + } +$Cstart= mktime(11,0,0,$Cmonth,1,$CYyear); +$CfirstdayARY = getdate($Cstart); +#echo "|$Cmon|$Cmonth|$CINC|\n"; +$CPRNTDAY = date("Y-m", $Cstart); + +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; + +foreach($Cdays as $Cday) +{ + $CDCLR="#ffffff"; +$CCAL_OUT .= ""; +} + +for( $Ccount=0;$Ccount<(6*7);$Ccount++) +{ + $Cdayarray = getdate($Cstart); + if((($Ccount) % 7) == 0) + { + if($Cdayarray['mon'] != $CfirstdayARY['mon']) + break; + $CCAL_OUT .= ""; + } + if($Ccount < $CfirstdayARY['wday'] || $Cdayarray['mon'] != $Cmonth) + { + $CCAL_OUT .= ""; + } + else + { + if( ($Cdayarray['mday'] == $CTODAYmday) and ($CPRNTDAY == $CTODAY) ) + { + $CPRNTmday = $Cdayarray['mday']; + if ($CPRNTmday < 10) {$CPRNTmday = "0$CPRNTmday";} + $CBL = ""; + $CEL = ""; + + $CCAL_OUT .= ""; + $Cstart += ADAY; + } + else + { + $CDCLR="#ffffff"; + if ( ($Cdayarray['mday'] < $CTODAYmday) and ($CPRNTDAY == $CTODAY) ) + { + $CDCLR="$MAIN_COLOR"; + $CBL = ''; + $CEL = ''; + } + else + { + $CPRNTmday = $Cdayarray['mday']; + if ($CPRNTmday < 10) {$CPRNTmday = "0$CPRNTmday";} + $CBL = ""; + $CEL = ""; + } + + $CCAL_OUT .= ""; + $Cstart += ADAY; + } + } +} +$CCAL_OUT .= ""; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "$CfirstdayARY[month] $CfirstdayARY[year]"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "$Cday"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
 "; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "$CBL$Cdayarray[mday]$CEL"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "$CBL$Cdayarray[mday]$CEL"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; + +#echo "$CCAL_OUT\n"; +################################################################ +### END - build the callback calendar (12 months) ### +################################################################ + + +?> + + + + +\n"; + + +?> + +
+ + MARGINWIDTH=0 MARGINHEIGHT=0 LEFTMARGIN=0 TOPMARGIN=0 VALIGN=TOP ALIGN=LEFT> +
+ + + +     + + 0) {echo "TERRITORIES     \n";} ?> + 0) {echo "GROUPS     \n";} ?> +LOGGA UT\n"; ?> +
+
+ + + height=30> + + + + + +
MAINSCRIPT VALIGN=MIDDLE ALIGN=CENTER>  LIVE   session ID:    Livesamtal
+
+ + + + + height=>

Agent Screen
+
+ + +MANUELL UPPRINGNING       SNABBUPPRINGNING
+
+ + +X AKTIVA ÅTERKOMSTER
+
+ + +
+
+ + sekunder: +     + + + + D1 - RING\n"; + echo "
\n"; + echo "D2 - RING\n"; + } + else {echo "
\n";} + ?> +

 
+
+ + + height=>
PERSONLIGA ÅTERKOMSTER :
Klicka på en återkomst nedan för att ringa, numret försvinner då från listan och du får välja nytt utfall. +
+
+
  + Uppdatera +                 + Tillbaka +
+
+ + + height=>
NYTT MANUELLT UPPRINGT LEAD FÖR :

Skriv in informationen för det nya leadet du vill ringa. +
+ \n"; + } + ?> + Note: all new manual dial leads will go into list

+ + + + + + + + + + + + + + + +
Landskod   (Detta är 46 för Sverige)
Telefon Number: +   (12 digits max - digits only) +
Sök existerande leads:   (Detta val söker efter telefonnumret i systemet innan ett nytt lead läggs till.)
+

+     +
+

Om du vill ringa ett nummer och INTE lägga till det som en ny lead, skriv in det exakta numret i \"Dial override\" nedan.För att avsluta detta samtal måste du öppna SAMTAL I DENNA SESSION i botten av fönstret och klicka på kanallänken där..
 
Dial Override:   (enbart siffror) +
+
+ Ring nu +                 + Förhandsgranska samtal +                 + Tillbaka +
+
+ + + +
+
+ + + + +Din status:
Calls Dialing: +
+ + + + + > + + +
+
+ + Vidarekoppla - Konferens            
+ + + + + + + + + + + + + + + + + + + + + + + +
+ + + LOKAL CLOSER     + + Lägg på xfer linje +
+ seconds +   + channel + + KONSULTERANDE   + + Lägg på båda linjerna +
+ Nummer att ringa +   +   + AGENTER + + + RING OVERRIDE + + Lämna 3-partssamtal +
+ Ring blindnummer +   + Ring med kund +   + Parkera kunduppringning +   + + D1 + D2 + D3 + D4 + D5 + +   + Blind Transfer VMail Message +
+ +
+
+
+
+ + + +
 Samtalskö:  
 
+ + + 0) + { + if ($view_calls_in_queue_launch > 0) + {echo "Dölj samtalskö\n";} + else + {echo "Visa samtalskö\n";} + } +?> + + + +
  +Andra agenters status:  
 
+ +
+Tillgängliga agenter koppla:
+ +
Agents View +
+ + + 0) + { + echo "Dialable Leads:
 \n"; + } +?> +
+ + + + + + height=70> + +
Leadet utföll som:

+ -
+
+
+ + + height=70> + + + + +
Snabbtangenter: + Tryck på motsvarande snabbtangent för att välja utfallet av detta samtal. Samtalet kommer avslutas och registreras automatiskt.:
+ + + + + +
+
+ + + height=70> + + + + + + +
Informaci�n Anterior Del Servicio repetido: close
+
+
+
+
+ +
+
+ + + height=70> + + + + + + +
Utökad information om alternativt telefonnummer: minimera
+
+
+
+
+ +
+
+ + + + + +
maximera
Alt Telefon Info
+
+ + + height=>
Ingen är i din session:
+ Tillbaka +

+ Ring agent igen +
+
+ + + height=>
Kunden har lagt på:
+ Tillbaka +

+ Avsluta och välj utfall av samtalet +
+
+ + + height=>
Call Wrapup: kvarvarande sekunder till avslut

+ +

+ Avsluta och gå vidare +
+
+ + +
+


+ Avslutningsmeddelande +
+
+ + + height=>
Din session har avbrytits
LOGGA UT

Tillbaka +
+
+ + + height=>
Det är problem med tidssynkroniseringen, kontakta din systemadministratör


Tillbaka +
+
+ + + height=>

LOGGA UT
+
+ + +
+
+ + +
 
+
+ + + height=47>
Inga ändringar som gjorts nedan kommer inte att sparas. Du måste ändra kundinformationen innan du lägger på samtalet.
+
+ + + height=>
SAMTALSUTFALL :       Lägg på igen       minimera
+ Val för utfallet av samtal +
+ PAUSA AGENTUPPRINGNING
+ RENSA FORMULÄR | + SKICKA +

+ WEB FORM SKICKA +

  +
+
+ + + height=>
VÄLJ PAUSKOD :
+ Paus Code Selection + +

  +
+
+ + + height=>
VÄLJ ETT GRUPPALIAS :
+ GRUPPALIAS val + +

  +
+
+ + + + + + height=>
Välj ett datum för återkomsten :
+ + + Välj datum   +     + Hour: +   + Minutes: +   + +  
+ PERSONLIG ÅTERKOMST
";} + ?> + Kommentar till ÅK:

+ + SKICKA

+ +

  +
+
+ + + height=>
INGÅENDE CLOSER GRUPPVAL
+ Ingående closer gruppval +
+ 0) and ($disable_blended_checkbox < 1) and ($dial_method != 'INBOUND_MAN') ) + { + ?> + MIXAD RINGNING(utgående aktiverat)
+ + ÅTERSTÄLL | + SKICKA +



  +
+
+ + + height=>
TERRITORY SELECTION
+ Territory Selection +
+ ÅTERSTÄLL | + SKICKA +



  +
+
+ + + + Kanal + Kanal + PERSONLIG ÅTERKOMST
";} + if ( ($outbound_autodial_active < 1) or ($disable_blended_checkbox > 0) or ($dial_method == 'INBOUND_MAN') ) + {echo " MIXAD RINGNING
";} + ?> +
+ + + + height=>
AGENT SCRIPT
+
+ + +refresh + + + + 0) && ( ($user_level>=$HKuser_level) or ($VU_hotkeys_active > 0) ) ) { ?> +SNABBTANGENTER ÄR INAKTIVA + + + + +> + + + + +
Agent web-client version:     SKAPA:               Server:              
+ +Visa konferenskanalsinformation +

 
+
+ 0) ) + {echo "Alert is ON";} +else + {echo "Alert is OFF";} +?> +
+ + + +
+
+ + + + + id="MainTable"> + + + + + + + + + + + + + + + +
STATUS:
+
+Ring nästa nummer
+ FÖRHANDSGRANSKA LEAD
+ RING ALTERNATIVT NUMMER
+ + +INSPELNINGSFIL:
+
+
+INSPELNINGSID:
+
+ +Starta inspelning
+
+Webformulär
+ 0) + {echo "\"Webformulär
\n";} +?> +
+Parkera samtal
+Vidarekoppla - Konferens
+ + 0) + {echo "\"Quick
\n";} +?> + + + + 0) + {echo "
\n";} +?> + + +
+Lägg på kund
+
+
Skicka DTMF

+
+
+
align=left valign=top> + + + + + + + + + + + + +
+ + + + + + + +
  Customer Time:   Kanal:
Kundinformation:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Titel:   Förnamn:   MI:   Efternamn:
Adress1:
Adress2: Adress3:
Stad: Stat: Postnummer:
Provins: VendorID: Kön:
Telefon: +                     "; + echo ""; + } +else + { + echo ""; + } +?> + +Landskod: Alternativ telefon:
Visa: Email:
Kommentarer: + +\n";} +else + {echo "\n";} +?> + +
+
+ +
+
> + 
+ + + + + + + 0) or ($one_mysql_log > 0) ) + { + $errno = mysql_errno($link); + if ( ($errno > 0) or ($mel > 1) or ($one_mysql_log > 0) ) + { + $error = mysql_error($link); + $efp = fopen ("./vicidial_mysql_errors.txt", "a"); + fwrite ($efp, "$NOW_TIME|vicidial |$query_id|$errno|$error|$stmt|$user|$server_ip|$session_name|\n"); + fclose($efp); + } + } +$one_mysql_log=0; +return $errno; +} + +?> diff --git a/LANG_www/agc_se/voicemail_check.php b/LANG_www/agc_se/voicemail_check.php new file mode 100644 index 00000000..87152cc0 --- /dev/null +++ b/LANG_www/agc_se/voicemail_check.php @@ -0,0 +1,141 @@ + LICENSE: AGPLv2 +# +# This script is designed purely to check whether the voicemail box on the server defined has new and old messages +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $format - ('text','debug') +# - $vmail_box - ('101','1234',...) +# +# +# changes +# 50422-1147 - First build of script +# 50503-1241 - added session_name checking for extra security +# 50711-1201 - removed HTTP authentication in favor of user/pass vars +# 60421-1147 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60619-1204 - Added variable filters to close security holes for login form +# 90508-0727 - Changed to PHP long tags +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["vmail_box"])) {$vmail_box=$_GET["vmail_box"];} + elseif (isset($_POST["vmail_box"])) {$vmail_box=$_POST["vmail_box"];} + +$user=ereg_replace("[^0-9a-zA-Z]","",$user); +$pass=ereg_replace("[^0-9a-zA-Z]","",$pass); + +# default optional vars if not set +if (!isset($format)) {$format="text";} + +$version = '0.0.5'; +$build = '60619-1204'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Felaktig Användarnamn/Lösenord: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Felaktig server_ip: |$server_ip| or Felaktig session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Felaktig session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Lyssna av röstbrevlåda"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + $MT[0]=''; + $row=''; $rowx=''; + if (strlen($vmail_box)<1) + { + $channel_live=0; + echo "röstbrevlåda $vmail_box är ej giltig\n"; + exit; + } + else + { + $stmt="SELECT messages,old_messages FROM phones where server_ip='$server_ip' and voicemail_id='$vmail_box' limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $vmails_list = mysql_num_rows($rslt); + $loop_count=0; + while ($vmails_list>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + echo "$row[0]|$row[1]"; + if ($format=='debug') {echo "\n";} + } + } + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/LANG_www/vicidial_br/AST_CLOSER_service_level.php b/LANG_www/vicidial_br/AST_CLOSER_service_level.php new file mode 100644 index 00000000..5de47198 --- /dev/null +++ b/LANG_www/vicidial_br/AST_CLOSER_service_level.php @@ -0,0 +1,991 @@ + LICENSE: AGPLv2 +# +# CHANGES +# +# 80509-0943 - First build +# 80510-1500 - Added fixed scale hold time graph +# 80519-0413 - rewrote time intervals code and stats gathering code +# 80528-2320 - fixed small calculation bugs and display bugs, added more shifts +# 90310-2117 - Added admin header +# 90508-0644 - Changed to PHP long tags +# 90801-0923 - Added in-group name to pulldown +# 100214-1421 - Sort menu alphabetically +# 100216-0042 - Added popup date selector +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +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["shift"])) {$shift=$_GET["shift"];} + elseif (isset($_POST["shift"])) {$shift=$_POST["shift"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} + +$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); +if ($qm_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $non_latin = $row[0]; + } +##### END SETTINGS LOOKUP ##### +########################################### + +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level >= 7 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 "Nome ou Senha inválidos: |$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;} +if (!isset($end_date)) {$end_date = $NOW_DATE;} + +$stmt="select group_id,group_name from vicidial_inbound_groups order by group_id;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] = $row[0]; + $group_names[$i] = $row[1]; + $i++; + } +?> + + + + + +\n"; +echo "\n"; + +echo "\n"; +echo "Inbound Service Level Report\n"; + +$short_header=1; + +require("admin_header.php"); + +echo "
"; + +echo "
\n"; +echo ""; + +?> + +"; + +?> + +\n"; + $o=0; +while ($groups_to_print > $o) + { + if ($groups[$o] == $group) {echo "\n";} + else {echo "\n";} + $o++; + } +echo "\n"; +echo "\n"; +echo "\n"; +echo "           ALTERAR | RELATÓRIOS \n"; +echo "
\n\n"; + +echo "
\n\n";
+
+
+if (!$group)
+	{
+	echo "\n\n";
+	echo "POR FAVOR SELECIONE UM GRUPO DE ENTRADA E PERÍODO ACIMA E CLIQUE ENVIAR\n";
+	}
+
+else
+{
+### FOR SHIFTS IT IS BEST TO STICK TO 15-MINUTE INCREMENTS FOR START TIMES ###
+
+if ($shift == 'AM') 
+	{
+#	$time_BEGIN=$AM_shift_BEGIN;
+#	$time_END=$AM_shift_END;
+#	if (strlen($time_BEGIN) < 6) {$time_BEGIN = "03:45:00";}   
+#	if (strlen($time_END) < 6) {$time_END = "15:15:00";}
+	if (strlen($time_BEGIN) < 6) {$time_BEGIN = "00:00:00";}   
+	if (strlen($time_END) < 6) {$time_END = "11:59:59";}
+#	if (strlen($time_BEGIN) < 6) {$time_BEGIN = "12:00:00";}   
+#	if (strlen($time_END) < 6) {$time_END = "11:59:59";}
+	}
+if ($shift == 'PM') 
+	{
+#	$time_BEGIN=$PM_shift_BEGIN;
+#	$time_END=$PM_shift_END;
+#	if (strlen($time_BEGIN) < 6) {$time_BEGIN = "15:15:00";}
+#	if (strlen($time_END) < 6) {$time_END = "23:15:00";}
+	if (strlen($time_BEGIN) < 6) {$time_BEGIN = "12:00:00";}
+	if (strlen($time_END) < 6) {$time_END = "23:59:59";}
+	}
+if ($shift == 'ALL') 
+	{
+	if (strlen($time_BEGIN) < 6) {$time_BEGIN = "00:00:00";}
+	if (strlen($time_END) < 6) {$time_END = "23:59:59";}
+	}
+if ($shift == 'DAYTIME') 
+	{
+	if (strlen($time_BEGIN) < 6) {$time_BEGIN = "08:45:00";}
+	if (strlen($time_END) < 6) {$time_END = "00:59:59";}
+	}
+if ($shift == '10AM-6PM') 
+	{
+	if (strlen($time_BEGIN) < 6) {$time_BEGIN = "10:00:00";}
+	if (strlen($time_END) < 6) {$time_END = "17:59:59";}
+	}
+if ($shift == '9AM-1AM') 
+	{
+	if (strlen($time_BEGIN) < 6) {$time_BEGIN = "09:00:00";}
+	if (strlen($time_END) < 6) {$time_END = "00:59:59";}
+	}
+if ($shift == '845-1745') 
+	{
+	if (strlen($time_BEGIN) < 6) {$time_BEGIN = "08:45:00";}
+	if (strlen($time_END) < 6) {$time_END = "17:44:59";}
+	}
+if ($shift == '1745-100') 
+	{
+	if (strlen($time_BEGIN) < 6) {$time_BEGIN = "17:45:00";}
+	if (strlen($time_END) < 6) {$time_END = "00:59:59";}
+	}
+
+$query_date_BEGIN = "$query_date $time_BEGIN";   
+$query_date_END = "$end_date $time_END";
+
+$SQdate_ARY =	explode(' ',$query_date_BEGIN);
+$SQday_ARY =	explode('-',$SQdate_ARY[0]);
+$SQtime_ARY =	explode(':',$SQdate_ARY[1]);
+$EQdate_ARY =	explode(' ',$query_date_END);
+$EQday_ARY =	explode('-',$EQdate_ARY[0]);
+$EQtime_ARY =	explode(':',$EQdate_ARY[1]);
+
+$SQepochDAY = mktime(0, 0, 0, $SQday_ARY[1], $SQday_ARY[2], $SQday_ARY[0]);
+$SQepoch = mktime($SQtime_ARY[0], $SQtime_ARY[1], $SQtime_ARY[2], $SQday_ARY[1], $SQday_ARY[2], $SQday_ARY[0]);
+$EQepoch = mktime($EQtime_ARY[0], $EQtime_ARY[1], $EQtime_ARY[2], $EQday_ARY[1], $EQday_ARY[2], $EQday_ARY[0]);
+
+$SQsec = ( ($SQtime_ARY[0] * 3600) + ($SQtime_ARY[1] * 60) + ($SQtime_ARY[2] * 1) );
+$EQsec = ( ($EQtime_ARY[0] * 3600) + ($EQtime_ARY[1] * 60) + ($EQtime_ARY[2] * 1) );
+
+$DURATIONsec = ($EQepoch - $SQepoch);
+$DURATIONday = intval( ($DURATIONsec / 86400) + 1 );
+
+if ( ($EQsec < $SQsec) and ($DURATIONday < 1) )
+	{
+	$EQepoch = ($SQepochDAY + ($EQsec + 86400) );
+	$query_date_END = date("Y-m-d H:i:s", $EQepoch);
+	$DURATIONday++;
+	}
+
+echo "Inbound Service Level Report                      $NOW_TIME\n";
+echo "\n";
+echo "Time range $DURATIONday days: $query_date_BEGIN to $query_date_END\n\n";
+#echo "Time range day sec: $SQsec - $EQsec   Day range in epoch: $SQepoch - $EQepoch   Start: $SQepochDAY\n";
+
+$d=0;
+while ($d < $DURATIONday)
+	{
+	$dSQepoch = ($SQepoch + ($d * 86400) );
+	$dEQepoch = ($SQepochDAY + ($EQsec + ($d * 86400) ) );
+
+	if ($EQsec < $SQsec)
+		{
+		$dEQepoch = ($dEQepoch + 86400);
+		}
+
+	$daySTART[$d] = date("Y-m-d H:i:s", $dSQepoch);
+	$dayEND[$d] = date("Y-m-d H:i:s", $dEQepoch);
+
+	$d++;
+	}
+
+##########################################################################
+#########  CALCULATE ALL OF THE 15-MINUTE PERIODS NEEDED FOR ALL DAYS ####
+
+### BUILD HOUR:MIN DISPLAY ARRAY ###
+$i=0;
+$h=4;
+$j=0;
+$Zhour=1;
+$active_time=0;
+$hour =		($SQtime_ARY[0] - 1);
+$startSEC = ($SQsec - 900);
+$endSEC =	($SQsec - 1);
+if ($SQtime_ARY[1] > 14) 
+	{
+	$h=1;
+	$hour++;
+	if ($hour < 10) {$hour = "0$hour";}
+	}
+if ($SQtime_ARY[1] > 29) {$h=2;}
+if ($SQtime_ARY[1] > 44) {$h=3;}
+while ($i < 96)
+	{
+	$startSEC = ($startSEC + 900);
+	$endSEC = ($endSEC + 900);
+	$time = '      ';
+	if ($h >= 4)
+		{
+		$hour++;
+		if ($Zhour == '00') 
+			{
+			$startSEC=0;
+			$endSEC=899;
+			}
+		$h=0;
+		if ($hour < 10) {$hour = "0$hour";}
+		$Stime="$hour:00";
+		$Etime="$hour:15";
+		$time = "+$Stime-$Etime+";
+		}
+	if ($h == 1)
+		{
+		$Stime="$hour:15";
+		$Etime="$hour:30";
+		$time = " $Stime-$Etime ";
+		}
+	if ($h == 2)
+		{
+		$Stime="$hour:30";
+		$Etime="$hour:45";
+		$time = " $Stime-$Etime ";
+		}
+	if ($h == 3)
+		{
+		$Zhour=$hour;
+		$Zhour++;
+		if ($Zhour < 10) {$Zhour = "0$Zhour";}
+		if ($Zhour == 24) {$Zhour = "00";}
+		$Stime="$hour:45";
+		$Etime="$Zhour:00";
+		$time = " $Stime-$Etime ";
+		if ($Zhour == '00') 
+			{$hour = ($Zhour - 1);}
+		}
+
+	if ( ( ($startSEC >= $SQsec) and ($endSEC <= $EQsec) and ($EQsec > $SQsec) ) or 
+		( ($startSEC >= $SQsec) and ($EQsec < $SQsec) ) or 
+		( ($endSEC <= $EQsec) and ($EQsec < $SQsec) ) )
+		{
+		$HMdisplay[$j] =	$time;
+		$HMstart[$j] =		$Stime;
+		$HMend[$j] =		$Etime;
+		$HMSepoch[$j] =		$startSEC;
+		$HMEepoch[$j] =		$endSEC;
+
+		$j++;
+		}
+
+	$h++;
+	$i++;
+	}
+
+$TOTintervals = $j;
+
+
+### GRAB ALL RECORDS WITHIN RANGE FROM THE DATABASE ###
+$stmt="select queue_seconds,UNIX_TIMESTAMP(call_date),length_in_sec,status from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and  campaign_id='" . mysql_real_escape_string($group) . "';";
+$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);
+	$qs[$i] = $row[0];
+	$dt[$i] = 0;
+	$ut[$i] = ($row[1] - $SQepochDAY);
+	while($ut[$i] >= 86400) 
+		{
+		$ut[$i] = ($ut[$i] - 86400);
+		$dt[$i]++;
+		}
+	if ( ($ut[$i] <= $EQsec) and ($EQsec < $SQsec) )
+		{
+		$dt[$i] = ($dt[$i] - 1);
+		}
+	$ls[$i] = $row[2];
+	$st[$i] = $row[3];
+
+#	echo "$qs[$i] $dt[$i] $ut[$i] $ls[$i] $st[$i]\n";
+
+	$i++;
+	}
+
+### PARSE THROUGH ALL RECORDS AND GENERATE STATS ###
+$MT[0]='0';
+$totCALLS=0;
+$totDROPS=0;
+$totQUEUE=0;
+$totCALLSsec=0;
+$totDROPSsec=0;
+$totQUEUEsec=0;
+$totCALLSmax=0;
+$totDROPSmax=0;
+$totQUEUEmax=0;
+$totCALLSdate=$MT;
+$totDROPSdate=$MT;
+$totQUEUEdate=$MT;
+$qrtCALLS=$MT;
+$qrtDROPS=$MT;
+$qrtQUEUE=$MT;
+$qrtCALLSsec=$MT;
+$qrtDROPSsec=$MT;
+$qrtQUEUEsec=$MT;
+$qrtCALLSavg=$MT;
+$qrtDROPSavg=$MT;
+$qrtQUEUEavg=$MT;
+$qrtCALLSmax=$MT;
+$qrtDROPSmax=$MT;
+$qrtQUEUEmax=$MT;
+$j=0;
+while ($j < $TOTintervals)
+	{
+	$jd__0[$j]=0; $jd_20[$j]=0; $jd_40[$j]=0; $jd_60[$j]=0; $jd_80[$j]=0; $jd100[$j]=0; $jd120[$j]=0; $jd121[$j]=0;
+	$Phd__0[$j]=0; $Phd_20[$j]=0; $Phd_40[$j]=0; $Phd_60[$j]=0; $Phd_80[$j]=0; $Phd100[$j]=0; $Phd120[$j]=0; $Phd121[$j]=0;
+	$qrtCALLS[$j]=0; $qrtCALLSsec[$j]=0; $qrtCALLSmax[$j]=0;
+	$qrtDROPS[$j]=0; $qrtDROPSsec[$j]=0; $qrtDROPSmax[$j]=0;
+	$qrtQUEUE[$j]=0; $qrtQUEUEsec[$j]=0; $qrtQUEUEmax[$j]=0;
+	$i=0;
+	while ($i < $records_to_grab)
+		{
+		if ( ($ut[$i] >= $HMSepoch[$j]) and ($ut[$i] <= $HMEepoch[$j]) )
+			{
+			$totCALLS++;
+			$totCALLSsec = ($totCALLSsec + $ls[$i]);
+			$totCALLSsecDATE[$dtt] = ($totCALLSsecDATE[$dtt] + $ls[$i]);
+			$qrtCALLS[$j]++;
+			$qrtCALLSsec[$j] = ($qrtCALLSsec[$j] + $ls[$i]);
+			$dtt = $dt[$i];
+			$totCALLSdate[$dtt]++;
+			if ($totCALLSmax < $ls[$i]) {$totCALLSmax = $ls[$i];}
+			if ($qrtCALLSmax[$j] < $ls[$i]) {$qrtCALLSmax[$j] = $ls[$i];}
+			if (ereg('DROP',$st[$i])) 
+				{
+				$totDROPS++;
+				$totDROPSsec = ($totDROPSsec + $ls[$i]);
+				$totDROPSsecDATE[$dtt] = ($totDROPSsecDATE[$dtt] + $ls[$i]);
+				$qrtDROPS[$j]++;
+				$qrtDROPSsec[$j] = ($qrtDROPSsec[$j] + $ls[$i]);
+				$totDROPSdate[$dtt]++;
+				if ($totDROPSmax < $ls[$i]) {$totDROPSmax = $ls[$i];}
+				if ($qrtDROPSmax[$j] < $ls[$i]) {$qrtDROPSmax[$j] = $ls[$i];}
+				}
+			if ($qs[$i] > 0) 
+				{
+				$totQUEUE++;
+				$totQUEUEsec = ($totQUEUEsec + $qs[$i]);
+				$totQUEUEsecDATE[$dtt] = ($totQUEUEsecDATE[$dtt] + $qs[$i]);
+				$qrtQUEUE[$j]++;
+				$qrtQUEUEsec[$j] = ($qrtQUEUEsec[$j] + $qs[$i]);
+				$totQUEUEdate[$dtt]++;
+				if ($totQUEUEmax < $qs[$i]) {$totQUEUEmax = $qs[$i];}
+				if ($qrtQUEUEmax[$j] < $qs[$i]) {$qrtQUEUEmax[$j] = $qs[$i];}
+				}
+
+			if ($qs[$i] == 0) {$hd__0[$j]++;}
+			if ( ($qs[$i] > 0) and ($qs[$i] <= 20) ) {$hd_20[$j]++;}
+			if ( ($qs[$i] > 20) and ($qs[$i] <= 40) ) {$hd_40[$j]++;}
+			if ( ($qs[$i] > 40) and ($qs[$i] <= 60) ) {$hd_60[$j]++;}
+			if ( ($qs[$i] > 60) and ($qs[$i] <= 80) ) {$hd_80[$j]++;}
+			if ( ($qs[$i] > 80) and ($qs[$i] <= 100) ) {$hd100[$j]++;}
+			if ( ($qs[$i] > 100) and ($qs[$i] <= 120) ) {$hd120[$j]++;}
+			if ($qs[$i] > 120) {$hd121[$j]++;}
+
+			}
+		
+		$i++;
+		}
+
+	$j++;
+	}
+
+
+
+
+###################################################
+### TOTALS SUMMARY SECTION ###
+echo "+-------------------------------------------+--------+--------+--------+--------+--------+--------+--------+--------+----------+--------+\n";
+echo "|                                           |        |        |        |        |        |  AVG   |  AVG   |        |  TOTAL   |  AVG   |\n";
+echo "| SHIFT                                     |        |        |  AVG   |        |        | HOLD(s)| HOLD(s)|        | CALLTIME |CALLTIME|\n";
+echo "| DATE-TIME RANGE                           | DROPS  | DROP % | DROP(s)| HOLD   | HOLD % |  HOLD  | TOTAL  | CALLS  | MIN:SEC  |SECONDS |\n";
+echo "+-------------------------------------------+--------+--------+--------+--------+--------+--------+--------+--------+----------+--------+\n";
+
+$d=0;
+while ($d < $DURATIONday)
+	{
+	if ($totDROPSdate[$d] < 1) {$totDROPSdate[$d]=0;}
+	if ($totQUEUEdate[$d] < 1) {$totQUEUEdate[$d]=0;}
+	if ($totCALLSdate[$d] < 1) {$totCALLSdate[$d]=0;}
+
+	if ($totDROPSdate[$d] > 0)
+		{$totDROPSpctDATE[$d] = ( ($totDROPSdate[$d] / $totCALLSdate[$d]) * 100);}
+	else {$totDROPSpctDATE[$d] = 0;}
+	$totDROPSpctDATE[$d] = round($totDROPSpctDATE[$d], 2);
+	if ($totQUEUEdate[$d] > 0)
+		{$totQUEUEpctDATE[$d] = ( ($totQUEUEdate[$d] / $totCALLSdate[$d]) * 100);}
+	else {$totQUEUEpctDATE[$d] = 0;}
+	$totQUEUEpctDATE[$d] = round($totQUEUEpctDATE[$d], 2);
+
+	if ($totDROPSsecDATE[$d] > 0)
+		{$totDROPSavgDATE[$d] = ($totDROPSsecDATE[$d] / $totDROPSdate[$d]);}
+	else {$totDROPSavgDATE[$d] = 0;}
+	if ($totQUEUEsecDATE[$d] > 0)
+		{$totQUEUEavgDATE[$d] = ($totQUEUEsecDATE[$d] / $totQUEUEdate[$d]);}
+	else {$totQUEUEavgDATE[$d] = 0;}
+	if ($totQUEUEsecDATE[$d] > 0)
+		{$totQUEUEtotDATE[$d] = ($totQUEUEsecDATE[$d] / $totCALLSdate[$d]);}
+	else {$totQUEUEtotDATE[$d] = 0;}
+
+	if ($totCALLSsecDATE[$d] > 0)
+		{
+		$totCALLSavgDATE[$d] = ($totCALLSsecDATE[$d] / $totCALLSdate[$d]);
+
+		$totTIME_M = ($totCALLSsecDATE[$d] / 60);
+		$totTIME_M_int = round($totTIME_M, 2);
+		$totTIME_M_int = intval("$totTIME_M");
+		$totTIME_S = ($totTIME_M - $totTIME_M_int);
+		$totTIME_S = ($totTIME_S * 60);
+		$totTIME_S = round($totTIME_S, 0);
+		if ($totTIME_S < 10) {$totTIME_S = "0$totTIME_S";}
+		$totTIME_MS = "$totTIME_M_int:$totTIME_S";
+		$totTIME_MS =		sprintf("%8s", $totTIME_MS);
+		}
+	else 
+		{
+		$totCALLSavgDATE[$d] = 0;
+		$totTIME_MS='        ';
+		}
+
+	$totCALLSavgDATE[$d] =	sprintf("%6.0f", $totCALLSavgDATE[$d]);
+	$totDROPSavgDATE[$d] =	sprintf("%7.2f", $totDROPSavgDATE[$d]);
+	$totQUEUEavgDATE[$d] =	sprintf("%7.2f", $totQUEUEavgDATE[$d]);
+	$totQUEUEtotDATE[$d] =	sprintf("%7.2f", $totQUEUEtotDATE[$d]);
+	$totDROPSpctDATE[$d] =	sprintf("%6.2f", $totDROPSpctDATE[$d]);
+	$totQUEUEpctDATE[$d] =	sprintf("%6.2f", $totQUEUEpctDATE[$d]);
+	$totDROPSdate[$d] =	sprintf("%6s", $totDROPSdate[$d]);
+	$totQUEUEdate[$d] =	sprintf("%6s", $totQUEUEdate[$d]);
+	$totCALLSdate[$d] =	sprintf("%6s", $totCALLSdate[$d]);
+
+	echo "| $daySTART[$d] - $dayEND[$d] | $totDROPSdate[$d] | $totDROPSpctDATE[$d]%|$totDROPSavgDATE[$d] | $totQUEUEdate[$d] | $totQUEUEpctDATE[$d]%|$totQUEUEavgDATE[$d] |$totQUEUEtotDATE[$d] | $totCALLSdate[$d] | $totTIME_MS | $totCALLSavgDATE[$d] |\n";
+	$d++;
+	}
+
+	if ($totDROPS > 0)
+		{$totDROPSpct = ( ($totDROPS / $totCALLS) * 100);}
+	else {$totDROPSpct = 0;}
+	$totDROPSpct = round($totDROPSpct, 2);
+	if ($totQUEUE > 0)
+		{$totQUEUEpct = ( ($totQUEUE / $totCALLS) * 100);}
+	else {$totQUEUEpct = 0;}
+	$totQUEUEpct = round($totQUEUEpct, 2);
+
+	if ($totDROPSsec > 0)
+		{$totDROPSavg = ($totDROPSsec / $totDROPS);}
+	else {$totDROPSavg = 0;}
+	if ($totQUEUEsec > 0)
+		{$totQUEUEavg = ($totQUEUEsec / $totQUEUE);}
+	else {$totQUEUEavg = 0;}
+	if ($totQUEUEsec > 0)
+		{$totQUEUEtot = ($totQUEUEsec / $totCALLS);}
+	else {$totQUEUEtot = 0;}
+
+if ($totCALLSsec > 0)
+	{
+	$totCALLSavg = ($totCALLSsec / $totCALLS);
+
+	$totTIME_M = ($totCALLSsec / 60);
+	$totTIME_M_int = round($totTIME_M, 2);
+	$totTIME_M_int = intval("$totTIME_M");
+	$totTIME_S = ($totTIME_M - $totTIME_M_int);
+	$totTIME_S = ($totTIME_S * 60);
+	$totTIME_S = round($totTIME_S, 0);
+	if ($totTIME_S < 10) {$totTIME_S = "0$totTIME_S";}
+	$totTIME_MS = "$totTIME_M_int:$totTIME_S";
+	$totTIME_MS =		sprintf("%9s", $totTIME_MS);
+	}
+else 
+	{
+	$totCALLSavg = 0;
+	$totTIME_MS='         ';
+	}
+
+
+	$FtotCALLSavg =	sprintf("%6.0f", $totCALLSavg);
+	$FtotDROPSavg =	sprintf("%7.2f", $totDROPSavg);
+	$FtotQUEUEavg =	sprintf("%7.2f", $totQUEUEavg);
+	$FtotQUEUEtot =	sprintf("%7.2f", $totQUEUEtot);
+	$FtotDROPSpct =	sprintf("%6.2f", $totDROPSpct);
+	$FtotQUEUEpct =	sprintf("%6.2f", $totQUEUEpct);
+	$FtotDROPS =	sprintf("%6s", $totDROPS);
+	$FtotQUEUE =	sprintf("%6s", $totQUEUE);
+	$FtotCALLS =	sprintf("%6s", $totCALLS);
+
+echo "+-------------------------------------------+--------+--------+--------+--------+--------+--------+--------+--------+----------+--------+\n";
+echo "|                                    TOTALS | $FtotDROPS | $FtotDROPSpct%|$FtotDROPSavg | $FtotQUEUE | $FtotQUEUEpct%|$FtotQUEUEavg |$FtotQUEUEtot | $FtotCALLS |$totTIME_MS | $FtotCALLSavg |\n";
+echo "+-------------------------------------------+--------+--------+--------+--------+--------+--------+--------+--------+----------+--------+\n";
+
+
+	## FORMAT OUTPUT ##
+	$i=0;
+	$hi_hour_count=0;
+	$hi_hold_count=0;
+
+	while ($i < $TOTintervals)
+		{
+
+		if ($qrtCALLS[$i] > 0)
+			{$qrtCALLSavg[$i] = ($qrtCALLSsec[$i] / $qrtCALLS[$i]);}
+		else {$qrtCALLSavg[$i] = 0;}
+		if ($qrtDROPS[$i] > 0)
+			{$qrtDROPSavg[$i] = ($qrtDROPSsec[$i] / $qrtDROPS[$i]);}
+		else {$qrtDROPSavg[$i] = 0;}
+		if ($qrtQUEUE[$i] > 0)
+			{$qrtQUEUEavg[$i] = ($qrtQUEUEsec[$i] / $qrtQUEUE[$i]);}
+		else {$qrtQUEUEavg[$i] = 0;}
+
+		if ($qrtCALLS[$i] > $hi_hour_count) {$hi_hour_count = $qrtCALLS[$i];}
+		if ($qrtQUEUEavg[$i] > $hi_hold_count) {$hi_hold_count = $qrtQUEUEavg[$i];}
+
+		$qrtQUEUEavg[$i] = round($qrtQUEUEavg[$i], 0);
+		if (strlen($qrtQUEUEavg[$i])<1) {$qrtQUEUEavg[$i]=0;}
+		$qrtQUEUEmax[$i] = round($qrtQUEUEmax[$i], 0);
+		if (strlen($qrtQUEUEmax[$i])<1) {$qrtQUEUEmax[$i]=0;}
+
+		$i++;
+		}
+
+if ($hi_hour_count < 1)
+	{$hour_multiplier = 0;}
+else
+	{$hour_multiplier = (20 / $hi_hour_count);}
+if ($hi_hold_count < 1)
+	{$hold_multiplier = 0;}
+else
+	{$hold_multiplier = (20 / $hi_hold_count);}
+
+
+
+
+###################################################################
+#########  HOLD TIME, CALL AND DROP STATS 15-MINUTE INCREMENTS ####
+
+echo "\n";
+echo "---------- HOLD TIME, CALL AND DROP STATS\n";
+
+echo "";
+
+echo "";
+echo "\n";
+echo "GRAPH IN 15 MINUTE INCREMENTS OF AVERAGE HOLD TIME FOR CALLS TAKEN INTO THIS IN-GROUP\n";
+
+
+$k=1;
+$Mk=0;
+$call_scale = '0';
+while ($k <= 22) 
+	{
+	if ( ($k < 1) or ($hour_multiplier <= 0) )
+		{$scale_num = 20;}
+	else
+		{
+		$TMPscale_num=(23 / $hour_multiplier);
+		$TMPscale_num = round($TMPscale_num, 0);
+		$scale_num=($k / $hour_multiplier);
+		$scale_num = round($scale_num, 0);
+		}
+	$tmpscl = "$call_scale$TMPscale_num";
+
+	if ( ($Mk >= 4) or (strlen($tmpscl)==23) )
+		{
+		$Mk=0;
+		$LENscale_num = (strlen($scale_num));
+		$k = ($k + $LENscale_num);
+		$call_scale .= "$scale_num";
+		}
+	else
+		{
+		$call_scale .= " ";
+		$k++;   $Mk++;
+		}
+	}
+$k=1;
+$Mk=0;
+$hold_scale = '0';
+while ($k <= 22) 
+	{
+	if ( ($k < 1) or ($hold_multiplier <= 0) )
+		{$scale_num = 20;}
+	else
+		{
+		$TMPscale_num=(23 / $hold_multiplier);
+		$TMPscale_num = round($TMPscale_num, 0);
+		$scale_num=($k / $hold_multiplier);
+		$scale_num = round($scale_num, 0);
+		}
+	$tmpscl = "$hold_scale$TMPscale_num";
+
+	if ( ($Mk >= 4) or (strlen($tmpscl)==23) )
+		{
+		$Mk=0;
+		$LENscale_num = (strlen($scale_num));
+		$k = ($k + $LENscale_num);
+		$hold_scale .= "$scale_num";
+		}
+	else
+		{
+		$hold_scale .= " ";
+		$k++;   $Mk++;
+		}
+	}
+
+
+echo "+-------------+-----------------------+-------+-------+  +-----------------------+-------+-------+\n";
+echo "|    TIME     |  AVG HOLD TIME (sec)  | (in seconds)  |  |    CALLS HANDLED      |       |       |\n";
+echo "| 15 MIN INT  |$hold_scale| AVG   | MAX   |  |$call_scale| DROPS | TOTAL |\n";
+echo "+-------------+-----------------------+-------+-------+  +-----------------------+-------+-------+\n";
+
+$i=0;
+while ($i < $TOTintervals)
+	{
+	$char_counter=0;
+	### BEGIN HOLD TIME TOTALS GRAPH ###
+		$Ghour_count = $qrtCALLS[$i];
+	if ($Ghour_count > 0) {$no_lines_yet=0;}
+
+	$Gavg_hold = $qrtQUEUEavg[$i];
+	if ($Gavg_hold < 1) 
+		{
+		if ($i < 0)
+			{
+			$do_nothing=1;
+			}
+		else
+			{
+			$TOT_lines++;
+			$qrtQUEUEavg[$i] =	sprintf("%5s", $qrtQUEUEavg[$i]);
+			$qrtQUEUEmax[$i] =	sprintf("%5s", $qrtQUEUEmax[$i]);
+			echo "|$HMdisplay[$i]|";
+			$k=0;   while ($k <= 22) {echo " ";   $k++;}
+			echo "| $qrtQUEUEavg[$i] | $qrtQUEUEmax[$i] |";
+			}
+		}
+	else
+		{
+		$TOT_lines++;
+		$no_lines_yet=0;
+		$Xavg_hold = ($Gavg_hold * $hold_multiplier);
+		$Yavg_hold = (19 - $Xavg_hold);
+
+		$qrtQUEUEavg[$i] =	sprintf("%5s", $qrtQUEUEavg[$i]);
+		$qrtQUEUEmax[$i] =	sprintf("%5s", $qrtQUEUEmax[$i]);
+
+		echo "|$HMdisplay[$i]|";
+		$k=0;   while ($k <= $Xavg_hold) {echo "*";   $k++;   $char_counter++;}
+		if ($char_counter >= 22) {echo "H";   $char_counter++;}
+		else {echo "*H";   $char_counter++;   $char_counter++;}
+		$k=0;   while ($k <= $Yavg_hold) {echo " ";   $k++;   $char_counter++;}
+			while ($char_counter <= 22) {echo " ";   $char_counter++;}
+		echo "| $qrtQUEUEavg[$i] | $qrtQUEUEmax[$i] |";
+		}
+	### END HOLD TIME TOTALS GRAPH ###
+
+	$char_counter=0;
+ 	### BEGIN CALLS TOTALS GRAPH ###
+	$Ghour_count = $qrtCALLS[$i];
+	if ($Ghour_count < 1) 
+		{
+		if ($i < 0)
+			{
+			$do_nothing=1;
+			}
+		else
+			{
+			$qrtCALLS[$i] =	sprintf("%5s", $qrtCALLS[$i]);
+			echo "  |";
+			$k=0;   while ($k <= 22) {echo " ";   $k++;}
+			echo "| $qrtCALLS[$i] |     0 |\n";
+			}
+		}
+	else
+		{
+		$no_lines_yet=0;
+		$Xhour_count = ($Ghour_count * $hour_multiplier);
+		$Yhour_count = (19 - $Xhour_count);
+
+		$Gdrop_count = $qrtDROPS[$i];
+		if ($Gdrop_count < 1) 
+			{
+			$qrtCALLS[$i] =	sprintf("%5s", $qrtCALLS[$i]);
+
+			echo "  |";
+			$k=0;   while ($k <= $Xhour_count) {echo "*";   $k++;   $char_counter++;}
+			if ($char_counter > 21) {echo "C";   $char_counter++;}
+			else {echo "*C";   $char_counter++;   $char_counter++;}
+			$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+				while ($char_counter <= 22) {echo " ";   $char_counter++;}
+			echo "|     0 | $qrtCALLS[$i] |\n";
+			}
+		else
+			{
+			$Xdrop_count = ($Gdrop_count * $hour_multiplier);
+
+		#	if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
+
+			$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
+
+			$qrtCALLS[$i] =	sprintf("%5s", $qrtCALLS[$i]);
+			$qrtDROPS[$i] =	sprintf("%5s", $qrtDROPS[$i]);
+
+			echo "  |";
+			$k=0;   while ($k <= $Xdrop_count) {echo ">";   $k++;   $char_counter++;}
+			echo "D";   $char_counter++;
+			$k=0;   while ($k <= $XXhour_count) {echo "*";   $k++;   $char_counter++;}
+			echo "C";   $char_counter++;
+			$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+				while ($char_counter <= 22) {echo " ";   $char_counter++;}
+			echo "| $qrtDROPS[$i] | $qrtCALLS[$i] |\n";
+			}
+		}
+	### END CALLS TOTALS GRAPH ###
+
+	$i++;
+	}
+
+
+if ($totQUEUEsec > 0)
+	{$totQUEUEavgRAW = ($totCALLS / $totQUEUEsec);}
+else
+	{$totQUEUEavgRAW = 0;}
+$totQUEUEavg =	sprintf("%5s", $totQUEUEavg); 
+	while (strlen($totQUEUEavg)>5) {$totQUEUEavg = ereg_replace(".$",'',$totQUEUEavg);}
+$totQUEUEmax =	sprintf("%5s", $totQUEUEmax);
+	while (strlen($totQUEUEmax)>5) {$totQUEUEmax = ereg_replace(".$",'',$totQUEUEmax);}
+$totDROPS =	sprintf("%5s", $totDROPS);
+$totCALLS =	sprintf("%5s", $totCALLS);
+
+
+echo "+-------------+-----------------------+-------+-------+  +-----------------------+-------+-------+\n";
+echo "| TOTAL                               | $totQUEUEavg | $totQUEUEmax |  |                       | $totDROPS | $totCALLS |\n";
+echo "+-------------------------------------+-------+-------+  +-----------------------+-------+-------+\n";
+
+
+
+
+##############################
+#########  CALL HOLD TIME BREAKDOWN IN SECONDS, 15-MINUTE INCREMENT
+
+
+echo "\n";
+echo "---------- TEMPO DE ESPERA POR SEGUNDOS\n";
+echo "+-------------+-------+-----------------------------------------+ +------+--------------------------------+\n";
+echo "|    TIME     |       |  % OF CALLS GROUPED BY HOLD TIME (SEC)  | |   AVERAGE TIME BEFORE RESPOSTA (SEC)    |\n";
+echo "| 15 MIN INT  | CALLS |    0   20   40   60   80  100  120 120+ | | AVG  |0   20   40   60   80  100  120 |\n";
+echo "+-------------+-------+-----------------------------------------+ +------+--------------------------------+\n";
+
+$APhd__0=0; $APhd_20=0; $APhd_40=0; $APhd_60=0; $APhd_80=0; $APhd100=0; $APhd120=0; $APhd121=0;
+$h=0;
+while ($h < $TOTintervals)
+	{
+	$Aavg_hold[$h] = $qrtQUEUEavg[$h]; 
+	if ($hd__0[$h] > 0) {$Phd__0[$h] = round( ( ($hd__0[$h] / $qrtCALLS[$h]) * 100) );}
+		else {$Phd__0[$h]=0;}
+	if ($hd_20[$h] > 0) {$Phd_20[$h] = round( ( ($hd_20[$h] / $qrtCALLS[$h]) * 100) );}
+		else {$Phd_20[$h]=0;}
+	if ($hd_40[$h] > 0) {$Phd_40[$h] = round( ( ($hd_40[$h] / $qrtCALLS[$h]) * 100) );}
+		else {$Phd_40[$h]=0;}
+	if ($hd_60[$h] > 0) {$Phd_60[$h] = round( ( ($hd_60[$h] / $qrtCALLS[$h]) * 100) );}
+		else {$Phd_60[$h]=0;}
+	if ($hd_80[$h] > 0) {$Phd_80[$h] = round( ( ($hd_80[$h] / $qrtCALLS[$h]) * 100) );}
+		else {$Phd_80[$h]=0;}
+	if ($hd100[$h] > 0) {$Phd100[$h] = round( ( ($hd100[$h] / $qrtCALLS[$h]) * 100) );}
+		else {$Phd100[$h]=0;}
+	if ($hd120[$h] > 0) {$Phd120[$h] = round( ( ($hd120[$h] / $qrtCALLS[$h]) * 100) );}
+		else {$Phd120[$h]=0;}
+	if ($hd121[$h] > 0) {$Phd121[$h] = round( ( ($hd121[$h] / $qrtCALLS[$h]) * 100) );}
+		else {$Phd121[$h]=0;}
+		while (strlen($qrtQUEUEavg[$h])>4) {$qrtQUEUEavg[$h] = ereg_replace(".$",'',$qrtQUEUEavg[$h]);}
+	$hd__0[$h] =	sprintf("%4s", $hd__0[$h]);
+	$hd_20[$h] =	sprintf("%4s", $hd_20[$h]);
+	$hd_40[$h] =	sprintf("%4s", $hd_40[$h]);
+	$hd_60[$h] =	sprintf("%4s", $hd_60[$h]);
+	$hd_80[$h] =	sprintf("%4s", $hd_80[$h]);
+	$hd100[$h] =	sprintf("%4s", $hd100[$h]);
+	$hd120[$h] =	sprintf("%4s", $hd120[$h]);
+	$hd121[$h] =	sprintf("%4s", $hd121[$h]);
+	$Phd__0[$h] =	sprintf("%4s", $Phd__0[$h]);
+	$Phd_20[$h] =	sprintf("%4s", $Phd_20[$h]);
+	$Phd_40[$h] =	sprintf("%4s", $Phd_40[$h]);
+	$Phd_60[$h] =	sprintf("%4s", $Phd_60[$h]);
+	$Phd_80[$h] =	sprintf("%4s", $Phd_80[$h]);
+	$Phd100[$h] =	sprintf("%4s", $Phd100[$h]);
+	$Phd120[$h] =	sprintf("%4s", $Phd120[$h]);
+	$Phd121[$h] =	sprintf("%4s", $Phd121[$h]);
+
+	$ALLcalls = ($ALLcalls + $qrtCALLS[$h]);
+	$ALLhd__0 = ($ALLhd__0 + $hd__0[$h]);
+	$ALLhd_20 = ($ALLhd_20 + $hd_20[$h]);
+	$ALLhd_40 = ($ALLhd_40 + $hd_40[$h]);
+	$ALLhd_60 = ($ALLhd_60 + $hd_60[$h]);
+	$ALLhd_80 = ($ALLhd_80 + $hd_80[$h]);
+	$ALLhd100 = ($ALLhd100 + $hd100[$h]);
+	$ALLhd120 = ($ALLhd120 + $hd120[$h]);
+	$ALLhd121 = ($ALLhd121 + $hd121[$h]);
+
+	if ( ($Aavg_hold[$h] < 1) or ($Aavg_hold[$h] > 119) )
+		{
+		if ($Aavg_hold[$h] < 1)		{$qrtQUEUEavg_scale[$h] = '                                ';}
+		if ($Aavg_hold[$h] > 119)	{$qrtQUEUEavg_scale[$h] = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';}
+		}
+	else
+		{
+		$qrtQUEUEavg_val[$h] = ( (32 / 120) * $Aavg_hold[$h] );
+		$k=0;
+		$blank=0;
+		while ($k < 32)
+			{
+			if ($k <= $qrtQUEUEavg_val[$h]) 
+				{
+				if ($k < 1) {$qrtQUEUEavg_scale[$h] .= '';}
+				$qrtQUEUEavg_scale[$h] .= 'x';
+				}
+			else 
+				{
+				if ( ($k > 0) and ($blank < 1) ) {$qrtQUEUEavg_scale[$h] .= '';}
+				$qrtQUEUEavg_scale[$h] .= ' ';
+				$blank++;
+				}
+			$k++;
+			if ( ($k > 31) and ($blank < 1) ) {$qrtQUEUEavg_scale[$h] .= '';}
+			}
+		}
+
+	$Aavg_hold[$h] = sprintf("%4s", $Aavg_hold[$h]);
+	while (strlen($Aavg_hold[$h])>4) {$Aavg_hold[$h] = ereg_replace("^.",'',$Aavg_hold[$h]);}
+
+	echo "|$HMdisplay[$h]| $qrtCALLS[$h] | $Phd__0[$h] $Phd_20[$h] $Phd_40[$h] $Phd_60[$h] $Phd_80[$h] $Phd100[$h] $Phd120[$h] $Phd121[$h] | | $Aavg_hold[$h] |$qrtQUEUEavg_scale[$h]|\n";
+	
+	$h++;
+	}
+
+if ($ALLhd__0 > 0) {$APhd__0 = round( ( ($ALLhd__0 / $ALLcalls) * 100) );}
+if ($ALLhd_20 > 0) {$APhd_20 = round( ( ($ALLhd_20 / $ALLcalls) * 100) );}
+if ($ALLhd_40 > 0) {$APhd_40 = round( ( ($ALLhd_40 / $ALLcalls) * 100) );}
+if ($ALLhd_60 > 0) {$APhd_60 = round( ( ($ALLhd_60 / $ALLcalls) * 100) );}
+if ($ALLhd_80 > 0) {$APhd_80 = round( ( ($ALLhd_80 / $ALLcalls) * 100) );}
+if ($ALLhd100 > 0) {$APhd100 = round( ( ($ALLhd100 / $ALLcalls) * 100) );}
+if ($ALLhd120 > 0) {$APhd120 = round( ( ($ALLhd120 / $ALLcalls) * 100) );}
+if ($ALLhd121 > 0) {$APhd121 = round( ( ($ALLhd121 / $ALLcalls) * 100) );}
+
+$ALLcalls =	sprintf("%5s", $ALLcalls);
+$APhd__0 =	sprintf("%4s", $APhd__0);
+$APhd_20 =	sprintf("%4s", $APhd_20);
+$APhd_40 =	sprintf("%4s", $APhd_40);
+$APhd_60 =	sprintf("%4s", $APhd_60);
+$APhd_80 =	sprintf("%4s", $APhd_80);
+$APhd100 =	sprintf("%4s", $APhd100);
+$APhd120 =	sprintf("%4s", $APhd120);
+$APhd121 =	sprintf("%4s", $APhd121);
+
+	while (strlen($totQUEUEavg)>4) {$totQUEUEavg = ereg_replace(".$",'',$totQUEUEavg);}
+
+echo "+-------------+-------+-----------------------------------------+ +------+--------------------------------+\n";
+echo "| TOTAL       | $ALLcalls | $APhd__0 $APhd_20 $APhd_40 $APhd_60 $APhd_80 $APhd100 $APhd120 $APhd121 | | $totQUEUEavg |\n";
+echo "+-------------+-------+-----------------------------------------+ +------+\n";
+
+$ENDtime = date("U");
+$RUNtime = ($ENDtime - $STARTtime);
+echo "\nRun Time: $RUNtime seconds\n";
+}
+
+
+
+?>
+
+
+ + diff --git a/LANG_www/vicidial_br/AST_CLOSERstats.php b/LANG_www/vicidial_br/AST_CLOSERstats.php new file mode 100644 index 00000000..cd897e3d --- /dev/null +++ b/LANG_www/vicidial_br/AST_CLOSERstats.php @@ -0,0 +1,1537 @@ + LICENSE: AGPLv2 +# +# CHANGES +# +# 60619-1714 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# 60905-1326 - Added queue time stats +# 71008-1436 - Added shift to be defined in dbconnect.php +# 71025-0021 - Added status breakdown +# 71218-1155 - Added end_date for multi-day reports +# 80430-1920 - Added Customer hangup cause stats +# 80709-0331 - Added time stats to call statuses +# 80722-2149 - Added Status Category stats +# 81015-0705 - Added IVR calls count +# 81024-0037 - Added multi-select inbound-groups +# 81105-2118 - Added Answered calls 15-minute breakdown +# 81109-2340 - Added custom indicators section +# 90116-1040 - Rewrite of the 15-minute sections to speed it up and allow multi-day calculations +# 90310-2037 - Admin header +# 90508-0644 - Changed to PHP long tags +# 90524-2231 - Changed to use functions.php for seconds to HH:MM:SS conversion +# 90801-0921 - Added in-group name to pulldown +# 91214-0955 - Added INITIAL QUEUE POSITION BREAKDOWN +# 100206-1454 - Fixed TMR(service level) calculation +# 100214-1421 - Sort menu alphabetically +# 100216-0042 - Added popup date selector +# + +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["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +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["shift"])) {$shift=$_GET["shift"];} + elseif (isset($_POST["shift"])) {$shift=$_POST["shift"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} +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); + +$MT[0]='0'; +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); +if ($qm_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $non_latin = $row[0]; + } +##### END SETTINGS LOOKUP ##### +########################################### + +$stmt = "SELECT local_gmt FROM servers where active='Y' limit 1;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$gmt_conf_ct = mysql_num_rows($rslt); +$dst = date("I"); +if ($gmt_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $local_gmt = $row[0]; + $epoch_offset = (($local_gmt + $dst) * 3600); + } + +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level >= 7 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 "Nome ou Senha inválidos: |$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;} +if (!isset($end_date)) {$end_date = $NOW_DATE;} + +$stmt="select group_id,group_name from vicidial_inbound_groups order by group_id;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +$LISTgroups[$i]='---NONE---'; +$i++; +$groups_to_print++; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $LISTgroups[$i] = $row[0]; + $LISTgroup_names[$i] = $row[1]; + $i++; + } + +$i=0; +$group_string='|'; +$group_ct = count($group); +while($i < $group_ct) + { + $group_string .= "$group[$i]|"; + $group_SQL .= "'$group[$i]',"; + $groupQS .= "&group[]=$group[$i]"; + $i++; + } +if ( (ereg("--NONE--",$group_string) ) or ($group_ct < 1) ) + { + $group_SQL = "''"; +# $group_SQL = "group_id IN('')"; + } +else + { + $group_SQL = eregi_replace(",$",'',$group_SQL); +# $group_SQL = "group_id IN($group_SQL)"; + } + + +$stmt="select vsc_id,vsc_name from vicidial_status_categories;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$statcats_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $statcats_to_print) + { + $row=mysql_fetch_row($rslt); + $vsc_id[$i] = $row[0]; + $vsc_name[$i] = $row[1]; + $vsc_count[$i] = 0; + $i++; + } +?> + + + + + +\n"; +echo "\n"; + +echo "\n"; +echo "Inbound Stats\n"; + +$short_header=1; + +require("admin_header.php"); + +echo "
"; + +if ($DB > 0) + { + echo "
\n"; + echo "$group_ct|$group_string|$group_SQL\n"; + echo "
\n"; + echo "$shift|$query_date|$end_date\n"; + echo "
\n"; + } + +echo "
\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "Período:
\n"; +echo ""; + +?> + +"; + +?> + +
\n"; +echo "Grupos de Entrada: \n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "           "; +echo "ALTERAR | "; +echo "RELATÓRIOS | "; +echo "IVR REPORT \n"; +echo "\n"; + +echo "
\n"; + +#echo "\n"; +echo "Shift: \n"; +echo "   \n"; +echo "
\n"; +echo "
\n\n"; + +echo "
\n\n";
+
+
+if ($groups_to_print < 1)
+{
+echo "\n\n";
+echo "POR FAVOR SELECIONE UM GRUPO DE ENTRADA E PERÍODO ACIMA E CLIQUE ENVIAR\n";
+}
+
+else
+{
+if ($shift == 'AM') 
+	{
+	$time_BEGIN=$AM_shift_BEGIN;
+	$time_END=$AM_shift_END;
+	if (strlen($time_BEGIN) < 6) {$time_BEGIN = "03:45:00";}   
+	if (strlen($time_END) < 6) {$time_END = "15:15:00";}
+	}
+if ($shift == 'PM') 
+	{
+	$time_BEGIN=$PM_shift_BEGIN;
+	$time_END=$PM_shift_END;
+	if (strlen($time_BEGIN) < 6) {$time_BEGIN = "15:15:00";}
+	if (strlen($time_END) < 6) {$time_END = "23:15:00";}
+	}
+if ($shift == 'ALL') 
+	{
+	if (strlen($time_BEGIN) < 6) {$time_BEGIN = "00:00:00";}
+	if (strlen($time_END) < 6) {$time_END = "23:59:59";}
+	}
+$query_date_BEGIN = "$query_date $time_BEGIN";   
+$query_date_END = "$end_date $time_END";
+
+
+
+echo "Inbound Call Stats: $group_string          $NOW_TIME\n";
+
+
+
+
+
+
+if ($group_ct > 1)
+	{
+	echo "\n";
+	echo "---------- MULTI-GROUP BREAKDOWN:\n";
+	echo "+----------------------+---------+---------+---------+---------+\n";
+	echo "| IN-GROUP             | CALLS   | DROPS   | DROP %  | IVR     |\n";
+	echo "+----------------------+---------+---------+---------+---------+\n";
+
+	$i=0;
+	while($i < $group_ct)
+		{
+		$stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id='$group[$i]';";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+
+		$stmt="select count(*) from live_inbound_log where start_time >= '$query_date_BEGIN' and start_time <= '$query_date_END' and comment_a='$group[$i]' and comment_b='START';";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$rowx=mysql_fetch_row($rslt);
+
+		$stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id='$group[$i]' and status IN('DROP','XDROP') and (length_in_sec <= 49999 or length_in_sec is null);";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$rowy=mysql_fetch_row($rslt);
+
+		$groupDISPLAY =	sprintf("%20s", $group[$i]);
+		$gTOTALcalls =	sprintf("%7s", $row[0]);
+		$gIVRcalls =	sprintf("%7s", $rowx[0]);
+		$gDROPcalls =	sprintf("%7s", $rowy[0]);
+		if ( ($gDROPcalls < 1) or ($gTOTALcalls < 1) )
+			{$gDROPpercent = '0';}
+		else
+			{
+			$gDROPpercent = (($gDROPcalls / $gTOTALcalls) * 100);
+			$gDROPpercent = round($gDROPpercent, 2);
+			}
+		$gDROPpercent =	sprintf("%6s", $gDROPpercent);
+
+		echo "| $groupDISPLAY | $gTOTALcalls | $gDROPcalls | $gDROPpercent% | $gIVRcalls |\n";
+		$i++;
+		}
+
+	echo "+----------------------+---------+---------+---------+---------+\n";
+
+	}
+
+
+echo "\n";
+echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
+echo "---------- TOTALS\n";
+
+$stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id IN($group_SQL);";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$stmt="select count(*),sum(queue_seconds) from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id IN($group_SQL) and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE','TIMEOT','AFTHRS','NANQUE','INBND');";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$rowy=mysql_fetch_row($rslt);
+
+$stmt="select count(*) from live_inbound_log where start_time >= '$query_date_BEGIN' and start_time <= '$query_date_END' and comment_a IN($group_SQL) and comment_b='START';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$rowx=mysql_fetch_row($rslt);
+
+$TOTALcalls =	sprintf("%10s", $row[0]);
+$IVRcalls =	sprintf("%10s", $rowx[0]);
+$TOTALsec =		$row[1];
+if ( ($row[0] < 1) or ($TOTALsec < 1) )
+	{$average_call_seconds = '         0';}
+else
+	{
+	$average_call_seconds = ($TOTALsec / $row[0]);
+	$average_call_seconds = round($average_call_seconds, 0);
+	$average_call_seconds =	sprintf("%10s", $average_call_seconds);
+	}
+$RESPOSTAEDcalls  =	sprintf("%10s", $rowy[0]);
+if ( ($RESPOSTAEDcalls < 1) or ($TOTALcalls < 1) )
+	{$RESPOSTAEDpercent = '0';}
+else
+	{
+	$RESPOSTAEDpercent = (($RESPOSTAEDcalls / $TOTALcalls) * 100);
+	$RESPOSTAEDpercent = round($RESPOSTAEDpercent, 0);
+	}
+if ( ($rowy[0] < 1) or ($RESPOSTAEDcalls < 1) )
+	{$average_answer_seconds = '         0';}
+else
+	{
+	$average_answer_seconds = ($rowy[1] / $rowy[0]);
+	$average_answer_seconds = round($average_answer_seconds, 2);
+	$average_answer_seconds =	sprintf("%10s", $average_answer_seconds);
+	}
+
+
+echo "Total de chamadas recebidas pelo Grupo:        $TOTALcalls\n";
+echo "Average Call Length for all Calls:            $average_call_seconds seconds\n";
+echo "Answered Calls:                               $RESPOSTAEDcalls  $RESPOSTAEDpercent%\n";
+echo "Average queue time for Answered Calls:        $average_answer_seconds seconds\n";
+echo "Calls taken into the IVR for this In-Grupo:   $IVRcalls\n";
+
+
+echo "\n";
+echo "---------- DERRUBADAS\n";
+
+$stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id IN($group_SQL) and status IN('DROP','XDROP') and (length_in_sec <= 49999 or length_in_sec is null);";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$DROPcalls =	sprintf("%10s", $row[0]);
+if ( ($DROPcalls < 1) or ($TOTALcalls < 1) )
+	{$DROPpercent = '0';}
+else
+	{
+	$DROPpercent = (($DROPcalls / $TOTALcalls) * 100);
+	$DROPpercent = round($DROPpercent, 0);
+	}
+
+if ( ($row[0] < 1) or ($row[1] < 1) )
+	{
+	$average_hold_seconds = '         0';
+	}
+else
+	{
+	$average_hold_seconds = ($row[1] / $row[0]);
+	$average_hold_seconds = round($average_hold_seconds, 0);
+	$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+	}
+if ( ($RESPOSTAEDcalls < 1) or ($DROPcalls < 1) )
+	{$DROP_RESPOSTAEDpercent = '0';}
+else
+	{
+	$DROP_RESPOSTAEDpercent = (($DROPcalls / $RESPOSTAEDcalls) * 100);
+	$DROP_RESPOSTAEDpercent = round($DROP_RESPOSTAEDpercent, 0);
+	}
+
+echo "Total de chamadas derrubadas:                 $DROPcalls  $DROPpercent%               drop/answered: $DROP_RESPOSTAEDpercent%\n";
+echo "Average hold time for DROP Calls:             $average_hold_seconds seconds\n";
+
+
+
+
+if (strlen($group_SQL)>3)
+	{
+	$stmt = "SELECT answer_sec_pct_rt_stat_one,answer_sec_pct_rt_stat_two from vicidial_inbound_groups where group_id IN($group_SQL) order by answer_sec_pct_rt_stat_one desc limit 1;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$Sanswer_sec_pct_rt_stat_one = $row[0];
+	$Sanswer_sec_pct_rt_stat_two = $row[1];
+
+	$stmt = "SELECT count(*) from vicidial_closer_log where campaign_id IN($group_SQL) and call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and queue_seconds <= $Sanswer_sec_pct_rt_stat_one and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE','TIMEOT','AFTHRS','NANQUE','INBND');";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$answer_sec_pct_rt_stat_one = $row[0];
+
+	$stmt = "SELECT count(*) from vicidial_closer_log where campaign_id IN($group_SQL) and call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and queue_seconds <= $Sanswer_sec_pct_rt_stat_two and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE','TIMEOT','AFTHRS','NANQUE','INBND');";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$answer_sec_pct_rt_stat_two = $row[0];
+
+	if ( ($RESPOSTAEDcalls > 0) and ($answer_sec_pct_rt_stat_one > 0) and ($answer_sec_pct_rt_stat_two > 0) )
+		{
+		$PCTanswer_sec_pct_rt_stat_one = (($answer_sec_pct_rt_stat_one / $RESPOSTAEDcalls) * 100);
+		$PCTanswer_sec_pct_rt_stat_one = round($PCTanswer_sec_pct_rt_stat_one, 0);
+		#$PCTanswer_sec_pct_rt_stat_one = sprintf("%10s", $PCTanswer_sec_pct_rt_stat_one);
+		$PCTanswer_sec_pct_rt_stat_two = (($answer_sec_pct_rt_stat_two / $RESPOSTAEDcalls) * 100);
+		$PCTanswer_sec_pct_rt_stat_two = round($PCTanswer_sec_pct_rt_stat_two, 0);
+		#$PCTanswer_sec_pct_rt_stat_two = sprintf("%10s", $PCTanswer_sec_pct_rt_stat_two);
+		}
+	}
+echo "\n";
+echo "---------- CUSTOM INDICATORS\n";
+echo "GDE (Answered/Chamadas totais atendidas in to this In-Group):  $RESPOSTAEDpercent%\n";
+echo "ACR (Dropped/Answered):                                $DROP_RESPOSTAEDpercent%\n";
+echo "TMR1 (Answered within $Sanswer_sec_pct_rt_stat_one seconds/Answered):            $PCTanswer_sec_pct_rt_stat_one%\n";
+echo "TMR2 (Answered within $Sanswer_sec_pct_rt_stat_two seconds/Answered):            $PCTanswer_sec_pct_rt_stat_two%\n";
+
+
+# GET LIST OF ALL STATUSES and create SQL from human_answered statuses
+$q=0;
+$stmt = "SELECT status,status_name,human_answered,category from vicidial_statuses;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$statuses_to_print = mysql_num_rows($rslt);
+$p=0;
+while ($p < $statuses_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$status[$q] =			$row[0];
+	$status_name[$q] =		$row[1];
+	$human_answered[$q] =	$row[2];
+	$category[$q] =			$row[3];
+	$statname_list["$status[$q]"] = "$status_name[$q]";
+	$statcat_list["$status[$q]"] = "$category[$q]";
+	$q++;
+	$p++;
+	}
+$stmt = "SELECT status,status_name,human_answered,category from vicidial_campaign_statuses;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$statuses_to_print = mysql_num_rows($rslt);
+$p=0;
+while ($p < $statuses_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$status[$q] =			$row[0];
+	$status_name[$q] =		$row[1];
+	$human_answered[$q] =	$row[2];
+	$category[$q] =			$row[3];
+	$statname_list["$status[$q]"] = "$status_name[$q]";
+	$statcat_list["$status[$q]"] = "$category[$q]";
+	$q++;
+	$p++;
+	}
+
+##############################
+#########  CALL QUEUE STATS
+echo "\n";
+echo "---------- QUEUE STATS\n";
+
+$stmt="select count(*),sum(queue_seconds) from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id IN($group_SQL) and (queue_seconds > 0);";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$QUEUEcalls =	sprintf("%10s", $row[0]);
+if ( ($QUEUEcalls < 1) or ($TOTALcalls < 1) )
+	{$QUEUEpercent = '0';}
+else
+	{
+	$QUEUEpercent = (($QUEUEcalls / $TOTALcalls) * 100);
+	$QUEUEpercent = round($QUEUEpercent, 0);
+	}
+
+if ( ($row[0] < 1) or ($row[1] < 1) )
+	{$average_queue_seconds = '         0';}
+else
+	{
+	$average_queue_seconds = ($row[1] / $row[0]);
+	$average_queue_seconds = round($average_queue_seconds, 2);
+	$average_queue_seconds = sprintf("%10.2f", $average_queue_seconds);
+	}
+
+if ( ($TOTALcalls < 1) or ($row[1] < 1) )
+	{$average_total_queue_seconds = '         0';}
+else
+	{
+	$average_total_queue_seconds = ($row[1] / $TOTALcalls);
+	$average_total_queue_seconds = round($average_total_queue_seconds, 2);
+	$average_total_queue_seconds = sprintf("%10.2f", $average_total_queue_seconds);
+	}
+
+echo "Total Calls That entered Queue:               $QUEUEcalls  $QUEUEpercent%\n";
+echo "Average QUEUE Length for queue calls:         $average_queue_seconds seconds\n";
+echo "Average QUEUE Length across all calls:        $average_total_queue_seconds seconds\n";
+
+
+
+##############################
+#########  CALL HOLD TIME BREAKDOWN IN SECONDS
+
+$TOTALcalls = 0;
+
+echo "\n";
+echo "---------- TEMPO DE ESPERA POR SEGUNDOS\n";
+echo "+-------------------------------------------------------------------------------------------+------------+\n";
+echo "|     0     5    10    15    20    25    30    35    40    45    50    55    60    90   +90 | TOTAL      |\n";
+echo "+-------------------------------------------------------------------------------------------+------------+\n";
+
+$stmt="select count(*),queue_seconds from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and  campaign_id IN($group_SQL) group by queue_seconds;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$reasons_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $reasons_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+
+	$TOTALcalls = ($TOTALcalls + $row[0]);
+
+	if ($row[1] == 0) {$hd_0 = ($hd_0 + $row[0]);}
+	if ( ($row[1] > 0) and ($row[1] <= 5) ) {$hd_5 = ($hd_5 + $row[0]);}
+	if ( ($row[1] > 5) and ($row[1] <= 10) ) {$hd10 = ($hd10 + $row[0]);}
+	if ( ($row[1] > 10) and ($row[1] <= 15) ) {$hd15 = ($hd15 + $row[0]);}
+	if ( ($row[1] > 15) and ($row[1] <= 20) ) {$hd20 = ($hd20 + $row[0]);}
+	if ( ($row[1] > 20) and ($row[1] <= 25) ) {$hd25 = ($hd25 + $row[0]);}
+	if ( ($row[1] > 25) and ($row[1] <= 30) ) {$hd30 = ($hd30 + $row[0]);}
+	if ( ($row[1] > 30) and ($row[1] <= 35) ) {$hd35 = ($hd35 + $row[0]);}
+	if ( ($row[1] > 35) and ($row[1] <= 40) ) {$hd40 = ($hd40 + $row[0]);}
+	if ( ($row[1] > 40) and ($row[1] <= 45) ) {$hd45 = ($hd45 + $row[0]);}
+	if ( ($row[1] > 45) and ($row[1] <= 50) ) {$hd50 = ($hd50 + $row[0]);}
+	if ( ($row[1] > 50) and ($row[1] <= 55) ) {$hd55 = ($hd55 + $row[0]);}
+	if ( ($row[1] > 55) and ($row[1] <= 60) ) {$hd60 = ($hd60 + $row[0]);}
+	if ( ($row[1] > 60) and ($row[1] <= 90) ) {$hd90 = ($hd90 + $row[0]);}
+	if ($row[1] > 90) {$hd99 = ($hd99 + $row[0]);}
+	$i++;
+	}
+
+$hd_0 =	sprintf("%5s", $hd_0);
+$hd_5 =	sprintf("%5s", $hd_5);
+$hd10 =	sprintf("%5s", $hd10);
+$hd15 =	sprintf("%5s", $hd15);
+$hd20 =	sprintf("%5s", $hd20);
+$hd25 =	sprintf("%5s", $hd25);
+$hd30 =	sprintf("%5s", $hd30);
+$hd35 =	sprintf("%5s", $hd35);
+$hd40 =	sprintf("%5s", $hd40);
+$hd45 =	sprintf("%5s", $hd45);
+$hd50 =	sprintf("%5s", $hd50);
+$hd55 =	sprintf("%5s", $hd55);
+$hd60 =	sprintf("%5s", $hd60);
+$hd90 =	sprintf("%5s", $hd90);
+$hd99 =	sprintf("%5s", $hd99);
+
+$TOTALcalls =		sprintf("%10s", $TOTALcalls);
+
+echo "| $hd_0 $hd_5 $hd10 $hd15 $hd20 $hd25 $hd30 $hd35 $hd40 $hd45 $hd50 $hd55 $hd60 $hd90 $hd99 | $TOTALcalls |\n";
+echo "+-------------------------------------------------------------------------------------------+------------+\n";
+
+
+
+##############################
+#########  CALL DROP TIME BREAKDOWN IN SECONDS
+
+$BDdropCALLS = 0;
+
+echo "\n";
+echo "---------- CALL DROP TIME BREAKDOWN IN SECONDS\n";
+echo "+-------------------------------------------------------------------------------------------+------------+\n";
+echo "|     0     5    10    15    20    25    30    35    40    45    50    55    60    90   +90 | TOTAL      |\n";
+echo "+-------------------------------------------------------------------------------------------+------------+\n";
+
+$stmt="select count(*),queue_seconds from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and  campaign_id IN($group_SQL) and status IN('DROP','XDROP') group by queue_seconds;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$reasons_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $reasons_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+
+	$BDdropCALLS = ($BDdropCALLS + $row[0]);
+
+	if ($row[1] == 0) {$dd_0 = ($dd_0 + $row[0]);}
+	if ( ($row[1] > 0) and ($row[1] <= 5) ) {$dd_5 = ($dd_5 + $row[0]);}
+	if ( ($row[1] > 5) and ($row[1] <= 10) ) {$dd10 = ($dd10 + $row[0]);}
+	if ( ($row[1] > 10) and ($row[1] <= 15) ) {$dd15 = ($dd15 + $row[0]);}
+	if ( ($row[1] > 15) and ($row[1] <= 20) ) {$dd20 = ($dd20 + $row[0]);}
+	if ( ($row[1] > 20) and ($row[1] <= 25) ) {$dd25 = ($dd25 + $row[0]);}
+	if ( ($row[1] > 25) and ($row[1] <= 30) ) {$dd30 = ($dd30 + $row[0]);}
+	if ( ($row[1] > 30) and ($row[1] <= 35) ) {$dd35 = ($dd35 + $row[0]);}
+	if ( ($row[1] > 35) and ($row[1] <= 40) ) {$dd40 = ($dd40 + $row[0]);}
+	if ( ($row[1] > 40) and ($row[1] <= 45) ) {$dd45 = ($dd45 + $row[0]);}
+	if ( ($row[1] > 45) and ($row[1] <= 50) ) {$dd50 = ($dd50 + $row[0]);}
+	if ( ($row[1] > 50) and ($row[1] <= 55) ) {$dd55 = ($dd55 + $row[0]);}
+	if ( ($row[1] > 55) and ($row[1] <= 60) ) {$dd60 = ($dd60 + $row[0]);}
+	if ( ($row[1] > 60) and ($row[1] <= 90) ) {$dd90 = ($dd90 + $row[0]);}
+	if ($row[1] > 90) {$dd99 = ($dd99 + $row[0]);}
+	$i++;
+	}
+
+$dd_0 =	sprintf("%5s", $dd_0);
+$dd_5 =	sprintf("%5s", $dd_5);
+$dd10 =	sprintf("%5s", $dd10);
+$dd15 =	sprintf("%5s", $dd15);
+$dd20 =	sprintf("%5s", $dd20);
+$dd25 =	sprintf("%5s", $dd25);
+$dd30 =	sprintf("%5s", $dd30);
+$dd35 =	sprintf("%5s", $dd35);
+$dd40 =	sprintf("%5s", $dd40);
+$dd45 =	sprintf("%5s", $dd45);
+$dd50 =	sprintf("%5s", $dd50);
+$dd55 =	sprintf("%5s", $dd55);
+$dd60 =	sprintf("%5s", $dd60);
+$dd90 =	sprintf("%5s", $dd90);
+$dd99 =	sprintf("%5s", $dd99);
+
+$BDdropCALLS =		sprintf("%10s", $BDdropCALLS);
+
+echo "| $dd_0 $dd_5 $dd10 $dd15 $dd20 $dd25 $dd30 $dd35 $dd40 $dd45 $dd50 $dd55 $dd60 $dd90 $dd99 | $BDdropCALLS |\n";
+echo "+-------------------------------------------------------------------------------------------+------------+\n";
+
+
+
+
+##############################
+#########  CALL ANSWERED TIME AND PERCENT BREAKDOWN IN SECONDS
+
+$BDansweredCALLS = 0;
+
+echo "\n";
+echo "           CALL RESPOSTAED TIME AND PERCENT BREAKDOWN IN SECONDS\n";
+echo "          +-------------------------------------------------------------------------------------------+------------+\n";
+echo "          |     0     5    10    15    20    25    30    35    40    45    50    55    60    90   +90 | TOTAL      |\n";
+echo "----------+-------------------------------------------------------------------------------------------+------------+\n";
+
+$stmt="select count(*),queue_seconds from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and  campaign_id IN($group_SQL) and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE','TIMEOT','AFTHRS','NANQUE','INBND') group by queue_seconds;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$reasons_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $reasons_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+
+	$BDansweredCALLS = ($BDansweredCALLS + $row[0]);
+	
+	### Get interval totals
+	if ($row[1] == 0) {$ad_0 = ($ad_0 + $row[0]);}
+	if ( ($row[1] > 0) and ($row[1] <= 5) ) {$ad_5 = ($ad_5 + $row[0]);}
+	if ( ($row[1] > 5) and ($row[1] <= 10) ) {$ad10 = ($ad10 + $row[0]);}
+	if ( ($row[1] > 10) and ($row[1] <= 15) ) {$ad15 = ($ad15 + $row[0]);}
+	if ( ($row[1] > 15) and ($row[1] <= 20) ) {$ad20 = ($ad20 + $row[0]);}
+	if ( ($row[1] > 20) and ($row[1] <= 25) ) {$ad25 = ($ad25 + $row[0]);}
+	if ( ($row[1] > 25) and ($row[1] <= 30) ) {$ad30 = ($ad30 + $row[0]);}
+	if ( ($row[1] > 30) and ($row[1] <= 35) ) {$ad35 = ($ad35 + $row[0]);}
+	if ( ($row[1] > 35) and ($row[1] <= 40) ) {$ad40 = ($ad40 + $row[0]);}
+	if ( ($row[1] > 40) and ($row[1] <= 45) ) {$ad45 = ($ad45 + $row[0]);}
+	if ( ($row[1] > 45) and ($row[1] <= 50) ) {$ad50 = ($ad50 + $row[0]);}
+	if ( ($row[1] > 50) and ($row[1] <= 55) ) {$ad55 = ($ad55 + $row[0]);}
+	if ( ($row[1] > 55) and ($row[1] <= 60) ) {$ad60 = ($ad60 + $row[0]);}
+	if ( ($row[1] > 60) and ($row[1] <= 90) ) {$ad90 = ($ad90 + $row[0]);}
+	if ($row[1] > 90) {$ad99 = ($ad99 + $row[0]);}
+	$i++;
+	}
+
+### Calculate cumulative totals
+$Cad_0 =$ad_0;
+$Cad_5 =($Cad_0 + $ad_5);
+$Cad10 =($Cad_5 + $ad10);
+$Cad15 =($Cad10 + $ad15);
+$Cad20 =($Cad15 + $ad20);
+$Cad25 =($Cad20 + $ad25);
+$Cad30 =($Cad25 + $ad30);
+$Cad35 =($Cad30 + $ad35);
+$Cad40 =($Cad35 + $ad40);
+$Cad45 =($Cad40 + $ad45);
+$Cad50 =($Cad45 + $ad50);
+$Cad55 =($Cad50 + $ad55);
+$Cad60 =($Cad55 + $ad60);
+$Cad90 =($Cad60 + $ad90);
+$Cad99 =($Cad90 + $ad99);
+
+### Calculate interval percentages
+$pad_0=0; $pad_5=0; $pad10=0; $pad15=0; $pad20=0; $pad25=0; $pad30=0; $pad35=0; $pad40=0; $pad45=0; $pad50=0; $pad55=0; $pad60=0; $pad90=0; $pad99=0; 
+$pCad_0=0; $pCad_5=0; $pCad10=0; $pCad15=0; $pCad20=0; $pCad25=0; $pCad30=0; $pCad35=0; $pCad40=0; $pCad45=0; $pCad50=0; $pCad55=0; $pCad60=0; $pCad90=0; $pCad99=0; 
+if ( ($BDansweredCALLS > 0) and ($TOTALcalls > 0) )
+	{
+	if ($ad_0 > 0) {$pad_0 = (($ad_0 / $TOTALcalls) * 100);	$pad_0 = round($pad_0, 0);}
+	if ($ad_5 > 0) {$pad_5 = (($ad_5 / $TOTALcalls) * 100);	$pad_5 = round($pad_5, 0);}
+	if ($ad10 > 0) {$pad10 = (($ad10 / $TOTALcalls) * 100);	$pad10 = round($pad10, 0);}
+	if ($ad15 > 0) {$pad15 = (($ad15 / $TOTALcalls) * 100);	$pad15 = round($pad15, 0);}
+	if ($ad20 > 0) {$pad20 = (($ad20 / $TOTALcalls) * 100);	$pad20 = round($pad20, 0);}
+	if ($ad25 > 0) {$pad25 = (($ad25 / $TOTALcalls) * 100);	$pad25 = round($pad25, 0);}
+	if ($ad30 > 0) {$pad30 = (($ad30 / $TOTALcalls) * 100);	$pad30 = round($pad30, 0);}
+	if ($ad35 > 0) {$pad35 = (($ad35 / $TOTALcalls) * 100);	$pad35 = round($pad35, 0);}
+	if ($ad40 > 0) {$pad40 = (($ad40 / $TOTALcalls) * 100);	$pad40 = round($pad40, 0);}
+	if ($ad45 > 0) {$pad45 = (($ad45 / $TOTALcalls) * 100);	$pad45 = round($pad45, 0);}
+	if ($ad50 > 0) {$pad50 = (($ad50 / $TOTALcalls) * 100);	$pad50 = round($pad50, 0);}
+	if ($ad55 > 0) {$pad55 = (($ad55 / $TOTALcalls) * 100);	$pad55 = round($pad55, 0);}
+	if ($ad60 > 0) {$pad60 = (($ad60 / $TOTALcalls) * 100);	$pad60 = round($pad60, 0);}
+	if ($ad90 > 0) {$pad90 = (($ad90 / $TOTALcalls) * 100);	$pad90 = round($pad90, 0);}
+	if ($ad99 > 0) {$pad99 = (($ad99 / $TOTALcalls) * 100);	$pad99 = round($pad99, 0);}
+
+	if ($Cad_0 > 0) {$pCad_0 = (($Cad_0 / $TOTALcalls) * 100);	$pCad_0 = round($pCad_0, 0);}
+	if ($Cad_5 > 0) {$pCad_5 = (($Cad_5 / $TOTALcalls) * 100);	$pCad_5 = round($pCad_5, 0);}
+	if ($Cad10 > 0) {$pCad10 = (($Cad10 / $TOTALcalls) * 100);	$pCad10 = round($pCad10, 0);}
+	if ($Cad15 > 0) {$pCad15 = (($Cad15 / $TOTALcalls) * 100);	$pCad15 = round($pCad15, 0);}
+	if ($Cad20 > 0) {$pCad20 = (($Cad20 / $TOTALcalls) * 100);	$pCad20 = round($pCad20, 0);}
+	if ($Cad25 > 0) {$pCad25 = (($Cad25 / $TOTALcalls) * 100);	$pCad25 = round($pCad25, 0);}
+	if ($Cad30 > 0) {$pCad30 = (($Cad30 / $TOTALcalls) * 100);	$pCad30 = round($pCad30, 0);}
+	if ($Cad35 > 0) {$pCad35 = (($Cad35 / $TOTALcalls) * 100);	$pCad35 = round($pCad35, 0);}
+	if ($Cad40 > 0) {$pCad40 = (($Cad40 / $TOTALcalls) * 100);	$pCad40 = round($pCad40, 0);}
+	if ($Cad45 > 0) {$pCad45 = (($Cad45 / $TOTALcalls) * 100);	$pCad45 = round($pCad45, 0);}
+	if ($Cad50 > 0) {$pCad50 = (($Cad50 / $TOTALcalls) * 100);	$pCad50 = round($pCad50, 0);}
+	if ($Cad55 > 0) {$pCad55 = (($Cad55 / $TOTALcalls) * 100);	$pCad55 = round($pCad55, 0);}
+	if ($Cad60 > 0) {$pCad60 = (($Cad60 / $TOTALcalls) * 100);	$pCad60 = round($pCad60, 0);}
+	if ($Cad90 > 0) {$pCad90 = (($Cad90 / $TOTALcalls) * 100);	$pCad90 = round($pCad90, 0);}
+	if ($Cad99 > 0) {$pCad99 = (($Cad99 / $TOTALcalls) * 100);	$pCad99 = round($pCad99, 0);}
+
+	if ($Cad_0 > 0) {$ApCad_0 = (($Cad_0 / $BDansweredCALLS) * 100);	$ApCad_0 = round($ApCad_0, 0);}
+	if ($Cad_5 > 0) {$ApCad_5 = (($Cad_5 / $BDansweredCALLS) * 100);	$ApCad_5 = round($ApCad_5, 0);}
+	if ($Cad10 > 0) {$ApCad10 = (($Cad10 / $BDansweredCALLS) * 100);	$ApCad10 = round($ApCad10, 0);}
+	if ($Cad15 > 0) {$ApCad15 = (($Cad15 / $BDansweredCALLS) * 100);	$ApCad15 = round($ApCad15, 0);}
+	if ($Cad20 > 0) {$ApCad20 = (($Cad20 / $BDansweredCALLS) * 100);	$ApCad20 = round($ApCad20, 0);}
+	if ($Cad25 > 0) {$ApCad25 = (($Cad25 / $BDansweredCALLS) * 100);	$ApCad25 = round($ApCad25, 0);}
+	if ($Cad30 > 0) {$ApCad30 = (($Cad30 / $BDansweredCALLS) * 100);	$ApCad30 = round($ApCad30, 0);}
+	if ($Cad35 > 0) {$ApCad35 = (($Cad35 / $BDansweredCALLS) * 100);	$ApCad35 = round($ApCad35, 0);}
+	if ($Cad40 > 0) {$ApCad40 = (($Cad40 / $BDansweredCALLS) * 100);	$ApCad40 = round($ApCad40, 0);}
+	if ($Cad45 > 0) {$ApCad45 = (($Cad45 / $BDansweredCALLS) * 100);	$ApCad45 = round($ApCad45, 0);}
+	if ($Cad50 > 0) {$ApCad50 = (($Cad50 / $BDansweredCALLS) * 100);	$ApCad50 = round($ApCad50, 0);}
+	if ($Cad55 > 0) {$ApCad55 = (($Cad55 / $BDansweredCALLS) * 100);	$ApCad55 = round($ApCad55, 0);}
+	if ($Cad60 > 0) {$ApCad60 = (($Cad60 / $BDansweredCALLS) * 100);	$ApCad60 = round($ApCad60, 0);}
+	if ($Cad90 > 0) {$ApCad90 = (($Cad90 / $BDansweredCALLS) * 100);	$ApCad90 = round($ApCad90, 0);}
+	if ($Cad99 > 0) {$ApCad99 = (($Cad99 / $BDansweredCALLS) * 100);	$ApCad99 = round($ApCad99, 0);}
+	}
+
+### Format variables
+$ad_0 = sprintf("%5s", $ad_0);
+$ad_5 = sprintf("%5s", $ad_5);
+$ad10 = sprintf("%5s", $ad10);
+$ad15 = sprintf("%5s", $ad15);
+$ad20 = sprintf("%5s", $ad20);
+$ad25 = sprintf("%5s", $ad25);
+$ad30 = sprintf("%5s", $ad30);
+$ad35 = sprintf("%5s", $ad35);
+$ad40 = sprintf("%5s", $ad40);
+$ad45 = sprintf("%5s", $ad45);
+$ad50 = sprintf("%5s", $ad50);
+$ad55 = sprintf("%5s", $ad55);
+$ad60 = sprintf("%5s", $ad60);
+$ad90 = sprintf("%5s", $ad90);
+$ad99 = sprintf("%5s", $ad99);
+$Cad_0 = sprintf("%5s", $Cad_0);
+$Cad_5 = sprintf("%5s", $Cad_5);
+$Cad10 = sprintf("%5s", $Cad10);
+$Cad15 = sprintf("%5s", $Cad15);
+$Cad20 = sprintf("%5s", $Cad20);
+$Cad25 = sprintf("%5s", $Cad25);
+$Cad30 = sprintf("%5s", $Cad30);
+$Cad35 = sprintf("%5s", $Cad35);
+$Cad40 = sprintf("%5s", $Cad40);
+$Cad45 = sprintf("%5s", $Cad45);
+$Cad50 = sprintf("%5s", $Cad50);
+$Cad55 = sprintf("%5s", $Cad55);
+$Cad60 = sprintf("%5s", $Cad60);
+$Cad90 = sprintf("%5s", $Cad90);
+$Cad99 = sprintf("%5s", $Cad99);
+$pad_0 = sprintf("%4s", $pad_0) . '%';
+$pad_5 = sprintf("%4s", $pad_5) . '%';
+$pad10 = sprintf("%4s", $pad10) . '%';
+$pad15 = sprintf("%4s", $pad15) . '%';
+$pad20 = sprintf("%4s", $pad20) . '%';
+$pad25 = sprintf("%4s", $pad25) . '%';
+$pad30 = sprintf("%4s", $pad30) . '%';
+$pad35 = sprintf("%4s", $pad35) . '%';
+$pad40 = sprintf("%4s", $pad40) . '%';
+$pad45 = sprintf("%4s", $pad45) . '%';
+$pad50 = sprintf("%4s", $pad50) . '%';
+$pad55 = sprintf("%4s", $pad55) . '%';
+$pad60 = sprintf("%4s", $pad60) . '%';
+$pad90 = sprintf("%4s", $pad90) . '%';
+$pad99 = sprintf("%4s", $pad99) . '%';
+$pCad_0 = sprintf("%4s", $pCad_0) . '%';
+$pCad_5 = sprintf("%4s", $pCad_5) . '%';
+$pCad10 = sprintf("%4s", $pCad10) . '%';
+$pCad15 = sprintf("%4s", $pCad15) . '%';
+$pCad20 = sprintf("%4s", $pCad20) . '%';
+$pCad25 = sprintf("%4s", $pCad25) . '%';
+$pCad30 = sprintf("%4s", $pCad30) . '%';
+$pCad35 = sprintf("%4s", $pCad35) . '%';
+$pCad40 = sprintf("%4s", $pCad40) . '%';
+$pCad45 = sprintf("%4s", $pCad45) . '%';
+$pCad50 = sprintf("%4s", $pCad50) . '%';
+$pCad55 = sprintf("%4s", $pCad55) . '%';
+$pCad60 = sprintf("%4s", $pCad60) . '%';
+$pCad90 = sprintf("%4s", $pCad90) . '%';
+$pCad99 = sprintf("%4s", $pCad99) . '%';
+$ApCad_0 = sprintf("%4s", $ApCad_0) . '%';
+$ApCad_5 = sprintf("%4s", $ApCad_5) . '%';
+$ApCad10 = sprintf("%4s", $ApCad10) . '%';
+$ApCad15 = sprintf("%4s", $ApCad15) . '%';
+$ApCad20 = sprintf("%4s", $ApCad20) . '%';
+$ApCad25 = sprintf("%4s", $ApCad25) . '%';
+$ApCad30 = sprintf("%4s", $ApCad30) . '%';
+$ApCad35 = sprintf("%4s", $ApCad35) . '%';
+$ApCad40 = sprintf("%4s", $ApCad40) . '%';
+$ApCad45 = sprintf("%4s", $ApCad45) . '%';
+$ApCad50 = sprintf("%4s", $ApCad50) . '%';
+$ApCad55 = sprintf("%4s", $ApCad55) . '%';
+$ApCad60 = sprintf("%4s", $ApCad60) . '%';
+$ApCad90 = sprintf("%4s", $ApCad90) . '%';
+$ApCad99 = sprintf("%4s", $ApCad99) . '%';
+
+$BDansweredCALLS =		sprintf("%10s", $BDansweredCALLS);
+
+### Format and output
+$answeredTOTALs = "$ad_0 $ad_5 $ad10 $ad15 $ad20 $ad25 $ad30 $ad35 $ad40 $ad45 $ad50 $ad55 $ad60 $ad90 $ad99 | $BDansweredCALLS |";
+$answeredCUMULATIVE = "$Cad_0 $Cad_5 $Cad10 $Cad15 $Cad20 $Cad25 $Cad30 $Cad35 $Cad40 $Cad45 $Cad50 $Cad55 $Cad60 $Cad90 $Cad99 | $BDansweredCALLS |";
+$answeredINT_PERCENT = "$pad_0 $pad_5 $pad10 $pad15 $pad20 $pad25 $pad30 $pad35 $pad40 $pad45 $pad50 $pad55 $pad60 $pad90 $pad99 |            |";
+$answeredCUM_PERCENT = "$pCad_0 $pCad_5 $pCad10 $pCad15 $pCad20 $pCad25 $pCad30 $pCad35 $pCad40 $pCad45 $pCad50 $pCad55 $pCad60 $pCad90 $pCad99 |            |";
+$answeredCUM_ANS_PERCENT = "$ApCad_0 $ApCad_5 $ApCad10 $ApCad15 $ApCad20 $ApCad25 $ApCad30 $ApCad35 $ApCad40 $ApCad45 $ApCad50 $ApCad55 $ApCad60 $ApCad90 $ApCad99 |            |";
+echo "INTERVAL  | $answeredTOTALs\n";
+echo "INT %     | $answeredINT_PERCENT\n";
+echo "CUMULATIVE| $answeredCUMULATIVE\n";
+echo "CUM %     | $answeredCUM_PERCENT\n";
+echo "CUM ANS % | $answeredCUM_ANS_PERCENT\n";
+echo "----------+-------------------------------------------------------------------------------------------+------------+\n";
+
+
+
+
+
+##############################
+#########  CALL HANGUP REASON STATS
+
+$TOTALcalls = 0;
+
+echo "\n";
+echo "---------- ESTATÍSTICA DE MOTIVO DE DESLIGAMENTO\n";
+echo "+----------------------+------------+\n";
+echo "| HANGUP REASON        | CALLS      |\n";
+echo "+----------------------+------------+\n";
+
+$stmt="select count(*),term_reason from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and  campaign_id IN($group_SQL) group by term_reason;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$reasons_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $reasons_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+
+	$TOTALcalls = ($TOTALcalls + $row[0]);
+
+	$REASONcount =	sprintf("%10s", $row[0]);while(strlen($REASONcount)>10) {$REASONcount = substr("$REASONcount", 0, -1);}
+	$reason =	sprintf("%-20s", $row[1]);while(strlen($reason)>20) {$reason = substr("$reason", 0, -1);}
+#	if (ereg("NONE",$reason)) {$reason = 'NO ANSWER           ';}
+
+	echo "| $reason | $REASONcount |\n";
+
+	$i++;
+	}
+
+$TOTALcalls =		sprintf("%10s", $TOTALcalls);
+
+echo "+----------------------+------------+\n";
+echo "| TOTAL:               | $TOTALcalls |\n";
+echo "+----------------------+------------+\n";
+
+
+
+
+##############################
+#########  CALL STATUS STATS
+
+$TOTALcalls = 0;
+
+echo "\n";
+echo "---------- CALL STATUS STATS\n";
+echo "+--------+----------------------+----------------------+------------+------------+----------+----------+\n";
+echo "| STATUS | DESCRIPTION          | CATEGORIA             | CALLS      | TOTAL TIME | AVG TIME |CALLS/HOUR|\n";
+echo "+--------+----------------------+----------------------+------------+------------+----------+----------+\n";
+
+
+## get counts and time totals for all statuses in this campaign
+$stmt="select count(*),status,sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and  campaign_id IN($group_SQL) group by status;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$statuses_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $statuses_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+
+	$STATUScount =	$row[0];
+	$RAWstatus =	$row[1];
+	$r=0;  $foundstat=0;
+	while ($r < $statcats_to_print)
+		{
+		if ( ($statcat_list[$RAWstatus] == "$vsc_id[$r]") and ($foundstat < 1) )
+			{
+			$vsc_count[$r] = ($vsc_count[$r] + $STATUScount);
+			}
+		$r++;
+		}
+
+	$TOTALcalls =	($TOTALcalls + $row[0]);
+	if ( ($STATUScount < 1) or ($TOTALsec < 1) )
+		{$STATUSrate = 0;}
+	else
+		{$STATUSrate =	($STATUScount / ($TOTALsec / 3600) );}
+	$STATUSrate =	sprintf("%.2f", $STATUSrate);
+
+	$STATUShours =		sec_convert($row[2],'H'); 
+	$STATUSavg_sec =	($row[2] / $STATUScount); 
+	$STATUSavg =		sec_convert($STATUSavg_sec,'H'); 
+
+	$STATUScount =	sprintf("%10s", $row[0]);while(strlen($STATUScount)>10) {$STATUScount = substr("$STATUScount", 0, -1);}
+	$status =	sprintf("%-6s", $row[1]);while(strlen($status)>6) {$status = substr("$status", 0, -1);}
+	$STATUShours =	sprintf("%10s", $STATUShours);while(strlen($STATUShours)>10) {$STATUShours = substr("$STATUShours", 0, -1);}
+	$STATUSavg =	sprintf("%8s", $STATUSavg);while(strlen($STATUSavg)>8) {$STATUSavg = substr("$STATUSavg", 0, -1);}
+	$STATUSrate =	sprintf("%8s", $STATUSrate);while(strlen($STATUSrate)>8) {$STATUSrate = substr("$STATUSrate", 0, -1);}
+
+	if ($non_latin < 1)
+		{
+		$status_name =	sprintf("%-20s", $statname_list[$RAWstatus]); 
+		while(strlen($status_name)>20) {$status_name = substr("$status_name", 0, -1);}	
+		$statcat =	sprintf("%-20s", $statcat_list[$RAWstatus]); 
+		while(strlen($statcat)>20) {$statcat = substr("$statcat", 0, -1);}	
+		}
+	else
+		{
+		$status_name =	sprintf("%-60s", $statname_list[$RAWstatus]); 
+		while(mb_strlen($status_name,'utf-8')>20) {$status_name = mb_substr("$status_name", 0, -1,'utf-8');}	
+		$statcat =	sprintf("%-60s", $statcat_list[$RAWstatus]); 
+		while(mb_strlen($statcat,'utf-8')>20) {$statcat = mb_substr("$statcat", 0, -1,'utf-8');}	
+		}
+
+
+	echo "| $status | $status_name | $statcat | $STATUScount | $STATUShours | $STATUSavg | $STATUSrate |\n";
+
+	$i++;
+	}
+
+if ($TOTALcalls < 1)
+	{
+	$TOTALhours =	'0:00:00';
+	$TOTALavg =		'0:00:00';
+	$TOTALrate =	'0.00';
+	}
+else
+	{
+	if ( ($TOTALcalls < 1) or ($TOTALsec < 1) )
+		{$TOTALrate = 0;}
+	else
+		{$TOTALrate =	($TOTALcalls / ($TOTALsec / 3600) );}
+	$TOTALrate =	sprintf("%.2f", $TOTALrate);
+
+	$TOTALhours =		sec_convert($TOTALsec,'H'); 
+	$TOTALavg_sec =		($TOTALsec / $TOTALcalls);
+	$TOTALavg =			sec_convert($TOTALavg_sec,'H'); 
+	}
+$TOTALcalls =	sprintf("%10s", $TOTALcalls);
+$TOTALhours =	sprintf("%10s", $TOTALhours);while(strlen($TOTALhours)>10) {$TOTALhours = substr("$TOTALhours", 0, -1);}
+$TOTALavg =	sprintf("%8s", $TOTALavg);while(strlen($TOTALavg)>8) {$TOTALavg = substr("$TOTALavg", 0, -1);}
+$TOTALrate =	sprintf("%8s", $TOTALrate);while(strlen($TOTALrate)>8) {$TOTALrate = substr("$TOTALrate", 0, -1);}
+
+echo "+--------+----------------------+----------------------+------------+------------+----------+----------+\n";
+echo "| TOTAL:                                               | $TOTALcalls | $TOTALhours | $TOTALavg | $TOTALrate |\n";
+echo "+------------------------------------------------------+------------+------------+----------+----------+\n";
+
+
+##############################
+#########  STATUS CATEGORY STATS
+
+echo "\n";
+echo "---------- CUSTOM STATUS CATEGORIA STATS\n";
+echo "+----------------------+------------+--------------------------------+\n";
+echo "| CATEGORIA             | CALLS      | DESCRIPTION                    |\n";
+echo "+----------------------+------------+--------------------------------+\n";
+
+$TOTCATcalls=0;
+$r=0;
+while ($r < $statcats_to_print)
+	{
+	if ($vsc_id[$r] != 'UNDEFINED')
+		{
+		$TOTCATcalls = ($TOTCATcalls + $vsc_count[$r]);
+		$category =	sprintf("%-20s", $vsc_id[$r]); while(strlen($category)>20) {$category = substr("$category", 0, -1);}
+		$CATcount =	sprintf("%10s", $vsc_count[$r]); while(strlen($CATcount)>10) {$CATcount = substr("$CATcount", 0, -1);}
+		$CATname =	sprintf("%-30s", $vsc_name[$r]); while(strlen($CATname)>30) {$CATname = substr("$CATname", 0, -1);}
+
+		echo "| $category | $CATcount | $CATname |\n";
+		}
+
+	$r++;
+	}
+
+$TOTCATcalls =	sprintf("%10s", $TOTCATcalls); while(strlen($TOTCATcalls)>10) {$TOTCATcalls = substr("$TOTCATcalls", 0, -1);}
+
+echo "+----------------------+------------+--------------------------------+\n";
+echo "| TOTAL                | $TOTCATcalls |\n";
+echo "+----------------------+------------+\n";
+
+
+##############################
+#########  CALL INITIAL QUEUE POSITION BREAKDOWN
+
+$TOTALcalls = 0;
+
+echo "\n";
+echo "---------- CALL INITIAL QUEUE POSITION BREAKDOWN\n";
+echo "+-------------------------------------------------------------------------------------+------------+\n";
+echo "|     1     2     3     4     5     6     7     8     9    10    15    20    25   +25 | TOTAL      |\n";
+echo "+-------------------------------------------------------------------------------------+------------+\n";
+
+$stmt="select count(*),queue_position from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and  campaign_id IN($group_SQL) group by queue_position;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$positions_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $positions_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+
+	$TOTALcalls = ($TOTALcalls + $row[0]);
+
+	if ( ($row[1] > 0) and ($row[1] <= 1) ) {$qp_1 = ($qp_1 + $row[0]);}
+	if ( ($row[1] > 1) and ($row[1] <= 2) ) {$qp_2 = ($qp_2 + $row[0]);}
+	if ( ($row[1] > 2) and ($row[1] <= 3) ) {$qp_3 = ($qp_3 + $row[0]);}
+	if ( ($row[1] > 3) and ($row[1] <= 4) ) {$qp_4 = ($qp_4 + $row[0]);}
+	if ( ($row[1] > 4) and ($row[1] <= 5) ) {$qp_5 = ($qp_5 + $row[0]);}
+	if ( ($row[1] > 5) and ($row[1] <= 6) ) {$qp_6 = ($qp_6 + $row[0]);}
+	if ( ($row[1] > 6) and ($row[1] <= 7) ) {$qp_7 = ($qp_7 + $row[0]);}
+	if ( ($row[1] > 7) and ($row[1] <= 8) ) {$qp_8 = ($qp_8 + $row[0]);}
+	if ( ($row[1] > 8) and ($row[1] <= 9) ) {$qp_9 = ($qp_9 + $row[0]);}
+	if ( ($row[1] > 9) and ($row[1] <= 10) ) {$qp10 = ($qp10 + $row[0]);}
+	if ( ($row[1] > 10) and ($row[1] <= 15) ) {$qp15 = ($qp15 + $row[0]);}
+	if ( ($row[1] > 15) and ($row[1] <= 20) ) {$qp20 = ($qp20 + $row[0]);}
+	if ( ($row[1] > 20) and ($row[1] <= 25) ) {$qp25 = ($qp25 + $row[0]);}
+	if ($row[1] > 25) {$qp99 = ($qp99 + $row[0]);}
+	$i++;
+	}
+
+$qp_1 =	sprintf("%5s", $qp_1);
+$qp_2 =	sprintf("%5s", $qp_2);
+$qp_3=	sprintf("%5s", $qp_3);
+$qp_4 =	sprintf("%5s", $qp_4);
+$qp_5 =	sprintf("%5s", $qp_5);
+$qp_6 =	sprintf("%5s", $qp_6);
+$qp_7 =	sprintf("%5s", $qp_7);
+$qp_8 =	sprintf("%5s", $qp_8);
+$qp_9 =	sprintf("%5s", $qp_9);
+$qp10 =	sprintf("%5s", $qp10);
+$qp15 =	sprintf("%5s", $qp15);
+$qp20 =	sprintf("%5s", $qp20);
+$qp25 =	sprintf("%5s", $qp25);
+$qp99 =	sprintf("%5s", $qp99);
+
+$TOTALcalls =		sprintf("%10s", $TOTALcalls);
+
+echo "| $qp_1 $qp_2 $qp_3 $qp_4 $qp_5 $qp_6 $qp_7 $qp_8 $qp_9 $qp10 $qp15 $qp20 $qp25 $qp99 | $TOTALcalls |\n";
+echo "+-------------------------------------------------------------------------------------+------------+\n";
+
+
+
+##############################
+#########  USER STATS
+
+$TOTagents=0;
+$TOTcalls=0;
+$TOTtime=0;
+$TOTavg=0;
+
+echo "\n";
+echo "---------- AGENTE STATS\n";
+echo "+--------------------------+------------+------------+--------+\n";
+echo "| AGENTE                    | CALLS      | TIME H:M:S |AVERAGE |\n";
+echo "+--------------------------+------------+------------+--------+\n";
+
+$stmt="select vicidial_closer_log.user,full_name,count(*),sum(length_in_sec),avg(length_in_sec) from vicidial_closer_log,vicidial_users where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and  campaign_id IN($group_SQL) and vicidial_closer_log.user is not null and length_in_sec is not null and length_in_sec > 0 and vicidial_closer_log.user=vicidial_users.user group by vicidial_closer_log.user;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$users_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $users_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+
+	$TOTcalls = ($TOTcalls + $row[2]);
+	$TOTtime = ($TOTtime + $row[3]);
+
+	$user =			sprintf("%-6s", $row[0]);
+	if ($non_latin < 1)
+		{
+		$full_name =	sprintf("%-15s", $row[1]); while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);}	
+		}
+	else
+		{
+		$full_name =	sprintf("%-45s", $row[1]); while(mb_strlen($full_name,'utf-8')>15) {$full_name = mb_substr("$full_name", 0, -1,'utf-8');}	
+		}
+	$USERcalls =	sprintf("%10s", $row[2]);
+	$USERtotTALK =	$row[3];
+	$USERavgTALK =	$row[4];
+
+	$USERtotTALK_MS =	sec_convert($USERtotTALK,'H'); 
+	$USERavgTALK_MS =	sec_convert($USERavgTALK,'H'); 
+
+	$USERtotTALK_MS =	sprintf("%9s", $USERtotTALK_MS);
+	$USERavgTALK_MS =	sprintf("%6s", $USERavgTALK_MS);
+
+	echo "| $user - $full_name | $USERcalls |  $USERtotTALK_MS | $USERavgTALK_MS |\n";
+
+	$i++;
+	}
+
+if ($TOTcalls < 1) {$TOTcalls = 0; $TOTavg=0;}
+else
+	{
+	$TOTavg = ($TOTtime / $TOTcalls);
+	$TOTavg_MS =	sec_convert($TOTavg,'H'); 
+	$TOTavg =		sprintf("%6s", $TOTavg_MS);
+	}
+
+$TOTtime_MS =	sec_convert($TOTtime,'H'); 
+$TOTtime =		sprintf("%10s", $TOTtime_MS);
+
+$TOTagents =		sprintf("%10s", $i);
+$TOTcalls =			sprintf("%10s", $TOTcalls);
+$TOTtime =			sprintf("%8s", $TOTtime);
+$TOTavg =			sprintf("%6s", $TOTavg);
+
+echo "+--------------------------+------------+------------+--------+\n";
+echo "| TOTAL Agentes: $TOTagents | $TOTcalls | $TOTtime | $TOTavg |\n";
+echo "+--------------------------+------------+------------+--------+\n";
+
+
+##############################
+#########  TIME STATS
+
+echo "\n";
+echo "---------- ESTATÍSTICAS DE TEMPO\n";
+
+echo "\n";
+
+
+##############################
+#########  15-minute increment breakdowns of total calls and drops, then answered table
+$BDansweredCALLS = 0;
+$stmt="SELECT status,queue_seconds,UNIX_TIMESTAMP(call_date),call_date from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id IN($group_SQL);";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$calls_to_print = mysql_num_rows($rslt);
+$j=0;
+while ($j < $calls_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$Cstatus[$j] =	$row[0];
+	$Cqueue[$j] =	$row[1];
+	$Cepoch[$j] =	$row[2];
+	$Cdate[$j] =	$row[3];
+	$Crem[$j] = ( ($Cepoch[$j] + $epoch_offset) % 86400); # find the remainder(Modulus) of seconds since start of the day
+#	echo "|$Cepoch[$j]|$Crem[$j]|$Cdate[$j]|\n";
+	$j++;
+	}
+
+### Loop through all call records and gather stats for total call/drop report and answered report
+$j=0;
+while ($j < $calls_to_print)
+	{
+	$i=0; $sec=0; $sec_end=900;
+	while ($i <= 96)
+		{
+		if ( ($Crem[$j] >= $sec) and ($Crem[$j] < $sec_end) ) 
+			{
+			$Ftotal[$i]++;
+			if (ereg("DROP",$Cstatus[$j])) {$Fdrop[$i]++;}
+			if (!ereg("DROP|XDROP|HXFER|QVMAIL|HOLDTO|LIVE|QUEUE|TIMEOT|AFTHRS|NANQUE|INBND",$Cstatus[$j]))
+				{
+				$BDansweredCALLS++;
+				$Fanswer[$i]++;
+
+				if ($Cqueue[$j] == 0)								{$adB_0[$i]++;}
+				if ( ($Cqueue[$j] > 0) and ($Cqueue[$j] <= 5) )		{$adB_5[$i]++;}
+				if ( ($Cqueue[$j] > 5) and ($Cqueue[$j] <= 10) )	{$adB10[$i]++;}
+				if ( ($Cqueue[$j] > 10) and ($Cqueue[$j] <= 15) )	{$adB15[$i]++;}
+				if ( ($Cqueue[$j] > 15) and ($Cqueue[$j] <= 20) )	{$adB20[$i]++;}
+				if ( ($Cqueue[$j] > 20) and ($Cqueue[$j] <= 25) )	{$adB25[$i]++;}
+				if ( ($Cqueue[$j] > 25) and ($Cqueue[$j] <= 30) )	{$adB30[$i]++;}
+				if ( ($Cqueue[$j] > 30) and ($Cqueue[$j] <= 35) )	{$adB35[$i]++;}
+				if ( ($Cqueue[$j] > 35) and ($Cqueue[$j] <= 40) )	{$adB40[$i]++;}
+				if ( ($Cqueue[$j] > 40) and ($Cqueue[$j] <= 45) )	{$adB45[$i]++;}
+				if ( ($Cqueue[$j] > 45) and ($Cqueue[$j] <= 50) )	{$adB50[$i]++;}
+				if ( ($Cqueue[$j] > 50) and ($Cqueue[$j] <= 55) )	{$adB55[$i]++;}
+				if ( ($Cqueue[$j] > 55) and ($Cqueue[$j] <= 60) )	{$adB60[$i]++;}
+				if ( ($Cqueue[$j] > 60) and ($Cqueue[$j] <= 90) )	{$adB90[$i]++;}
+				if ($Cqueue[$j] > 90)								{$adB99[$i]++;}
+				}
+
+			}
+		$sec = ($sec + 900);
+		$sec_end = ($sec_end + 900);
+		$i++;
+		}
+	$j++;
+	}	##### END going through all records
+
+
+
+
+
+
+
+##### 15-minute total and drops graph
+$hi_hour_count=0;
+$last_full_record=0;
+$i=0;
+$h=0;
+while ($i <= 96)
+	{
+	$hour_count[$i] = $Ftotal[$i];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$drop_count[$i] = $Fdrop[$i];
+	$i++;
+	}
+
+if ($hi_hour_count < 1)
+	{$hour_multiplier = 0;}
+else
+	{
+	$hour_multiplier = (100 / $hi_hour_count);
+	#$hour_multiplier = round($hour_multiplier, 0);
+	}
+
+echo "\n";
+echo "GRÁFICO TOTAL DE CHAMADAS A CADA 15 MINUTOS TAKEN INTO THIS IN-GROUP\n";
+
+$k=1;
+$Mk=0;
+$call_scale = '0';
+while ($k <= 102) 
+	{
+	if ($Mk >= 5) 
+		{
+		$Mk=0;
+		if ( ($k < 1) or ($hour_multiplier <= 0) )
+			{$scale_num = 100;}
+		else
+			{
+			$scale_num=($k / $hour_multiplier);
+			$scale_num = round($scale_num, 0);
+			}
+		$LENscale_num = (strlen($scale_num));
+		$k = ($k + $LENscale_num);
+		$call_scale .= "$scale_num";
+		}
+	else
+		{
+		$call_scale .= " ";
+		$k++;   $Mk++;
+		}
+	}
+
+
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP                                  | DROPS | TOTAL |\n";
+echo "| HOUR |$call_scale| DROPS | TOTAL |\n";
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+$ZZ = '00';
+$i=0;
+$h=4;
+$hour= -1;
+$no_lines_yet=1;
+
+while ($i <= 96)
+	{
+	$char_counter=0;
+	$time = '      ';
+	if ($h >= 4) 
+		{
+		$hour++;
+		$h=0;
+		if ($hour < 10) {$hour = "0$hour";}
+		$time = "+$hour$ZZ+";
+		}
+	if ($h == 1) {$time = "   15 ";}
+	if ($h == 2) {$time = "   30 ";}
+	if ($h == 3) {$time = "   45 ";}
+	$Ghour_count = $hour_count[$i];
+	if ($Ghour_count < 1) 
+		{
+		if ( ($no_lines_yet) or ($i > $last_full_record) )
+			{
+			$do_nothing=1;
+			}
+		else
+			{
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+			echo "|$time|";
+			$k=0;   while ($k <= 102) {echo " ";   $k++;}
+			echo "| $hour_count[$i] |\n";
+			}
+		}
+	else
+		{
+		$no_lines_yet=0;
+		$Xhour_count = ($Ghour_count * $hour_multiplier);
+		$Yhour_count = (99 - $Xhour_count);
+
+		$Gdrop_count = $drop_count[$i];
+		if ($Gdrop_count < 1) 
+			{
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+
+			echo "|$time|";
+			$k=0;   while ($k <= $Xhour_count) {echo "*";   $k++;   $char_counter++;}
+			echo "*X";   $char_counter++;
+			$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+				while ($char_counter <= 101) {echo " ";   $char_counter++;}
+			echo "| 0     | $hour_count[$i] |\n";
+
+			}
+		else
+			{
+			$Xdrop_count = ($Gdrop_count * $hour_multiplier);
+
+		#	if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
+
+			$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
+
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+			$drop_count[$i] =	sprintf("%-5s", $drop_count[$i]);
+
+			echo "|$time|";
+			$k=0;   while ($k <= $Xdrop_count) {echo ">";   $k++;   $char_counter++;}
+			echo "D";   $char_counter++;
+			$k=0;   while ($k <= $XXhour_count) {echo "*";   $k++;   $char_counter++;}
+			echo "X";   $char_counter++;
+			$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+				while ($char_counter <= 102) {echo " ";   $char_counter++;}
+			echo "| $drop_count[$i] | $hour_count[$i] |\n";
+			}
+		}
+	
+	
+	$i++;
+	$h++;
+	}
+
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n\n";
+
+
+
+
+
+
+##### Answered wait time breakdown
+echo "\n";
+echo "---------- CALL RESPOSTAED TIME BREAKDOWN IN SECONDS\n";
+echo "+------+-------------------------------------------------------------------------------------------+------------+\n";
+echo "| HOUR |     0     5    10    15    20    25    30    35    40    45    50    55    60    90   +90 | TOTAL      |\n";
+echo "+------+-------------------------------------------------------------------------------------------+------------+\n";
+
+$ZZ = '00';
+$i=0;
+$h=4;
+$hour= -1;
+$no_lines_yet=1;
+while ($i <= 96)
+	{
+	$char_counter=0;
+	$time = '      ';
+	if ($h >= 4) 
+		{
+		$hour++;
+		$h=0;
+		if ($hour < 10) {$hour = "0$hour";}
+		$time = "+$hour$ZZ+";
+		$SQLtime = "$hour:$ZZ:00";
+		$SQLtimeEND = "$hour:15:00";
+		}
+	if ($h == 1) {$time = "   15 ";   $SQLtime = "$hour:15:00";   $SQLtimeEND = "$hour:30:00";}
+	if ($h == 2) {$time = "   30 ";   $SQLtime = "$hour:30:00";   $SQLtimeEND = "$hour:45:00";}
+	if ($h == 3) 
+		{
+		$time = "   45 ";
+		$SQLtime = "$hour:45:00";
+		$hourEND = ($hour + 1);
+		if ($hourEND < 10) {$hourEND = "0$hourEND";}
+		if ($hourEND > 23) {$SQLtimeEND = "23:59:59";}
+		else {$SQLtimeEND = "$hourEND:00:00";}
+		}
+
+
+	if (strlen($adB_0[$i]) < 1)  {$adB_0[$i]='-';}
+	if (strlen($adB_5[$i]) < 1)  {$adB_5[$i]='-';}
+	if (strlen($adB10[$i]) < 1)  {$adB10[$i]='-';}
+	if (strlen($adB15[$i]) < 1)  {$adB15[$i]='-';}
+	if (strlen($adB20[$i]) < 1)  {$adB20[$i]='-';}
+	if (strlen($adB25[$i]) < 1)  {$adB25[$i]='-';}
+	if (strlen($adB30[$i]) < 1)  {$adB30[$i]='-';}
+	if (strlen($adB35[$i]) < 1)  {$adB35[$i]='-';}
+	if (strlen($adB40[$i]) < 1)  {$adB40[$i]='-';}
+	if (strlen($adB45[$i]) < 1)  {$adB45[$i]='-';}
+	if (strlen($adB50[$i]) < 1)  {$adB50[$i]='-';}
+	if (strlen($adB55[$i]) < 1)  {$adB55[$i]='-';}
+	if (strlen($adB60[$i]) < 1)  {$adB60[$i]='-';}
+	if (strlen($adB90[$i]) < 1)  {$adB90[$i]='-';}
+	if (strlen($adB99[$i]) < 1)  {$adB99[$i]='-';}
+	if (strlen($Fanswer[$i]) < 1)  {$Fanswer[$i]='0';}
+
+	$adB_0[$i] = sprintf("%5s", $adB_0[$i]);
+	$adB_5[$i] = sprintf("%5s", $adB_5[$i]);
+	$adB10[$i] = sprintf("%5s", $adB10[$i]);
+	$adB15[$i] = sprintf("%5s", $adB15[$i]);
+	$adB20[$i] = sprintf("%5s", $adB20[$i]);
+	$adB25[$i] = sprintf("%5s", $adB25[$i]);
+	$adB30[$i] = sprintf("%5s", $adB30[$i]);
+	$adB35[$i] = sprintf("%5s", $adB35[$i]);
+	$adB40[$i] = sprintf("%5s", $adB40[$i]);
+	$adB45[$i] = sprintf("%5s", $adB45[$i]);
+	$adB50[$i] = sprintf("%5s", $adB50[$i]);
+	$adB55[$i] = sprintf("%5s", $adB55[$i]);
+	$adB60[$i] = sprintf("%5s", $adB60[$i]);
+	$adB90[$i] = sprintf("%5s", $adB90[$i]);
+	$adB99[$i] = sprintf("%5s", $adB99[$i]);
+	$Fanswer[$i] = sprintf("%10s", $Fanswer[$i]);
+
+	echo "|$time| $adB_0[$i] $adB_5[$i] $adB10[$i] $adB15[$i] $adB20[$i] $adB25[$i] $adB30[$i] $adB35[$i] $adB40[$i] $adB45[$i] $adB50[$i] $adB55[$i] $adB60[$i] $adB90[$i] $adB99[$i] | $Fanswer[$i] |\n";
+
+	$i++;
+	$h++;
+	}
+
+$BDansweredCALLS =		sprintf("%10s", $BDansweredCALLS);
+
+echo "+------+-------------------------------------------------------------------------------------------+------------+\n";
+echo "|TOTALS|                                                                                           | $BDansweredCALLS |\n";
+echo "+------+-------------------------------------------------------------------------------------------+------------+\n";
+
+
+
+$ENDtime = date("U");
+$RUNtime = ($ENDtime - $STARTtime);
+echo "\nRun Time: $RUNtime seconds\n";
+}
+
+
+
+
+?>
+
+
+ + diff --git a/LANG_www/vicidial_br/AST_CLOSERsummary_hourly.php b/LANG_www/vicidial_br/AST_CLOSERsummary_hourly.php new file mode 100644 index 00000000..2c5f60dc --- /dev/null +++ b/LANG_www/vicidial_br/AST_CLOSERsummary_hourly.php @@ -0,0 +1,689 @@ + LICENSE: AGPLv2 +# +# CHANGES +# +# 90801-0910 - First build +# 90809-0216 - Added Exclude Outbound Drop Group option +# 100214-1421 - Sort menu alphabetically +# 100216-0042 - Added popup date selector +# + +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["print_calls"])) {$print_calls=$_GET["print_calls"];} + elseif (isset($_POST["print_calls"])) {$print_calls=$_POST["print_calls"];} +if (isset($_GET["exclude_rollover"])) {$exclude_rollover=$_GET["exclude_rollover"];} + elseif (isset($_POST["exclude_rollover"])) {$exclude_rollover=$_POST["exclude_rollover"];} +if (isset($_GET["inbound_rate"])) {$inbound_rate=$_GET["inbound_rate"];} + elseif (isset($_POST["inbound_rate"])) {$inbound_rate=$_POST["inbound_rate"];} +if (isset($_GET["outbound_rate"])) {$outbound_rate=$_GET["outbound_rate"];} + elseif (isset($_POST["outbound_rate"])) {$outbound_rate=$_POST["outbound_rate"];} +if (isset($_GET["bareformat"])) {$bareformat=$_GET["bareformat"];} + elseif (isset($_POST["bareformat"])) {$bareformat=$_POST["bareformat"];} +if (isset($_GET["costformat"])) {$costformat=$_GET["costformat"];} + elseif (isset($_POST["costformat"])) {$costformat=$_POST["costformat"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +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["shift"])) {$shift=$_GET["shift"];} + elseif (isset($_POST["shift"])) {$shift=$_POST["shift"];} +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); + +$MT[0]='0'; +if (strlen($shift)<2) {$shift='ALL';} +if (strlen($exclude_rollover)<2) {$exclude_rollover='NO';} + +############################################# +##### 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); +if ($qm_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $non_latin = $row[0]; + } +##### END SETTINGS LOOKUP ##### +########################################### + +$stmt = "SELECT local_gmt FROM servers where active='Y' limit 1;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$gmt_conf_ct = mysql_num_rows($rslt); +$dst = date("I"); +if ($gmt_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $local_gmt = $row[0]; + $epoch_offset = (($local_gmt + $dst) * 3600); + } + +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level >= 7 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;} +if (!isset($end_date)) {$end_date = $NOW_DATE;} + +$exclude_rolloverSQL=''; +if (eregi("YES",$exclude_rollover)) + {$exclude_rolloverSQL = " where group_id NOT IN(SELECT drop_inbound_group from vicidial_campaigns)";} +$stmt="select group_id,group_name from vicidial_inbound_groups $exclude_rolloverSQL order by group_id;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +#$LISTgroups[$i]='---NONE---'; +#$i++; +#$groups_to_print++; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $LISTgroups[$i] = $row[0]; + $LISTgroup_names[$i] = $row[1]; + $i++; + } + +$i=0; +$group_string='|'; +$group_ct = count($group); +while($i < $group_ct) + { + $group_string .= "$group[$i]|"; + $group_SQL .= "'$group[$i]',"; + $groupQS .= "&group[]=$group[$i]"; + $i++; + } +if ( (ereg("--NONE--",$group_string) ) or ($group_ct < 1) ) + { + $group_SQL = "''"; +# $group_SQL = "group_id IN('')"; + } +else + { + $group_SQL = eregi_replace(",$",'',$group_SQL); +# $group_SQL = "group_id IN($group_SQL)"; + } + + +$stmt="select vsc_id,vsc_name from vicidial_status_categories;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$statcats_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $statcats_to_print) + { + $row=mysql_fetch_row($rslt); + $vsc_id[$i] = $row[0]; + $vsc_name[$i] = $row[1]; + $vsc_count[$i] = 0; + $i++; + } + +$stmt="select call_time_id,call_time_name from vicidial_call_times order by call_time_id;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$times_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $times_to_print) + { + $row=mysql_fetch_row($rslt); + $call_times[$i] = $row[0]; + $call_time_names[$i] = $row[1]; + $i++; + } + +?> + + + + + +\n"; +echo "\n"; + +echo "\n"; +echo "Inbound Summary Hourly Report\n"; + +if ($bareformat < 1) + { + $short_header=1; + + require("admin_header.php"); + + echo "
"; + + if ($DB > 0) + { + echo "
\n"; + echo "$group_ct|$group_string|$group_SQL\n"; + echo "
\n"; + echo "$shift|$query_date|$end_date\n"; + echo "
\n"; + } + + echo "
\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "Date Range:
\n"; + echo ""; + + ?> + + "; + + ?> + +
  \n"; + echo "\n"; + echo "Inbound Groups:
\n"; + echo "\n"; + echo "
\n"; + echo "           "; + echo "MODIFY | "; + echo "REPORTS"; + echo "

\n"; + echo "   Exclude Outbound Drop Groups:
"; + echo "   \n"; + echo "
                      "; + echo "\n"; + + echo "
\n"; + + echo "Call Time:
\n"; + echo "\n"; + echo "
\n"; + echo "
\n"; + echo "
\n\n"; + + echo "
\n\n";
+	}
+
+if ($groups_to_print < 1)
+	{
+	echo "\n\n";
+	echo "PLEASE SELECT AN IN-GROUP AND DATE RANGE ABOVE AND CLICK SUBMIT\n";
+	}
+
+else
+	{
+	if ($shift == 'ALL') 
+		{
+		$Gct_default_start = "0";
+		$Gct_default_stop = "2400";
+		}
+	else 
+		{
+		$stmt="SELECT call_time_id,call_time_name,call_time_comments,ct_default_start,ct_default_stop,ct_sunday_start,ct_sunday_stop,ct_monday_start,ct_monday_stop,ct_tuesday_start,ct_tuesday_stop,ct_wednesday_start,ct_wednesday_stop,ct_thursday_start,ct_thursday_stop,ct_friday_start,ct_friday_stop,ct_saturday_start,ct_saturday_stop,ct_state_call_times FROM vicidial_call_times where call_time_id='$shift';";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$calltimes_to_print = mysql_num_rows($rslt);
+		if ($calltimes_to_print > 0)
+			{
+			$row=mysql_fetch_row($rslt);
+			$Gct_default_start =	$row[3];
+			$Gct_default_stop =		$row[4];
+			$Gct_sunday_start =		$row[5];
+			$Gct_sunday_stop =		$row[6];
+			$Gct_monday_start =		$row[7];
+			$Gct_monday_stop =		$row[8];
+			$Gct_tuesday_start =	$row[9];
+			$Gct_tuesday_stop =		$row[10];
+			$Gct_wednesday_start =	$row[11];
+			$Gct_wednesday_stop =	$row[12];
+			$Gct_thursday_start =	$row[13];
+			$Gct_thursday_stop =	$row[14];
+			$Gct_friday_start =		$row[15];
+			$Gct_friday_stop =		$row[16];
+			$Gct_saturday_start =	$row[17];
+			$Gct_saturday_stop =	$row[18];
+			}
+		else
+			{
+			$Gct_default_start = "0";
+			$Gct_default_stop = "2400";
+			}
+		}
+	$h=0;
+	while ($h < 24)
+		{
+		$H_test = $h . "00";
+		if ( ($H_test >= $Gct_default_start) and ($H_test <= $Gct_default_stop) )
+			{
+			$Hcalltime[$h]++;
+			}
+		$h++;
+		}
+
+	$query_date_BEGIN = "$query_date 00:00:00";   
+	$query_date_END = "$end_date 23:59:59";
+
+
+	$MAIN .= "Inbound Summary Hourly Report: $group_string          $NOW_TIME\n";
+
+
+	if ($group_ct > 0)
+		{
+		$MAIN .= "\n";
+		$MAIN .= "---------- MULTI-GROUP BREAKDOWN:\n";
+		$MAIN .= "+------------------------------------------+--------+--------+-----------+---------+-----------+---------+---------+--------+\n";
+		$MAIN .= "|                                          |        |        |           |         | TOTAL     | AVERAGE | MAXIMUM | TOTAL  |\n";
+		$MAIN .= "|                                          | TOTAL  | TOTAL  | TOTAL     | AVERAGE | QUEUE     | QUEUE   | QUEUE   | ABANDON|\n";
+		$MAIN .= "| IN-GROUP                                 | CALLS  | ANSWER | TALK      | TALK    | TIME      | TIME    | TIME    | CALLS  |\n";
+		$MAIN .= "+------------------------------------------+--------+--------+-----------+---------+-----------+---------+---------+--------+\n";
+
+		$i=0;
+		$TOTcalls_count=0;
+		$TOTanswer_count=0;
+		$TOTtalk_sec=0;
+		$TOTtalk_avg=0;
+		$TOTqueue_seconds=0;
+		$TOTqueue_avg=0;
+		$TOTmax_queue_seconds=0;
+		$TOTdrop_count=0;
+		$SUBoutput='';
+
+		while($i < $group_ct)
+			{
+			$stmt="select group_name,agent_alert_delay from vicidial_inbound_groups where group_id='$group[$i]';";
+			$rslt=mysql_query($stmt, $link);
+			if ($DB) {echo "$stmt\n";}
+			$row=mysql_fetch_row($rslt);
+			$group_name[$i] =			$row[0];
+			$agent_alert_delay[$i] =	round($row[1] / 1000);
+
+			$out_of_call_time=0;
+			$length_in_sec[$i]=0;
+			$queue_seconds[$i]=0;
+			$talk_sec[$i]=0;
+			$calls_count[$i]=0;
+			$drop_count[$i]=0;
+			$answer_count[$i]=0;
+			$max_queue_seconds[$i]=0;
+			$Hlength_in_sec=$MT;
+			$Hqueue_seconds=$MT;
+			$Htalk_sec=$MT;
+			$Hcalls_count=$MT;
+			$Hdrop_count=$MT;
+			$Hanswer_count=$MT;
+			$Hmax_queue_seconds=$MT;
+			$hTOTALcalls =	0;
+			$hANSWERcalls =	0;
+			$hSUMtalk =		0;
+			$hAVGtalk =		0;
+			$hSUMqueue =	0;
+			$hAVGqueue =	0;
+			$hMAXqueue =	0;
+			$hDROPcalls =	0;
+			$hPRINT =		0;
+			$hTOTcalls_count =			0;
+			$hTOTanswer_count =			0;
+			$hTOTtalk_sec =				0;
+			$hTOTtalk_avg =				0;
+			$hTOTqueue_seconds =		0;
+			$hTOTqueue_avg =			0;
+			$hTOTmax_queue_seconds =	0;
+			$hTOTdrop_count =			0;
+
+			$stmt = "SELECT status,length_in_sec,queue_seconds,call_date,UNIX_TIMESTAMP(call_date),phone_number,campaign_id from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id='$group[$i]';";
+			$rslt=mysql_query($stmt, $link);
+			if ($DB) {echo "$stmt\n";}
+			$calls_to_parse = mysql_num_rows($rslt);
+			$p=0;
+			while ($p < $calls_to_parse)
+				{
+				$row=mysql_fetch_row($rslt);
+				$call_date = explode(" ", $row[3]);
+				$call_time = ereg_replace("[^0-9]","",$call_date[1]);
+				$epoch = $row[4];
+				$Cwday = date("w", $epoch);
+
+				$CTstart = $Gct_default_start . "00";
+				$CTstop = $Gct_default_stop . "59";
+
+				if ( ($Cwday == 0) and ( ($Gct_sunday_start > 0) and ($Gct_sunday_stop > 0) ) )
+					{$CTstart = $Gct_sunday_start . "00";   $CTstop = $Gct_sunday_stop . "59";}
+				if ( ($Cwday == 1) and ( ($Gct_monday_start > 0) and ($Gct_monday_stop > 0) ) )
+					{$CTstart = $Gct_monday_start . "00";   $CTstop = $Gct_monday_stop . "59";}
+				if ( ($Cwday == 2) and ( ($Gct_tuesday_start > 0) and ($Gct_tuesday_stop > 0) ) )
+					{$CTstart = $Gct_tuesday_start . "00";   $CTstop = $Gct_tuesday_stop . "59";}
+				if ( ($Cwday == 3) and ( ($Gct_wednesday_start > 0) and ($Gct_wednesday_stop > 0) ) )
+					{$CTstart = $Gct_wednesday_start . "00";   $CTstop = $Gct_wednesday_stop . "59";}
+				if ( ($Cwday == 4) and ( ($Gct_thursday_start > 0) and ($Gct_thursday_stop > 0) ) )
+					{$CTstart = $Gct_thursday_start . "00";   $CTstop = $Gct_thursday_stop . "59";}
+				if ( ($Cwday == 5) and ( ($Gct_friday_start > 0) and ($Gct_friday_stop > 0) ) )
+					{$CTstart = $Gct_friday_start . "00";   $CTstop = $Gct_friday_stop . "59";}
+				if ( ($Cwday == 6) and ( ($Gct_saturday_start > 0) and ($Gct_saturday_stop > 0) ) )
+					{$CTstart = $Gct_saturday_start . "00";   $CTstop = $Gct_saturday_stop . "59";}
+
+				$Chour = date("G", $epoch);
+				if ( ($call_time > $CTstart) and ($call_time < $CTstop) )
+					{
+					$calls_count[$i]++;
+					$length_in_sec[$i] =	($length_in_sec[$i] + $row[1]);
+					$queue_seconds[$i] =	($queue_seconds[$i] + $row[2]);
+					$TEMPtalk = ( ($row[1] - $row[2]) - $agent_alert_delay[$i]);
+					if ($TEMPtalk < 0) {$TEMPtalk = 0;}
+					$talk_sec[$i] =	($talk_sec[$i] + $TEMPtalk);
+					if ($max_queue_seconds[$i] < $row[2])
+						{$max_queue_seconds[$i] = $row[2];}
+					if (eregi("DROP",$row[0]))
+						{$drop_count[$i]++;}
+					else
+						{$answer_count[$i]++;}
+
+					$Hcalls_count[$Chour]++;
+					$Hlength_in_sec[$Chour] =	($Hlength_in_sec[$Chour] + $row[1]);
+					$Hqueue_seconds[$Chour] =	($Hqueue_seconds[$Chour] + $row[2]);
+					$Htalk_sec[$Chour] =	($Htalk_sec[$Chour] + $TEMPtalk);
+					if ($Hmax_queue_seconds[$Chour] < $row[2])
+						{$Hmax_queue_seconds[$Chour] = $row[2];}
+					if (eregi("DROP",$row[0]))
+						{$Hdrop_count[$Chour]++;}
+					else
+						{$Hanswer_count[$Chour]++;}
+					$Hcalltime[$Chour]++;
+
+					if ($print_calls > 0)
+						{
+						echo "$row[5]\t$row[6]\t$TEMPtalk\n";
+						$PCtemptalk = ($PCtemptalk + $TEMPtalk);
+						}
+					$q++;
+					}
+				else
+					{$out_of_call_time++;}
+				if ($DB)
+					{echo "$call_time > $CTstart | $call_time < $CTstop | $Cwday | $Chour | $Hcalltime[$Chour] | $talk_sec[$i]\n";}
+				$p++;
+				}
+			if ( ($answer_count[$i] > 0) and ($talk_sec[$i] > 0) )
+				{$talk_avg[$i] = ($talk_sec[$i] / $answer_count[$i]);}
+			else
+				{$talk_avg[$i] = 0;}
+			if ( ($calls_count[$i] > 0) and ($queue_seconds[$i] > 0) )
+				{$queue_avg[$i] = ($queue_seconds[$i] / $calls_count[$i]);}
+			else
+				{$queue_avg[$i] = 0;}
+
+			if ($print_calls > 0)
+				{
+				$PCtemptalkmin = ($PCtemptalk  / 60);
+				echo "$q\t$PCtemptalk\t$PCtemptalkmin\n";
+				}
+
+			$TOTcalls_count =			($TOTcalls_count + $calls_count[$i]);
+			$TOTanswer_count =			($TOTanswer_count + $answer_count[$i]);
+			$TOTtalk_sec =				($TOTtalk_sec + $talk_sec[$i]);
+			$TOTqueue_seconds =			($TOTqueue_seconds + $queue_seconds[$i]);
+			$TOTdrop_count =			($TOTdrop_count + $drop_count[$i]);
+			if ($max_queue_seconds[$i] > $TOTmax_queue_seconds)
+				{$TOTmax_queue_seconds = $max_queue_seconds[$i];}
+
+			$talk_sec[$i] =				sec_convert($talk_sec[$i],'H'); 
+			$talk_avg[$i] =				sec_convert($talk_avg[$i],'H'); 
+			$queue_seconds[$i] =		sec_convert($queue_seconds[$i],'H'); 
+			$queue_avg[$i] =			sec_convert($queue_avg[$i],'H'); 
+			$max_queue_seconds[$i] =	sec_convert($max_queue_seconds[$i],'H'); 
+
+			$groupDISPLAY =	sprintf("%-40s", "$group[$i] - $group_name[$i]");
+			$gTOTALcalls =	sprintf("%6s", $calls_count[$i]);
+			$gANSWERcalls =	sprintf("%6s", $answer_count[$i]);
+			$gSUMtalk =		sprintf("%9s", $talk_sec[$i]);
+			$gAVGtalk =		sprintf("%7s", $talk_avg[$i]);
+			$gSUMqueue =	sprintf("%9s", $queue_seconds[$i]);
+			$gAVGqueue =	sprintf("%7s", $queue_avg[$i]);
+			$gMAXqueue =	sprintf("%7s", $max_queue_seconds[$i]);
+			$gDROPcalls =	sprintf("%6s", $drop_count[$i]);
+
+			while(strlen($groupDISPLAY)>40) {$groupDISPLAY = substr("$groupDISPLAY", 0, -1);}
+
+			$MAIN .= "| $groupDISPLAY | $gTOTALcalls | $gANSWERcalls | $gSUMtalk | $gAVGtalk | $gSUMqueue | $gAVGqueue | $gMAXqueue | $gDROPcalls |";
+			$MAIN .= "\n";
+
+			### hour by hour sumaries
+			$SUBoutput .= "\n---------- $group[$i] - $group_name[$i]     HOURLY BREAKDOWN:\n";
+			$SUBoutput .= "+------+--------+--------+-----------+---------+-----------+---------+---------+--------+\n";
+			$SUBoutput .= "|      |        |        |           |         | TOTAL     | AVERAGE | MAXIMUM | TOTAL  |\n";
+			$SUBoutput .= "|      | TOTAL  | TOTAL  | TOTAL     | AVERAGE | QUEUE     | QUEUE   | QUEUE   | ABANDON|\n";
+			$SUBoutput .= "| HOUR | CALLS  | ANSWER | TALK      | TALK    | TIME      | TIME    | TIME    | CALLS  |\n";
+			$SUBoutput .= "+------+--------+--------+-----------+---------+-----------+---------+---------+--------+\n";
+
+			$h=0;
+			while ($h < 24)
+				{
+				if ($Hcalltime[$h] > 0)
+					{
+					if (strlen($Hcalls_count[$h]) < 1)			{$Hcalls_count[$h] = 0;}
+					if (strlen($Hanswer_count[$h]) < 1)			{$Hanswer_count[$h] = 0;}
+					if (strlen($Htalk_sec[$h]) < 1)				{$Htalk_sec[$h] = 0;}
+					if (strlen($Hqueue_seconds[$h]) < 1)		{$Hqueue_seconds[$h] = 0;}
+					if (strlen($Hmax_queue_seconds[$h]) < 1)	{$Hmax_queue_seconds[$h] = 0;}
+					if (strlen($Hdrop_count[$h]) < 1)			{$Hdrop_count[$h] = 0;}
+
+					$hTOTcalls_count =			($hTOTcalls_count + $Hcalls_count[$h]);
+					$hTOTanswer_count =			($hTOTanswer_count + $Hanswer_count[$h]);
+					$hTOTtalk_sec =				($hTOTtalk_sec + $Htalk_sec[$h]);
+					$hTOTqueue_seconds =		($hTOTqueue_seconds + $Hqueue_seconds[$h]);
+					$hTOTdrop_count =			($hTOTdrop_count + $Hdrop_count[$h]);
+					if ($Hmax_queue_seconds[$h] > $hTOTmax_queue_seconds)
+						{$hTOTmax_queue_seconds = $Hmax_queue_seconds[$h];}
+
+					if ( ($Hanswer_count[$h] > 0) and ($Htalk_sec[$h] > 0) )
+						{$Htalk_avg[$h] = ($Htalk_sec[$h] / $Hanswer_count[$h]);}
+					else
+						{$Htalk_avg[$h] = 0;}
+					if ( ($Hcalls_count[$h] > 0) and ($Hqueue_seconds[$h] > 0) )
+						{$Hqueue_avg[$h] = ($Hqueue_seconds[$h] / $Hcalls_count[$h]);}
+					else
+						{$Hqueue_avg[$h] = 0;}
+
+					$Htalk_sec[$h] =			sec_convert($Htalk_sec[$h],'H'); 
+					$Htalk_avg[$h] =			sec_convert($Htalk_avg[$h],'H'); 
+					$Hqueue_seconds[$h] =		sec_convert($Hqueue_seconds[$h],'H'); 
+					$Hqueue_avg[$h] =			sec_convert($Hqueue_avg[$h],'H'); 
+					$Hmax_queue_seconds[$h] =	sec_convert($Hmax_queue_seconds[$h],'H');
+					
+					$hTOTALcalls =	sprintf("%6s", $Hcalls_count[$h]);
+					$hANSWERcalls =	sprintf("%6s", $Hanswer_count[$h]);
+					$hSUMtalk =		sprintf("%9s", $Htalk_sec[$h]);
+					$hAVGtalk =		sprintf("%7s", $Htalk_avg[$h]);
+					$hSUMqueue =	sprintf("%9s", $Hqueue_seconds[$h]);
+					$hAVGqueue =	sprintf("%7s", $Hqueue_avg[$h]);
+					$hMAXqueue =	sprintf("%7s", $Hmax_queue_seconds[$h]);
+					$hDROPcalls =	sprintf("%6s", $Hdrop_count[$h]);
+					$hPRINT =		sprintf("%2s", $h);
+
+					$SUBoutput .= "| $hPRINT   | $hTOTALcalls | $hANSWERcalls | $hSUMtalk | $hAVGtalk | $hSUMqueue | $hAVGqueue | $hMAXqueue | $hDROPcalls |\n";
+					}
+
+				$h++;
+				}
+
+			if ( ($hTOTanswer_count > 0) and ($hTOTtalk_sec > 0) )
+				{$hTOTtalk_avg = ($hTOTtalk_sec / $hTOTanswer_count);}
+			else
+				{$hTOTtalk_avg = 0;}
+			if ( ($hTOTcalls_count > 0) and ($hTOTqueue_seconds > 0) )
+				{$hTOTqueue_avg = ($hTOTqueue_seconds / $hTOTcalls_count);}
+			else
+				{$hTOTqueue_avg = 0;}
+
+			$hTOTtalk_sec =			sec_convert($hTOTtalk_sec,'H'); 
+			$hTOTtalk_avg =			sec_convert($hTOTtalk_avg,'H'); 
+			$hTOTqueue_seconds =		sec_convert($hTOTqueue_seconds,'H'); 
+			$hTOTqueue_avg =			sec_convert($hTOTqueue_avg,'H'); 
+			$hTOTmax_queue_seconds =	sec_convert($hTOTmax_queue_seconds,'H'); 
+
+			$hTOTcalls_count =			sprintf("%6s", $hTOTcalls_count);
+			$hTOTanswer_count =			sprintf("%6s", $hTOTanswer_count);
+			$hTOTtalk_sec =				sprintf("%9s", $hTOTtalk_sec);
+			$hTOTtalk_avg =				sprintf("%7s", $hTOTtalk_avg);
+			$hTOTqueue_seconds =		sprintf("%9s", $hTOTqueue_seconds);
+			$hTOTqueue_avg =			sprintf("%7s", $hTOTqueue_avg);
+			$hTOTmax_queue_seconds =	sprintf("%7s", $hTOTmax_queue_seconds);
+			$hTOTdrop_count =			sprintf("%6s", $hTOTdrop_count);
+
+			$SUBoutput .= "+------+--------+--------+-----------+---------+-----------+---------+---------+--------+\n";
+			$SUBoutput .= "|TOTALS| $hTOTcalls_count | $hTOTanswer_count | $hTOTtalk_sec | $hTOTtalk_avg | $hTOTqueue_seconds | $hTOTqueue_avg | $hTOTmax_queue_seconds | $hTOTdrop_count |\n";
+			$SUBoutput .= "+------+--------+--------+-----------+---------+-----------+---------+---------+--------+\n";
+
+			$i++;
+			}
+
+		$rawTOTtalk_sec = $TOTtalk_sec;
+		$rawTOTtalk_min = round($rawTOTtalk_sec / 60);
+
+		if ( ($TOTanswer_count > 0) and ($TOTtalk_sec > 0) )
+			{$TOTtalk_avg = ($TOTtalk_sec / $TOTanswer_count);}
+		else
+			{$TOTtalk_avg = 0;}
+		if ( ($TOTcalls_count > 0) and ($TOTqueue_seconds > 0) )
+			{$TOTqueue_avg = ($TOTqueue_seconds / $TOTcalls_count);}
+		else
+			{$TOTqueue_avg = 0;}
+
+		$TOTtalk_sec =			sec_convert($TOTtalk_sec,'H'); 
+		$TOTtalk_avg =			sec_convert($TOTtalk_avg,'H'); 
+		$TOTqueue_seconds =		sec_convert($TOTqueue_seconds,'H'); 
+		$TOTqueue_avg =			sec_convert($TOTqueue_avg,'H'); 
+		$TOTmax_queue_seconds =	sec_convert($TOTmax_queue_seconds,'H'); 
+
+		$i =					sprintf("%4s", $i);
+		$TOTcalls_count =		sprintf("%6s", $TOTcalls_count);
+		$TOTanswer_count =		sprintf("%6s", $TOTanswer_count);
+		$TOTtalk_sec =			sprintf("%9s", $TOTtalk_sec);
+		$TOTtalk_avg =			sprintf("%7s", $TOTtalk_avg);
+		$TOTqueue_seconds =		sprintf("%9s", $TOTqueue_seconds);
+		$TOTqueue_avg =			sprintf("%7s", $TOTqueue_avg);
+		$TOTmax_queue_seconds =	sprintf("%7s", $TOTmax_queue_seconds);
+		$TOTdrop_count =		sprintf("%6s", $TOTdrop_count);
+
+		$MAIN .= "+------------------------------------------+--------+--------+-----------+---------+-----------+---------+---------+--------+\n";
+		$MAIN .= "| TOTALS       In-Groups: $i             | $TOTcalls_count | $TOTanswer_count | $TOTtalk_sec | $TOTtalk_avg | $TOTqueue_seconds | $TOTqueue_avg | $TOTmax_queue_seconds | $TOTdrop_count |\n";
+		$MAIN .= "+------------------------------------------+--------+--------+-----------+---------+-----------+---------+---------+--------+\n";
+		}
+
+	if ($costformat > 0)
+		{
+		echo "
\n"; + $inbound_cost = ($rawTOTtalk_min * $inbound_rate); + $inbound_cost = sprintf("%8.2f", $inbound_cost); + + echo "INBOUND $query_date to $end_date,   $rawTOTtalk_min minutes at \$$inbound_rate = \$$inbound_cost\n"; + + exit; + } + + + echo "$MAIN"; + echo "$SUBoutput"; + + + + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $STARTtime); + echo "\n\nRun Time: $RUNtime seconds\n"; + } + + + + +?> + +
+ + diff --git a/LANG_www/vicidial_br/AST_IVRfilter.php b/LANG_www/vicidial_br/AST_IVRfilter.php new file mode 100644 index 00000000..32810a0e --- /dev/null +++ b/LANG_www/vicidial_br/AST_IVRfilter.php @@ -0,0 +1,249 @@ + LICENSE: AGPLv2 +# +# CHANGES +# +# 81030-0432 - First build +# 90310-2054 - Admin header +# 90508-0644 - Changed to PHP long tags +# + +require("dbconnect.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["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} +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); + +############################################# +##### 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 >= 7 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 "Nome ou Senha inválidos: |$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($query_date)) {$query_date = $NOW_DATE;} +if (!isset($end_date)) {$end_date = $NOW_DATE;} + +$i=0; + +?> + + + + + +\n"; +echo "VICIDIAL: VDL IVR Filter Stats\n"; + + $short_header=1; + + require("admin_header.php"); + +echo "
"; + +echo "
\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "Período:
\n"; +echo "\n"; +echo " to \n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "           "; +echo "ADMIN | "; +echo "RELATÓRIOS\n"; +echo "\n"; + +echo "
\n"; + +echo "   \n"; +echo "
\n"; +echo "
\n\n"; + +echo "
\n\n";
+
+$shift = 'ALL';
+
+if ($shift == 'AM') 
+	{
+	$time_BEGIN=$AM_shift_BEGIN;
+	$time_END=$AM_shift_END;
+	if (strlen($time_BEGIN) < 6) {$time_BEGIN = "03:45:00";}   
+	if (strlen($time_END) < 6) {$time_END = "15:15:00";}
+	}
+if ($shift == 'PM') 
+	{
+	$time_BEGIN=$PM_shift_BEGIN;
+	$time_END=$PM_shift_END;
+	if (strlen($time_BEGIN) < 6) {$time_BEGIN = "15:15:00";}
+	if (strlen($time_END) < 6) {$time_END = "23:15:00";}
+	}
+if ($shift == 'ALL') 
+	{
+	if (strlen($time_BEGIN) < 6) {$time_BEGIN = "00:00:00";}
+	if (strlen($time_END) < 6) {$time_END = "23:59:59";}
+	}
+$query_date_BEGIN = "$query_date $time_BEGIN";   
+$query_date_END = "$end_date $time_END";
+
+
+
+echo "VDL: IVR Filter Stats:           $NOW_TIME\n";
+
+
+echo "\n";
+echo "+----------------------+---------+---------+---------+\n";
+echo "| CATEGORIA             | CALLS   | UNIQUE  |      %  |\n";
+echo "+----------------------+---------+---------+---------+\n";
+
+
+$stmtA="select count(*),count(distinct caller_id) from live_inbound_log where start_time >= '$query_date_BEGIN' and start_time <= '$query_date_END' and comment_a='ENTRANTE_IVR_FILTER' and comment_b='CLEAN';";
+$rsltA=mysql_query($stmtA, $link);
+if ($DB) {echo "$stmtA\n";}
+$rowA=mysql_fetch_row($rsltA);
+
+$stmtB="select count(*),count(distinct caller_id) from live_inbound_log where start_time >= '$query_date_BEGIN' and start_time <= '$query_date_END' and comment_a='ENTRANTE_IVR_FILTER' and comment_b='NOT_FOUND';";
+$rsltB=mysql_query($stmtB, $link);
+if ($DB) {echo "$stmtB\n";}
+$rowB=mysql_fetch_row($rsltB);
+
+$stmtC="select count(*),count(distinct caller_id) from live_inbound_log where start_time >= '$query_date_BEGIN' and start_time <= '$query_date_END' and comment_a='ENTRANTE_IVR_FILTER' and comment_b='EXISTING' and comment_c='DNC';";
+$rsltC=mysql_query($stmtC, $link);
+if ($DB) {echo "$stmtC\n";}
+$rowC=mysql_fetch_row($rsltC);
+
+$stmtD="select count(*),count(distinct caller_id) from live_inbound_log where start_time >= '$query_date_BEGIN' and start_time <= '$query_date_END' and comment_a='ENTRANTE_IVR_FILTER' and comment_b='EXISTING' and comment_c='SALE';";
+$rsltD=mysql_query($stmtD, $link);
+if ($DB) {echo "$stmtD\n";}
+$rowD=mysql_fetch_row($rsltD);
+
+$stmtE="select count(*),count(distinct caller_id) from live_inbound_log where start_time >= '$query_date_BEGIN' and start_time <= '$query_date_END' and comment_a='ENTRANTE_IVR_FILTER' and comment_b='EXISTING' and comment_c='ARCHIVE';";
+$rsltE=mysql_query($stmtE, $link);
+if ($DB) {echo "$stmtE\n";}
+$rowE=mysql_fetch_row($rsltE);
+
+
+$total = ($rowA[0] + $rowB[0] + $rowC[0] + $rowD[0] + $rowE[0]);
+$Utotal = ($rowA[1] + $rowB[1] + $rowC[1] + $rowD[1] + $rowE[1]);
+
+$agent =	sprintf("%7s", $rowA[0]);
+$Uagent =	sprintf("%7s", $rowA[1]);
+if ( ($Utotal < 1) or ($rowA[1] < 1) )
+	{$UagentPERCENT = '0';}
+else
+	{$UagentPERCENT = (($rowA[1] / $Utotal) * 100);   $UagentPERCENT = round($UagentPERCENT, 2);}
+$UagentPERCENT =	sprintf("%6s", $UagentPERCENT);
+
+$ntfnd =	sprintf("%7s", $rowB[0]);
+$Untfnd =	sprintf("%7s", $rowB[1]);
+if ( ($Utotal < 1) or ($rowB[1] < 1) )
+	{$UntfndPERCENT = '0';}
+else
+	{$UntfndPERCENT = (($rowB[1] / $Utotal) * 100);   $UntfndPERCENT = round($UntfndPERCENT, 2);}
+$UntfndPERCENT =	sprintf("%6s", $UntfndPERCENT);
+
+$prdnc =	sprintf("%7s", $rowC[0]);
+$Uprdnc =	sprintf("%7s", $rowC[1]);
+if ( ($Utotal < 1) or ($rowC[1] < 1) )
+	{$UprdncPERCENT = '0';}
+else
+	{$UprdncPERCENT = (($rowC[1] / $Utotal) * 100);   $UprdncPERCENT = round($UprdncPERCENT, 2);}
+$UprdncPERCENT =	sprintf("%6s", $UprdncPERCENT);
+
+$psale =	sprintf("%7s", $rowD[0]);
+$Upsale =	sprintf("%7s", $rowD[1]);
+if ( ($Utotal < 1) or ($rowD[1] < 1) )
+	{$UpsalePERCENT = '0';}
+else
+	{$UpsalePERCENT = (($rowD[1] / $Utotal) * 100);   $UpsalePERCENT = round($UpsalePERCENT, 2);}
+$UpsalePERCENT =	sprintf("%6s", $UpsalePERCENT);
+
+$archv =	sprintf("%7s", $rowE[0]);
+$Uarchv =	sprintf("%7s", $rowE[1]);
+if ( ($Utotal < 1) or ($rowE[1] < 1) )
+	{$UarchvPERCENT = '0';}
+else
+	{$UarchvPERCENT = (($rowE[1] / $Utotal) * 100);   $UarchvPERCENT = round($UarchvPERCENT, 2);}
+$UarchvPERCENT =	sprintf("%6s", $UarchvPERCENT);
+
+$total =	sprintf("%7s", $total);
+$Utotal =	sprintf("%7s", $Utotal);
+
+
+echo "| CALL SENT TO AGENTE   | $agent | $Uagent | $UagentPERCENT% |\n";
+echo "| CALLERID NOT FOUND   | $ntfnd | $Untfnd | $UntfndPERCENT% |\n";
+echo "| PREVIOUS DNC         | $prdnc | $Uprdnc | $UprdncPERCENT% |\n";
+echo "| PREVIOUS SALE        | $psale | $Upsale | $UpsalePERCENT% |\n";
+echo "| ARCHIVE ONLY         | $archv | $Uarchv | $UarchvPERCENT% |\n";
+echo "+----------------------+---------+---------+---------+\n";
+echo "|               TOTALS:| $total | $Utotal |\n";
+echo "+----------------------+---------+---------+\n";
+
+
+
+
+$ENDtime = date("U");
+$RUNtime = ($ENDtime - $STARTtime);
+echo "\nRun Time: $RUNtime seconds\n";
+
+
+
+
+?>
+
+
+ + diff --git a/LANG_www/vicidial_br/AST_IVRstats.php b/LANG_www/vicidial_br/AST_IVRstats.php new file mode 100644 index 00000000..80291e02 --- /dev/null +++ b/LANG_www/vicidial_br/AST_IVRstats.php @@ -0,0 +1,733 @@ + LICENSE: AGPLv2 +# +# CHANGES +# 81026-2026 - First build +# 81107-0341 - Added time range and option and 15-minute increment graph +# 81107-1148 - Added average times and totals +# 81108-0922 - Added no-callerID and unique caller counts +# 90310-2056 - Admin header +# 90508-0644 - Changed to PHP long tags +# 91112-0719 - Added in-group names to select list +# 100214-1421 - Sort menu alphabetically +# 100301-1401 - Added popup date selector +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +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["shift"])) {$shift=$_GET["shift"];} + elseif (isset($_POST["shift"])) {$shift=$_POST["shift"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} +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); +if ($qm_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $non_latin = $row[0]; + } +##### END SETTINGS LOOKUP ##### +########################################### + +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level >= 7 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 "Nome ou Senha inválidos: |$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:23:59";} + +$stmt="select group_id,group_name from vicidial_inbound_groups order by group_id;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; + $LISTgroups[$i]='CALLMENU'; + $LISTgroups_names[$i]='IVR'; + $i++; + $groups_to_print++; + $LISTgroups[$i]='XMLPULL'; + $LISTgroups_names[$i]='Dynamic Application'; + $i++; + $groups_to_print++; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $LISTgroups[$i] = $row[0]; + $LISTgroups_names[$i] = $row[1]; + $i++; + } + +$i=0; +$group_string='|'; +$group_ct = count($group); +while($i < $group_ct) + { + $group_string .= "$group[$i]|"; + $group_SQL .= "'$group[$i]',"; + $groupQS .= "&group[]=$group[$i]"; + $i++; + } +if ( (ereg("--NONE--",$group_string) ) or ($group_ct < 1) ) + { + $group_SQL = "''"; +# $group_SQL = "group_id IN('')"; + } +else + { + $group_SQL = eregi_replace(",$",'',$group_SQL); +# $group_SQL = "group_id IN($group_SQL)"; + } + + +$stmt="select vsc_id,vsc_name from vicidial_status_categories;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$statcats_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $statcats_to_print) + { + $row=mysql_fetch_row($rslt); + $vsc_id[$i] = $row[0]; + $vsc_name[$i] = $row[1]; + $vsc_count[$i] = 0; + $i++; + } +?> + + + + + + + + + + +\n"; +echo "IVR Stats Report\n"; + + $short_header=1; + + require("admin_header.php"); + +echo "
"; + +if ($DB > 0) + { + echo "
\n"; + echo "$group_ct|$group_string|$group_SQL\n"; + echo "
\n"; + echo "$shift|$query_date|$end_date\n"; + echo "
\n"; + } + +echo "
\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "Período:
\n"; + +echo "\n"; +echo "\n"; +echo ""; + +?> + +"; + +echo "
to
"; + +?> + +"; + + +echo "
\n"; +echo "Grupos de Entrada: \n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "           "; +echo "ALTERAR | "; +echo "RELATÓRIOS | "; +echo "RELATÓRIO DE FINALIZADOR(CLOSER) \n"; +echo "\n"; + +echo "
\n"; + +#echo "\n"; +echo "Shift: \n"; + +?> + + +   +
\n"; +echo "
\n\n"; + +echo "
\n\n";
+
+
+if ($groups_to_print < 1)
+	{
+	echo "\n\n";
+	echo "POR FAVOR SELECIONE UM GRUPO DE ENTRADA E PERÍODO ACIMA E CLIQUE ENVIAR\n";
+	}
+
+else
+	{
+	echo "IVR Stats Report: $query_date_BEGIN to $query_date_END               $NOW_TIME\n";
+	echo "                  $group_string\n";
+
+	$TOTALcalls=0;
+	$NOCALLERIDcalls=0;
+	$UNIQUEcallers=0;
+	$totFLOWivr_time=0;
+	$totFLOWtotal_time=0;
+
+	##### Grab all records for the IVR for the specified time period
+	$stmt="select uniqueid,extension,start_time,comment_a,comment_b,comment_d,UNIX_TIMESTAMP(start_time),phone_ext from live_inbound_log where start_time >= '$query_date_BEGIN' and start_time <= '$query_date_END' and comment_a IN($group_SQL) order by uniqueid,start_time;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$logs_to_print = mysql_num_rows($rslt);
+	$p=0;
+	while ($p < $logs_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		$uniqueid[$p] =		$row[0];
+		$extension[$p] =	$row[1];
+		$start_time[$p] =	$row[2];
+		$comment_a[$p] =	$row[3];
+		$comment_b[$p] =	$row[4];
+		$comment_d[$p] =	$row[5];
+		$epoch[$p] =		$row[6];
+		$phone_ext[$p] =	$row[7];
+		$p++;
+		}
+
+	### create the call flow of all calls by uniqueid
+	$last_uniqueid='';
+	$first_epoch='';
+	$last_epoch='';
+	$p=0;
+	$r=-1;
+	while ($p < $logs_to_print)
+		{
+		if ($DB > 0) {echo "$p|$uniqueid[$p]|$comment_b[$p]";}
+		if ($last_uniqueid === "$uniqueid[$p]")
+			{
+			$unique_calls[$r] .= "----------$comment_b[$p]";
+			if ($DB > 0) {echo "   $r|$unique_calls[$r]\n";}
+			$last_epoch[$r]=$epoch[$p];
+			}
+		else
+			{
+			$r++;
+			$caller_id[$r]=$phone_ext[$p];
+			if (strlen($phone_ext[$p])<2)
+				{$NOCALLERIDcalls++;}
+			else
+				{
+				if (!ereg("_$phone_ext[$p]_",$unique_callerIDs))
+					{
+					$unique_callerIDs .= "_$phone_ext[$p]_";
+					$UNIQUEcallers++;
+					}
+				}
+			$first_epoch[$r]=$epoch[$p];
+			$last_epoch[$r]=$epoch[$p];
+			$unique_calls[$r] = $comment_b[$p];
+			$FLOWuniqueid[$r] = "$uniqueid[$p]";
+			$last_uniqueid = "$uniqueid[$p]";
+			if ($DB > 0) {echo "   $r|$unique_calls[$r]\n";}
+			}
+		$p++;
+		}
+
+	### sort call flows for counting
+	$RAWunique_calls = $unique_calls;
+	if ($logs_to_print > 0)
+		{sort($unique_calls);}
+
+
+	### count each unique call flow
+	$last_Suniqueid='';
+	$p=-1;
+	$s=0;
+	while ($s <= $r)
+		{
+		if ($DB > 0) {echo "$s|$unique_calls[$s]\n";}
+		if ($last_Suniqueid === "$unique_calls[$s]")
+			{
+			$STunique_calls_count[$p]++;
+			}
+		else
+			{
+			$p++;
+			$STunique_calls[$p] = $unique_calls[$s];
+			$last_Suniqueid = "$unique_calls[$s]";
+			$STunique_calls_count[$p]=1;
+			}
+		$s++;
+		}
+
+
+	### put call flows and counts together for sorting again
+	$TOTALcalls=0;
+	$s=0;
+	while ($s <= $p)
+		{
+		$TOTALcalls = ($TOTALcalls + $STunique_calls_count[$s]);
+		$STunique_calls_count[$s] = sprintf("%07s", $STunique_calls_count[$s]);
+		$FLOWunique_calls[$s] = "$STunique_calls_count[$s]__________$STunique_calls[$s]";
+		$s++;
+		}
+
+	#### PRINT TOTAL DE CHAMADAS INTO THIS IVR
+	echo "\n";
+	echo "Calls taken into this IVR:   $TOTALcalls\n";
+	echo "Calls with no CallerID:      $NOCALLERIDcalls\n";
+	echo "Unique Callers:              $UNIQUEcallers\n";
+	echo "\n";
+
+	### sort call flows for counting
+	if ($p > 0)
+		{rsort($FLOWunique_calls);}
+
+
+	### put call flows and counts together for sorting again
+	$RUC_ct = count($RAWunique_calls);
+	$s=0;
+	while ($s <= $p)
+		{
+		$FLOWsummary = explode('__________',$FLOWunique_calls[$s]);
+		$FLOWsummary[0] = ($FLOWsummary[0] + 0);
+
+		$t=0;
+		while ($t < $RUC_ct)
+			{
+			if ($FLOWsummary[1] === "$RAWunique_calls[$t]")
+				{
+				$FLOWunique_calls_list[$s] .= "'$FLOWuniqueid[$t]',";
+				if ($last_epoch[$t] <= $first_epoch[$t]) {$last_epoch[$t] = ($first_epoch[$t] + 5);}
+				else {$last_epoch[$t] = ($last_epoch[$t] + 10);}
+				$FLOWivr_time[$s] = ($FLOWivr_time[$s] + ($last_epoch[$t] - $first_epoch[$t]));
+				}
+			$t++;
+			}
+
+		$s++;
+		}
+
+
+	### put call flows and counts together for sorting again
+	$s=0;
+
+	echo "+--------+--------+--------+--------+------+------+\n";
+	echo "|        |        | QUEUE  | QUEUE  | IVR  | TOTAL|\n";
+	echo "| IVR    | QUEUE  | DROP   | DROP   | AVG  | AVG  |\n";
+	echo "| CALLS  | CALLS  | CALLS  | PERCENT| TIME | TIME | CALL PATH\n";
+	echo "+--------+--------+--------+--------+------+------+------------\n";
+
+	while ($s <= $p)
+		{
+		$vcl_statuses = $MT;
+		$FLOWdrop[$s]=0;
+		$FLOWtotal[$s]=0;
+		$FLOWdropPCT[$s]=0;
+		$FLOWsummary = explode('__________',$FLOWunique_calls[$s]);
+		$FLOWsummary[0] = ($FLOWsummary[0] + 0);
+
+		$FLOWunique_calls_list[$s] = preg_replace("/,$/","",$FLOWunique_calls_list[$s]);
+
+
+		##### Grab all records for the IVR for the specified time period
+		$stmt="select status,length_in_sec from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id IN($group_SQL) and uniqueid IN($FLOWunique_calls_list[$s]);";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$vcl_statuses_to_print = mysql_num_rows($rslt);
+		$w=0;
+		while ($w < $vcl_statuses_to_print)
+			{
+			$row=mysql_fetch_row($rslt);
+			$vcl_statuses[$w] =		$row[0];
+			if ( (ereg("DROP",$vcl_statuses[$w])) or (ereg("XDROP",$vcl_statuses[$w])) )
+				{$FLOWdrop[$s]++;}
+			$FLOWclose_time[$s] = ($FLOWclose_time[$s] + $row[1]);
+			$FLOWtotal[$s]++;
+			$w++;
+			}
+		if ( ($FLOWtotal[$s] > 0) and ($FLOWdrop[$s] > 0) )
+			{
+			$FLOWdropPCT[$s] = ( ($FLOWdrop[$s] / $FLOWtotal[$s]) * 100);
+			$FLOWdropPCT[$s] = round($FLOWdropPCT[$s], 2);
+			}
+		$FLOWsummary[0] =	sprintf("%6s", $FLOWsummary[0]);
+		$FLOWtotal[$s] =	sprintf("%6s", $FLOWtotal[$s]);
+		$FLOWdrop[$s] =		sprintf("%6s", $FLOWdrop[$s]);
+		$FLOWdropPCT[$s] =	sprintf("%6s", $FLOWdropPCT[$s]);
+		$FLOWsummary[1] = ereg_replace('----------',' / ',$FLOWsummary[1]);
+		$FLOWtotal_time[$s] = ($FLOWivr_time[$s] + $FLOWclose_time[$s]);
+
+		$avgFLOWivr_time[$s] = ($FLOWivr_time[$s] / $FLOWsummary[0]);
+		$avgFLOWivr_time[$s] = round($avgFLOWivr_time[$s], 0);
+		$avgFLOWivr_time[$s] = sprintf("%4s", $avgFLOWivr_time[$s]);
+		$avgFLOWtotal_time[$s] = ($FLOWtotal_time[$s] / $FLOWsummary[0]);
+		$avgFLOWtotal_time[$s] = round($avgFLOWtotal_time[$s], 0);
+		$avgFLOWtotal_time[$s] = sprintf("%4s", $avgFLOWtotal_time[$s]);
+
+		$totFLOWtotal_time = ($totFLOWtotal_time + $FLOWtotal_time[$s]);
+		$totFLOWivr_time = ($totFLOWivr_time + $FLOWivr_time[$s]);
+		$totFLOWtotal = ($totFLOWtotal + $FLOWtotal[$s]);
+		$totFLOWdrop = ($totFLOWdrop + $FLOWdrop[$s]);
+
+		echo "| $FLOWsummary[0] | $FLOWtotal[$s] | $FLOWdrop[$s] | $FLOWdropPCT[$s]%| $avgFLOWivr_time[$s] | $avgFLOWtotal_time[$s] | $FLOWsummary[1]\n";
+
+		$s++;
+		}
+	$TOTALcalls = sprintf("%6s", $TOTALcalls);
+	$totFLOWtotal = sprintf("%6s", $totFLOWtotal);
+	$totFLOWdrop = sprintf("%6s", $totFLOWdrop);
+	if ( ($totFLOWivr_time > 0) and ($TOTALcalls > 0) )
+		{$TavgFLOWivr_time = ($totFLOWivr_time / $TOTALcalls);}
+	$TavgFLOWivr_time = round($TavgFLOWivr_time, 0);
+	$TavgFLOWivr_time = sprintf("%4s", $TavgFLOWivr_time);
+	if ( ($totFLOWtotal_time > 0) and ($TOTALcalls > 0) )
+		{$TavgFLOWtotal_time = ($totFLOWtotal_time / $TOTALcalls);}
+	$TavgFLOWtotal_time = round($TavgFLOWtotal_time, 0);
+	$TavgFLOWtotal_time = sprintf("%4s", $TavgFLOWtotal_time);
+	if ( ($totFLOWtotal < 1) or ($totFLOWdrop < 1) )
+		{$totFLOWdropPCT = '0';}
+	else
+		{
+		$totFLOWdropPCT = (($totFLOWdrop / $totFLOWtotal) * 100);
+		$totFLOWdropPCT = round($totFLOWdropPCT, 0);
+		}
+	$totFLOWdropPCT = sprintf("%5s", $totFLOWdropPCT);
+
+	echo "+--------+--------+--------+--------+------+------+------------\n";
+	echo "| $TOTALcalls | $totFLOWtotal | $totFLOWdrop | $totFLOWdropPCT% | $TavgFLOWivr_time | $TavgFLOWtotal_time |\n";
+	echo "+--------+--------+--------+--------+------+------+\n";
+
+
+	##############################
+	#########  TIME STATS
+
+	echo "\n";
+	echo "---------- ESTATÍSTICAS DE TEMPO\n";
+
+	echo "\n";
+
+	$hi_hour_count=0;
+	$last_full_record=0;
+	$i=0;
+	$h=0;
+	while ($i <= 96)
+		{
+		$stmt="select count(*) from live_inbound_log where start_time >= '$query_date $h:00:00' and start_time <= '$query_date $h:14:59' and comment_a IN($group_SQL) and comment_b='START';";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$hour_count[$i] = $row[0];
+		if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+		if ($hour_count[$i] > 0) {$last_full_record = $i;}
+		$i++;
+
+
+		$stmt="select count(*) from live_inbound_log where start_time >= '$query_date $h:15:00' and start_time <= '$query_date $h:29:59' and comment_a IN($group_SQL) and comment_b='START';";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$hour_count[$i] = $row[0];
+		if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+		if ($hour_count[$i] > 0) {$last_full_record = $i;}
+		$i++;
+
+		$stmt="select count(*) from live_inbound_log where start_time >= '$query_date $h:30:00' and start_time <= '$query_date $h:44:59' and comment_a IN($group_SQL) and comment_b='START';";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$hour_count[$i] = $row[0];
+		if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+		if ($hour_count[$i] > 0) {$last_full_record = $i;}
+		$i++;
+
+		$stmt="select count(*) from live_inbound_log where start_time >= '$query_date $h:45:00' and start_time <= '$query_date $h:59:59' and comment_a IN($group_SQL) and comment_b='START';";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$hour_count[$i] = $row[0];
+		if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+		if ($hour_count[$i] > 0) {$last_full_record = $i;}
+		$i++;
+		$h++;
+		}
+
+	if ($hi_hour_count < 1)
+		{$hour_multiplier = 0;}
+	else
+		{
+		$hour_multiplier = (100 / $hi_hour_count);
+		#$hour_multiplier = round($hour_multiplier, 0);
+		}
+
+	echo "\n";
+	echo "GRÁFICO TOTAL DE CHAMADAS A CADA 15 MINUTOS TAKEN INTO THIS IVR\n";
+
+	$k=1;
+	$Mk=0;
+	$call_scale = '0';
+	while ($k <= 102) 
+		{
+		if ($Mk >= 5) 
+			{
+			$Mk=0;
+			if ( ($k < 1) or ($hour_multiplier <= 0) )
+				{$scale_num = 100;}
+			else
+				{
+				$scale_num=($k / $hour_multiplier);
+				$scale_num = round($scale_num, 0);
+				}
+			$LENscale_num = (strlen($scale_num));
+			$k = ($k + $LENscale_num);
+			$call_scale .= "$scale_num";
+			}
+		else
+			{
+			$call_scale .= " ";
+			$k++;   $Mk++;
+			}
+		}
+
+
+	echo "+------+-------------------------------------------------------------------------------------------------------+-------+\n";
+	#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP                                  | TOTAL |\n";
+	echo "| HOUR |$call_scale| TOTAL |\n";
+	echo "+------+-------------------------------------------------------------------------------------------------------+-------+\n";
+
+	$ZZ = '00';
+	$i=0;
+	$h=4;
+	$hour= -1;
+	$no_lines_yet=1;
+
+	while ($i <= 96)
+		{
+		$char_counter=0;
+		$time = '      ';
+		if ($h >= 4) 
+			{
+			$hour++;
+			$h=0;
+			if ($hour < 10) {$hour = "0$hour";}
+			$time = "+$hour$ZZ+";
+			}
+		if ($h == 1) {$time = "   15 ";}
+		if ($h == 2) {$time = "   30 ";}
+		if ($h == 3) {$time = "   45 ";}
+		$Ghour_count = $hour_count[$i];
+		if ($Ghour_count < 1) 
+			{
+			if ( ($no_lines_yet) or ($i > $last_full_record) )
+				{
+				$do_nothing=1;
+				}
+			else
+				{
+				$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+				echo "|$time|";
+				$k=0;   while ($k <= 102) {echo " ";   $k++;}
+				echo "| $hour_count[$i] |\n";
+				}
+			}
+		else
+			{
+			$no_lines_yet=0;
+			$Xhour_count = ($Ghour_count * $hour_multiplier);
+			$Yhour_count = (99 - $Xhour_count);
+
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+
+			echo "|$time|";
+			$k=0;   while ($k <= $Xhour_count) {echo "*";   $k++;   $char_counter++;}
+			echo "*X";   $char_counter++;
+			$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+				while ($char_counter <= 101) {echo " ";   $char_counter++;}
+			echo "| $hour_count[$i] |\n";
+			}
+		
+		
+		$i++;
+		$h++;
+		}
+
+
+	echo "+------+-------------------------------------------------------------------------------------------------------+-------+\n\n";
+
+
+	$ENDtime = date("U");
+	$RUNtime = ($ENDtime - $STARTtime);
+	echo "\nRun Time: $RUNtime seconds\n";
+	}
+
+
+
+?>
+
+
+ + diff --git a/LANG_www/vicidial_br/AST_OUTBOUNDsummary_interval.php b/LANG_www/vicidial_br/AST_OUTBOUNDsummary_interval.php new file mode 100644 index 00000000..4ce1906b --- /dev/null +++ b/LANG_www/vicidial_br/AST_OUTBOUNDsummary_interval.php @@ -0,0 +1,1281 @@ + LICENSE: AGPLv2 +# +# CHANGES +# +# 091128-0311 - First build +# 091129-0017 - Added Sales-type and DNC-type tallies +# 100214-1421 - Sort menu alphabetically +# 100216-0042 - Added popup date selector +# + +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["time_interval"])) {$time_interval=$_GET["time_interval"];} + elseif (isset($_POST["time_interval"])) {$time_interval=$_POST["time_interval"];} +if (isset($_GET["print_calls"])) {$print_calls=$_GET["print_calls"];} + elseif (isset($_POST["print_calls"])) {$print_calls=$_POST["print_calls"];} +if (isset($_GET["include_rollover"])) {$include_rollover=$_GET["include_rollover"];} + elseif (isset($_POST["include_rollover"])) {$include_rollover=$_POST["include_rollover"];} +if (isset($_GET["bareformat"])) {$bareformat=$_GET["bareformat"];} + elseif (isset($_POST["bareformat"])) {$bareformat=$_POST["bareformat"];} +if (isset($_GET["costformat"])) {$costformat=$_GET["costformat"];} + elseif (isset($_POST["costformat"])) {$costformat=$_POST["costformat"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +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["shift"])) {$shift=$_GET["shift"];} + elseif (isset($_POST["shift"])) {$shift=$_POST["shift"];} +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); + +$MT[0]='0'; +if (strlen($shift)<2) {$shift='ALL';} +if (strlen($include_rollover)<2) {$include_rollover='NO';} + +############################################# +##### 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); +if ($qm_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $non_latin = $row[0]; + } +##### END SETTINGS LOOKUP ##### +########################################### + +$stmt = "SELECT local_gmt FROM servers where active='Y' limit 1;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$gmt_conf_ct = mysql_num_rows($rslt); +$dst = date("I"); +if ($gmt_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $local_gmt = $row[0]; + $epoch_offset = (($local_gmt + $dst) * 3600); + } + +$auth=0; +$stmt="SELECT full_name,user_level,user_group from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level >= 7 and view_reports='1' and active='Y';"; +if ($DB) {echo "|$stmt|\n";} +if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");} +$rslt=mysql_query($stmt, $link); +$records_to_print = mysql_num_rows($rslt); +if ($records_to_print > 0) + { + $row=mysql_fetch_row($rslt); + $full_name = $row[0]; + $user_level = $row[1]; + $user_group = $row[2]; + $auth++; + } + +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; + } + +$LOGallowed_campaignsSQL=''; +$whereLOGallowed_campaignsSQL=''; +if ($user_level < 9) + { + $stmt="SELECT allowed_campaigns from vicidial_user_groups where user_group='$user_group';"; + $rslt=mysql_query($stmt, $link); + $records_to_print = mysql_num_rows($rslt); + if ($records_to_print > 0) + { + $row=mysql_fetch_row($rslt); + if ( (!eregi("ALL-CAMPAIGNS",$row[0])) ) + { + $rawLOGallowed_campaignsSQL = eregi_replace(' -','',$row[0]); + $rawLOGallowed_campaignsSQL = eregi_replace(' ',"','",$rawLOGallowed_campaignsSQL); + $LOGallowed_campaignsSQL = "and campaign_id IN('$rawLOGallowed_campaignsSQL')"; + $whereLOGallowed_campaignsSQL = "where campaign_id IN('$rawLOGallowed_campaignsSQL')"; + } + } + else + { + echo "Campaigns Permissions Error: |$PHP_AUTH_USER|$user_group|\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;} +if (!isset($end_date)) {$end_date = $NOW_DATE;} + +$i=0; +$group_string='|'; +$group_ct = count($group); +while($i < $group_ct) + { + $group_string .= "$group[$i]|"; + $i++; + } + +$stmt="select campaign_id,campaign_name from vicidial_campaigns $whereLOGallowed_campaignsSQL order by campaign_id;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$campaigns_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $campaigns_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] = $row[0]; + $group_names[$i] = $row[1]; + if (eregi('--ALL--',$group_string)) + {$group[$i] = $row[0];} + $i++; + } + +if ($DB) {echo "$group_string|$i\n";} + +$rollover_groups_count=0; +$i=0; +$group_string='|'; +$group_ct = count($group); +while($i < $group_ct) + { + $group_string .= "$group[$i]|"; + $group_SQL .= "'$group[$i]',"; + $groupQS .= "&group[]=$group[$i]"; + + $stmt="select campaign_name from vicidial_campaigns where campaign_id='$group[$i]' $LOGallowed_campaignsSQL;"; + $rslt=mysql_query($stmt, $link); + $campaign_names_to_print = mysql_num_rows($rslt); + if ($campaign_names_to_print > 0) + { + $row=mysql_fetch_row($rslt); + $group_cname[$i] = $row[0]; + } + + if (eregi("YES",$include_rollover)) + { + $stmt="select drop_inbound_group from vicidial_campaigns where campaign_id='$group[$i]' $LOGallowed_campaignsSQL and drop_inbound_group NOT LIKE \"%NONE%\" and drop_inbound_group is NOT NULL and drop_inbound_group != '';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $in_groups_to_print = mysql_num_rows($rslt); + if ($in_groups_to_print > 0) + { + $row=mysql_fetch_row($rslt); + $group_drop_SQL .= "'$row[0]',"; + + $rollover_groups_count++; + } + } + + $i++; + } +if ( (ereg("--ALL--",$group_string) ) or ($group_ct < 1) ) + { + $group_SQL = ""; + $group_drop_SQL = ""; + } +else + { + $group_SQL = eregi_replace(",$",'',$group_SQL); + $group_drop_SQL = eregi_replace(",$",'',$group_drop_SQL); + $both_group_SQLand = "and ( (campaign_id IN($group_drop_SQL)) or (campaign_id IN($group_SQL)) )"; + $both_group_SQL = "where ( (campaign_id IN($group_drop_SQL)) or (campaign_id IN($group_SQL)) )"; + $group_SQLand = "and campaign_id IN($group_SQL)"; + $group_SQL = "where campaign_id IN($group_SQL)"; + $group_drop_SQLand = "and campaign_id IN($group_drop_SQL)"; + $group_drop_SQL = "where campaign_id IN($group_drop_SQL)"; + } + +$stmt="select vsc_id,vsc_name from vicidial_status_categories;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$statcats_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $statcats_to_print) + { + $row=mysql_fetch_row($rslt); + $vsc_id[$i] = $row[0]; + $vsc_name[$i] = $row[1]; + $vsc_count[$i] = 0; + $i++; + } + +$stmt="select call_time_id,call_time_name from vicidial_call_times order by call_time_id;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$times_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $times_to_print) + { + $row=mysql_fetch_row($rslt); + $call_times[$i] = $row[0]; + $call_time_names[$i] = $row[1]; + $i++; + } + +$customer_interactive_statuses=''; +$stmt="select status from vicidial_statuses where human_answered='Y';"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$statha_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $statha_to_print) + { + $row=mysql_fetch_row($rslt); + $customer_interactive_statuses .= "'$row[0]',"; + $i++; + } +$stmt="select status from vicidial_campaign_statuses where human_answered='Y';"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$statha_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $statha_to_print) + { + $row=mysql_fetch_row($rslt); + $customer_interactive_statuses .= "'$row[0]',"; + $i++; + } +if (strlen($customer_interactive_statuses)>2) + {$customer_interactive_statuses = substr("$customer_interactive_statuses", 0, -1);} +else + {$customer_interactive_statuses="''";} + +$stmt="select status from vicidial_statuses where sale='Y';"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$statsale_to_print = mysql_num_rows($rslt); +$i=0; +$sale_ct=0; +while ($i < $statsale_to_print) + { + $row=mysql_fetch_row($rslt); + $sale_statusesLIST[$sale_ct] = $row[0]; + $sale_ct++; + $i++; + } +$stmt="select status from vicidial_campaign_statuses where sale='Y';"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$statsale_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $statsale_to_print) + { + $row=mysql_fetch_row($rslt); + $sale_statusesLIST[$sale_ct] = $row[0]; + $sale_ct++; + $i++; + } + +$stmt="select status from vicidial_statuses where dnc='Y';"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$statdnc_to_print = mysql_num_rows($rslt); +$i=0; +$dnc_ct=0; +while ($i < $statdnc_to_print) + { + $row=mysql_fetch_row($rslt); + $dnc_statusesLIST[$dnc_ct] = $row[0]; + $dnc_ct++; + $i++; + } +$stmt="select status from vicidial_campaign_statuses where dnc='Y';"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$statdnc_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $statdnc_to_print) + { + $row=mysql_fetch_row($rslt); + $dnc_statusesLIST[$dnc_ct] = $row[0]; + $dnc_ct++; + $i++; + } + +?> + + + + + +\n"; +echo "\n"; + +echo "\n"; +echo "Outbound Summary Interval Report\n"; + +if ($bareformat < 1) + { + $short_header=1; + + require("admin_header.php"); + + echo "
"; + + if ($DB > 0) + { + echo "
\n"; + echo "$group_ct|$group_string|$group_SQL\n"; + echo "
\n"; + echo "$shift|$query_date|$end_date\n"; + echo "
\n"; + } + + echo "
\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "Date Range:
\n"; + echo ""; + + ?> + + "; + + ?> + +
Campaigns:
"; + echo "\n"; + echo "
"; + echo "Include Drop  
Rollover:
"; + echo "
\n"; + echo "Time Interval:
"; + echo "\n"; + echo "
\n"; + echo "         "; + echo "MODIFY | "; + echo "REPORTS"; + echo "

\n"; + echo "
        "; + echo "\n"; + + echo "
\n"; + + echo "Call Time:
\n"; + echo "\n"; + echo "
\n"; + echo "
\n"; + echo "
\n\n"; + + echo "
\n\n";
+	}
+
+if ($group_ct < 1)
+	{
+	echo "\n\n";
+	echo "PLEASE SELECT A CAMPAIGN AND DATE RANGE ABOVE AND CLICK SUBMIT\n";
+	}
+
+else
+	{
+	if ($shift == 'ALL') 
+		{
+		$Gct_default_start = "0";
+		$Gct_default_stop = "2400";
+		}
+	else 
+		{
+		$stmt="SELECT call_time_id,call_time_name,call_time_comments,ct_default_start,ct_default_stop,ct_sunday_start,ct_sunday_stop,ct_monday_start,ct_monday_stop,ct_tuesday_start,ct_tuesday_stop,ct_wednesday_start,ct_wednesday_stop,ct_thursday_start,ct_thursday_stop,ct_friday_start,ct_friday_stop,ct_saturday_start,ct_saturday_stop,ct_state_call_times FROM vicidial_call_times where call_time_id='$shift';";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$calltimes_to_print = mysql_num_rows($rslt);
+		if ($calltimes_to_print > 0)
+			{
+			$row=mysql_fetch_row($rslt);
+			$Gct_default_start =	$row[3];
+			$Gct_default_stop =		$row[4];
+			$Gct_sunday_start =		$row[5];
+			$Gct_sunday_stop =		$row[6];
+			$Gct_monday_start =		$row[7];
+			$Gct_monday_stop =		$row[8];
+			$Gct_tuesday_start =	$row[9];
+			$Gct_tuesday_stop =		$row[10];
+			$Gct_wednesday_start =	$row[11];
+			$Gct_wednesday_stop =	$row[12];
+			$Gct_thursday_start =	$row[13];
+			$Gct_thursday_stop =	$row[14];
+			$Gct_friday_start =		$row[15];
+			$Gct_friday_stop =		$row[16];
+			$Gct_saturday_start =	$row[17];
+			$Gct_saturday_stop =	$row[18];
+			}
+		else
+			{
+			$Gct_default_start = "0";
+			$Gct_default_stop = "2400";
+			}
+		}
+	$h=0;
+	$hh=0;
+	while ($h < $interval_count)
+		{
+		if ($interval_count>=96)
+			{
+			if ($hf < 45)
+				{
+				$hf = ($hf + 15);
+				}
+			else
+				{
+				$hf = "00";
+				if ($h > 0)
+					{$hh++;}
+				}
+			$H_test = "$hh$hf";
+			}
+		if ($interval_count==48)
+			{
+			if ($hf < 30)
+				{
+				$hf = ($hf + 30);
+				}
+			else
+				{
+				$hf = "00";
+				if ($h > 0)
+					{$hh++;}
+				}
+			$H_test = "$hh$hf";
+			}
+		if ($interval_count<=24)
+			{
+			$H_test = $h . "00";
+			}
+		if ( ($H_test >= $Gct_default_start) and ($H_test <= $Gct_default_stop) )
+			{
+			$Hcalltime[$h]++;
+			$Hcalltime_HHMM[$h] = "$H_test";
+			}
+		if ($DB)
+			{echo "( ($H_test >= $Gct_default_start) and ($H_test <= $Gct_default_stop) ) $hh $hf\n";}
+		$h++;
+		}
+
+	$query_date_BEGIN = "$query_date 00:00:00";   
+	$query_date_END = "$end_date 23:59:59";
+
+
+	$MAIN .= "Outbound Summary Interval Report: $group_string          $NOW_TIME\n";
+
+
+
+
+	##### Loop through each campaign and gether stats
+	if ($group_ct > 0)
+		{
+		$MAIN .= "\n";
+		$MAIN .= "---------- MULTI-CAMPAIGN BREAKDOWN:\n";
+		$MAIN .= "+------------------------------------------+--------+--------+--------+--------+--------+--------+--------+------------+------------+\n";
+		$MAIN .= "|                                          |        | SYSTEM | AGENT  |        |        | NO     |        | AGENT      | AGENT      |\n";
+		$MAIN .= "|                                          | TOTAL  | RELEASE| RELEASE| SALE   | DNC    | ANSWER | DROP   | LOGIN      | PAUSE      |\n";
+		$MAIN .= "| CAMPAIGN                                 | CALLS  | CALLS  | CALLS  | CALLS  | CALLS  | PERCENT| PERCENT| TIME(H:M:S)| TIME(H:M:S)|\n";
+		$MAIN .= "+------------------------------------------+--------+--------+--------+--------+--------+--------+--------+------------+------------+\n";
+
+		$i=0;
+		$TOTcalls_count=0;
+		$TOTsystem_count=0;
+		$TOTagent_count=0;
+		$TOTptp_count=0;
+		$TOTrtp_count=0;
+		$TOTna_count=0;
+		$TOTdrop_count=0;
+		$TOTagent_login_sec=0;
+		$TOTagent_pause_sec=0;
+		$SUBoutput='';
+
+		while($i < $group_ct)
+			{
+			$u=0;
+
+			##### Gather Agent time records
+			$stmt="select event_time,UNIX_TIMESTAMP(event_time),campaign_id,pause_sec,wait_sec,talk_sec,dispo_sec from vicidial_agent_log where event_time >= '$query_date_BEGIN' and event_time <= '$query_date_END' and campaign_id IN('$group_drop[$i]','$group[$i]');";
+			$rslt=mysql_query($stmt, $link);
+			if ($DB) {echo "$stmt\n";}
+			$AGENTtime_to_print = mysql_num_rows($rslt);
+			$s=0;
+			while ($s < $AGENTtime_to_print)
+				{
+				$row=mysql_fetch_row($rslt);
+				$inTOTALsec =		($row[3] + $row[4] + $row[5] + $row[6]);	
+				$ATcall_date[$s] =		$row[0];
+				$ATepoch[$s] =			$row[1];
+				$ATcampaign_id[$s] =	$row[2];
+				$ATpause_sec[$s] =		$row[3];
+				$ATagent_sec[$s] =		$inTOTALsec;
+				$s++;
+				}
+
+			##### Gather outbound calls
+			$stmt = "SELECT status,length_in_sec,call_date,UNIX_TIMESTAMP(call_date),phone_number,campaign_id,uniqueid,lead_id from vicidial_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id='$group[$i]';";
+			$rslt=mysql_query($stmt, $link);
+			if ($DB) {echo "$stmt\n";}
+			$calls_to_parse = mysql_num_rows($rslt);
+			$p=0;
+			while ($p < $calls_to_parse)
+				{
+				$row=mysql_fetch_row($rslt);
+				$CPstatus[$u] =			$row[0];
+				$CPlength_in_sec[$u] =	$row[1];
+				$CPcall_date[$u] =		$row[2];
+				$CPepoch[$u] =			$row[3];
+				$CPphone_number[$u] =	$row[4];
+				$CPcampaign_id[$u] =	$row[5];
+				$CPvicidial_id[$u] =	$row[6];
+				$CPlead_id[$u] =		$row[7];
+				$TESTlead_id[$u] =		$row[7];
+				$TESTuniqueid[$u] =		$row[6];
+				$CPin_out[$u] =			'OUT';
+				$p++;
+				$u++;
+				}
+
+			$group_drop[$i]='';
+			if (eregi("YES",$include_rollover))
+				{
+				##### Gather inbound calls from drop inbound group if selected
+				$stmt="select drop_inbound_group from vicidial_campaigns where campaign_id='$group[$i]' $LOGallowed_campaignsSQL and drop_inbound_group NOT LIKE \"%NONE%\" and drop_inbound_group is NOT NULL and drop_inbound_group != '';";
+				$rslt=mysql_query($stmt, $link);
+				if ($DB) {echo "$stmt\n";}
+				$in_groups_to_print = mysql_num_rows($rslt);
+				if ($in_groups_to_print > 0)
+					{
+					$row=mysql_fetch_row($rslt);
+					$group_drop[$i] = $row[0];
+					$rollover_groups_count++;
+					}
+
+				$length_in_secZ=0;
+				$queue_secondsZ=0;
+				$agent_alert_delayZ=0;
+				$stmt="select status,length_in_sec,queue_seconds,agent_alert_delay,call_date,UNIX_TIMESTAMP(call_date),phone_number,campaign_id,closecallid,lead_id,uniqueid from vicidial_closer_log,vicidial_inbound_groups where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and group_id=campaign_id and campaign_id='$group_drop[$i]';";
+				$rslt=mysql_query($stmt, $link);
+				if ($DB) {echo "$stmt\n";}
+				$INallcalls_to_printZ = mysql_num_rows($rslt);
+				$y=0;
+				while ($y < $INallcalls_to_printZ)
+					{
+					$row=mysql_fetch_row($rslt);
+
+					$k=0;
+					$front_call_found=0;
+					while($k < $p)
+						{
+						if ($TESTuniqueid[$k] == $row[10])
+							{$front_call_found++;}
+						$k++;
+						}
+					if ($front_call_found > 0)
+						{
+						$length_in_secZ = $row[1];
+						$queue_secondsZ = $row[2];
+						$agent_alert_delayZ = $row[3];
+
+						$TOTALdelay =		round($agent_alert_delayZ / 1000);
+						$thiscallsec = (($length_in_secZ - $queue_secondsZ) - $TOTALdelay);
+						if ($thiscallsec < 0)
+							{$thiscallsec = 0;}
+						$inTOTALsec =	($inTOTALsec + $thiscallsec);	
+
+						$CPstatus[$u] =			$row[0];
+						$CPlength_in_sec[$u] =	$inTOTALsec;
+						$CPcall_date[$u] =		$row[4];
+						$CPepoch[$u] =			$row[5];
+						$CPphone_number[$u] =	$row[6];
+						$CPcampaign_id[$u] =	$row[7];
+						$CPvicidial_id[$u] =	$row[8];
+						$CPlead_id[$u] =		$row[9];
+						$CPin_out[$u] =			'IN';
+						$u++;
+						}
+					$y++;
+					}
+				}
+
+
+			$out_of_call_time=0;
+			$length_in_sec[$i]=0;
+			$queue_seconds[$i]=0;
+			$agent_sec[$i]=0;
+			$pause_sec[$i]=0;
+			$talk_sec[$i]=0;
+			$calls_count[$i]=0;
+			$calls_count_IN[$i]=0;
+			$drop_count[$i]=0;
+			$drop_count_OUT[$i]=0;
+			$system_count[$i]=0;
+			$agent_count[$i]=0;
+			$ptp_count[$i]=0;
+			$rtp_count[$i]=0;
+			$na_count[$i]=0;
+			$answer_count[$i]=0;
+			$max_queue_seconds[$i]=0;
+			$Hlength_in_sec=$MT;
+			$Hqueue_seconds=$MT;
+			$Hagent_sec=$MT;
+			$Hpause_sec=$MT;
+			$Htalk_sec=$MT;
+			$Hcalls_count=$MT;
+			$Hcalls_count_IN=$MT;
+			$Hdrop_count=$MT;
+			$Hdrop_count_OUT=$MT;
+			$Hsystem_count=$MT;
+			$Hagent_count=$MT;
+			$Hptp_count=$MT;
+			$Hrtp_count=$MT;
+			$Hna_count=$MT;
+			$Hanswer_count=$MT;
+			$Hmax_queue_seconds=$MT;
+			$hTOTALcalls =	0;
+			$hANSWERcalls =	0;
+			$hSUMagent =	0;
+			$hSUMpause =	0;
+			$hSUMtalk =		0;
+			$hAVGtalk =		0;
+			$hSUMqueue =	0;
+			$hAVGqueue =	0;
+			$hMAXqueue =	0;
+			$hDROPcalls =	0;
+			$hPRINT =		0;
+			$hTOTcalls_count =			0;
+			$hTOTsystem_count =			0;
+			$hTOTagent_count =			0;
+			$hTOTptp_count =			0;
+			$hTOTrtp_count =			0;
+			$hTOTna_count =				0;
+			$hTOTanswer_count =			0;
+			$hTOTagent_sec =			0;
+			$hTOTpause_sec =			0;
+			$hTOTtalk_sec =				0;
+			$hTOTtalk_avg =				0;
+			$hTOTqueue_seconds =		0;
+			$hTOTqueue_avg =			0;
+			$hTOTmax_queue_seconds =	0;
+			$hTOTdrop_count =			0;
+
+			##### Parse through the agent time records to tally the time
+			$p=0;
+			while ($p < $s)
+				{
+				$call_date = explode(" ", $ATcall_date[$p]);
+				$call_time = ereg_replace("[^0-9]","",$call_date[1]);
+				$epoch = $ATepoch[$p];
+				$Cwday = date("w", $epoch);
+
+				$CTstart = $Gct_default_start . "00";
+				$CTstop = $Gct_default_stop . "59";
+
+				if ( ($Cwday == 0) and ( ($Gct_sunday_start > 0) and ($Gct_sunday_stop > 0) ) )
+					{$CTstart = $Gct_sunday_start . "00";   $CTstop = $Gct_sunday_stop . "59";}
+				if ( ($Cwday == 1) and ( ($Gct_monday_start > 0) and ($Gct_monday_stop > 0) ) )
+					{$CTstart = $Gct_monday_start . "00";   $CTstop = $Gct_monday_stop . "59";}
+				if ( ($Cwday == 2) and ( ($Gct_tuesday_start > 0) and ($Gct_tuesday_stop > 0) ) )
+					{$CTstart = $Gct_tuesday_start . "00";   $CTstop = $Gct_tuesday_stop . "59";}
+				if ( ($Cwday == 3) and ( ($Gct_wednesday_start > 0) and ($Gct_wednesday_stop > 0) ) )
+					{$CTstart = $Gct_wednesday_start . "00";   $CTstop = $Gct_wednesday_stop . "59";}
+				if ( ($Cwday == 4) and ( ($Gct_thursday_start > 0) and ($Gct_thursday_stop > 0) ) )
+					{$CTstart = $Gct_thursday_start . "00";   $CTstop = $Gct_thursday_stop . "59";}
+				if ( ($Cwday == 5) and ( ($Gct_friday_start > 0) and ($Gct_friday_stop > 0) ) )
+					{$CTstart = $Gct_friday_start . "00";   $CTstop = $Gct_friday_stop . "59";}
+				if ( ($Cwday == 6) and ( ($Gct_saturday_start > 0) and ($Gct_saturday_stop > 0) ) )
+					{$CTstart = $Gct_saturday_start . "00";   $CTstop = $Gct_saturday_stop . "59";}
+
+				$Chour = date("G", $epoch);
+				$Cmin = date("i", $epoch);
+				if ($interval_count==96)
+					{
+					$ChourX = ($Chour * 4);
+					if ($Cmin < 15) {$Cmin = "00"; $CminX = 0;}
+					if ( ($Cmin >= 15) and ($Cmin < 30) ) {$Cmin = "15"; $CminX = 1;}
+					if ( ($Cmin >= 30) and ($Cmin < 45) ) {$Cmin = "30"; $CminX = 2;}
+					if ($Cmin >= 45) {$Cmin = "45"; $CminX = 3;}
+					$Chour = ($ChourX + $CminX);
+					}
+				if ($interval_count==48)
+					{
+					$ChourX = ($Chour * 2);
+					if ($Cmin < 30) {$Cmin = "00"; $CminX = 0;}
+					if ($Cmin >= 30) {$Cmin = "30"; $CminX = 1;}
+					$Chour = ($ChourX + $CminX);
+					}
+
+				if ( ($call_time > $CTstart) and ($call_time < $CTstop) )
+					{
+					$agent_sec[$i] = ($agent_sec[$i] + $ATagent_sec[$p]);
+					$Hagent_sec[$Chour] = ($Hagent_sec[$Chour] + $ATagent_sec[$p]);
+					$pause_sec[$i] = ($pause_sec[$i] + $ATpause_sec[$p]);
+					$Hpause_sec[$Chour] = ($Hpause_sec[$Chour] + $ATpause_sec[$p]);
+
+					$Hcalltime[$Chour]++;
+
+					if ($print_calls > 0)
+						{
+						echo "$row[5]\t$row[6]\t$TEMPtalk\n";
+						$PCtemptalk = ($PCtemptalk + $TEMPtalk);
+						}
+					$q++;
+					}
+				else
+					{$out_of_call_time++;}
+				if ($DB)
+					{echo "$Hcalltime[$Chour] | AGENT: $agent_sec[$i] PAUSE: $pause_sec[$i]\n";}
+				$p++;
+				}
+
+
+
+
+
+
+			##### Parse through call records to tally the counts
+			$p=0;
+			while ($p < $u)
+				{
+				$call_date = explode(" ", $CPcall_date[$p]);
+				$call_time = ereg_replace("[^0-9]","",$call_date[1]);
+				$epoch = $CPepoch[$p];
+				$Cwday = date("w", $epoch);
+
+				$CTstart = $Gct_default_start . "00";
+				$CTstop = $Gct_default_stop . "59";
+
+				if ( ($Cwday == 0) and ( ($Gct_sunday_start > 0) and ($Gct_sunday_stop > 0) ) )
+					{$CTstart = $Gct_sunday_start . "00";   $CTstop = $Gct_sunday_stop . "59";}
+				if ( ($Cwday == 1) and ( ($Gct_monday_start > 0) and ($Gct_monday_stop > 0) ) )
+					{$CTstart = $Gct_monday_start . "00";   $CTstop = $Gct_monday_stop . "59";}
+				if ( ($Cwday == 2) and ( ($Gct_tuesday_start > 0) and ($Gct_tuesday_stop > 0) ) )
+					{$CTstart = $Gct_tuesday_start . "00";   $CTstop = $Gct_tuesday_stop . "59";}
+				if ( ($Cwday == 3) and ( ($Gct_wednesday_start > 0) and ($Gct_wednesday_stop > 0) ) )
+					{$CTstart = $Gct_wednesday_start . "00";   $CTstop = $Gct_wednesday_stop . "59";}
+				if ( ($Cwday == 4) and ( ($Gct_thursday_start > 0) and ($Gct_thursday_stop > 0) ) )
+					{$CTstart = $Gct_thursday_start . "00";   $CTstop = $Gct_thursday_stop . "59";}
+				if ( ($Cwday == 5) and ( ($Gct_friday_start > 0) and ($Gct_friday_stop > 0) ) )
+					{$CTstart = $Gct_friday_start . "00";   $CTstop = $Gct_friday_stop . "59";}
+				if ( ($Cwday == 6) and ( ($Gct_saturday_start > 0) and ($Gct_saturday_stop > 0) ) )
+					{$CTstart = $Gct_saturday_start . "00";   $CTstop = $Gct_saturday_stop . "59";}
+
+				$Chour = date("G", $epoch);
+				$Cmin = date("i", $epoch);
+				if ($interval_count==96)
+					{
+					$ChourX = ($Chour * 4);
+					if ($Cmin < 15) {$Cmin = "00"; $CminX = 0;}
+					if ( ($Cmin >= 15) and ($Cmin < 30) ) {$Cmin = "15"; $CminX = 1;}
+					if ( ($Cmin >= 30) and ($Cmin < 45) ) {$Cmin = "30"; $CminX = 2;}
+					if ($Cmin >= 45) {$Cmin = "45"; $CminX = 3;}
+					$Chour = ($ChourX + $CminX);
+					}
+				if ($interval_count==48)
+					{
+					$ChourX = ($Chour * 2);
+					if ($Cmin < 30) {$Cmin = "00"; $CminX = 0;}
+					if ($Cmin >= 30) {$Cmin = "30"; $CminX = 1;}
+					$Chour = ($ChourX + $CminX);
+					}
+
+				if ( ($call_time > $CTstart) and ($call_time < $CTstop) )
+					{
+					$calls_count[$i]++;
+					$length_in_sec[$i] =	($length_in_sec[$i] + $CPlength_in_sec[$p]);
+					$Hlength_in_sec[$Chour] =	($Hlength_in_sec[$Chour] + $row[1]);
+					$Hqueue_seconds[$Chour] =	($Hqueue_seconds[$Chour] + $row[2]);
+					$TEMPtalk = $CPlength_in_sec[$p];
+					if ($TEMPtalk < 0) {$TEMPtalk = 0;}
+					$talk_sec[$i] =	($talk_sec[$i] + $TEMPtalk);
+					$Htalk_sec[$Chour] =	($Htalk_sec[$Chour] + $TEMPtalk);
+
+					$Hcalls_count[$Chour]++;
+					if (eregi("DROP",$CPstatus[$p]))
+						{
+						if ($CPin_out[$p] == 'OUT')
+							{
+							$drop_count_OUT[$i]++;
+							$Hdrop_count_OUT[$Chour]++;
+							}
+						$drop_count[$i]++;
+						$Hdrop_count[$Chour]++;
+						}
+					else
+						{
+						$answer_count[$i]++;
+						$Hanswer_count[$Chour]++;
+						}
+					if (eregi("\|$CPstatus[$p]\|",'|NA|NEW|QUEUE|INCALL|DROP|XDROP|AA|AM|AL|AFAX|AB|ADC|DNCL|DNCC|PU|PM|SVYEXT|SVYHU|SVYVM|SVYREC|QVMAIL|'))
+						{
+						$system_count[$i]++;
+						$Hsystem_count[$Chour]++;
+						}
+					else
+						{
+						$agent_count[$i]++;
+						$Hagent_count[$Chour]++;
+						}
+					if ($CPstatus[$p] == 'NA')
+						{
+						$na_count[$i]++;
+						$Hna_count[$Chour]++;
+						}
+					if ($CPin_out[$p] == 'IN')
+						{
+						$calls_count_IN[$i]++;
+						$Hcalls_count_IN[$Chour]++;
+						}
+
+					$k=0;
+					while($k < $sale_ct)
+						{
+						if ($sale_statusesLIST[$k] == $CPstatus[$p])
+							{
+							$ptp_count[$i]++;
+							$Hptp_count[$Chour]++;
+							}
+						$k++;
+						}
+
+					$k=0;
+					while($k < $dnc_ct)
+						{
+						if ($dnc_statusesLIST[$k] == $CPstatus[$p])
+							{
+							$rtp_count[$i]++;
+							$Hrtp_count[$Chour]++;
+							}
+						$k++;
+						}
+
+					$Hcalltime[$Chour]++;
+					
+
+					if ($print_calls > 0)
+						{
+						echo "$row[5]\t$row[6]\t$TEMPtalk\n";
+						$PCtemptalk = ($PCtemptalk + $TEMPtalk);
+						}
+					$q++;
+					}
+				else
+					{$out_of_call_time++;}
+				if ($DB)
+					{echo "$call_time > $CTstart | $call_time < $CTstop | $Cwday | $Chour | $Hcalltime[$Chour] | $talk_sec[$i]\n";}
+				$p++;
+				}
+
+
+			if ( ($answer_count[$i] > 0) and ($talk_sec[$i] > 0) )
+				{$talk_avg[$i] = ($talk_sec[$i] / $answer_count[$i]);}
+			else
+				{$talk_avg[$i] = 0;}
+			if ( ($calls_count[$i] > 0) and ($queue_seconds[$i] > 0) )
+				{$queue_avg[$i] = ($queue_seconds[$i] / $calls_count[$i]);}
+			else
+				{$queue_avg[$i] = 0;}
+
+			if ($print_calls > 0)
+				{
+				$PCtemptalkmin = ($PCtemptalk  / 60);
+				echo "$q\t$PCtemptalk\t$PCtemptalkmin\n";
+				}
+
+			if ( ($calls_count_IN[$i] > 0) and ($drop_count_OUT[$i] > 0) )
+				{
+				$drop_count[$i] = ($drop_count[$i] - $calls_count_IN[$i]);
+				$calls_count[$i] = ($calls_count[$i] - $calls_count_IN[$i]);
+				$system_count[$i] = ($system_count[$i] - $calls_count_IN[$i]);
+				if ($drop_count[$i] < 0)
+					{$drop_count[$i] = 0;}
+				}
+			$TOTcalls_count =			($TOTcalls_count + $calls_count[$i]);
+			$TOTsystem_count =			($TOTsystem_count + $system_count[$i]);
+			$TOTagent_count =			($TOTagent_count + $agent_count[$i]);
+			$TOTptp_count =				($TOTptp_count + $ptp_count[$i]);
+			$TOTrtp_count =				($TOTrtp_count + $rtp_count[$i]);
+			$TOTna_count =				($TOTna_count + $na_count[$i]);
+			$TOTanswer_count =			($TOTanswer_count + $answer_count[$i]);
+			$TOTagent_sec =				($TOTagent_sec + $agent_sec[$i]);
+			$TOTpause_sec =				($TOTpause_sec + $pause_sec[$i]);
+			$TOTtalk_sec =				($TOTtalk_sec + $talk_sec[$i]);
+			$TOTqueue_seconds =			($TOTqueue_seconds + $queue_seconds[$i]);
+			$TOTdrop_count =			($TOTdrop_count + $drop_count[$i]);
+			if ($max_queue_seconds[$i] > $TOTmax_queue_seconds)
+				{$TOTmax_queue_seconds = $max_queue_seconds[$i];}
+
+			$agent_sec[$i] =			sec_convert($agent_sec[$i],'H'); 
+			$pause_sec[$i] =			sec_convert($pause_sec[$i],'H'); 
+			$talk_sec[$i] =				sec_convert($talk_sec[$i],'H'); 
+			$talk_avg[$i] =				sec_convert($talk_avg[$i],'H'); 
+			$queue_seconds[$i] =		sec_convert($queue_seconds[$i],'H'); 
+			$queue_avg[$i] =			sec_convert($queue_avg[$i],'H'); 
+			$max_queue_seconds[$i] =	sec_convert($max_queue_seconds[$i],'H'); 
+
+
+			$groupDISPLAY =	sprintf("%-40s", "$group[$i] - $group_cname[$i]");
+			$gTOTALcalls =	sprintf("%6s", $calls_count[$i]);
+			$gSYSTEMcalls =	sprintf("%6s", $system_count[$i]);
+			$gAGENTcalls =	sprintf("%6s", $agent_count[$i]);
+			$gPTPcalls =	sprintf("%6s", $ptp_count[$i]);
+			$gRTPcalls =	sprintf("%6s", $rtp_count[$i]);
+			if ( ($calls_count[$i] < 1) or ($na_count[$i] < 1) )
+				{$gNApercent=0;}
+			else
+				{$gNApercent = ( ($na_count[$i] / $calls_count[$i]) * 100);}
+			$gNApercent =	sprintf("%6.2f",$gNApercent);
+			$gNAcalls =		sprintf("%6s", $na_count[$i]);
+			$gANSWERcalls =	sprintf("%6s", $answer_count[$i]);
+			$gSUMagent =	sprintf("%10s", $agent_sec[$i]);
+			$gSUMpause =	sprintf("%10s", $pause_sec[$i]);
+			$gSUMtalk =		sprintf("%9s", $talk_sec[$i]);
+			$gAVGtalk =		sprintf("%7s", $talk_avg[$i]);
+			$gSUMqueue =	sprintf("%9s", $queue_seconds[$i]);
+			$gAVGqueue =	sprintf("%7s", $queue_avg[$i]);
+			$gMAXqueue =	sprintf("%7s", $max_queue_seconds[$i]);
+			if ( ($calls_count[$i] < 1) or ($drop_count[$i] < 1) )
+				{$gDROPpercent=0;}
+			else
+				{$gDROPpercent = ( ($drop_count[$i] / $calls_count[$i]) * 100);}
+			$gDROPpercent =		sprintf("%6.2f",$gDROPpercent);
+			$gDROPcalls =	sprintf("%6s", $drop_count[$i]);
+
+			while(strlen($groupDISPLAY)>40) {$groupDISPLAY = substr("$groupDISPLAY", 0, -1);}
+
+			$MAIN .= "| $groupDISPLAY | $gTOTALcalls | $gSYSTEMcalls | $gAGENTcalls | $gPTPcalls | $gRTPcalls | $gNApercent%| $gDROPpercent%| $gSUMagent | $gSUMpause |";
+			if ($DB) {$MAIN .= " $gDROPcalls($calls_count_IN[$i]/$drop_count_OUT[$i]) |";}
+			$MAIN .= "\n";
+
+			### hour by hour sumaries
+			$SUBoutput .= "\n---------- $group[$i] - $group_cname[$i]     INTERVAL BREAKDOWN:\n";
+			$SUBoutput .= "+---------------------+--------+--------+--------+--------+--------+--------+--------+------------+------------+\n";
+			$SUBoutput .= "|                     |        | SYSTEM | AGENT  |        |        | NO     |        | AGENT      | AGENT      |\n";
+			$SUBoutput .= "|                     | TOTAL  | RELEASE| RELEASE| SALE   | DNC    | ANSWER | DROP   | LOGIN      | PAUSE      |\n";
+			$SUBoutput .= "| INTERVAL            | CALLS  | CALLS  | CALLS  | CALLS  | CALLS  | PERCENT| PERCENT| TIME(H:M:S)| TIME(H:M:S)|\n";
+			$SUBoutput .= "+---------------------+--------+--------+--------+--------+--------+--------+--------+------------+------------+\n";
+
+			$h=0;
+			while ($h < $interval_count)
+				{
+				if ($Hcalltime[$h] > 0)
+					{
+					if (strlen($Hcalls_count[$h]) < 1)			{$Hcalls_count[$h] = 0;}
+					if (strlen($Hsystem_count[$h]) < 1)			{$Hsystem_count[$h] = 0;}
+					if (strlen($Hagent_count[$h]) < 1)			{$Hagent_count[$h] = 0;}
+					if (strlen($Hptp_count[$h]) < 1)			{$Hptp_count[$h] = 0;}
+					if (strlen($Hrtp_count[$h]) < 1)			{$Hrtp_count[$h] = 0;}
+					if (strlen($Hna_count[$h]) < 1)				{$Hna_count[$h] = 0;}
+					if (strlen($Hanswer_count[$h]) < 1)			{$Hanswer_count[$h] = 0;}
+					if (strlen($Hagent_sec[$h]) < 1)			{$Hagent_sec[$h] = 0;}
+					if (strlen($Hpause_sec[$h]) < 1)			{$Hpause_sec[$h] = 0;}
+					if (strlen($Htalk_sec[$h]) < 1)				{$Htalk_sec[$h] = 0;}
+					if (strlen($Hqueue_seconds[$h]) < 1)		{$Hqueue_seconds[$h] = 0;}
+					if (strlen($Hmax_queue_seconds[$h]) < 1)	{$Hmax_queue_seconds[$h] = 0;}
+					if (strlen($Hdrop_count[$h]) < 1)			{$Hdrop_count[$h] = 0;}
+
+					if ( ($Hcalls_count_IN[$h] > 0) and ($Hdrop_count_OUT[$h] > 0) )
+						{
+						$Hdrop_count[$h] = ($Hdrop_count[$h] - $Hcalls_count_IN[$h]);
+						$Hcalls_count[$h] = ($Hcalls_count[$h] - $Hcalls_count_IN[$h]);
+						$Hsystem_count[$h] = ($Hsystem_count[$h] - $Hcalls_count_IN[$h]);
+						if ($Hdrop_count[$h] < 0)
+							{$Hdrop_count[$h] = 0;}
+						}
+					$hTOTcalls_count =			($hTOTcalls_count + $Hcalls_count[$h]);
+					$hTOTsystem_count =			($hTOTsystem_count + $Hsystem_count[$h]);
+					$hTOTagent_count =			($hTOTagent_count + $Hagent_count[$h]);
+					$hTOTptp_count =			($hTOTptp_count + $Hptp_count[$h]);
+					$hTOTrtp_count =			($hTOTrtp_count + $Hrtp_count[$h]);
+					$hTOTna_count =				($hTOTna_count + $Hna_count[$h]);
+					$hTOTanswer_count =			($hTOTanswer_count + $Hanswer_count[$h]);
+					$hTOTagent_sec =			($hTOTagent_sec + $Hagent_sec[$h]);
+					$hTOTpause_sec =			($hTOTpause_sec + $Hpause_sec[$h]);
+					$hTOTtalk_sec =				($hTOTtalk_sec + $Htalk_sec[$h]);
+					$hTOTqueue_seconds =		($hTOTqueue_seconds + $Hqueue_seconds[$h]);
+					$hTOTdrop_count =			($hTOTdrop_count + $Hdrop_count[$h]);
+					if ($Hmax_queue_seconds[$h] > $hTOTmax_queue_seconds)
+						{$hTOTmax_queue_seconds = $Hmax_queue_seconds[$h];}
+
+					if ( ($Hanswer_count[$h] > 0) and ($Htalk_sec[$h] > 0) )
+						{$Htalk_avg[$h] = ($Htalk_sec[$h] / $Hanswer_count[$h]);}
+					else
+						{$Htalk_avg[$h] = 0;}
+					if ( ($Hcalls_count[$h] > 0) and ($Hqueue_seconds[$h] > 0) )
+						{$Hqueue_avg[$h] = ($Hqueue_seconds[$h] / $Hcalls_count[$h]);}
+					else
+						{$Hqueue_avg[$h] = 0;}
+
+					$Hagent_sec[$h] =			sec_convert($Hagent_sec[$h],'H'); 
+					$Hpause_sec[$h] =			sec_convert($Hpause_sec[$h],'H'); 
+					$Htalk_sec[$h] =			sec_convert($Htalk_sec[$h],'H'); 
+					$Htalk_avg[$h] =			sec_convert($Htalk_avg[$h],'H'); 
+					$Hqueue_seconds[$h] =		sec_convert($Hqueue_seconds[$h],'H'); 
+					$Hqueue_avg[$h] =			sec_convert($Hqueue_avg[$h],'H'); 
+					$Hmax_queue_seconds[$h] =	sec_convert($Hmax_queue_seconds[$h],'H');
+					
+					$hTOTALcalls =	sprintf("%6s", $Hcalls_count[$h]);
+					$hSYSTEMcalls =	sprintf("%6s", $Hsystem_count[$h]);
+					$hAGENTcalls =	sprintf("%6s", $Hagent_count[$h]);
+					$hPTPcalls =	sprintf("%6s", $Hptp_count[$h]);
+					$hRTPcalls =	sprintf("%6s", $Hrtp_count[$h]);
+					if ( ($Hcalls_count[$h] < 1) or ($Hna_count[$h] < 1) )
+						{$hNApercent=0;}
+					else
+						{$hNApercent = ( ($Hna_count[$h] / $Hcalls_count[$h]) * 100);}
+					$hNApercent =		sprintf("%6.2f",$hNApercent);
+					$hNAcalls =		sprintf("%6s", $Hna_count[$h]);
+					$hANSWERcalls =	sprintf("%6s", $Hanswer_count[$h]);
+					$hSUMagent =	sprintf("%10s", $Hagent_sec[$h]);
+					$hSUMpause =	sprintf("%10s", $Hpause_sec[$h]);
+					$hSUMtalk =		sprintf("%9s", $Htalk_sec[$h]);
+					$hAVGtalk =		sprintf("%7s", $Htalk_avg[$h]);
+					$hSUMqueue =	sprintf("%9s", $Hqueue_seconds[$h]);
+					$hAVGqueue =	sprintf("%7s", $Hqueue_avg[$h]);
+					$hMAXqueue =	sprintf("%7s", $Hmax_queue_seconds[$h]);
+					if ( ($Hcalls_count[$h] < 1) or ($Hdrop_count[$h] < 1) )
+						{$hDROPpercent=0;}
+					else
+						{$hDROPpercent = ( ($Hdrop_count[$h] / $Hcalls_count[$h]) * 100);}
+					$hDROPpercent =		sprintf("%6.2f",$hDROPpercent);
+					$hDROPcalls =	sprintf("%6s", $Hdrop_count[$h]);
+					$hPRINT =		sprintf("%19s", $Hcalltime_HHMM[$h]);
+
+					$SUBoutput .= "| $hPRINT | $hTOTALcalls | $hSYSTEMcalls | $hAGENTcalls | $hPTPcalls | $hRTPcalls | $hNApercent%| $hDROPpercent%| $hSUMagent | $hSUMpause |\n";
+					if ($DB) {$SUBoutput .= " $hDROPcalls($Hcalls_count_IN[$h]/$Hdrop_count_OUT[$h]) |\n";}
+					}
+
+				$h++;
+				}
+
+			if ( ($hTOTanswer_count > 0) and ($hTOTtalk_sec > 0) )
+				{$hTOTtalk_avg = ($hTOTtalk_sec / $hTOTanswer_count);}
+			else
+				{$hTOTtalk_avg = 0;}
+			if ( ($hTOTcalls_count > 0) and ($hTOTqueue_seconds > 0) )
+				{$hTOTqueue_avg = ($hTOTqueue_seconds / $hTOTcalls_count);}
+			else
+				{$hTOTqueue_avg = 0;}
+
+			$hTOTagent_sec =			sec_convert($hTOTagent_sec,'H'); 
+			$hTOTpause_sec =			sec_convert($hTOTpause_sec,'H'); 
+			$hTOTtalk_sec =				sec_convert($hTOTtalk_sec,'H'); 
+			$hTOTtalk_avg =				sec_convert($hTOTtalk_avg,'H'); 
+			$hTOTqueue_seconds =		sec_convert($hTOTqueue_seconds,'H'); 
+			$hTOTqueue_avg =			sec_convert($hTOTqueue_avg,'H'); 
+			$hTOTmax_queue_seconds =	sec_convert($hTOTmax_queue_seconds,'H'); 
+
+			$hTOTcalls_count =			sprintf("%6s", $hTOTcalls_count);
+			$hTOTsystem_count =			sprintf("%6s", $hTOTsystem_count);
+			$hTOTagent_count =			sprintf("%6s", $hTOTagent_count);
+			$hTOTptp_count =			sprintf("%6s", $hTOTrtp_count);
+			$hTOTrtp_count =			sprintf("%6s", $hTOTptp_count);
+			if ( ($hTOTcalls_count < 1) or ($hTOTna_count < 1) )
+				{$hTOTna_percent=0;}
+			else
+				{$hTOTna_percent = ( ($hTOTna_count / $hTOTcalls_count) * 100);}
+			$hTOTna_percent =			sprintf("%6.2f",$hTOTna_percent);
+			$hTOTna_count =				sprintf("%6s", $hTOTna_count);
+			$hTOTanswer_count =			sprintf("%6s", $hTOTanswer_count);
+			$hTOTagent_sec =			sprintf("%10s", $hTOTagent_sec);
+			$hTOTpause_sec =			sprintf("%10s", $hTOTpause_sec);
+			$hTOTtalk_sec =				sprintf("%9s", $hTOTtalk_sec);
+			$hTOTtalk_avg =				sprintf("%7s", $hTOTtalk_avg);
+			$hTOTqueue_seconds =		sprintf("%9s", $hTOTqueue_seconds);
+			$hTOTqueue_avg =			sprintf("%7s", $hTOTqueue_avg);
+			$hTOTmax_queue_seconds =	sprintf("%7s", $hTOTmax_queue_seconds);
+			if ( ($hTOTcalls_count < 1) or ($hTOTdrop_count < 1) )
+				{$hTOTdrop_percent=0;}
+			else
+				{$hTOTdrop_percent = ( ($hTOTdrop_count / $hTOTcalls_count) * 100);}
+			$hTOTdrop_percent =			sprintf("%6.2f",$hTOTdrop_percent);
+			$hTOTdrop_count =			sprintf("%6s", $hTOTdrop_count);
+
+			$SUBoutput .= "+---------------------+--------+--------+--------+--------+--------+--------+--------+------------+------------+\n";
+			$SUBoutput .= "| TOTALS              | $hTOTcalls_count | $hTOTsystem_count | $hTOTagent_count | $hTOTptp_count | $hTOTrtp_count | $hTOTna_percent%| $hTOTdrop_percent%| $hTOTagent_sec | $hTOTpause_sec |\n";
+			$SUBoutput .= "+---------------------+--------+--------+--------+--------+--------+--------+--------+------------+------------+\n";
+
+			$i++;
+			}
+
+		$rawTOTtalk_sec = $TOTtalk_sec;
+		$rawTOTtalk_min = round($rawTOTtalk_sec / 60);
+
+		if ( ($TOTanswer_count > 0) and ($TOTtalk_sec > 0) )
+			{$TOTtalk_avg = ($TOTtalk_sec / $TOTanswer_count);}
+		else
+			{$TOTtalk_avg = 0;}
+		if ( ($TOTcalls_count > 0) and ($TOTqueue_seconds > 0) )
+			{$TOTqueue_avg = ($TOTqueue_seconds / $TOTcalls_count);}
+		else
+			{$TOTqueue_avg = 0;}
+
+		$TOTagent_sec =			sec_convert($TOTagent_sec,'H'); 
+		$TOTpause_sec =			sec_convert($TOTpause_sec,'H'); 
+		$TOTtalk_sec =			sec_convert($TOTtalk_sec,'H'); 
+		$TOTtalk_avg =			sec_convert($TOTtalk_avg,'H'); 
+		$TOTqueue_seconds =		sec_convert($TOTqueue_seconds,'H'); 
+		$TOTqueue_avg =			sec_convert($TOTqueue_avg,'H'); 
+		$TOTmax_queue_seconds =	sec_convert($TOTmax_queue_seconds,'H'); 
+
+		$i =					sprintf("%4s", $i);
+		$TOTcalls_count =		sprintf("%6s", $TOTcalls_count);
+		$TOTsystem_count =		sprintf("%6s", $TOTsystem_count);
+		$TOTagent_count =		sprintf("%6s", $TOTagent_count);
+		$TOTptp_count =			sprintf("%6s", $TOTptp_count);
+		$TOTrtp_count =			sprintf("%6s", $TOTrtp_count);
+		if ( ($TOTcalls_count < 1) or ($TOTna_count < 1) )
+			{$TOTna_percent=0;}
+		else
+			{$TOTna_percent = ( ($TOTna_count / $TOTcalls_count) * 100);}
+		$TOTna_percent =		sprintf("%6.2f",$TOTna_percent);
+		$TOTna_count =			sprintf("%6s", $TOTna_count);
+		$TOTanswer_count =		sprintf("%6s", $TOTanswer_count);
+		$TOTagent_sec =			sprintf("%10s", $TOTagent_sec);
+		$TOTpause_sec =			sprintf("%10s", $TOTpause_sec);
+		$TOTtalk_sec =			sprintf("%9s", $TOTtalk_sec);
+		$TOTtalk_avg =			sprintf("%7s", $TOTtalk_avg);
+		$TOTqueue_seconds =		sprintf("%9s", $TOTqueue_seconds);
+		$TOTqueue_avg =			sprintf("%7s", $TOTqueue_avg);
+		$TOTmax_queue_seconds =	sprintf("%7s", $TOTmax_queue_seconds);
+		if ( ($TOTcalls_count < 1) or ($TOTdrop_count < 1) )
+			{$TOTdrop_percent=0;}
+		else
+			{$TOTdrop_percent = ( ($TOTdrop_count / $TOTcalls_count) * 100);}
+		$TOTdrop_percent =		sprintf("%6.2f",$TOTdrop_percent);
+		$TOTdrop_count =		sprintf("%6s", $TOTdrop_count);
+
+		$MAIN .= "+------------------------------------------+--------+--------+--------+--------+--------+--------+--------+------------+------------+\n";
+		$MAIN .= "| TOTALS       Campaigns: $i             | $TOTcalls_count | $TOTsystem_count | $TOTagent_count | $TOTptp_count | $TOTrtp_count | $TOTna_percent%| $TOTdrop_percent%| $TOTagent_sec | $TOTpause_sec |\n";
+		$MAIN .= "+------------------------------------------+--------+--------+--------+--------+--------+--------+--------+------------+------------+\n";
+		}
+
+	if ($costformat > 0)
+		{
+		echo "
\n"; + $inbound_cost = ($rawTOTtalk_min * $inbound_rate); + $inbound_cost = sprintf("%8.2f", $inbound_cost); + + echo "INBOUND $query_date to $end_date,   $rawTOTtalk_min minutes at \$$inbound_rate = \$$inbound_cost\n"; + + exit; + } + + + echo "$MAIN"; + echo "$SUBoutput"; + + + + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $STARTtime); + echo "\n\nRun Time: $RUNtime seconds\n"; + } + + + + +?> + +
+ + diff --git a/LANG_www/vicidial_br/AST_VDADstats.php b/LANG_www/vicidial_br/AST_VDADstats.php new file mode 100644 index 00000000..59814637 --- /dev/null +++ b/LANG_www/vicidial_br/AST_VDADstats.php @@ -0,0 +1,1458 @@ + LICENSE: AGPLv2 +# +# CHANGES +# 60619-1718 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# 61215-1139 - Added drop percentage of answered and round-2 decimal +# 71008-1436 - Added shift to be defined in dbconnect.php +# 71218-1155 - Added end_date for multi-day reports +# 80430-1920 - Added Customer hangup cause stats +# 80620-0031 - Fixed human answered calculation for drop perfentage +# 80709-0230 - Added time stats to call statuses +# 80717-2118 - Added calls/hour out of agent login time in status summary +# 80722-2049 - Added Status Category stats +# 81109-2341 - Added Productivity Rating +# 90225-1140 - Changed to multi-campaign capability +# 90310-2034 - Admin header +# 90508-0644 - Changed to PHP long tags +# 90524-2231 - Changed to use functions.php for seconds to HH:MM:SS conversion +# 90608-0251 - Added optional carrier codes stats, made graph at bottom optional +# 90806-0001 - Added CI(Customer Interaction/Human Answered) stats, added option to add inbound rollover stats to these +# 90827-1154 - Added List ID breakdown of calls +# 91222-0843 - Fixed ALL-CAMPAIGNS inbound rollover issue(bug #262), and some other bugs +# 100202-1034 - Added statuses to no-answer section +# 100214-1421 - Sort menu alphabetically +# 100216-0042 - Added popup date selector +# + +header ("Content-type: text/html; charset=utf-8"); + +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["print_calls"])) {$print_calls=$_GET["print_calls"];} + elseif (isset($_POST["print_calls"])) {$print_calls=$_POST["print_calls"];} +if (isset($_GET["outbound_rate"])) {$outbound_rate=$_GET["outbound_rate"];} + elseif (isset($_POST["outbound_rate"])) {$outbound_rate=$_POST["outbound_rate"];} +if (isset($_GET["costformat"])) {$costformat=$_GET["costformat"];} + elseif (isset($_POST["costformat"])) {$costformat=$_POST["costformat"];} +if (isset($_GET["include_rollover"])) {$include_rollover=$_GET["include_rollover"];} + elseif (isset($_POST["include_rollover"])) {$include_rollover=$_POST["include_rollover"];} +if (isset($_GET["carrier_stats"])) {$carrier_stats=$_GET["carrier_stats"];} + elseif (isset($_POST["carrier_stats"])) {$carrier_stats=$_POST["carrier_stats"];} +if (isset($_GET["bottom_graph"])) {$bottom_graph=$_GET["bottom_graph"];} + elseif (isset($_POST["bottom_graph"])) {$bottom_graph=$_POST["bottom_graph"];} +if (isset($_GET["agent_hours"])) {$agent_hours=$_GET["agent_hours"];} + elseif (isset($_POST["agent_hours"])) {$agent_hours=$_POST["agent_hours"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +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["shift"])) {$shift=$_GET["shift"];} + elseif (isset($_POST["shift"])) {$shift=$_POST["shift"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} + +$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';} +if (strlen($bottom_graph)<2) {$bottom_graph='NO';} +if (strlen($carrier_stats)<2) {$carrier_stats='NO';} +if (strlen($include_rollover)<2) {$include_rollover='NO';} + + +############################################# +##### 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); +if ($qm_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $non_latin = $row[0]; + } +##### END SETTINGS LOOKUP ##### +########################################### + +##### SERVER CARRIER LOGGING LOOKUP ##### +$stmt = "SELECT count(*) FROM servers where carrier_logging_active='Y' and max_vicidial_trunks > 0;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$srv_conf_ct = mysql_num_rows($rslt); +if ($srv_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $carrier_logging_active = $row[0]; + } + +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level >= 7 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 "Nome ou Senha inválidos: |$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;} +if (!isset($end_date)) {$end_date = $NOW_DATE;} + +$i=0; +$group_string='|'; +$group_ct = count($group); +while($i < $group_ct) + { + $group_string .= "$group[$i]|"; + $i++; + } + +$stmt="select campaign_id,campaign_name from vicidial_campaigns order by campaign_id;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$campaigns_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $campaigns_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] = $row[0]; + $group_names[$i] = $row[1]; + if (ereg("--ALL",$group_string) ) + {$group[$i] = $groups[$i];} + $i++; + } + +$rollover_groups_count=0; +$i=0; +$group_string='|'; +$group_ct = count($group); +while($i < $group_ct) + { + $group_string .= "$group[$i]|"; + $group_SQL .= "'$group[$i]',"; + $groupQS .= "&group[]=$group[$i]"; + + if (eregi("YES",$include_rollover)) + { + $stmt="select drop_inbound_group from vicidial_campaigns where campaign_id='$group[$i]' and drop_inbound_group NOT LIKE \"%NONE%\" and drop_inbound_group is NOT NULL and drop_inbound_group != '';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $in_groups_to_print = mysql_num_rows($rslt); + if ($in_groups_to_print > 0) + { + $row=mysql_fetch_row($rslt); + $group_drop_SQL .= "'$row[0]',"; + + $rollover_groups_count++; + } + } + + $i++; + } +if (strlen($group_drop_SQL) < 2) + {$group_drop_SQL = "''";} +if ( (ereg("--ALL--",$group_string) ) or ($group_ct < 1) ) + { + $group_SQL = ""; + $group_drop_SQL = ""; + } +else + { + $group_SQL = eregi_replace(",$",'',$group_SQL); + $group_drop_SQL = eregi_replace(",$",'',$group_drop_SQL); + $both_group_SQLand = "and ( (campaign_id IN($group_drop_SQL)) or (campaign_id IN($group_SQL)) )"; + $both_group_SQL = "where ( (campaign_id IN($group_drop_SQL)) or (campaign_id IN($group_SQL)) )"; + $group_SQLand = "and campaign_id IN($group_SQL)"; + $group_SQL = "where campaign_id IN($group_SQL)"; + $group_drop_SQLand = "and campaign_id IN($group_drop_SQL)"; + $group_drop_SQL = "where campaign_id IN($group_drop_SQL)"; + } + +$stmt="select vsc_id,vsc_name from vicidial_status_categories;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$statcats_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $statcats_to_print) + { + $row=mysql_fetch_row($rslt); + $vsc_id[$i] = $row[0]; + $vsc_name[$i] = $row[1]; + $vsc_count[$i] = 0; + $i++; + } + +$customer_interactive_statuses=''; +$stmt="select status from vicidial_statuses where human_answered='Y';"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$statha_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $statha_to_print) + { + $row=mysql_fetch_row($rslt); + $customer_interactive_statuses .= "'$row[0]',"; + $i++; + } +$stmt="select status from vicidial_campaign_statuses where human_answered='Y';"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$statha_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $statha_to_print) + { + $row=mysql_fetch_row($rslt); + $customer_interactive_statuses .= "'$row[0]',"; + $i++; + } +if (strlen($customer_interactive_statuses)>2) + {$customer_interactive_statuses = substr("$customer_interactive_statuses", 0, -1);} +else + {$customer_interactive_statuses="''";} + +?> + + + + + +\n"; +echo "\n"; + +echo "\n"; +echo "Outbound Stats\n"; + +$short_header=1; + +require("admin_header.php"); + +echo "
"; + +echo "
\n"; +echo "
Datas:
"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo ""; + +?> + + to
"; + +?> + +
Campanhas:
"; +echo "\n"; +echo "
"; +echo "Include Drop  
Rollover:
"; +echo "\n"; +echo "
Bottom Graph:  
\n"; +echo "
\n"; +if ($carrier_logging_active > 0) + { + echo "
Carrier Stats:  
"; + echo "\n"; + } +echo "
Shift:  
"; +echo "

\n"; +echo "\n"; +echo "
        "; +echo ""; +if (strlen($group[0]) > 1) + { + echo " ALTERAR | \n"; + echo " RELATÓRIOS \n"; + } +else + { + echo " CAMPANHAS | \n"; + echo " RELATÓRIOS \n"; + } +echo "
"; +echo "
\n\n"; + +echo "
\n\n";
+
+
+if (strlen($group[0]) < 1)
+	{
+	echo "\n\n";
+	echo "POR FAVOR SELECIONE UMA CAMPANHA E UMA DATA ACIMA E CLIQUE EM ENVIAR\n";
+	}
+
+else
+	{
+	if ($shift == 'AM') 
+		{
+		$time_BEGIN=$AM_shift_BEGIN;
+		$time_END=$AM_shift_END;
+		if (strlen($time_BEGIN) < 6) {$time_BEGIN = "03:45:00";}   
+		if (strlen($time_END) < 6) {$time_END = "15:15:00";}
+		}
+	if ($shift == 'PM') 
+		{
+		$time_BEGIN=$PM_shift_BEGIN;
+		$time_END=$PM_shift_END;
+		if (strlen($time_BEGIN) < 6) {$time_BEGIN = "15:15:00";}
+		if (strlen($time_END) < 6) {$time_END = "23:15:00";}
+		}
+	if ($shift == 'ALL') 
+		{
+		if (strlen($time_BEGIN) < 6) {$time_BEGIN = "00:00:00";}
+		if (strlen($time_END) < 6) {$time_END = "23:59:59";}
+		}
+	$query_date_BEGIN = "$query_date $time_BEGIN";   
+	$query_date_END = "$end_date $time_END";
+
+
+	$OUToutput = '';
+	$OUToutput .= "Outbound Calling Stats                             $NOW_TIME\n";
+
+	$OUToutput .= "\n";
+	$OUToutput .= "Time range: $query_date_BEGIN to $query_date_END\n\n";
+	$OUToutput .= "---------- TOTALS\n";
+
+	$stmt="select count(*),sum(length_in_sec) from vicidial_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' $group_SQLand;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {$OUToutput .= "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+
+	$TOTALcallsRAW = $row[0];
+	$TOTALsec =		$row[1];
+	$inTOTALcallsRAW=0;
+	if (eregi("YES",$include_rollover))
+		{
+		$length_in_secZ=0;
+		$queue_secondsZ=0;
+		$agent_alert_delayZ=0;
+		$stmt="select length_in_sec,queue_seconds,agent_alert_delay from vicidial_closer_log,vicidial_inbound_groups where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and group_id=campaign_id $group_drop_SQLand;";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$INallcalls_to_printZ = mysql_num_rows($rslt);
+		$y=0;
+		while ($y < $INallcalls_to_printZ)
+			{
+			$row=mysql_fetch_row($rslt);
+
+			$length_in_secZ = $row[0];
+			$queue_secondsZ = $row[1];
+			$agent_alert_delayZ = $row[2];
+
+			$TOTALdelay =		round($agent_alert_delayZ / 1000);
+			$thiscallsec = (($length_in_secZ - $queue_secondsZ) - $TOTALdelay);
+			if ($thiscallsec < 0)
+				{$thiscallsec = 0;}
+			$inTOTALsec =	($inTOTALsec + $thiscallsec);	
+
+			$y++;
+			}
+
+		$inTOTALcallsRAW =	$y;
+		$TOTALsec = ($TOTALsec + $inTOTALsec);
+		$inTOTALcalls =	sprintf("%10s", $inTOTALcallsRAW);
+		}
+
+	$TOTALcalls =	sprintf("%10s", $TOTALcallsRAW);
+	if ( ($row[0] < 1) or ($TOTALsec < 1) )
+		{$average_call_seconds = '         0';}
+	else
+		{
+		$average_call_seconds = ($TOTALsec / $TOTALcallsRAW);
+		$average_call_seconds = round($average_call_seconds, 2);
+		$average_call_seconds =	sprintf("%10s", $average_call_seconds);
+		}
+
+	$OUToutput .= "Total de chamadas desta campanha:             $TOTALcalls\n";
+	$OUToutput .= "Tempo médio das chamadas (seg):               $average_call_seconds\n";
+	if (eregi("YES",$include_rollover))
+		{$OUToutput .= "Calls that went to rollover In-Grupo:         $inTOTALcalls\n";}
+
+
+	$OUToutput .= "\n";
+	$OUToutput .= "---------- RESPOSTA HUMANOAS\n";
+
+	$stmt="select count(*),sum(length_in_sec) from vicidial_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and status IN($customer_interactive_statuses) $group_SQLand;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {$OUToutput .= "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$CIcallsRAW =	$row[0];
+	$CIsec =		$row[1];
+
+	if (eregi("YES",$include_rollover))
+		{
+		$length_in_secZ=0;
+		$queue_secondsZ=0;
+		$agent_alert_delayZ=0;
+		$stmt="select length_in_sec,queue_seconds,agent_alert_delay from vicidial_closer_log,vicidial_inbound_groups where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and group_id=campaign_id and vicidial_closer_log.status IN($customer_interactive_statuses) $group_drop_SQLand;";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$INallcalls_to_printZ = mysql_num_rows($rslt);
+		$y=0;
+		while ($y < $INallcalls_to_printZ)
+			{
+			$row=mysql_fetch_row($rslt);
+
+			$length_in_secZ = $row[0];
+			$queue_secondsZ = $row[1];
+			$agent_alert_delayZ = $row[2];
+
+			$CIdelay =		round($agent_alert_delayZ / 1000);
+			$thiscallsec = (($length_in_secZ - $queue_secondsZ) - $CIdelay);
+			if ($thiscallsec < 0)
+				{$thiscallsec = 0;}
+			$inCIsec =	($inCIsec + $thiscallsec);	
+
+			$y++;
+			}
+
+		$inCIcallsRAW =	$y;
+		$CIsec = ($CIsec + $inCIsec);
+		$CIcallsRAW = ($CIcallsRAW + $inCIcallsRAW);
+		}
+
+	$CIcalls =	sprintf("%10s", $CIcallsRAW);
+	if ( ($CIcallsRAW < 1) or ($CIsec < 1) )
+		{$average_ci_seconds = '         0';}
+	else
+		{
+		$average_ci_seconds = ($CIsec / $CIcallsRAW);
+		$average_ci_seconds = round($average_ci_seconds, 2);
+		$average_ci_seconds =	sprintf("%10s", $average_ci_seconds);
+		}
+	$CIsec =		sec_convert($CIsec,'H'); 
+
+
+	$OUToutput .= "Total Resposta Humanaed calls for this Campanha: $CIcalls\n";
+	$OUToutput .= "Average Call Length for all HA in seconds:    $average_ci_seconds     Total Time: $CIsec\n";
+
+
+	$OUToutput .= "\n";
+	$OUToutput .= "---------- DERRUBADAS\n";
+
+	$stmt="select count(*),sum(length_in_sec) from vicidial_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' $group_SQLand and status='DROP' and (length_in_sec <= 6000 or length_in_sec is null);";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {$OUToutput .= "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$DROPcalls =	sprintf("%10s", $row[0]);
+	$DROPcallsRAW =	$row[0];
+	$DROPseconds =	$row[1];
+
+
+	# GET LIST OF ALL STATUS and create SQL from human_answered statuses
+	$q=0;
+	$stmt = "SELECT status,status_name,human_answered,category from vicidial_statuses;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {$OUToutput .= "$stmt\n";}
+	$statuses_to_print = mysql_num_rows($rslt);
+	$p=0;
+	while ($p < $statuses_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		$status[$q] =			$row[0];
+		$status_name[$q] =		$row[1];
+		$human_answered[$q] =	$row[2];
+		$category[$q] =			$row[3];
+		$statname_list["$status[$q]"] = "$status_name[$q]";
+		$statcat_list["$status[$q]"] = "$category[$q]";
+		if ($human_answered[$q]=='Y')
+			{$camp_ANS_STAT_SQL .=	 "'$row[0]',";}
+		$q++;
+		$p++;
+		}
+
+	$stmt = "SELECT distinct status,status_name,human_answered,category from vicidial_campaign_statuses $group_SQL;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {$OUToutput .= "$stmt\n";}
+	$statuses_to_print = mysql_num_rows($rslt);
+	$p=0;
+	while ($p < $statuses_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		$status[$q] =			$row[0];
+		$status_name[$q] =		$row[1];
+		$human_answered[$q] =	$row[2];
+		$category[$q] =			$row[3];
+		$statname_list["$status[$q]"] = "$status_name[$q]";
+		$statcat_list["$status[$q]"] = "$category[$q]";
+		if ($human_answered[$q]=='Y')
+			{$camp_ANS_STAT_SQL .=	 "'$row[0]',";}
+		$q++;
+		$p++;
+		}
+	$camp_ANS_STAT_SQL = eregi_replace(",$",'',$camp_ANS_STAT_SQL);
+
+
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' $group_SQLand and status IN($camp_ANS_STAT_SQL);";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {$OUToutput .= "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$RESPOSTAcalls =	$row[0];
+
+	if ( ($DROPcalls < 1) or ($TOTALcalls < 1) )
+		{$DROPpercent = '0';}
+	else
+		{
+		$DROPpercent = (($DROPcallsRAW / $TOTALcalls) * 100);
+		$DROPpercent = round($DROPpercent, 2);
+		}
+
+	if ( ($DROPcalls < 1) or ($RESPOSTAcalls < 1) )
+		{$DROPRESPOSTApercent = '0';}
+	else
+		{
+		$DROPRESPOSTApercent = (($DROPcallsRAW / $RESPOSTAcalls) * 100);
+		$DROPRESPOSTApercent = round($DROPRESPOSTApercent, 2);
+		}
+
+	if ( ($DROPseconds < 1) or ($DROPcallsRAW < 1) )
+		{$average_hold_seconds = '         0';}
+	else
+		{
+		$average_hold_seconds = ($DROPseconds / $DROPcallsRAW);
+		$average_hold_seconds = round($average_hold_seconds, 2);
+		$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+		}
+
+	$OUToutput .= "Total Outbound DROP Calls:                    $DROPcalls  $DROPpercent%\n";
+	$OUToutput .= "Percent of DROP Calls taken out of Answers:   $DROPcalls / $RESPOSTAcalls  $DROPRESPOSTApercent%\n";
+
+	if (eregi("YES",$include_rollover))
+		{
+		if ( ($DROPcalls < 1) or ($CIcallsRAW < 1) )
+			{$inDROPRESPOSTApercent = '0';}
+		else
+			{
+			$inDROPRESPOSTApercent = (($DROPcallsRAW / $CIcallsRAW) * 100);
+			$inDROPRESPOSTApercent = round($inDROPRESPOSTApercent, 2);
+			}
+
+		$OUToutput .= "Percent of DROP/Answer Calls with Rollover:   $DROPcalls / $CIcallsRAW  $inDROPRESPOSTApercent%\n";
+		}
+
+	$OUToutput .= "Tempo médio das chamadas derrubadas:          $average_hold_seconds\n";
+
+	$stmt = "select closer_campaigns from vicidial_campaigns $group_SQL;";
+	$rslt=mysql_query($stmt, $link);
+	$ccamps_to_print = mysql_num_rows($rslt);
+	$c=0;
+	while ($ccamps_to_print > $c)
+		{
+		$row=mysql_fetch_row($rslt);
+		$closer_campaigns = $row[0];
+		$closer_campaigns = preg_replace("/^ | -$/","",$closer_campaigns);
+		$closer_campaigns = preg_replace("/ /","','",$closer_campaigns);
+		$closer_campaignsSQL .= "'$closer_campaigns',";
+		$c++;
+		}
+	$closer_campaignsSQL = eregi_replace(",$",'',$closer_campaignsSQL);
+
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and  campaign_id IN($closer_campaignsSQL) and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE');";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {$OUToutput .= "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$TOTALanswers = ($row[0] + $RESPOSTAcalls);
+
+
+	$stmt = "SELECT sum(wait_sec + talk_sec + dispo_sec) from vicidial_agent_log where event_time >= '$query_date_BEGIN' and event_time <= '$query_date_END' $group_SQLand;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {$OUToutput .= "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$agent_non_pause_sec = $row[0];
+
+	if ($agent_non_pause_sec > 0)
+		{
+		$AVG_RESPOSTAagent_non_pause_sec = (($TOTALanswers / $agent_non_pause_sec) * 60);
+		$AVG_RESPOSTAagent_non_pause_sec = round($AVG_RESPOSTAagent_non_pause_sec, 2);
+		}
+	else
+		{$AVG_RESPOSTAagent_non_pause_sec=0;}
+	$AVG_RESPOSTAagent_non_pause_sec = sprintf("%10s", $AVG_RESPOSTAagent_non_pause_sec);
+
+	$OUToutput .= "Productivity Rating:                          $AVG_RESPOSTAagent_non_pause_sec\n";
+
+
+
+
+	$OUToutput .= "\n";
+	$OUToutput .= "---------- NO RESPOSTAS\n";
+
+	$stmt="select count(*),sum(length_in_sec) from vicidial_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' $group_SQLand and status IN('NA','ADC','AB','CPDB','CPDUK','CPDATB','CPDNA','CPDREJ','CPDINV','CPDSUA','CPDSI','CPDSNC','CPDSR','CPDSUK','CPDSV','CPDERR') and (length_in_sec <= 60 or length_in_sec is null);";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {$OUToutput .= "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$autoNAcalls =	sprintf("%10s", $row[0]);
+
+	$stmt="select count(*),sum(length_in_sec) from vicidial_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' $group_SQLand and status IN('B','DC','N') and (length_in_sec <= 60 or length_in_sec is null);";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {$OUToutput .= "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$manualNAcalls =	sprintf("%10s", $row[0]);
+
+	$totalNAcalls = ($autoNAcalls + $manualNAcalls);
+	$totalNAcalls =	sprintf("%10s", $totalNAcalls);
+
+	if ( ($totalNAcalls < 1) or ($TOTALcalls < 1) )
+		{$NApercent = '0';}
+	else
+		{
+		$NApercent = (($totalNAcalls / $TOTALcalls) * 100);
+		$NApercent = round($NApercent, 2);
+		}
+
+	if ( ($row[0] < 1) or ($row[1] < 1) )
+		{$average_na_seconds = '         0';}
+	else
+		{
+		$average_na_seconds = ($row[1] / $row[0]);
+		$average_na_seconds = round($average_na_seconds, 2);
+		$average_na_seconds =	sprintf("%10s", $average_na_seconds);
+		}
+
+	$OUToutput .= "Total NA calls -Busy,Disconnect,RingNoAnswer: $totalNAcalls  $NApercent%\n";
+	$OUToutput .= "Total auto NA calls -system-set:              $autoNAcalls\n";
+	$OUToutput .= "Total manual NA calls -agent-set:             $manualNAcalls\n";
+	$OUToutput .= "Tempo médio das chamadas sem contato:         $average_na_seconds\n";
+
+
+	##############################
+	#########  ESTATÍSTICA DE MOTIVO DE DESLIGAMENTO
+
+	$TOTALcalls = 0;
+
+	$OUToutput .= "\n";
+	$OUToutput .= "---------- ESTATÍSTICA DE MOTIVO DE DESLIGAMENTO\n";
+	$OUToutput .= "+----------------------+------------+\n";
+	$OUToutput .= "| HANGUP REASON        | CALLS      |\n";
+	$OUToutput .= "+----------------------+------------+\n";
+
+	$stmt="select count(*),term_reason from vicidial_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' $group_SQLand group by term_reason;";
+	if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");}
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {$OUToutput .= "$stmt\n";}
+	$reasons_to_print = mysql_num_rows($rslt);
+	$i=0;
+	while ($i < $reasons_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+
+		$TOTALcalls = ($TOTALcalls + $row[0]);
+
+		$REASONcount =	sprintf("%10s", $row[0]);while(strlen($REASONcount)>10) {$REASONcount = substr("$REASONcount", 0, -1);}
+		$reason =	sprintf("%-20s", $row[1]);while(strlen($reason)>20) {$reason = substr("$reason", 0, -1);}
+		if (ereg("NONE",$reason))	{$reason = 'NO RESPOSTA           ';}
+		if (ereg("CALLER",$reason)) {$reason = 'CUSTOMER            ';}
+
+		$OUToutput .= "| $reason | $REASONcount |\n";
+
+		$i++;
+		}
+
+	$TOTALcalls =		sprintf("%10s", $TOTALcalls);
+
+	$OUToutput .= "+----------------------+------------+\n";
+	$OUToutput .= "| TOTAL:               | $TOTALcalls |\n";
+	$OUToutput .= "+----------------------+------------+\n";
+
+
+
+
+
+	##############################
+	#########  CALL STATUS STATS
+
+	$TOTALcalls = 0;
+
+	$OUToutput .= "\n";
+	$OUToutput .= "---------- CALL STATUS STATS\n";
+	$OUToutput .= "+--------+----------------------+----------------------+------------+----------------------------------+----------+\n";
+	$OUToutput .= "|        |                      |                      |            |      CALL TIME                   |AGENTE TIME|\n";
+	$OUToutput .= "| STATUS | DESCRIPTION          | CATEGORIA             | CALLS      | TOTAL TIME | AVG TIME |CALLS/HOUR|CALLS/HOUR|\n";
+	$OUToutput .= "+--------+----------------------+----------------------+------------+------------+----------+----------+----------+\n";
+
+	$campaignSQL = "$group_SQLand";
+	if (eregi("YES",$include_rollover))
+		{$campaignSQL = "$both_group_SQLand";}
+	## Pull the count of agent seconds for the total tally
+	$stmt="SELECT sum(pause_sec + wait_sec + talk_sec + dispo_sec) from vicidial_agent_log where event_time >= '$query_date_BEGIN' and event_time <= '$query_date_END' $campaignSQL and pause_sec<36000 and wait_sec<36000 and talk_sec<36000 and dispo_sec<36000;";
+	$rslt=mysql_query($stmt, $link);
+	$Ctally_to_print = mysql_num_rows($rslt);
+	if ($Ctally_to_print > 0) 
+		{
+		$rowx=mysql_fetch_row($rslt);
+		$AGENTsec = "$rowx[0]";
+		}
+	if ($DB) {$OUToutput .= "$AGENTsec|$Ctally_to_print|$stmt\n";}
+
+
+	## get counts and time totals for all statuses in this campaign
+	$rollover_exclude_dropSQL='';
+	if (eregi("YES",$include_rollover))
+		{$rollover_exclude_dropSQL = "and status NOT IN('DROP')";}
+	$stmt="select count(*),status,sum(length_in_sec) from vicidial_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' $rollover_exclude_dropSQL $group_SQLand group by status;";
+
+	if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");}
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {$OUToutput .= "$stmt\n";}
+	$statuses_to_print = mysql_num_rows($rslt);
+	$i=0;
+	while ($i < $statuses_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		$STATUScountARY[$i] =	$row[0];
+		$RAWstatusARY[$i] =		$row[1];
+		$RAWhoursARY[$i] =		$row[2];
+		$statusSQL .=			"'$row[1]',";
+		$i++;
+		}
+	if (eregi("YES",$include_rollover))
+		{
+		if (strlen($statusSQL) < 2)
+			{$statusSQL = "''";}
+		else
+			{
+			$statusSQL = eregi_replace(",$",'',$statusSQL);
+			}
+		$stmt="select distinct status from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and status NOT IN($statusSQL) $group_drop_SQLand;";
+		$rslt=mysql_query($stmt, $link);
+		$inS_statuses_to_print = mysql_num_rows($rslt);
+		$n=0;
+		while ($inS_statuses_to_print > $n) 
+			{
+			$rowx=mysql_fetch_row($rslt);
+			$STATUScountARY[$i] =	0;
+			$RAWstatusARY[$i] =		$rowx[0];
+			$RAWhoursARY[$i] =		0;
+			$i++;
+			$n++;
+			$statuses_to_print++;
+			}
+		}
+
+
+	$i=0;
+	while ($i < $statuses_to_print)
+		{
+		$STATUScount = $STATUScountARY[$i];
+		$RAWstatus = $RAWstatusARY[$i];
+		$RAWhours = $RAWhoursARY[$i];
+
+		if (eregi("YES",$include_rollover))
+			{
+			$stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and status='$RAWstatus' $group_drop_SQLand;";
+			$rslt=mysql_query($stmt, $link);
+			$in_statuses_to_print = mysql_num_rows($rslt);
+			if ($in_statuses_to_print > 0) 
+				{
+				$rowx=mysql_fetch_row($rslt);
+				$inSTATUScount =	$rowx[0];
+				$inRAWhours =		$rowx[1];
+
+				$STATUScount = ($STATUScount + $inSTATUScount);
+				$RAWhours = ($RAWhours + $inRAWhours);
+				}
+			}
+
+		$r=0;
+		while ($r < $statcats_to_print)
+			{
+			if ($statcat_list[$RAWstatus] == "$vsc_id[$r]")
+				{
+				$vsc_count[$r] = ($vsc_count[$r] + $STATUScount);
+				}
+			$r++;
+			}
+		if ($AGENTsec < 1) {$AGENTsec=1;}
+		$TOTALcalls =	($TOTALcalls + $STATUScount);
+		$TOTALtimeS =	($TOTALtimeS + $RAWhours);
+		$STATUSrate =	($STATUScount / ($TOTALsec / 3600) );
+			$STATUSrate =	sprintf("%.2f", $STATUSrate);
+		$AGENTrate =	($STATUScount / ($AGENTsec / 3600) );
+			$AGENTrate =	sprintf("%.2f", $AGENTrate);
+
+		$STATUShours =		sec_convert($RAWhours,'H'); 
+		$STATUSavg_sec =	($RAWhours / $STATUScount); 
+		$STATUSavg =		sec_convert($STATUSavg_sec,'H'); 
+
+		$STATUScount =	sprintf("%10s", $STATUScount);while(strlen($STATUScount)>10) {$STATUScount = substr("$STATUScount", 0, -1);}
+		$status =	sprintf("%-6s", $RAWstatus);while(strlen($status)>6) {$status = substr("$status", 0, -1);}
+		$STATUShours =	sprintf("%10s", $STATUShours);while(strlen($STATUShours)>10) {$STATUShours = substr("$STATUShours", 0, -1);}
+		$STATUSavg =	sprintf("%8s", $STATUSavg);while(strlen($STATUSavg)>8) {$STATUSavg = substr("$STATUSavg", 0, -1);}
+		$STATUSrate =	sprintf("%8s", $STATUSrate);while(strlen($STATUSrate)>8) {$STATUSrate = substr("$STATUSrate", 0, -1);}
+		$AGENTrate =	sprintf("%8s", $AGENTrate);while(strlen($AGENTrate)>8) {$AGENTrate = substr("$AGENTrate", 0, -1);}
+
+		if ($non_latin < 1)
+			{
+			$status_name =	sprintf("%-20s", $statname_list[$RAWstatus]); 
+			while(strlen($status_name)>20) {$status_name = substr("$status_name", 0, -1);}	
+			$statcat =	sprintf("%-20s", $statcat_list[$RAWstatus]); 
+			while(strlen($statcat)>20) {$statcat = substr("$statcat", 0, -1);}	
+			}
+		else
+			{
+			$status_name =	sprintf("%-60s", $statname_list[$RAWstatus]); 
+			while(mb_strlen($status_name,'utf-8')>20) {$status_name = mb_substr("$status_name", 0, -1,'utf-8');}	
+			$statcat =	sprintf("%-60s", $statcat_list[$RAWstatus]); 
+			while(mb_strlen($statcat,'utf-8')>20) {$statcat = mb_substr("$statcat", 0, -1,'utf-8');}	
+			}
+
+		$OUToutput .= "| $status | $status_name | $statcat | $STATUScount | $STATUShours | $STATUSavg | $STATUSrate | $AGENTrate |\n";
+
+		$i++;
+		}
+
+	if ($TOTALcalls < 1)
+		{
+		$TOTALhours =	'0:00:00';
+		$TOTALavg =		'0:00:00';
+		$TOTALrate =	'0.00';
+		}
+	else
+		{
+		$TOTALrate =	($TOTALcalls / ($TOTALsec / 3600) );
+			$TOTALrate =	sprintf("%.2f", $TOTALrate);
+		$aTOTALrate =	($TOTALcalls / ($AGENTsec / 3600) );
+			$aTOTALrate =	sprintf("%.2f", $aTOTALrate);
+
+		$aTOTALhours =		sec_convert($AGENTsec,'H'); 
+		$TOTALhours =		sec_convert($TOTALtimeS,'H'); 
+		$TOTALavg_sec =		($TOTALtimeS / $TOTALcalls);
+		$TOTALavg =			sec_convert($TOTALavg_sec,'H'); 
+		}
+	$TOTALcalls =	sprintf("%10s", $TOTALcalls);
+	$TOTALhours =	sprintf("%10s", $TOTALhours);while(strlen($TOTALhours)>10) {$TOTALhours = substr("$TOTALhours", 0, -1);}
+	$aTOTALhours =	sprintf("%10s", $aTOTALhours);while(strlen($aTOTALhours)>10) {$aTOTALhours = substr("$aTOTALhours", 0, -1);}
+	$TOTALavg =	sprintf("%8s", $TOTALavg);while(strlen($TOTALavg)>8) {$TOTALavg = substr("$TOTALavg", 0, -1);}
+	$TOTALrate =	sprintf("%8s", $TOTALrate);while(strlen($TOTALrate)>8) {$TOTALrate = substr("$TOTALrate", 0, -1);}
+	$aTOTALrate =	sprintf("%8s", $aTOTALrate);while(strlen($aTOTALrate)>8) {$aTOTALrate = substr("$aTOTALrate", 0, -1);}
+
+	$OUToutput .= "+--------+----------------------+----------------------+------------+------------+----------+----------+----------+\n";
+	$OUToutput .= "| TOTAL:                                               | $TOTALcalls | $TOTALhours | $TOTALavg | $TOTALrate |          |\n";
+#	$OUToutput .= "|   AGENT TIME                                                      | $aTOTALhours |                     | $aTOTALrate |\n";
+	$OUToutput .= "+------------------------------------------------------+------------+------------+---------------------+----------+\n";
+
+
+
+
+
+	##############################
+	#########  ID DA LISTA BREAKDOWN STATS
+
+	$TOTALcalls = 0;
+
+	$OUToutput .= "\n";
+	$OUToutput .= "---------- ID DA LISTA STATS\n";
+	$OUToutput .= "+------------------------------------------+------------+\n";
+	$OUToutput .= "| LIST                                     | CALLS      |\n";
+	$OUToutput .= "+------------------------------------------+------------+\n";
+
+	$stmt="select count(*),list_id from vicidial_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' $group_SQLand group by list_id;";
+	if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");}
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {$OUToutput .= "$stmt\n";}
+	$listids_to_print = mysql_num_rows($rslt);
+	$i=0;
+	while ($i < $listids_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		$LISTIDcalls[$i] =	$row[0];
+		$LISTIDlists[$i] =	$row[1];
+		$i++;
+		}
+
+	$i=0;
+	while ($i < $listids_to_print)
+		{
+		$stmt="select list_name from vicidial_lists where list_id='$LISTIDlists[$i]';";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {$OUToutput .= "$stmt\n";}
+		$list_name_to_print = mysql_num_rows($rslt);
+		if ($list_name_to_print > 0)
+			{
+			$row=mysql_fetch_row($rslt);
+			$LISTIDlist_names[$i] =	$row[0];
+			}
+
+		$TOTALcalls = ($TOTALcalls + $LISTIDcalls[$i]);
+
+		$LISTIDcount =	sprintf("%10s", $LISTIDcalls[$i]);while(strlen($LISTIDcount)>10) {$LISTIDcount = substr("$LISTIDcount", 0, -1);}
+		$LISTIDname =	sprintf("%-40s", "$LISTIDlists[$i] - $LISTIDlist_names[$i]");while(strlen($LISTIDname)>40) {$LISTIDname = substr("$LISTIDname", 0, -1);}
+
+		$OUToutput .= "| $LISTIDname | $LISTIDcount |\n";
+
+		$i++;
+		}
+
+	$TOTALcalls =		sprintf("%10s", $TOTALcalls);
+
+	$OUToutput .= "+------------------------------------------+------------+\n";
+	$OUToutput .= "| TOTAL:                                   | $TOTALcalls |\n";
+	$OUToutput .= "+------------------------------------------+------------+\n";
+
+
+
+
+
+	if ( ($carrier_logging_active > 0) and ($carrier_stats == 'YES') )
+		{
+		##############################
+		#########  STATUS CATEGORIA STATS
+
+		$OUToutput .= "\n";
+		$OUToutput .= "---------- CARRIER CALL STATUS\n";
+		$OUToutput .= "+----------------------+------------+\n";
+		$OUToutput .= "| STATUS               | CALLS      |\n";
+		$OUToutput .= "+----------------------+------------+\n";
+
+		## get counts and time totals for all statuses in this campaign
+		$stmt="select dialstatus,count(*) from vicidial_carrier_log vcl,vicidial_log vl where vcl.uniqueid=vl.uniqueid and vcl.call_date > \"$query_date_BEGIN\" and vcl.call_date < \"$query_date_END\" and vl.call_date > \"$query_date_BEGIN\" and vl.call_date < \"$query_date_END\" $group_SQLand group by dialstatus order by dialstatus;";
+		if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");}
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {$OUToutput .= "$stmt\n";}
+		$carrierstatuses_to_print = mysql_num_rows($rslt);
+		$i=0;
+		while ($i < $carrierstatuses_to_print)
+			{
+			$row=mysql_fetch_row($rslt);
+			$TOTCARcalls = ($TOTCARcalls + $row[1]);
+			$CARstatus =	sprintf("%-20s", $row[0]); while(strlen($CARstatus)>20) {$CARstatus = substr("$CARstatus", 0, -1);}
+			$CARcount =		sprintf("%10s", $row[1]); while(strlen($CARcount)>10) {$CARcount = substr("$CARcount", 0, -1);}
+
+			$OUToutput .= "| $CARstatus | $CARcount |\n";
+
+			$i++;
+			}
+
+		$TOTCARcalls =	sprintf("%10s", $TOTCARcalls); while(strlen($TOTCARcalls)>10) {$TOTCARcalls = substr("$TOTCARcalls", 0, -1);}
+
+		$OUToutput .= "+----------------------+------------+\n";
+		$OUToutput .= "| TOTAL                | $TOTCARcalls |\n";
+		$OUToutput .= "+----------------------+------------+\n";
+		}
+
+
+	##############################
+	#########  STATUS CATEGORIA STATS
+
+	$OUToutput .= "\n";
+	$OUToutput .= "---------- CUSTOM STATUS CATEGORIA STATS\n";
+	$OUToutput .= "+----------------------+------------+--------------------------------+\n";
+	$OUToutput .= "| CATEGORIA             | CALLS      | DESCRIPTION                    |\n";
+	$OUToutput .= "+----------------------+------------+--------------------------------+\n";
+
+
+	$TOTCATcalls=0;
+	$r=0;
+	while ($r < $statcats_to_print)
+		{
+		if ($vsc_id[$r] != 'UNDEFINED')
+			{
+			$TOTCATcalls = ($TOTCATcalls + $vsc_count[$r]);
+			$category =	sprintf("%-20s", $vsc_id[$r]); while(strlen($category)>20) {$category = substr("$category", 0, -1);}
+			$CATcount =	sprintf("%10s", $vsc_count[$r]); while(strlen($CATcount)>10) {$CATcount = substr("$CATcount", 0, -1);}
+			$CATname =	sprintf("%-30s", $vsc_name[$r]); while(strlen($CATname)>30) {$CATname = substr("$CATname", 0, -1);}
+
+			$OUToutput .= "| $category | $CATcount | $CATname |\n";
+			}
+		$r++;
+		}
+
+	$TOTCATcalls =	sprintf("%10s", $TOTCATcalls); while(strlen($TOTCATcalls)>10) {$TOTCATcalls = substr("$TOTCATcalls", 0, -1);}
+
+	$OUToutput .= "+----------------------+------------+--------------------------------+\n";
+	$OUToutput .= "| TOTAL                | $TOTCATcalls |\n";
+	$OUToutput .= "+----------------------+------------+\n";
+
+
+
+	##############################
+	#########  USER STATS
+
+	$TOTagents=0;
+	$TOTcalls=0;
+	$TOTtime=0;
+	$TOTavg=0;
+
+	$OUToutput .= "\n";
+	$OUToutput .= "---------- AGENTE STATS\n";
+	$OUToutput .= "+--------------------------+------------+------------+--------+\n";
+	$OUToutput .= "| AGENTE                    | CALLS      | TIME H:M:S |AVERAGE |\n";
+	$OUToutput .= "+--------------------------+------------+------------+--------+\n";
+
+	$stmt="select vicidial_log.user,full_name,count(*),sum(length_in_sec),avg(length_in_sec) from vicidial_log,vicidial_users where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' $group_SQLand and vicidial_log.user is not null and length_in_sec is not null and length_in_sec > 0 and vicidial_log.user=vicidial_users.user group by vicidial_log.user;";
+	if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");}
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {$OUToutput .= "$stmt\n";}
+	$users_to_print = mysql_num_rows($rslt);
+	$i=0;
+	while ($i < $users_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+
+		$RAWuser[$i] =			$row[0];
+		$RAWfull_name[$i] =		$row[1];
+		$RAWuser_calls[$i] =	$row[2];
+		$RAWuser_talk[$i] =		$row[3];
+		$RAWuser_average[$i] =	$row[4];
+
+		$TOTcalls = ($TOTcalls + $row[2]);
+		$TOTtime = ($TOTtime + $row[3]);
+
+		$i++;
+		}
+
+	$i=0;
+	while ($i < $users_to_print)
+		{
+		$user =	sprintf("%-6s", $RAWuser[$i]);while(strlen($user)>6) {$user = substr("$user", 0, -1);}
+		if ($non_latin < 1)
+			{
+			$full_name =	sprintf("%-15s", $RAWfull_name[$i]); while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);}	
+			}
+		else
+			{
+			$full_name =	sprintf("%-45s", $RAWfull_name[$i]); while(mb_strlen($full_name,'utf-8')>15) {$full_name = mb_substr("$full_name", 0, -1,'utf-8');}	
+			}
+		if (eregi("YES",$include_rollover))
+			{
+			$length_in_secZ=0;
+			$queue_secondsZ=0;
+			$agent_alert_delayZ=0;
+			$stmt="select length_in_sec,queue_seconds,agent_alert_delay from vicidial_closer_log,vicidial_inbound_groups where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and group_id=campaign_id and user='$RAWuser[$i]' $group_drop_SQLand;";
+			$rslt=mysql_query($stmt, $link);
+			if ($DB) {echo "$stmt\n";}
+			$INallcalls_to_printZ = mysql_num_rows($rslt);
+			$y=0;
+			while ($y < $INallcalls_to_printZ)
+				{
+				$row=mysql_fetch_row($rslt);
+
+				$length_in_secZ = $row[0];
+				$queue_secondsZ = $row[1];
+				$agent_alert_delayZ = $row[2];
+
+				$CIdelay =		round($agent_alert_delayZ / 1000);
+				$thiscallsec = (($length_in_secZ - $queue_secondsZ) - $CIdelay);
+				if ($thiscallsec < 0)
+					{$thiscallsec = 0;}
+				$inCIsec =	($inCIsec + $thiscallsec);	
+
+				$y++;
+				}
+
+			$inCIcallsRAW =	$y;
+			$RAWuser_talk[$i] = ($RAWuser_talk[$i] + $inCIsec);
+			$RAWuser_calls[$i] = ($RAWuser_calls[$i] + $inCIcallsRAW);
+
+			$TOTcalls = ($TOTcalls + $inCIcallsRAW);
+			$TOTtime = ($TOTtime + $inCIsec);
+			}
+
+		$USERcalls =	sprintf("%10s", $RAWuser_calls[$i]);
+		$USERtotTALK =	$RAWuser_talk[$i];
+		$USERavgTALK =	round($RAWuser_talk[$i] / $RAWuser_calls[$i]);
+
+		$USERtotTALK_MS =	sec_convert($USERtotTALK,'H'); 
+		$USERavgTALK_MS =	sec_convert($USERavgTALK,'H'); 
+
+		$USERtotTALK_MS =	sprintf("%9s", $USERtotTALK_MS);
+		$USERavgTALK_MS =	sprintf("%6s", $USERavgTALK_MS);
+
+		$OUToutput .= "| $user - $full_name | $USERcalls |  $USERtotTALK_MS | $USERavgTALK_MS |\n";
+
+		$i++;
+		}
+
+	$rawTOTtime = $TOTtime;
+
+	if (!$TOTcalls) {$TOTcalls = 1;}
+	$TOTavg = ($TOTtime / $TOTcalls);
+
+	$TOTavg_MS =	sec_convert($TOTavg,'H'); 
+	$TOTtime_MS =	sec_convert($TOTtime,'H'); 
+
+	$TOTavg =		sprintf("%6s", $TOTavg_MS);
+	$TOTtime =		sprintf("%10s", $TOTtime_MS);
+
+	$TOTagents =		sprintf("%10s", $i);
+	$TOTcalls =			sprintf("%10s", $TOTcalls);
+	$TOTtime =			sprintf("%8s", $TOTtime);
+	$TOTavg =			sprintf("%6s", $TOTavg);
+
+	$stmt="select avg(wait_sec) from vicidial_agent_log where event_time >= '$query_date_BEGIN' and event_time <= '$query_date_END' $group_SQLand;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {$OUToutput .= "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+
+	$AVGwait = $row[0];
+	$AVGwait_MS =	sec_convert($AVGwait,'H'); 
+	$AVGwait =		sprintf("%6s", $AVGwait_MS);
+
+	$OUToutput .= "+--------------------------+------------+------------+--------+\n";
+	$OUToutput .= "| TOTAL Agentes: $TOTagents | $TOTcalls | $TOTtime | $TOTavg |\n";
+	$OUToutput .= "+--------------------------+------------+------------+--------+\n";
+	$OUToutput .= "| Average Wait time between calls                      $AVGwait |\n";
+	$OUToutput .= "+-------------------------------------------------------------+\n";
+
+
+
+	if ($costformat > 0)
+		{
+		$stmt="select campaign_id,phone_number,length_in_sec from vicidial_log,vicidial_users where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' $group_SQLand and vicidial_log.user=vicidial_users.user;";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$allcalls_to_print = mysql_num_rows($rslt);
+		$w=0;
+		while ($w < $allcalls_to_print)
+			{
+			$row=mysql_fetch_row($rslt);
+
+			if ($print_calls > 0)
+				{echo "$row[0]\t$row[1]\t$row[2]\n";}
+			$tempTALK = ($tempTALK + $row[2]);
+			$w++;
+			}
+		if (eregi("YES",$include_rollover))
+			{
+			$stmt="select campaign_id,phone_number,length_in_sec,queue_seconds,agent_alert_delay from vicidial_closer_log,vicidial_inbound_groups where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and group_id=campaign_id $group_drop_SQLand;";
+			$rslt=mysql_query($stmt, $link);
+			if ($DB) {echo "$stmt\n";}
+			$INallcalls_to_print = mysql_num_rows($rslt);
+			$w=0;
+			while ($w < $INallcalls_to_print)
+				{
+				$row=mysql_fetch_row($rslt);
+
+				if ($print_calls > 0)
+				{	echo "$row[0]\t$row[1]\t$row[2]\t$row[3]\t$row[4]\n";}
+				$newTALK = ($row[2] - $row[3] - ($row[4] / 1000) );
+				if ($newTALK < 0) {$newTALK = 0;}
+				$tempTALK = ($tempTALK + $newTALK);
+				$w++;
+				}
+			}
+		$tempTALKmin = ($tempTALK  / 60);
+		if ($print_calls > 0)
+			{echo "$w\t$tempTALK\t$tempTALKmin\n";}
+
+		echo "
\n"; + $rawTOTtalk_min = round($tempTALK / 60); + $outbound_cost = ($rawTOTtalk_min * $outbound_rate); + $outbound_cost = sprintf("%8.2f", $outbound_cost); + + echo "SAINTE $query_date to $end_date,   $rawTOTtalk_min minutes at \$$outbound_rate = \$$outbound_cost\n"; + + exit; + } + + + echo "$OUToutput"; + + + + + if ($bottom_graph == 'YES') + { + ############################## + ######### TIME STATS + + echo "\n"; + echo "---------- ESTATÍSTICAS DE TEMPO\n"; + + echo "\n"; + + $hi_hour_count=0; + $last_full_record=0; + $i=0; + $h=0; + while ($i <= 96) + { + $stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' $group_SQLand;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $hour_count[$i] = $row[0]; + if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];} + if ($hour_count[$i] > 0) {$last_full_record = $i;} + $stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' $group_SQLand and status='DROP';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $drop_count[$i] = $row[0]; + $i++; + + + $stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' $group_SQLand;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $hour_count[$i] = $row[0]; + if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];} + if ($hour_count[$i] > 0) {$last_full_record = $i;} + $stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' $group_SQLand and status='DROP';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $drop_count[$i] = $row[0]; + $i++; + + $stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' $group_SQLand;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $hour_count[$i] = $row[0]; + if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];} + if ($hour_count[$i] > 0) {$last_full_record = $i;} + $stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' $group_SQLand and status='DROP';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $drop_count[$i] = $row[0]; + $i++; + + $stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' $group_SQLand;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $hour_count[$i] = $row[0]; + if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];} + if ($hour_count[$i] > 0) {$last_full_record = $i;} + $stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' $group_SQLand and status='DROP';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $drop_count[$i] = $row[0]; + $i++; + $h++; + } + + if ($hi_hour_count < 1) + {$hour_multiplier = 0;} + else + { + $hour_multiplier = (100 / $hi_hour_count); + #$hour_multiplier = round($hour_multiplier, 0); + } + + echo "\n"; + echo "GRÁFICO DO TOTAL DE CHAMADAS FEITAS POR ESSA CAMPANHA A CADA 15 MINUTOS\n"; + + $k=1; + $Mk=0; + $call_scale = '0'; + while ($k <= 102) + { + if ($Mk >= 5) + { + $Mk=0; + if ( ($k < 1) or ($hour_multiplier <= 0) ) + {$scale_num = 100;} + else + { + $scale_num=($k / $hour_multiplier); + $scale_num = round($scale_num, 0); + } + $LENscale_num = (strlen($scale_num)); + $k = ($k + $LENscale_num); + $call_scale .= "$scale_num"; + } + else + { + $call_scale .= " "; + $k++; $Mk++; + } + } + + + echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n"; + #echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP | DROPS | TOTAL |\n"; + echo "| HOUR |$call_scale| DROPS | TOTAL |\n"; + echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n"; + + $ZZ = '00'; + $i=0; + $h=4; + $hour= -1; + $no_lines_yet=1; + + while ($i <= 96) + { + $char_counter=0; + $time = ' '; + if ($h >= 4) + { + $hour++; + $h=0; + if ($hour < 10) {$hour = "0$hour";} + $time = "+$hour$ZZ+"; + } + if ($h == 1) {$time = " 15 ";} + if ($h == 2) {$time = " 30 ";} + if ($h == 3) {$time = " 45 ";} + $Ghour_count = $hour_count[$i]; + if ($Ghour_count < 1) + { + if ( ($no_lines_yet) or ($i > $last_full_record) ) + { + $do_nothing=1; + } + else + { + $hour_count[$i] = sprintf("%-5s", $hour_count[$i]); + echo "|$time|"; + $k=0; while ($k <= 102) {echo " "; $k++;} + echo "| $hour_count[$i] |\n"; + } + } + else + { + $no_lines_yet=0; + $Xhour_count = ($Ghour_count * $hour_multiplier); + $Yhour_count = (99 - $Xhour_count); + + $Gdrop_count = $drop_count[$i]; + if ($Gdrop_count < 1) + { + $hour_count[$i] = sprintf("%-5s", $hour_count[$i]); + + echo "|$time|"; + $k=0; while ($k <= $Xhour_count) {echo "*"; $k++; $char_counter++;} + echo "*X"; $char_counter++; + $k=0; while ($k <= $Yhour_count) {echo " "; $k++; $char_counter++;} + while ($char_counter <= 101) {echo " "; $char_counter++;} + echo "| 0 | $hour_count[$i] |\n"; + + } + else + { + $Xdrop_count = ($Gdrop_count * $hour_multiplier); + + # if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);} + + $XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 ); + + $hour_count[$i] = sprintf("%-5s", $hour_count[$i]); + $drop_count[$i] = sprintf("%-5s", $drop_count[$i]); + + echo "|$time|"; + $k=0; while ($k <= $Xdrop_count) {echo ">"; $k++; $char_counter++;} + echo "D"; $char_counter++; + $k=0; while ($k <= $XXhour_count) {echo "*"; $k++; $char_counter++;} + echo "X"; $char_counter++; + $k=0; while ($k <= $Yhour_count) {echo " "; $k++; $char_counter++;} + while ($char_counter <= 102) {echo " "; $char_counter++;} + echo "| $drop_count[$i] | $hour_count[$i] |\n"; + } + } + + + $i++; + $h++; + } + + + echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n"; + + ### END bottom graph + } + + + + + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $STARTtime); + echo "\nRun Time: $RUNtime seconds\n"; + } + + + +?> + +
+ + diff --git a/LANG_www/vicidial_br/AST_VICIDIAL_hopperlist.php b/LANG_www/vicidial_br/AST_VICIDIAL_hopperlist.php new file mode 100644 index 00000000..19a94de6 --- /dev/null +++ b/LANG_www/vicidial_br/AST_VICIDIAL_hopperlist.php @@ -0,0 +1,167 @@ + LICENSE: AGPLv2 +# +# CHANGES +# +# 60619-1654 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# 70115-1614 - Added ALT field for vicidial_hopper alt_dial column +# 71029-0852 - Added list_id to the output +# 71030-2118 - Added priority to display +# 90508-0644 - Changed to PHP long tags +# 91023-1540 - Changed to only show hopper status of READY +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6 and view_reports='1' and modify_campaigns='1';"; +if ($DB) {echo "|$stmt|\n";} +$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 "Nome ou Senha inválidos: |$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;} +if (!isset($server_ip)) {$server_ip = '10.10.10.15';} + +$stmt="select campaign_id,campaign_name from vicidial_campaigns order by campaign_id;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$campaigns_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $campaigns_to_print) + { + $row=mysql_fetch_row($rslt); + $campaign_id[$i] =$row[0]; + $campaign_name[$i] =$row[1]; + $i++; + } +?> + + + + + +\n"; +echo "Lista De Hopper Report\n"; +echo "
\n"; +#echo "\n"; +#echo "\n"; +echo "\n"; +echo "\n"; +echo "           ALTERAR \n"; +echo "
\n\n"; + +echo "
\n\n";
+
+
+if (!$group)
+	{
+	echo "\n\n";
+	echo "POR FAVOR SELECIONE UMA CAMPANHA ACIMA E CLIQUE EM ENVIAR\n";
+	}
+
+else
+	{
+	echo "Lista Online do Hopper                      $NOW_TIME\n";
+
+	echo "\n";
+	echo "---------- TOTALS\n";
+
+	$stmt="select count(*) from vicidial_hopper where campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+
+	$TOTALcalls =	sprintf("%10s", $row[0]);
+
+	echo "Total de registros no hopper agora:       $TOTALcalls\n";
+
+
+	##############################
+	#########  LEAD STATS
+
+	echo "\n";
+	echo "---------- LEADS IN HOPPER\n";
+	echo "+------+--------+-----------+------------+------------+-------+--------+-------+--------+-------+\n";
+	echo "|ORDER |PRIORIDADE| LEAD ID   | ID DA LISTA    | PHONE NUM  | STATE | STATUS | COUNT | GMT    | ALT   |\n";
+	echo "+------+--------+-----------+------------+------------+-------+--------+-------+--------+-------+\n";
+
+	$stmt="select vicidial_hopper.lead_id,phone_number,vicidial_hopper.state,vicidial_list.status,called_count,vicidial_hopper.gmt_offset_now,hopper_id,alt_dial,vicidial_hopper.list_id,vicidial_hopper.priority from vicidial_hopper,vicidial_list where vicidial_hopper.campaign_id='" . mysql_real_escape_string($group) . "' and vicidial_hopper.status='READY' and vicidial_hopper.lead_id=vicidial_list.lead_id order by priority desc,hopper_id limit 5000;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$users_to_print = mysql_num_rows($rslt);
+	$i=0;
+	while ($i < $users_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+
+		$FMT_i =		sprintf("%-4s", $i);
+		$lead_id =		sprintf("%-9s", $row[0]);
+		$phone_number =	sprintf("%-10s", $row[1]);
+		$state =		sprintf("%-5s", $row[2]);
+		$status =		sprintf("%-6s", $row[3]);
+		$count =		sprintf("%-5s", $row[4]);
+		$gmt =			sprintf("%-6s", $row[5]);
+		$hopper_id =	sprintf("%-6s", $row[6]);
+		$alt_dial =		sprintf("%-5s", $row[7]);
+		$list_id =		sprintf("%-10s", $row[8]);
+		$priority =		sprintf("%-6s", $row[9]);
+
+		if ($DB) {echo "| $FMT_i | $priority | $lead_id | $list_id | $phone_number | $state | $status | $count | $gmt | $hopper_id |\n";}
+		else {echo "| $FMT_i | $priority | $lead_id | $list_id | $phone_number | $state | $status | $count | $gmt | $alt_dial |\n";}
+
+		$i++;
+		}
+
+	echo "+------+--------+-----------+------------+------------+-------+--------+-------+--------+-------+\n";
+
+	}
+
+
+?>
+
+ + diff --git a/LANG_www/vicidial_br/AST_agent_days_detail.php b/LANG_www/vicidial_br/AST_agent_days_detail.php new file mode 100644 index 00000000..dddf0a58 --- /dev/null +++ b/LANG_www/vicidial_br/AST_agent_days_detail.php @@ -0,0 +1,633 @@ + LICENSE: AGPLv2 +# +# CHANGES +# +# 90206-2202 - First build +# 90225-1051 - Added CSV download option +# 90310-0752 - Added admin header +# 90508-0644 - Changed to PHP long tags +# 100214-1421 - Sort menu alphabetically +# 100216-0042 - Added popup date selector +# + + +require("dbconnect.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["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["shift"])) {$shift=$_GET["shift"];} + elseif (isset($_POST["shift"])) {$shift=$_POST["shift"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["file_download"])) {$file_download=$_GET["file_download"];} + elseif (isset($_POST["file_download"])) {$file_download=$_POST["file_download"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} + +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); +if ($qm_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $non_latin = $row[0]; + } +##### END SETTINGS LOOKUP ##### +########################################### + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$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 "Nome ou Senha inválidos: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$MT[0]=''; +$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;} +if (!isset($end_date)) {$end_date = $NOW_DATE;} + +$stmt="select campaign_id from vicidial_campaigns;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$campaigns_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $campaigns_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } + +$i=0; +$group_string='|'; +$group_ct = count($group); +while($i < $group_ct) + { + $group_string .= "$group[$i]|"; + $group_SQL .= "'$group[$i]',"; + $groupQS .= "&group[]=$group[$i]"; + $i++; + } +if ( (ereg("--ALL--",$group_string) ) or ($group_ct < 1) ) + {$group_SQL = "";} +else + { + $group_SQL = eregi_replace(",$",'',$group_SQL); + $group_SQL = "and campaign_id IN($group_SQL)"; + } + +$customer_interactive_statuses=''; +$stmt="select status from vicidial_statuses where human_answered='Y';"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$statha_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $statha_to_print) + { + $row=mysql_fetch_row($rslt); + $customer_interactive_statuses .= "|$row[0]"; + $i++; + } +$stmt="select status from vicidial_campaign_statuses where human_answered='Y';"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$statha_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $statha_to_print) + { + $row=mysql_fetch_row($rslt); + $customer_interactive_statuses .= "|$row[0]"; + $i++; + } +if (strlen($customer_interactive_statuses)>0) + {$customer_interactive_statuses .= '|';} + +#$customer_interactive_statuses = '|NI|DNC|CALLBK|AP|SALE|COMP|HAP1|HAP2|HBED|DIED|'; +#$customer_interactive_statuses = '|NI|DNC|CALLBK|XFER|C2|B7|B8|C1|'; + +$LINKbase = "$PHP_SELF?query_date=$query_date&end_date=$end_date&shift=$shift&DB=$DB&user=$user$groupQS"; + +if ($file_download < 1) + { + ?> + + + + + + \n"; + echo "\n"; + + echo "\n"; + echo "Agent Status Diário Report\n"; + echo ""; + + $short_header=1; + + require("admin_header.php"); + + echo "\n"; + echo "\n"; + echo "
\n";
+	}
+
+if (strlen($group[0]) < 1)
+	{
+	echo "\n";
+	echo "POR FAVOR SELECIONE UM USUÁRIO E PERÍODO ACIMA E CLIQUE ENVIAR\n";
+	echo " NOTE: stats taken from shift specified\n";
+	}
+
+else
+	{
+	if ($shift == 'AM') 
+		{
+		$time_BEGIN=$AM_shift_BEGIN;
+		$time_END=$AM_shift_END;
+		if (strlen($time_BEGIN) < 6) {$time_BEGIN = "03:45:00";}   
+		if (strlen($time_END) < 6) {$time_END = "15:15:00";}
+		}
+	if ($shift == 'PM') 
+		{
+		$time_BEGIN=$PM_shift_BEGIN;
+		$time_END=$PM_shift_END;
+		if (strlen($time_BEGIN) < 6) {$time_BEGIN = "15:15:00";}
+		if (strlen($time_END) < 6) {$time_END = "23:15:00";}
+		}
+	if ($shift == 'ALL') 
+		{
+		if (strlen($time_BEGIN) < 6) {$time_BEGIN = "00:00:00";}
+		if (strlen($time_END) < 6) {$time_END = "23:59:59";}
+		}
+	$query_date_BEGIN = "$query_date $time_BEGIN";   
+	$query_date_END = "$end_date $time_END";
+
+	if (strlen($user_group)>0) {$ugSQL="and vicidial_agent_log.user_group='$user_group'";}
+	else {$ugSQL='';}
+
+	if ($file_download < 1)
+		{
+		echo "Agent Status Diário Report: $user                     $NOW_TIME\n";
+
+		echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
+		echo "---------- AGENTE Detalhess -------------\n\n";
+		}
+	else
+		{
+		$file_output .= "Agent Status Diário Report: $user                     $NOW_TIME\n";
+		$file_output .= "Time range: $query_date_BEGIN to $query_date_END\n\n";
+		}
+
+	$statuses='-';
+	$statusesTXT='';
+	$statusesHEAD='';
+	$statusesHTML='';
+	$statusesFILE='';
+	$statusesARY[0]='';
+	$j=0;
+	$dates='-';
+	$datesARY[0]='';
+	$date_namesARY[0]='';
+	$k=0;
+
+	$stmt="select date_format(event_time, '%Y-%m-%d') as date,count(*) as calls,status from vicidial_users,vicidial_agent_log where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and vicidial_users.user=vicidial_agent_log.user and vicidial_agent_log.user='$user' $group_SQL $user_group_SQL group by date,status order by date,status desc limit 500000;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$rows_to_print = mysql_num_rows($rslt);
+	$i=0;
+	while ($i < $rows_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+
+		if ( ($row[1] > 0) and (strlen($row[2]) > 0) )
+			{
+			$date[$i] =			$row[0];
+			$calls[$i] =		$row[1];
+			$status[$i] =		$row[2];
+			if ( (!eregi("-$status[$i]-", $statuses)) and (strlen($status[$i])>0) )
+				{
+				$statusesTXT = sprintf("%8s", $status[$i]);
+				$statusesHEAD .= "----------+";
+				$statusesHTML .= " $statusesTXT |";
+				$statusesFILE .= "$statusesTXT,";
+				$statuses .= "$status[$i]-";
+				$statusesARY[$j] = $status[$i];
+				$j++;
+				}
+			if (!eregi("-$date[$i]-", $dates))
+				{
+				$dates .= "$date[$i]-";
+				$datesARY[$k] = $date[$i];
+				$k++;
+				}
+			}
+		$i++;
+		}
+
+	if ($file_download < 1)
+		{
+		echo "LEAD STATS BREAKDOWN:\n";
+		echo "+------------+--------+--------+--------+$statusesHEAD\n";
+		echo "| DATE       | CALLS  | CIcalls| DNC/CI%|$statusesHTML\n";
+		echo "+------------+--------+--------+--------+$statusesHEAD\n";
+		}
+	else
+		{
+		$file_output .= "DATE,CALLS,CIcalls,DNC-CI%,$statusesFILE\n";
+		}
+
+	### BEGIN loop through each user ###
+	$m=0;
+	$CIScountTOT=0;
+	$DNCcountTOT=0;
+	while ($m < $k)
+		{
+		$Sdate=$datesARY[$m];
+		$Scalls=$calls[$m];
+		$SstatusesHTML='';
+		$SstatusesFILE='';
+		$CIScount=0;
+		$DNCcount=0;
+
+		### BEGIN loop through each status ###
+		$n=0;
+		while ($n < $j)
+			{
+			$Sstatus=$statusesARY[$n];
+			$SstatusTXT='';
+			### BEGIN loop through each stat line ###
+			$i=0; $status_found=0;
+			while ($i < $rows_to_print)
+				{
+	#			if ( (eregi("$date[$i]", $Sdate)) and ($Sstatus=="$status[$i]") )
+				if ( ($Sdate=="$date[$i]") and ($Sstatus=="$status[$i]") )
+					{
+					$Scalls =		($Scalls + $calls[$i]);
+					if (eregi("\|$status[$i]\|",$customer_interactive_statuses))
+						{
+						$CIScount =	($CIScount + $calls[$i]);
+						$CIScountTOT =	($CIScountTOT + $calls[$i]);
+						}
+					if (eregi("DNC", $status[$i]))
+						{
+						$DNCcount =	($DNCcount + $calls[$i]);
+						$DNCcountTOT =	($DNCcountTOT + $calls[$i]);
+						}
+					$SstatusTXT = sprintf("%8s", $calls[$i]);
+					$SstatusesHTML .= " $SstatusTXT |";
+					$SstatusesFILE .= "$SstatusTXT,";
+					$status_found++;
+					}
+				$i++;
+				}
+			if ($status_found < 1)
+				{
+				$SstatusesHTML .= "        0 |";
+				}
+			### END loop through each stat line ###
+			$n++;
+			}
+		### END loop through each status ###
+		$TOTcalls=($TOTcalls + $Scalls);
+
+		$RAWdate = $Sdate;
+		$RAWcalls = $Scalls;
+		$RAWcis = $CIScount;
+		$Scalls =	sprintf("%6s", $Scalls);
+		$CIScount =	sprintf("%6s", $CIScount);
+
+		$Sdate =		sprintf("%-10s", $Sdate);
+			while(strlen($Suser)>10) {$Suser = substr("$Sdate", 0, -1);}
+
+		if ( ($DNCcount < 1) or ($CIScount < 1) )
+			{$DNCcountPCTs=0;}
+		else
+			{
+			$DNCcountPCTs = ( ($DNCcount / $CIScount) * 100);
+			}
+		$RAWdncPCT = $DNCcountPCTs;
+	#	$DNCcountPCTs = round($DNCcountPCTs,2);
+		$DNCcountPCTs = round($DNCcountPCTs);
+		$rawDNCcountPCTs = $DNCcountPCTs;
+	#	$DNCcountPCTs = sprintf("%3.2f", $DNCcountPCTs);
+		$DNCcountPCTs = sprintf("%6s", $DNCcountPCTs);
+
+		if ($file_download < 1)
+			{
+			$Toutput = "| $Sdate | $Scalls | $CIScount | $DNCcountPCTs%|$SstatusesHTML\n";
+			}
+		else
+			{
+			$fileToutput = "$RAWdate,$RAWcalls,$RAWcis,$rawDNCcountPCTs%,$SstatusesFILE\n";
+			}
+
+		$TOPsorted_output[$m] = $Toutput;
+		$TOPsorted_outputFILE[$m] = $fileToutput;
+
+		if ($stage == 'ID')
+			{
+			$TOPsort[$m] =	'' . sprintf("%08s", $RAWdate) . '-----' . $m . '-----' . sprintf("%020s", $RAWdate);
+			$TOPsortTALLY[$m]=$RAWcalls;
+			}
+		if ($stage == 'LEADS')
+			{
+			$TOPsort[$m] =	'' . sprintf("%08s", $RAWcalls) . '-----' . $m . '-----' . sprintf("%020s", $RAWdate);
+			$TOPsortTALLY[$m]=$RAWcalls;
+			}
+		if ($stage == 'TIME')
+			{
+			$TOPsort[$m] =	'' . sprintf("%08s", $Stime) . '-----' . $m . '-----' . sprintf("%020s", $RAWdate);
+			$TOPsortTALLY[$m]=$Stime;
+			}
+		if ($stage == 'CI')
+			{
+			$TOPsort[$m] =	'' . sprintf("%08s", $RAWcis) . '-----' . $m . '-----' . sprintf("%020s", $RAWdate);
+			$TOPsortTALLY[$m]=$RAWcis;
+			}
+		if ($stage == 'DNCCI')
+			{
+			$TOPsort[$m] =	'' . sprintf("%08s", $RAWdncPCT) . '-----' . $m . '-----' . sprintf("%020s", $RAWdate);
+			$TOPsortTALLY[$m]=$RAWdncPCT;
+			}
+		if (!ereg("ID|TIME|LEADS|CI|DNCCI",$stage))
+			{
+			if ($file_download < 1)
+				{echo "$Toutput";}
+			else
+				{$file_output .= "$fileToutput";}
+			}
+
+		if ($TOPsortMAX < $TOPsortTALLY[$m]) {$TOPsortMAX = $TOPsortTALLY[$m];}
+
+		$m++;
+		}
+	### END loop through each user ###
+
+	$TOT_AGENTS = sprintf("%4s", $m);
+
+
+	### BEGIN sort through output to display properly ###
+	if (ereg("ID|TIME|LEADS|CI|DNCCI",$stage))
+		{
+		if (ereg("ID",$stage))
+			{sort($TOPsort, SORT_NUMERIC);}
+		if (ereg("TIME|LEADS|CI|DNCCI",$stage))
+			{rsort($TOPsort, SORT_NUMERIC);}
+
+		$m=0;
+		while ($m < $k)
+			{
+			$sort_split = explode("-----",$TOPsort[$m]);
+			$i = $sort_split[1];
+			$sort_order[$m] = "$i";
+			if ($file_download < 1)
+				{echo "$TOPsorted_output[$i]";}
+			else
+				{$file_output .= "$TOPsorted_outputFILE[$i]";}
+			$m++;
+			}
+		}
+	### END sort through output to display properly ###
+
+
+
+	###### LAST LINE FORMATTING ##########
+	### BEGIN loop through each status ###
+	$SUMstatusesHTML='';
+	$n=0;
+	while ($n < $j)
+		{
+		$Scalls=0;
+		$Sstatus=$statusesARY[$n];
+		$SUMstatusTXT='';
+		### BEGIN loop through each stat line ###
+		$i=0; $status_found=0;
+		while ($i < $rows_to_print)
+			{
+			if ($Sstatus=="$status[$i]")
+				{
+				$Scalls =		($Scalls + $calls[$i]);
+				$status_found++;
+				}
+			$i++;
+			}
+		### END loop through each stat line ###
+		if ($status_found < 1)
+			{
+			$SUMstatusesHTML .= "        0 |";
+			}
+		else
+			{
+			$SUMstatusTXT = sprintf("%8s", $Scalls);
+			$SUMstatusesHTML .= " $SUMstatusTXT |";
+			$SUMstatusesFILE .= "$SUMstatusTXT,";
+			}
+		$n++;
+		}
+	### END loop through each status ###
+
+	$TOTcalls = sprintf("%7s", $TOTcalls);
+	$CIScountTOT = sprintf("%7s", $CIScountTOT);
+	if ( ($DNCcountTOT < 1) or ($CIScountTOT < 1) )
+		{$DNCcountPCT=0;}
+	else
+		{
+		$DNCcountPCT = ( ($DNCcountTOT / $CIScountTOT) * 100);
+		}
+	#$DNCcountPCT = round($DNCcountPCT,2);
+	$DNCcountPCT = round($DNCcountPCT);
+	#$DNCcountPCT = sprintf("%3.2f", $DNCcountPCT);
+	$DNCcountPCT = sprintf("%6s", $DNCcountPCT);
+
+
+	if ($file_download < 1)
+		{
+		echo "+------------+--------+--------+--------+$statusesHEAD\n";
+		echo "| TOTALS     | $TOTcalls| $CIScountTOT| $DNCcountPCT%|$SUMstatusesHTML\n";
+		echo "+------------+--------+--------+--------+$statusesHEAD\n";
+
+		echo "\n\n
"; + } + else + { + $file_output .= "TOTALS,$TOTcalls,$CIScountTOT,$DNCcountPCT%,$SUMstatusesFILE\n"; + } + } + + +if ($file_download > 0) + { + $US='_'; + $FILE_TIME = date("Ymd-His"); + $CSVfilename = "AGENT_DAYS_$user$US$FILE_TIME.csv"; + + // We'll be outputting a TXT file + header('Content-type: application/octet-stream'); + + // It will be called LIST_101_20090209-121212.txt + header("Content-Disposition: attachment; filename=\"$CSVfilename\""); + header('Expires: 0'); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header('Pragma: public'); + ob_clean(); + flush(); + + echo "$file_output"; + + exit; + } + + + + +echo "
\n"; +echo "
Datas:
"; +echo "\n"; +echo ""; + +?> + + to
"; + +?> + +
Campanhas:
"; +echo "\n"; +echo "
Usuário:
"; +echo "\n"; +echo "
Shift:
"; +echo "

\n"; +echo "\n"; +echo "
        "; +echo ""; +if (strlen($user) > 1) + { + echo " DOWNLOAD | \n"; + echo " USER | \n"; + echo " USER STATS | \n"; + } +else + {echo " USUÁRIOS | \n";} +echo "RELATÓRIOS \n"; +echo "
"; + +echo "
\n\n"; + +echo "
\n"; +echo "\n"; +echo "
\n\n\n\n\n\n\n\n\n\n";
+
+$m=0;
+while ($m < $k)
+	{
+	$sort_split = explode("-----",$TOPsort[$m]);
+	$i = $sort_split[1];
+	$sort_order[$m] = "$i";
+
+	if ( ($TOPsortTALLY[$i] < 1) or ($TOPsortMAX < 1) )
+		{echo "              \n";}
+	else
+		{
+		echo "              ";
+		$TOPsortPLOT = ( ($TOPsortTALLY[$i] / $TOPsortMAX) * 120 );
+		$h=0;
+		while ($h <= $TOPsortPLOT)
+			{
+			echo " ";
+			$h++;
+			}
+		echo "\n";
+		}
+	$m++;
+	}
+
+echo "\n";
+
+?>
+
+
diff --git a/LANG_www/vicidial_br/AST_agent_performance.php b/LANG_www/vicidial_br/AST_agent_performance.php
new file mode 100644
index 00000000..7b42b355
--- /dev/null
+++ b/LANG_www/vicidial_br/AST_agent_performance.php
@@ -0,0 +1,258 @@
+    LICENSE: AGPLv2
+#
+# CHANGES
+#
+# 60619-1711 - Added variable filtering to eliminate SQL injection attack threat
+#            - Added required user/pass to gain access to this page
+# 70201-1203 - Added non_latin UTF8 output code, widened USER ID to 8 chars
+# 90508-0644 - Changed to PHP long tags
+#
+
+require("dbconnect.php");
+
+$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
+$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
+$PHP_SELF=$_SERVER['PHP_SELF'];
+if (isset($_GET["group"]))				{$group=$_GET["group"];}
+	elseif (isset($_POST["group"]))		{$group=$_POST["group"];}
+if (isset($_GET["query_date"]))				{$query_date=$_GET["query_date"];}
+	elseif (isset($_POST["query_date"]))		{$query_date=$_POST["query_date"];}
+if (isset($_GET["shift"]))				{$shift=$_GET["shift"];}
+	elseif (isset($_POST["shift"]))		{$shift=$_POST["shift"];}
+if (isset($_GET["submit"]))				{$submit=$_GET["submit"];}
+	elseif (isset($_POST["submit"]))		{$submit=$_POST["submit"];}
+if (isset($_GET["ENVIAR"]))				{$ENVIAR=$_GET["ENVIAR"];}
+	elseif (isset($_POST["ENVIAR"]))		{$ENVIAR=$_POST["ENVIAR"];}
+
+$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
+$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
+
+	$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 "Nome ou Senha inválidos: |$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;}
+
+$stmt="select campaign_id from vicidial_campaigns;";
+if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");}
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$campaigns_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $campaigns_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$groups[$i] =$row[0];
+	$i++;
+	}
+?>
+
+
+
+
+
+\n";
+echo "VICIDIAL: Agent Performance\n";
+echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "           ALTERAR | RELATÓRIOS \n"; +echo "
\n\n"; + +echo "
\n";
+
+
+if (!$group)
+{
+echo "\n";
+echo "PLEASE SELECT A SERVIDOR AND DATE-TIME ABOVE AND CLICK ENVIAR\n";
+echo " NOTE: stats taken from 6 hour shift specified\n";
+}
+
+else
+{
+if ($shift == 'AM') 
+	{
+	$query_date_BEGIN = "$query_date 08:45:00";   
+	$query_date_END = "$query_date 15:33:00";
+	$time_BEGIN = "08:45:00";   
+	$time_END = "15:33:00";
+	}
+if ($shift == 'PM') 
+	{
+	$query_date_BEGIN = "$query_date 15:33:00";   
+	$query_date_END = "$query_date 23:15:00";
+	$time_BEGIN = "15:33:00";   
+	$time_END = "23:15:00";
+	}
+
+echo "VICIDIAL: Agent Performance                             $NOW_TIME\n";
+
+echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
+echo "---------- AGENTS Detalhess -------------\n\n";
+
+echo "+-----------------+----------+--------+--------+--------+------+------+------+------+------+------+------+\n";
+echo "| USER NAME       | ID       | CALLS  | TALK   | TALKAVG| A    | B    | DC   | DNC  | N    | NI   | SALE |\n";
+echo "+-----------------+----------+--------+--------+--------+------+------+------+------+------+------+------+\n";
+
+$stmt="select count(*) as calls,sum(length_in_sec) as talk,full_name,vicidial_users.user,avg(length_in_sec) from vicidial_users,vicidial_log where call_date <= '$query_date_END' and call_date >= '$query_date_BEGIN' and vicidial_users.user=vicidial_log.user and campaign_id='" . mysql_real_escape_string($group) . "' group by full_name order by calls desc limit 1000;";
+if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");}
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$rows_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $rows_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$TOTcalls=($TOTcalls + $row[0]);
+	$TOTtotTALK=($TOTtotTALK + $row[1]);
+	$calls[$i] =	sprintf("%-6s", $row[0]);
+
+	if ($non_latin < 1)
+	{
+   	 $full_name[$i]=	sprintf("%-15s", $row[2]); 
+	 while(strlen($full_name[$i])>15) {$full_name[$i] = substr("$full_name[$i]", 0, -1);}
+
+	 $user[$i] =		sprintf("%-6s", $row[3]);
+        while(strlen($user[$i])>6) {$user[$i] = substr("$user[$i]", 0, -1);}
+       }
+	else
+	{	
+        $full_name[$i]=	sprintf("%-45s", $row[2]); 
+	 while(mb_strlen($full_name[$i],'utf-8')>15) {$full_name[$i] = mb_substr("$full_name[$i]", 0, -1,'utf-8');}
+
+ 	 $user[$i] =		sprintf("%-18s", $row[3]);
+	 while(mb_strlen($user[$i],'utf-8')>6) {$user[$i] = mb_substr("$user[$i]", 0, -1,'utf-8');}
+	}
+
+	$user[$i] =		sprintf("%-8s", $row[3]);
+	$USERtotTALK =	$row[1];
+	$USERavgTALK =	$row[4];
+
+	$USERtotTALK_M = ($USERtotTALK / 60);
+	$USERtotTALK_M = round($USERtotTALK_M, 2);
+	$USERtotTALK_M_int = intval("$USERtotTALK_M");
+	$USERtotTALK_S = ($USERtotTALK_M - $USERtotTALK_M_int);
+	$USERtotTALK_S = ($USERtotTALK_S * 60);
+	$USERtotTALK_S = round($USERtotTALK_S, 0);
+	if ($USERtotTALK_S < 10) {$USERtotTALK_S = "0$USERtotTALK_S";}
+	$USERtotTALK_MS = "$USERtotTALK_M_int:$USERtotTALK_S";
+	$pfUSERtotTALK_MS[$i] =		sprintf("%6s", $USERtotTALK_MS);
+
+	$USERavgTALK_M = ($USERavgTALK / 60);
+	$USERavgTALK_M = round($USERavgTALK_M, 2);
+	$USERavgTALK_M_int = intval("$USERavgTALK_M");
+	$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
+	$USERavgTALK_S = ($USERavgTALK_S * 60);
+	$USERavgTALK_S = round($USERavgTALK_S, 0);
+	if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
+	$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
+	$pfUSERavgTALK_MS[$i] =		sprintf("%6s", $USERavgTALK_MS);
+	$i++;
+	}
+
+$k=0;
+while($k < $i)
+	{
+	$ctA[$k]="0   "; $ctB[$k]="0   "; $ctDC[$k]="0   "; $ctDNC[$k]="0   "; $ctN[$k]="0   "; $ctNI[$k]="0   "; $ctSALE[$k]="0   "; 
+	$stmt="select count(*),status from vicidial_log where call_date <= '$query_date_END' and call_date >= '$query_date_BEGIN' and user='$user[$k]' and campaign_id='" . mysql_real_escape_string($group) . "' group by status;";
+	if ($non_latin > 0)
+	{
+	$rslt=mysql_query("SET NAMES 'UTF8'");
+	}
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$rows_to_print = mysql_num_rows($rslt);
+	$m=0;
+	while ($m < $rows_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		if ($row[1] == 'A') {$ctA[$k]=sprintf("%-4s", $row[0]);		$TOT_A = ($TOT_A + $row[0]);}
+		if ($row[1] == 'B') {$ctB[$k]=sprintf("%-4s", $row[0]);		$TOT_B = ($TOT_B + $row[0]);}
+		if ($row[1] == 'DC') {$ctDC[$k]=sprintf("%-4s", $row[0]);	$TOT_DC = ($TOT_DC + $row[0]);}
+		if ($row[1] == 'DNC') {$ctDNC[$k]=sprintf("%-4s", $row[0]);	$TOT_DNC = ($TOT_DNC + $row[0]);}
+		if ($row[1] == 'N') {$ctN[$k]=sprintf("%-4s", $row[0]);		$TOT_N = ($TOT_N + $row[0]);}
+		if ($row[1] == 'NI') {$ctNI[$k]=sprintf("%-4s", $row[0]);	$TOT_NI = ($TOT_NI + $row[0]);}
+		if (($row[1] == 'SALE') || ($row[1] == 'XFER') ) {$ctSALE[$k]=sprintf("%-4s", $row[0]);	$TOT_SALE = ($TOT_SALE + $row[0]);}
+		$m++;
+		}
+	echo "| $full_name[$k] | $user[$k] | $calls[$k] | $pfUSERtotTALK_MS[$k] | $pfUSERavgTALK_MS[$k] | $ctA[$k] | $ctB[$k] | $ctDC[$k] | $ctDNC[$k] | $ctN[$k] | $ctNI[$k] | $ctSALE[$k] |\n";
+
+
+
+	$k++;
+	}
+
+	$TOTcalls =	sprintf("%-7s", $TOTcalls);
+
+	$TOTtotTALK_M = ($TOTtotTALK / 60);
+	$TOTtotTALK_M = round($TOTtotTALK_M, 2);
+	$TOTtotTALK_M_int = intval("$TOTtotTALK_M");
+	$TOTtotTALK_S = ($TOTtotTALK_M - $TOTtotTALK_M_int);
+	$TOTtotTALK_S = ($TOTtotTALK_S * 60);
+	$TOTtotTALK_S = round($TOTtotTALK_S, 0);
+	if ($TOTtotTALK_S < 10) {$TOTtotTALK_S = "0$TOTtotTALK_S";}
+	$TOTtotTALK_MS = "$TOTtotTALK_M_int:$TOTtotTALK_S";
+	$TOTtotTALK_MS =		sprintf("%7s", $TOTtotTALK_MS);
+		while(strlen($TOTtotTALK_MS)>7) {$TOTtotTALK_MS = substr("$TOTtotTALK_MS", 0, -1);}
+
+	$TOT_A = sprintf("%-5s", $TOT_A);
+	$TOT_B = sprintf("%-5s", $TOT_B);
+	$TOT_DC = sprintf("%-5s", $TOT_DC);
+	$TOT_DNC = sprintf("%-5s", $TOT_DNC);
+	$TOT_N = sprintf("%-5s", $TOT_N);
+	$TOT_NI = sprintf("%-5s", $TOT_NI);
+	$TOT_SALE = sprintf("%-5s", $TOT_SALE);
+
+echo "+-----------------+----------+--------+--------+--------+------+------+------+------+------+------+------+\n";
+echo "|  TOTALS                    | $TOTcalls| $TOTtotTALK_MS|        | $TOT_A| $TOT_B| $TOT_DC| $TOT_DNC| $TOT_N| $TOT_NI| $TOT_SALE|\n";
+echo "+-----------------+----------+--------+--------+--------+------+------+------+------+------+------+------+\n";
+
+echo "\n";
+
+}
+
+
+
+?>
+
+
\ No newline at end of file
diff --git a/LANG_www/vicidial_br/AST_agent_performance_detail.php b/LANG_www/vicidial_br/AST_agent_performance_detail.php
new file mode 100644
index 00000000..243b9b4d
--- /dev/null
+++ b/LANG_www/vicidial_br/AST_agent_performance_detail.php
@@ -0,0 +1,875 @@
+    LICENSE: AGPLv2
+#
+# CHANGES
+#
+# 71119-2359 - First build
+# 71121-0144 - Replace existing AST_agent_performance_detail.php script with this one
+#            - Fixed zero division bug
+# 71218-1155 - added end_date for multi-day reports
+# 80428-0144 - UTF8 cleanup
+# 80712-1007 - tally bug fixes and time display change
+# 81030-0346 - Added pause code stats
+# 81030-1924 - Added total non-pause and total logged-in time to pause code section
+# 81108-0716 - fixed user same-name bug
+# 81110-0056 - fixed pause code display bug
+# 90310-2039 - Admin header
+# 90508-0644 - Changed to PHP long tags
+# 90523-0935 - Rewrite of seconds to minutes and hours conversion
+# 90717-1500 - Changed to be multi-campaign, multi-user-group select
+# 90908-1058 - Added DEAD time statistics
+# 100203-1131 - Added CUSTOMER time statistics
+# 100214-1421 - Sort menu alphabetically
+# 100216-0042 - Added popup date selector
+#
+
+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["group"]))					{$group=$_GET["group"];}
+	elseif (isset($_POST["group"]))			{$group=$_POST["group"];}
+if (isset($_GET["user_group"]))				{$user_group=$_GET["user_group"];}
+	elseif (isset($_POST["user_group"]))	{$user_group=$_POST["user_group"];}
+if (isset($_GET["shift"]))					{$shift=$_GET["shift"];}
+	elseif (isset($_POST["shift"]))			{$shift=$_POST["shift"];}
+if (isset($_GET["stage"]))					{$stage=$_GET["stage"];}
+	elseif (isset($_POST["stage"]))			{$stage=$_POST["stage"];}
+if (isset($_GET["DB"]))						{$DB=$_GET["DB"];}
+	elseif (isset($_POST["DB"]))			{$DB=$_POST["DB"];}
+if (isset($_GET["submit"]))					{$submit=$_GET["submit"];}
+	elseif (isset($_POST["submit"]))		{$submit=$_POST["submit"];}
+if (isset($_GET["ENVIAR"]))					{$ENVIAR=$_GET["ENVIAR"];}
+	elseif (isset($_POST["ENVIAR"]))		{$ENVIAR=$_POST["ENVIAR"];}
+
+
+if (strlen($shift)<2) {$shift='ALL';}
+
+$LINKbase = "$PHP_SELF?query_date=$query_date&end_date=$end_date&group=$group&user_group=$user_group&shift=$shift&DB=$DB";
+
+#############################################
+##### 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);
+if ($qm_conf_ct > 0)
+	{
+	$row=mysql_fetch_row($rslt);
+	$non_latin =					$row[0];
+	}
+##### END SETTINGS LOOKUP #####
+###########################################
+
+$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
+$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
+
+$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 "Nome ou Senha inválidos: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
+    exit;
+	}
+
+$MT[0]='';
+$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;}
+if (!isset($end_date)) {$end_date = $NOW_DATE;}
+
+$stmt="select campaign_id from vicidial_campaigns order by campaign_id;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$campaigns_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $campaigns_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$groups[$i] =$row[0];
+	$i++;
+	}
+$stmt="select user_group from vicidial_user_groups order by user_group;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$user_groups_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $user_groups_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$user_groups[$i] =$row[0];
+	$i++;
+	}
+
+$i=0;
+$group_string='|';
+$group_ct = count($group);
+while($i < $group_ct)
+	{
+	$group_string .= "$group[$i]|";
+	$group_SQL .= "'$group[$i]',";
+	$groupQS .= "&group[]=$group[$i]";
+	$i++;
+	}
+if ( (ereg("--ALL--",$group_string) ) or ($group_ct < 1) )
+	{$group_SQL = "";}
+else
+	{
+	$group_SQL = eregi_replace(",$",'',$group_SQL);
+	$group_SQL = "and campaign_id IN($group_SQL)";
+	}
+
+$i=0;
+$user_group_string='|';
+$user_group_ct = count($user_group);
+while($i < $user_group_ct)
+	{
+	$user_group_string .= "$user_group[$i]|";
+	$user_group_SQL .= "'$user_group[$i]',";
+	$user_groupQS .= "&user_group[]=$user_group[$i]";
+	$i++;
+	}
+if ( (ereg("--ALL--",$user_group_string) ) or ($user_group_ct < 1) )
+	{$user_group_SQL = "";}
+else
+	{
+	$user_group_SQL = eregi_replace(",$",'',$user_group_SQL);
+	$user_group_SQL = "and vicidial_agent_log.user_group IN($user_group_SQL)";
+	}
+
+if ($DB) {echo "$user_group_string|$user_group_ct|$user_groupQS|$i
";} +?> + + + + + +\n"; +echo "\n"; + +echo "\n"; +echo "Agent Performance Detalhes\n"; + + $short_header=1; + + require("admin_header.php"); + +echo "
"; + +echo "
\n"; +echo "
Datas:
"; +echo "\n"; +echo ""; + +?> + + to
"; + +?> + +
Campanhas:
"; +echo "\n"; +echo "
Grupos de Usuário:
"; +echo "\n"; +echo "
Shift:
"; +echo "

\n"; +echo "\n"; +echo "
        "; + +echo "          \n"; +echo " RELATÓRIOS \n"; +echo "\n"; +echo "
"; + +echo "
\n\n"; + + +echo "
\n";
+
+
+if (!$group)
+{
+echo "\n";
+echo "POR FAVOR SELECIONE UMA CAMPANHA E PERÍODO ACIMA E CLIQUE ENVIAR\n";
+echo " NOTE: stats taken from shift specified\n";
+}
+
+else
+{
+if ($shift == 'AM') 
+	{
+	$time_BEGIN=$AM_shift_BEGIN;
+	$time_END=$AM_shift_END;
+	if (strlen($time_BEGIN) < 6) {$time_BEGIN = "03:45:00";}   
+	if (strlen($time_END) < 6) {$time_END = "15:15:00";}
+	}
+if ($shift == 'PM') 
+	{
+	$time_BEGIN=$PM_shift_BEGIN;
+	$time_END=$PM_shift_END;
+	if (strlen($time_BEGIN) < 6) {$time_BEGIN = "15:15:00";}
+	if (strlen($time_END) < 6) {$time_END = "23:15:00";}
+	}
+if ($shift == 'ALL') 
+	{
+	if (strlen($time_BEGIN) < 6) {$time_BEGIN = "00:00:00";}
+	if (strlen($time_END) < 6) {$time_END = "23:59:59";}
+	}
+$query_date_BEGIN = "$query_date $time_BEGIN";   
+$query_date_END = "$end_date $time_END";
+
+if (strlen($user_group)>0) {$ugSQL="and vicidial_agent_log.user_group='$user_group'";}
+else {$ugSQL='';}
+
+echo "Agent Performance Detalhes                        $NOW_TIME\n";
+
+echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
+echo "---------- AGENTS Detalhess -------------\n\n";
+
+
+
+
+
+$statuses='-';
+$statusesTXT='';
+$statusesHEAD='';
+$statusesHTML='';
+$statusesARY[0]='';
+$j=0;
+$users='-';
+$usersARY[0]='';
+$user_namesARY[0]='';
+$k=0;
+
+$stmt="select count(*) as calls,sum(talk_sec) as talk,full_name,vicidial_users.user,sum(pause_sec),sum(wait_sec),sum(dispo_sec),status,sum(dead_sec) from vicidial_users,vicidial_agent_log where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and vicidial_users.user=vicidial_agent_log.user and pause_sec<36000 and wait_sec<36000 and talk_sec<36000 and dispo_sec<36000  $group_SQL $user_group_SQL group by user,full_name,status order by full_name,user,status desc limit 500000;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$rows_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $rows_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+#	$row[0] = ($row[0] - 1);	# subtract 1 for login/logout event compensation
+	
+	$calls[$i] =		$row[0];
+	$talk_sec[$i] =		$row[1];
+	$full_name[$i] =	$row[2];
+	$user[$i] =			$row[3];
+	$pause_sec[$i] =	$row[4];
+	$wait_sec[$i] =		$row[5];
+	$dispo_sec[$i] =	$row[6];
+	$status[$i] =		$row[7];
+	$dead_sec[$i] =		$row[8];
+	$customer_sec[$i] =	($talk_sec[$i] - $dead_sec[$i]);
+	if ($customer_sec[$i] < 1)
+		{$customer_sec[$i]=0;}
+	if ( (!eregi("-$status[$i]-", $statuses)) and (strlen($status[$i])>0) )
+		{
+		$statusesTXT = sprintf("%8s", $status[$i]);
+		$statusesHEAD .= "----------+";
+		$statusesHTML .= " $statusesTXT |";
+		$statuses .= "$status[$i]-";
+		$statusesARY[$j] = $status[$i];
+		$j++;
+		}
+	if (!eregi("-$user[$i]-", $users))
+		{
+		$users .= "$user[$i]-";
+		$usersARY[$k] = $user[$i];
+		$user_namesARY[$k] = $full_name[$i];
+		$k++;
+		}
+
+	$i++;
+	}
+
+echo "CALL STATS BREAKDOWN: (Statistics related to handling of calls only)\n";
+echo "+-----------------+----------+--------+-----------+----------+--------+----------+--------+----------+--------+----------+--------+----------+--------+----------+--------+$statusesHEAD\n";
+echo "| USER NAME       | ID       | CALLS  | TIME      | PAUSE    |PAUSAVG | WAIT     |WAITAVG | TALK     |TALKAVG | DISPO    |DISPAVG | DEAD     |DEADAVG | CUSTOMER |CUSTAVG |$statusesHTML\n";
+echo "+-----------------+----------+--------+-----------+----------+--------+----------+--------+----------+--------+----------+--------+----------+--------+----------+--------+$statusesHEAD\n";
+
+
+### BEGIN loop through each user ###
+$m=0;
+while ($m < $k)
+	{
+	$Suser=$usersARY[$m];
+	$Sfull_name=$user_namesARY[$m];
+	$Stime=0;
+	$Scalls=0;
+	$Stalk_sec=0;
+	$Spause_sec=0;
+	$Swait_sec=0;
+	$Sdispo_sec=0;
+	$Sdead_sec=0;
+	$Scustomer_sec=0;
+	$SstatusesHTML='';
+
+	### BEGIN loop through each status ###
+	$n=0;
+	while ($n < $j)
+		{
+		$Sstatus=$statusesARY[$n];
+		$SstatusTXT='';
+		### BEGIN loop through each stat line ###
+		$i=0; $status_found=0;
+		while ($i < $rows_to_print)
+			{
+			if ( ($Suser=="$user[$i]") and ($Sstatus=="$status[$i]") )
+				{
+				$Scalls =		($Scalls + $calls[$i]);
+				$Stalk_sec =	($Stalk_sec + $talk_sec[$i]);
+				$Spause_sec =	($Spause_sec + $pause_sec[$i]);
+				$Swait_sec =	($Swait_sec + $wait_sec[$i]);
+				$Sdispo_sec =	($Sdispo_sec + $dispo_sec[$i]);
+				$Sdead_sec =	($Sdead_sec + $dead_sec[$i]);
+				$Scustomer_sec =	($Scustomer_sec + $customer_sec[$i]);
+				$SstatusTXT = sprintf("%8s", $calls[$i]);
+				$SstatusesHTML .= " $SstatusTXT |";
+				$status_found++;
+				}
+			$i++;
+			}
+		if ($status_found < 1)
+			{
+			$SstatusesHTML .= "        0 |";
+			}
+		### END loop through each stat line ###
+		$n++;
+		}
+	### END loop through each status ###
+	$Stime = ($Stalk_sec + $Spause_sec + $Swait_sec + $Sdispo_sec);
+	$TOTcalls=($TOTcalls + $Scalls);
+	$TOTtime=($TOTtime + $Stime);
+	$TOTtotTALK=($TOTtotTALK + $Stalk_sec);
+	$TOTtotWAIT=($TOTtotWAIT + $Swait_sec);
+	$TOTtotPAUSE=($TOTtotPAUSE + $Spause_sec);
+	$TOTtotDISPO=($TOTtotDISPO + $Sdispo_sec);
+	$TOTtotDEAD=($TOTtotDEAD + $Sdead_sec);
+	$TOTtotCUSTOMER=($TOTtotCUSTOMER + $Scustomer_sec);
+	$Stime = ($Stalk_sec + $Spause_sec + $Swait_sec + $Sdispo_sec);
+	if ( ($Scalls > 0) and ($Stalk_sec > 0) ) {$Stalk_avg = ($Stalk_sec/$Scalls);}
+		else {$Stalk_avg=0;}
+	if ( ($Scalls > 0) and ($Spause_sec > 0) ) {$Spause_avg = ($Spause_sec/$Scalls);}
+		else {$Spause_avg=0;}
+	if ( ($Scalls > 0) and ($Swait_sec > 0) ) {$Swait_avg = ($Swait_sec/$Scalls);}
+		else {$Swait_avg=0;}
+	if ( ($Scalls > 0) and ($Sdispo_sec > 0) ) {$Sdispo_avg = ($Sdispo_sec/$Scalls);}
+		else {$Sdispo_avg=0;}
+	if ( ($Scalls > 0) and ($Sdead_sec > 0) ) {$Sdead_avg = ($Sdead_sec/$Scalls);}
+		else {$Sdead_avg=0;}
+	if ( ($Scalls > 0) and ($Scustomer_sec > 0) ) {$Scustomer_avg = ($Scustomer_sec/$Scalls);}
+		else {$Scustomer_avg=0;}
+
+	$RAWuser = $Suser;
+	$RAWcalls = $Scalls;
+	$Scalls =	sprintf("%6s", $Scalls);
+
+	if ($non_latin < 1)
+		{
+		$Sfull_name=	sprintf("%-15s", $Sfull_name); 
+		while(strlen($Sfull_name)>15) {$Sfull_name = substr("$Sfull_name", 0, -1);}
+		$Suser =		sprintf("%-8s", $Suser);
+		while(strlen($Suser)>8) {$Suser = substr("$Suser", 0, -1);}
+		}
+	else
+		{	
+		$Sfull_name=	sprintf("%-45s", $Sfull_name); 
+		while(mb_strlen($Sfull_name,'utf-8')>15) {$Sfull_name = mb_substr("$Sfull_name", 0, -1,'utf-8');}
+		$Suser =	sprintf("%-24s", $Suser);
+		while(mb_strlen($Suser,'utf-8')>8) {$Suser = mb_substr("$Suser", 0, -1,'utf-8');}
+		}
+
+	$pfUSERtime_MS =		sec_convert($Stime,'H'); 
+	$pfUSERtotTALK_MS =		sec_convert($Stalk_sec,'H'); 
+	$pfUSERavgTALK_MS =		sec_convert($Stalk_avg,'M'); 
+	$USERtotPAUSE_MS =		sec_convert($Spause_sec,'H'); 
+	$USERavgPAUSE_MS =		sec_convert($Spause_avg,'M'); 
+	$USERtotWAIT_MS =		sec_convert($Swait_sec,'H'); 
+	$USERavgWAIT_MS =		sec_convert($Swait_avg,'M'); 
+	$USERtotDISPO_MS =		sec_convert($Sdispo_sec,'H'); 
+	$USERavgDISPO_MS =		sec_convert($Sdispo_avg,'M'); 
+	$USERtotDEAD_MS =		sec_convert($Sdead_sec,'H'); 
+	$USERavgDEAD_MS =		sec_convert($Sdead_avg,'M'); 
+	$USERtotCUSTOMER_MS =	sec_convert($Scustomer_sec,'H'); 
+	$USERavgCUSTOMER_MS =	sec_convert($Scustomer_avg,'M'); 
+
+	$pfUSERtime_MS =		sprintf("%9s", $pfUSERtime_MS);
+	$pfUSERtotTALK_MS =		sprintf("%8s", $pfUSERtotTALK_MS);
+	$pfUSERavgTALK_MS =		sprintf("%6s", $pfUSERavgTALK_MS);
+	$pfUSERtotPAUSE_MS =	sprintf("%8s", $USERtotPAUSE_MS);
+	$pfUSERavgPAUSE_MS =	sprintf("%6s", $USERavgPAUSE_MS);
+	$pfUSERtotWAIT_MS =		sprintf("%8s", $USERtotWAIT_MS);
+	$pfUSERavgWAIT_MS =		sprintf("%6s", $USERavgWAIT_MS);
+	$pfUSERtotDISPO_MS =	sprintf("%8s", $USERtotDISPO_MS);
+	$pfUSERavgDISPO_MS =	sprintf("%6s", $USERavgDISPO_MS);
+	$pfUSERtotDEAD_MS =		sprintf("%8s", $USERtotDEAD_MS);
+	$pfUSERavgDEAD_MS =		sprintf("%6s", $USERavgDEAD_MS);
+	$pfUSERtotCUSTOMER_MS =	sprintf("%8s", $USERtotCUSTOMER_MS);
+	$pfUSERavgCUSTOMER_MS =	sprintf("%6s", $USERavgCUSTOMER_MS);
+	$PAUSEtotal[$m] = $pfUSERtotPAUSE_MS;
+
+	$Toutput = "| $Sfull_name | $Suser | $Scalls | $pfUSERtime_MS | $pfUSERtotPAUSE_MS | $pfUSERavgPAUSE_MS | $pfUSERtotWAIT_MS | $pfUSERavgWAIT_MS | $pfUSERtotTALK_MS | $pfUSERavgTALK_MS | $pfUSERtotDISPO_MS | $pfUSERavgDISPO_MS | $pfUSERtotDEAD_MS | $pfUSERavgDEAD_MS | $pfUSERtotCUSTOMER_MS | $pfUSERavgCUSTOMER_MS |$SstatusesHTML\n";
+
+	$TOPsorted_output[$m] = $Toutput;
+
+	if ($stage == 'ID')
+		{$TOPsort[$m] =	'' . sprintf("%08s", $RAWuser) . '-----' . $m . '-----' . sprintf("%020s", $RAWuser);}
+	if ($stage == 'LEADS')
+		{$TOPsort[$m] =	'' . sprintf("%08s", $RAWcalls) . '-----' . $m . '-----' . sprintf("%020s", $RAWuser);}
+	if ($stage == 'TIME')
+		{$TOPsort[$m] =	'' . sprintf("%08s", $Stime) . '-----' . $m . '-----' . sprintf("%020s", $RAWuser);}
+	if (!ereg("ID|TIME|LEADS",$stage))
+		{echo "$Toutput";}
+
+	$m++;
+	}
+### END loop through each user ###
+
+
+
+### BEGIN sort through output to display properly ###
+if (ereg("ID|TIME|LEADS",$stage))
+	{
+	if (ereg("ID",$stage))
+		{sort($TOPsort, SORT_NUMERIC);}
+	if (ereg("TIME|LEADS",$stage))
+		{rsort($TOPsort, SORT_NUMERIC);}
+
+	$m=0;
+	while ($m < $k)
+		{
+		$sort_split = explode("-----",$TOPsort[$m]);
+		$i = $sort_split[1];
+		$sort_order[$m] = "$i";
+		echo "$TOPsorted_output[$i]";
+		$m++;
+		}
+	}
+### END sort through output to display properly ###
+
+
+
+###### LAST LINE FORMATTING ##########
+### BEGIN loop through each status ###
+$SUMstatusesHTML='';
+$n=0;
+while ($n < $j)
+	{
+	$Scalls=0;
+	$Sstatus=$statusesARY[$n];
+	$SUMstatusTXT='';
+	### BEGIN loop through each stat line ###
+	$i=0; $status_found=0;
+	while ($i < $rows_to_print)
+		{
+		if ($Sstatus=="$status[$i]")
+			{
+			$Scalls =		($Scalls + $calls[$i]);
+			$status_found++;
+			}
+		$i++;
+		}
+	### END loop through each stat line ###
+	if ($status_found < 1)
+		{
+		$SUMstatusesHTML .= "        0 |";
+		}
+	else
+		{
+		$SUMstatusTXT = sprintf("%8s", $Scalls);
+		$SUMstatusesHTML .= " $SUMstatusTXT |";
+		}
+	$n++;
+	}
+### END loop through each status ###
+
+$TOTcalls =	sprintf("%7s", $TOTcalls);
+$TOT_AGENTS = sprintf("%-4s", $m);
+
+if ($TOTtotTALK < 1) {$TOTavgTALK = '0';}
+else {$TOTavgTALK = ($TOTtotTALK / $TOTcalls);}
+if ($TOTtotDISPO < 1) {$TOTavgDISPO = '0';}
+else {$TOTavgDISPO = ($TOTtotDISPO / $TOTcalls);}
+if ($TOTtotDEAD < 1) {$TOTavgDEAD = '0';}
+else {$TOTavgDEAD = ($TOTtotDEAD / $TOTcalls);}
+if ($TOTtotPAUSE < 1) {$TOTavgPAUSE = '0';}
+else {$TOTavgPAUSE = ($TOTtotPAUSE / $TOTcalls);}
+if ($TOTtotWAIT < 1) {$TOTavgWAIT = '0';}
+else {$TOTavgWAIT = ($TOTtotWAIT / $TOTcalls);}
+if ($TOTtotCUSTOMER < 1) {$TOTavgCUSTOMER = '0';}
+else {$TOTavgCUSTOMER = ($TOTtotCUSTOMER / $TOTcalls);}
+
+$TOTtime_MS =		sec_convert($TOTtime,'H'); 
+$TOTtotTALK_MS =	sec_convert($TOTtotTALK,'H'); 
+$TOTtotDISPO_MS =	sec_convert($TOTtotDISPO,'H'); 
+$TOTtotDEAD_MS =	sec_convert($TOTtotDEAD,'H'); 
+$TOTtotPAUSE_MS =	sec_convert($TOTtotPAUSE,'H'); 
+$TOTtotWAIT_MS =	sec_convert($TOTtotWAIT,'H'); 
+$TOTtotCUSTOMER_MS =	sec_convert($TOTtotCUSTOMER,'H'); 
+$TOTavgTALK_MS =	sec_convert($TOTavgTALK,'M'); 
+$TOTavgDISPO_MS =	sec_convert($TOTavgDISPO,'H'); 
+$TOTavgDEAD_MS =	sec_convert($TOTavgDEAD,'H'); 
+$TOTavgPAUSE_MS =	sec_convert($TOTavgPAUSE,'H'); 
+$TOTavgWAIT_MS =	sec_convert($TOTavgWAIT,'H'); 
+$TOTavgCUSTOMER_MS =	sec_convert($TOTavgCUSTOMER,'H'); 
+
+$TOTtime_MS =		sprintf("%10s", $TOTtime_MS);
+$TOTtotTALK_MS =	sprintf("%10s", $TOTtotTALK_MS);
+$TOTtotDISPO_MS =	sprintf("%10s", $TOTtotDISPO_MS);
+$TOTtotDEAD_MS =	sprintf("%10s", $TOTtotDEAD_MS);
+$TOTtotPAUSE_MS =	sprintf("%10s", $TOTtotPAUSE_MS);
+$TOTtotWAIT_MS =	sprintf("%10s", $TOTtotWAIT_MS);
+$TOTtotCUSTOMER_MS =	sprintf("%10s", $TOTtotCUSTOMER_MS);
+$TOTavgTALK_MS =	sprintf("%6s", $TOTavgTALK_MS);
+$TOTavgDISPO_MS =	sprintf("%6s", $TOTavgDISPO_MS);
+$TOTavgDEAD_MS =	sprintf("%6s", $TOTavgDEAD_MS);
+$TOTavgPAUSE_MS =	sprintf("%6s", $TOTavgPAUSE_MS);
+$TOTavgWAIT_MS =	sprintf("%6s", $TOTavgWAIT_MS);
+$TOTavgCUSTOMER_MS =	sprintf("%6s", $TOTavgCUSTOMER_MS);
+
+while(strlen($TOTtime_MS)>10) {$TOTtime_MS = substr("$TOTtime_MS", 0, -1);}
+while(strlen($TOTtotTALK_MS)>10) {$TOTtotTALK_MS = substr("$TOTtotTALK_MS", 0, -1);}
+while(strlen($TOTtotDISPO_MS)>10) {$TOTtotDISPO_MS = substr("$TOTtotDISPO_MS", 0, -1);}
+while(strlen($TOTtotDEAD_MS)>10) {$TOTtotDEAD_MS = substr("$TOTtotDEAD_MS", 0, -1);}
+while(strlen($TOTtotPAUSE_MS)>10) {$TOTtotPAUSE_MS = substr("$TOTtotPAUSE_MS", 0, -1);}
+while(strlen($TOTtotWAIT_MS)>10) {$TOTtotWAIT_MS = substr("$TOTtotWAIT_MS", 0, -1);}
+while(strlen($TOTtotCUSTOMER_MS)>10) {$TOTtotCUSTOMER_MS = substr("$TOTtotCUSTOMER_MS", 0, -1);}
+while(strlen($TOTavgTALK_MS)>6) {$TOTavgTALK_MS = substr("$TOTavgTALK_MS", 0, -1);}
+while(strlen($TOTavgDISPO_MS)>6) {$TOTavgDISPO_MS = substr("$TOTavgDISPO_MS", 0, -1);}
+while(strlen($TOTavgDEAD_MS)>6) {$TOTavgDEAD_MS = substr("$TOTavgDEAD_MS", 0, -1);}
+while(strlen($TOTavgPAUSE_MS)>6) {$TOTavgPAUSE_MS = substr("$TOTavgPAUSE_MS", 0, -1);}
+while(strlen($TOTavgWAIT_MS)>6) {$TOTavgWAIT_MS = substr("$TOTavgWAIT_MS", 0, -1);}
+while(strlen($TOTavgCUSTOMER_MS)>6) {$TOTavgCUSTOMER_MS = substr("$TOTavgCUSTOMER_MS", 0, -1);}
+
+
+echo "+-----------------+----------+--------+-----------+----------+--------+----------+--------+----------+--------+----------+--------+----------+--------+----------+--------+$statusesHEAD\n";
+echo "|  TOTALS        AGENTS:$TOT_AGENTS | $TOTcalls| $TOTtime_MS|$TOTtotPAUSE_MS| $TOTavgPAUSE_MS |$TOTtotWAIT_MS| $TOTavgWAIT_MS |$TOTtotTALK_MS| $TOTavgTALK_MS |$TOTtotDISPO_MS| $TOTavgDISPO_MS |$TOTtotDEAD_MS| $TOTavgDEAD_MS |$TOTtotCUSTOMER_MS| $TOTavgCUSTOMER_MS |$SUMstatusesHTML\n";
+echo "+-----------------+----------+--------+-----------+----------+--------+----------+--------+----------+--------+----------+--------+----------+--------+----------+--------+$statusesHEAD\n";
+
+echo "\n\n";
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+$sub_statuses='-';
+$sub_statusesTXT='';
+$sub_statusesHEAD='';
+$sub_statusesHTML='';
+$sub_statusesARY=$MT;
+$j=0;
+$PCusers='-';
+$PCusersARY=$MT;
+$PCuser_namesARY=$MT;
+$k=0;
+$stmt="select full_name,vicidial_users.user,sum(pause_sec),sub_status,sum(wait_sec + talk_sec + dispo_sec) from vicidial_users,vicidial_agent_log where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and vicidial_users.user=vicidial_agent_log.user and pause_sec<36000  $group_SQL $user_group_SQL group by user,full_name,sub_status order by user,full_name,sub_status desc limit 100000;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$subs_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $subs_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$PCfull_name[$i] =	$row[0];
+	$PCuser[$i] =		$row[1];
+	$PCpause_sec[$i] =	$row[2];
+	$sub_status[$i] =	$row[3];
+	$PCnon_pause_sec[$i] =	$row[4];
+
+#	echo "$sub_status[$i]|$PCpause_sec[$i]\n";
+#	if ( (!eregi("-$sub_status[$i]-", $sub_statuses)) and (strlen($sub_status[$i])>0) )
+	if (!eregi("-$sub_status[$i]-", $sub_statuses))
+		{
+		$sub_statusesTXT = sprintf("%8s", $sub_status[$i]);
+		$sub_statusesHEAD .= "----------+";
+		$sub_statusesHTML .= " $sub_statusesTXT |";
+		$sub_statuses .= "$sub_status[$i]-";
+		$sub_statusesARY[$j] = $sub_status[$i];
+		$j++;
+		}
+	if (!eregi("-$PCuser[$i]-", $PCusers))
+		{
+		$PCusers .= "$PCuser[$i]-";
+		$PCusersARY[$k] = $PCuser[$i];
+		$PCuser_namesARY[$k] = $PCfull_name[$i];
+		$k++;
+		}
+
+	$i++;
+	}
+
+echo "PAUSE CODE BREAKDOWN:\n";
+echo "+-----------------+----------+----------+----------+----------+  +$sub_statusesHEAD\n";
+echo "| USER NAME       | ID       | TOTAL    | NONPAUSE | PAUSE    |  |$sub_statusesHTML\n";
+echo "+-----------------+----------+----------+----------+----------+  +$sub_statusesHEAD\n";
+
+
+### BEGIN loop through each user ###
+$m=0;
+$Suser_ct = count($usersARY);
+$TOTtotNONPAUSE = 0;
+$TOTtotTOTAL = 0;
+
+while ($m < $k)
+	{
+	$d=0;
+	while ($d < $Suser_ct)
+		{
+		if ($usersARY[$d] === "$PCusersARY[$m]")
+			{$pcPAUSEtotal = $PAUSEtotal[$d];}
+		$d++;
+		}
+	$Suser=$PCusersARY[$m];
+	$Sfull_name=$PCuser_namesARY[$m];
+	$Spause_sec=0;
+	$Snon_pause_sec=0;
+	$Stotal_sec=0;
+	$SstatusesHTML='';
+
+	### BEGIN loop through each status ###
+	$n=0;
+	while ($n < $j)
+		{
+		$Sstatus=$sub_statusesARY[$n];
+		$SstatusTXT='';
+		### BEGIN loop through each stat line ###
+		$i=0; $status_found=0;
+		while ($i < $subs_to_print)
+			{
+			if ( ($Suser=="$PCuser[$i]") and ($Sstatus=="$sub_status[$i]") )
+				{
+				$Spause_sec =	($Spause_sec + $PCpause_sec[$i]);
+				$Snon_pause_sec =	($Snon_pause_sec + $PCnon_pause_sec[$i]);
+				$Stotal_sec =	($Stotal_sec + $PCnon_pause_sec[$i] + $PCpause_sec[$i]);
+
+				$USERcodePAUSE_MS =		sec_convert($PCpause_sec[$i],'H'); 
+				$pfUSERcodePAUSE_MS =	sprintf("%6s", $USERcodePAUSE_MS);
+
+				$SstatusTXT = sprintf("%8s", $pfUSERcodePAUSE_MS);
+				$SstatusesHTML .= " $SstatusTXT |";
+				$status_found++;
+				}
+			$i++;
+			}
+		if ($status_found < 1)
+			{
+			$SstatusesHTML .= "        0 |";
+			}
+		### END loop through each stat line ###
+		$n++;
+		}
+	### END loop through each status ###
+	$TOTtotPAUSE=($TOTtotPAUSE + $Spause_sec);
+
+	if ($non_latin < 1)
+		{
+		$Sfull_name=	sprintf("%-15s", $Sfull_name); 
+		while(strlen($Sfull_name)>15) {$Sfull_name = substr("$Sfull_name", 0, -1);}
+		$Suser =		sprintf("%-8s", $Suser);
+		while(strlen($Suser)>8) {$Suser = substr("$Suser", 0, -1);}
+		}
+	else
+		{
+		$Sfull_name=	sprintf("%-45s", $Sfull_name); 
+		while(mb_strlen($Sfull_name,'utf-8')>15) {$Sfull_name = mb_substr("$Sfull_name", 0, -1,'utf-8');}
+		$Suser =	sprintf("%-24s", $Suser);
+		while(mb_strlen($Suser,'utf-8')>8) {$Suser = mb_substr("$Suser", 0, -1,'utf-8');}
+		}
+
+	$TOTtotNONPAUSE = ($TOTtotNONPAUSE + $Snon_pause_sec);
+	$TOTtotTOTAL = ($TOTtotTOTAL + $Stotal_sec);
+
+	$USERtotPAUSE_MS =		sec_convert($Spause_sec,'H'); 
+	$USERtotNONPAUSE_MS =	sec_convert($Snon_pause_sec,'H'); 
+	$USERtotTOTAL_MS =		sec_convert($Stotal_sec,'H'); 
+
+	$pfUSERtotPAUSE_MS =		sprintf("%8s", $USERtotPAUSE_MS);
+	$pfUSERtotNONPAUSE_MS =		sprintf("%8s", $USERtotNONPAUSE_MS);
+	$pfUSERtotTOTAL_MS =		sprintf("%8s", $USERtotTOTAL_MS);
+
+	$BOTTOMoutput = "| $Sfull_name | $Suser | $pfUSERtotTOTAL_MS | $pfUSERtotNONPAUSE_MS | $pfUSERtotPAUSE_MS |  |$SstatusesHTML\n";
+
+	$BOTTOMsorted_output[$m] = $BOTTOMoutput;
+
+	echo "$BOTTOMoutput";
+
+	$m++;
+	}
+### END loop through each user ###
+
+
+
+### BEGIN sort through output to display properly ###
+#if (ereg("ID|TIME|LEADS",$stage))
+#	{
+#	$n=0;
+#	while ($n <= $m)
+#		{
+#		$i = $sort_order[$m];
+#		echo "$BOTTOMsorted_output[$i]";
+#		$m--;
+#		}
+#	}
+### END sort through output to display properly ###
+
+
+
+###### LAST LINE FORMATTING ##########
+### BEGIN loop through each status ###
+$SUMstatusesHTML='';
+$TOTtotPAUSE=0;
+$n=0;
+while ($n < $j)
+	{
+	$Scalls=0;
+	$Sstatus=$sub_statusesARY[$n];
+	$SUMstatusTXT='';
+	### BEGIN loop through each stat line ###
+	$i=0; $status_found=0;
+	while ($i < $subs_to_print)
+		{
+		if ($Sstatus=="$sub_status[$i]")
+			{
+			$Scalls =		($Scalls + $PCpause_sec[$i]);
+			$status_found++;
+			}
+		$i++;
+		}
+	### END loop through each stat line ###
+	if ($status_found < 1)
+		{
+		$SUMstatusesHTML .= "        0 |";
+		}
+	else
+		{
+		$TOTtotPAUSE = ($TOTtotPAUSE + $Scalls);
+
+		$USERsumstatPAUSE_MS =		sec_convert($Scalls,'H'); 
+		$pfUSERsumstatPAUSE_MS =	sprintf("%8s", $USERsumstatPAUSE_MS);
+
+		$SUMstatusTXT = sprintf("%8s", $pfUSERsumstatPAUSE_MS);
+		$SUMstatusesHTML .= " $SUMstatusTXT |";
+		}
+	$n++;
+	}
+### END loop through each status ###
+
+	$TOT_AGENTS = sprintf("%-4s", $m);
+
+	$TOTtotPAUSE_MS =		sec_convert($TOTtotPAUSE,'H'); 
+	$TOTtotNONPAUSE_MS =	sec_convert($TOTtotNONPAUSE,'H'); 
+	$TOTtotTOTAL_MS =		sec_convert($TOTtotTOTAL,'H'); 
+
+	$TOTtotPAUSE_MS =		sprintf("%10s", $TOTtotPAUSE_MS);
+	$TOTtotNONPAUSE_MS =	sprintf("%10s", $TOTtotNONPAUSE_MS);
+	$TOTtotTOTAL_MS =		sprintf("%10s", $TOTtotTOTAL_MS);
+
+	while(strlen($TOTtotPAUSE_MS)>10) {$TOTtotPAUSE_MS = substr("$TOTtotPAUSE_MS", 0, -1);}
+	while(strlen($TOTtotNONPAUSE_MS)>10) {$TOTtotNONPAUSE_MS = substr("$TOTtotNONPAUSE_MS", 0, -1);}
+	while(strlen($TOTtotTOTAL_MS)>10) {$TOTtotTOTAL_MS = substr("$TOTtotTOTAL_MS", 0, -1);}
+
+
+echo "+-----------------+----------+----------+----------+----------+  +$sub_statusesHEAD\n";
+echo "|  TOTALS        AGENTS:$TOT_AGENTS |$TOTtotTOTAL_MS|$TOTtotNONPAUSE_MS|$TOTtotPAUSE_MS|  |$SUMstatusesHTML\n";
+echo "+----------------------------+----------+----------+----------+  +$sub_statusesHEAD\n";
+
+echo "\n\n";
+
+}
+
+
+?>
+
+
+ + diff --git a/LANG_www/vicidial_br/AST_agent_status_detail.php b/LANG_www/vicidial_br/AST_agent_status_detail.php new file mode 100644 index 00000000..796cea31 --- /dev/null +++ b/LANG_www/vicidial_br/AST_agent_status_detail.php @@ -0,0 +1,700 @@ + LICENSE: AGPLv2 +# +# CHANGES +# +# 90206-1554 - First build +# 90225-2252 - Added CSV download option +# 90310-2030 - Admin header +# 90508-0644 - Changed to PHP long tags +# 100119-0935 - Fixed bug 291 +# 100214-1421 - Sort menu alphabetically +# 100216-0042 - Added popup date selector +# + + +require("dbconnect.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["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["user_group"])) {$user_group=$_GET["user_group"];} + elseif (isset($_POST["user_group"])) {$user_group=$_POST["user_group"];} +if (isset($_GET["shift"])) {$shift=$_GET["shift"];} + elseif (isset($_POST["shift"])) {$shift=$_POST["shift"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["file_download"])) {$file_download=$_GET["file_download"];} + elseif (isset($_POST["file_download"])) {$file_download=$_POST["file_download"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} + +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); +if ($qm_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $non_latin = $row[0]; + } +##### END SETTINGS LOOKUP ##### +########################################### + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$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 "Nome ou Senha inválidos: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$MT[0]=''; +$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;} +if (!isset($end_date)) {$end_date = $NOW_DATE;} + +$stmt="select campaign_id from vicidial_campaigns order by campaign_id;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$campaigns_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $campaigns_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } +$stmt="select user_group from vicidial_user_groups order by user_group;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$user_groups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $user_groups_to_print) + { + $row=mysql_fetch_row($rslt); + $user_groups[$i] =$row[0]; + $i++; + } + +$i=0; +$group_string='|'; +$group_ct = count($group); +while($i < $group_ct) + { + $group_string .= "$group[$i]|"; + $group_SQL .= "'$group[$i]',"; + $groupQS .= "&group[]=$group[$i]"; + $i++; + } +if ( (ereg("--ALL--",$group_string) ) or ($group_ct < 1) ) + {$group_SQL = "";} +else + { + $group_SQL = eregi_replace(",$",'',$group_SQL); + $group_SQL = "and campaign_id IN($group_SQL)"; + } + +$i=0; +$user_group_string='|'; +$user_group_ct = count($user_group); +while($i < $user_group_ct) + { + $user_group_string .= "$user_group[$i]|"; + $user_group_SQL .= "'$user_group[$i]',"; + $user_groupQS .= "&user_group[]=$user_group[$i]"; + $i++; + } +if ( (ereg("--ALL--",$user_group_string) ) or ($user_group_ct < 1) ) + {$user_group_SQL = "";} +else + { + $user_group_SQL = eregi_replace(",$",'',$user_group_SQL); + $user_group_SQL = "and vicidial_agent_log.user_group IN($user_group_SQL)"; + } + +if ($DB) {echo "$user_group_string|$user_group_ct|$user_groupQS|$i
";} + +$stmt="select vsc_id,vsc_name from vicidial_status_categories;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$statcats_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $statcats_to_print) + { + $row=mysql_fetch_row($rslt); + $vsc_id[$i] = $row[0]; + $vsc_name[$i] = $row[1]; + $vsc_count[$i] = 0; + $i++; + } + +$customer_interactive_statuses=''; +$stmt="select status from vicidial_statuses where human_answered='Y';"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$statha_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $statha_to_print) + { + $row=mysql_fetch_row($rslt); + $customer_interactive_statuses .= "|$row[0]"; + $i++; + } +$stmt="select status from vicidial_campaign_statuses where human_answered='Y';"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$statha_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $statha_to_print) + { + $row=mysql_fetch_row($rslt); + $customer_interactive_statuses .= "|$row[0]"; + $i++; + } +if (strlen($customer_interactive_statuses)>0) + {$customer_interactive_statuses .= '|';} + +#$customer_interactive_statuses = '|NI|DNC|CALLBK|AP|SALE|COMP|HAP1|HAP2|HBED|DIED|'; +#$customer_interactive_statuses = '|NI|DNC|CALLBK|XFER|C2|B7|B8|C1|'; + +$LINKbase = "$PHP_SELF?query_date=$query_date&end_date=$end_date$groupQS$user_groupQS&shift=$shift&DB=$DB"; + +if ($file_download < 1) + { + ?> + + + + + + \n"; + echo "\n"; + + echo "\n"; + echo "Agent Status Detalhes Report\n"; + echo ""; + + $short_header=1; + + require("admin_header.php"); + + echo "\n"; + echo "\n"; + echo "
\n";
+	}
+
+if ( (strlen($group[0]) < 1) or (strlen($user_group[0]) < 1) )
+	{
+	echo "\n";
+	echo "POR FAVOR SELECIONE UMA CAMPANHA OU GRUPO DE USUÁRIO E PERÍODO ACIMA E CLIQUE ENVIAR\n";
+	echo " NOTE: stats taken from shift specified\n";
+	}
+
+else
+	{
+	if ($shift == 'AM') 
+		{
+		$time_BEGIN=$AM_shift_BEGIN;
+		$time_END=$AM_shift_END;
+		if (strlen($time_BEGIN) < 6) {$time_BEGIN = "03:45:00";}   
+		if (strlen($time_END) < 6) {$time_END = "15:15:00";}
+		}
+	if ($shift == 'PM') 
+		{
+		$time_BEGIN=$PM_shift_BEGIN;
+		$time_END=$PM_shift_END;
+		if (strlen($time_BEGIN) < 6) {$time_BEGIN = "15:15:00";}
+		if (strlen($time_END) < 6) {$time_END = "23:15:00";}
+		}
+	if ($shift == 'ALL') 
+		{
+		if (strlen($time_BEGIN) < 6) {$time_BEGIN = "00:00:00";}
+		if (strlen($time_END) < 6) {$time_END = "23:59:59";}
+		}
+	$query_date_BEGIN = "$query_date $time_BEGIN";   
+	$query_date_END = "$end_date $time_END";
+
+	if (strlen($user_group)>0) {$ugSQL="and vicidial_agent_log.user_group='$user_group'";}
+	else {$ugSQL='';}
+
+	if ($file_download < 1)
+		{
+		echo "Agent Status Detalhes Report                     $NOW_TIME\n";
+
+		echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
+		echo "---------- AGENTE Detalhess -------------\n\n";
+		}
+	else
+		{
+		$file_output .= "Agent Status Detalhes Report                     $NOW_TIME\n";
+		$file_output .= "Time range: $query_date_BEGIN to $query_date_END\n\n";
+		}
+
+	$statuses='-';
+	$statusesTXT='';
+	$statusesHEAD='';
+	$statusesHTML='';
+	$statusesFILE='';
+	$statusesARY[0]='';
+	$j=0;
+	$users='-';
+	$usersARY[0]='';
+	$user_namesARY[0]='';
+	$k=0;
+
+	$stmt="select count(*) as calls,full_name,vicidial_users.user,status from vicidial_users,vicidial_agent_log where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and vicidial_users.user=vicidial_agent_log.user $group_SQL $user_group_SQL group by user,full_name,status order by full_name,user,status desc limit 500000;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$rows_to_print = mysql_num_rows($rslt);
+	$i=0;
+	while ($i < $rows_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+
+		if ( ($row[0] > 0) and (strlen($row[3]) > 0) and (!eregi("NULL",$row[3])))
+			{
+			$calls[$i] =		$row[0];
+			$full_name[$i] =	$row[1];
+			$user[$i] =			$row[2];
+			$status[$i] =		$row[3];
+			if ( (!eregi("-$status[$i]-", $statuses)) and (strlen($status[$i])>0) )
+				{
+				$statusesTXT = sprintf("%8s", $status[$i]);
+				$statusesHEAD .= "----------+";
+				$statusesHTML .= " $statusesTXT |";
+				$statusesFILE .= "$statusesTXT,";
+				$statuses .= "$status[$i]-";
+				$statusesARY[$j] = $status[$i];
+				$j++;
+				}
+			if (!eregi("-$user[$i]-", $users))
+				{
+				$users .= "$user[$i]-";
+				$usersARY[$k] = $user[$i];
+				$user_namesARY[$k] = $full_name[$i];
+				$k++;
+				}
+			}
+		$i++;
+		}
+
+	if ($file_download < 1)
+		{
+		echo "CALLS STATS BREAKDOWN:\n";
+		echo "+-----------------+----------+--------+--------+--------+$statusesHEAD\n";
+		echo "| USER NAME       | ID       | CALLS  | CIcalls| DNC/CI%|$statusesHTML\n";
+		echo "+-----------------+----------+--------+--------+--------+$statusesHEAD\n";
+		}
+	else
+		{
+		$file_output .= "USER,ID,CALLS,CIcalls,DNC-CI%,$statusesFILE\n";
+		}
+
+
+	### BEGIN loop through each user ###
+	$m=0;
+	$CIScountTOT=0;
+	$DNCcountTOT=0;
+	while ($m < $k)
+		{
+		$Suser=$usersARY[$m];
+		$Sfull_name=$user_namesARY[$m];
+		$Scalls=0;
+		$SstatusesHTML='';
+		$SstatusesFILE='';
+		$CIScount=0;
+		$DNCcount=0;
+
+		### BEGIN loop through each status ###
+		$n=0;
+		while ($n < $j)
+			{
+			$Sstatus=$statusesARY[$n];
+			$SstatusTXT='';
+			### BEGIN loop through each stat line ###
+			$i=0; $status_found=0;
+			while ($i < $rows_to_print)
+				{
+				if ( ($Suser=="$user[$i]") and ($Sstatus=="$status[$i]") )
+					{
+					$Scalls =		($Scalls + $calls[$i]);
+					if (eregi("\|$status[$i]\|",$customer_interactive_statuses))
+						{
+						$CIScount =	($CIScount + $calls[$i]);
+						$CIScountTOT =	($CIScountTOT + $calls[$i]);
+						}
+					if (eregi("DNC", $status[$i]))
+						{
+						$DNCcount =	($DNCcount + $calls[$i]);
+						$DNCcountTOT =	($DNCcountTOT + $calls[$i]);
+						}
+					$SstatusTXT = sprintf("%8s", $calls[$i]);
+					$SstatusesHTML .= " $SstatusTXT |";
+					$SstatusesFILE .= "$SstatusTXT,";
+					$status_found++;
+					}
+				$i++;
+				}
+			if ($status_found < 1)
+				{
+				$SstatusesHTML .= "        0 |";
+				$SstatusesFILE .= "0,";
+				}
+			### END loop through each stat line ###
+			$n++;
+			}
+		### END loop through each status ###
+		$TOTcalls=($TOTcalls + $Scalls);
+
+		$RAWuser = $Suser;
+		$RAWcalls = $Scalls;
+		$RAWcis = $CIScount;
+		$Scalls =	sprintf("%6s", $Scalls);
+		$CIScount =	sprintf("%6s", $CIScount);
+
+		if ($non_latin < 1)
+			{
+			 $Sfull_name=	sprintf("%-15s", $Sfull_name); 
+				while(strlen($Sfull_name)>15) {$Sfull_name = substr("$Sfull_name", 0, -1);}
+			 $Suser =		sprintf("%-8s", $Suser);
+				while(strlen($Suser)>8) {$Suser = substr("$Suser", 0, -1);}
+			}
+		else
+			{	
+				$Sfull_name=	sprintf("%-45s", $Sfull_name); 
+			 while(mb_strlen($Sfull_name,'utf-8')>15) {$Sfull_name = mb_substr("$Sfull_name", 0, -1,'utf-8');}
+
+				$Suser =	sprintf("%-24s", $Suser);
+			 while(mb_strlen($Suser,'utf-8')>8) {$Suser = mb_substr("$Suser", 0, -1,'utf-8');}
+			}
+
+		if ( ($DNCcount < 1) or ($CIScount < 1) )
+			{$DNCcountPCTs=0;}
+		else
+			{
+			$DNCcountPCTs = ( ($DNCcount / $CIScount) * 100);
+			}
+		$RAWdncPCT = $DNCcountPCTs;
+	#	$DNCcountPCTs = round($DNCcountPCTs,2);
+		$DNCcountPCTs = round($DNCcountPCTs);
+		$rawDNCcountPCTs = $DNCcountPCTs;
+	#	$DNCcountPCTs = sprintf("%3.2f", $DNCcountPCTs);
+		$DNCcountPCTs = sprintf("%6s", $DNCcountPCTs);
+
+		if ($file_download < 1)
+			{
+			$Toutput = "| $Sfull_name | $Suser | $Scalls | $CIScount | $DNCcountPCTs%|$SstatusesHTML\n";
+			}
+		else
+			{
+			$fileToutput = "$Sfull_name,$RAWuser,$RAWcalls,$RAWcis,$rawDNCcountPCTs%,$SstatusesFILE\n";
+			}
+
+		$TOPsorted_output[$m] = $Toutput;
+		$TOPsorted_outputFILE[$m] = $fileToutput;
+
+		if ($stage == 'ID')
+			{
+			$TOPsort[$m] =	'' . sprintf("%08s", $RAWuser) . '-----' . $m . '-----' . sprintf("%020s", $RAWuser);
+			$TOPsortTALLY[$m]=$RAWcalls;
+			}
+		if ($stage == 'LEADS')
+			{
+			$TOPsort[$m] =	'' . sprintf("%08s", $RAWcalls) . '-----' . $m . '-----' . sprintf("%020s", $RAWuser);
+			$TOPsortTALLY[$m]=$RAWcalls;
+			}
+		if ($stage == 'TIME')
+			{
+			$TOPsort[$m] =	'' . sprintf("%08s", $Stime) . '-----' . $m . '-----' . sprintf("%020s", $RAWuser);
+			$TOPsortTALLY[$m]=$Stime;
+			}
+		if ($stage == 'CI')
+			{
+			$TOPsort[$m] =	'' . sprintf("%08s", $RAWcis) . '-----' . $m . '-----' . sprintf("%020s", $RAWuser);
+			$TOPsortTALLY[$m]=$RAWcis;
+			}
+		if ($stage == 'DNCCI')
+			{
+			$TOPsort[$m] =	'' . sprintf("%08s", $RAWdncPCT) . '-----' . $m . '-----' . sprintf("%020s", $RAWuser);
+			$TOPsortTALLY[$m]=$RAWdncPCT;
+			}
+		if (!ereg("ID|TIME|LEADS|CI|DNCCI",$stage))
+			if ($file_download < 1)
+				{echo "$Toutput";}
+			else
+				{$file_output .= "$fileToutput";}
+
+		if ($TOPsortMAX < $TOPsortTALLY[$m]) {$TOPsortMAX = $TOPsortTALLY[$m];}
+
+		$m++;
+		}
+	### END loop through each user ###
+
+	$TOT_AGENTS = sprintf("%4s", $m);
+
+
+	### BEGIN sort through output to display properly ###
+	if (ereg("ID|TIME|LEADS|CI|DNCCI",$stage))
+		{
+		if (ereg("ID",$stage))
+			{sort($TOPsort, SORT_NUMERIC);}
+		if (ereg("TIME|LEADS|CI|DNCCI",$stage))
+			{rsort($TOPsort, SORT_NUMERIC);}
+
+		$m=0;
+		while ($m < $k)
+			{
+			$sort_split = explode("-----",$TOPsort[$m]);
+			$i = $sort_split[1];
+			$sort_order[$m] = "$i";
+			if ($file_download < 1)
+				{echo "$TOPsorted_output[$i]";}
+			else
+				{$file_output .= "$TOPsorted_outputFILE[$i]";}
+			$m++;
+			}
+		}
+	### END sort through output to display properly ###
+
+
+
+	###### LAST LINE FORMATTING ##########
+	### BEGIN loop through each status ###
+	$SUMstatusesHTML='';
+	$n=0;
+	while ($n < $j)
+		{
+		$Scalls=0;
+		$Sstatus=$statusesARY[$n];
+		$SUMstatusTXT='';
+		### BEGIN loop through each stat line ###
+		$i=0; $status_found=0;
+		while ($i < $rows_to_print)
+			{
+			if ($Sstatus=="$status[$i]")
+				{
+				$Scalls =		($Scalls + $calls[$i]);
+				$status_found++;
+				}
+			$i++;
+			}
+		### END loop through each stat line ###
+		if ($status_found < 1)
+			{
+			$SUMstatusesHTML .= "        0 |";
+			}
+		else
+			{
+			$SUMstatusTXT = sprintf("%8s", $Scalls);
+			$SUMstatusesHTML .= " $SUMstatusTXT |";
+			$SUMstatusesFILE .= "$SUMstatusTXT,";
+			}
+		$n++;
+		}
+	### END loop through each status ###
+
+	$TOTcalls = sprintf("%7s", $TOTcalls);
+	$CIScountTOT = sprintf("%7s", $CIScountTOT);
+	$DNCcountPCT = ( ($DNCcountTOT / $CIScountTOT) * 100);
+	$DNCcountPCT = round($DNCcountPCT,2);
+	$DNCcountPCT = sprintf("%3.2f", $DNCcountPCT);
+	if ( ($DNCcountTOT < 1) or ($CIScountTOT < 1) )
+		{$DNCcountPCT=0;}
+	else
+		{
+		$DNCcountPCT = ( ($DNCcountTOT / $CIScountTOT) * 100);
+		}
+	#$DNCcountPCT = round($DNCcountPCT,2);
+	$DNCcountPCT = round($DNCcountPCT);
+	#$DNCcountPCT = sprintf("%3.2f", $DNCcountPCT);
+	$DNCcountPCT = sprintf("%6s", $DNCcountPCT);
+
+	if ($file_download < 1)
+		{
+		echo "+-----------------+----------+--------+--------+--------+$statusesHEAD\n";
+		echo "|  TOTALS        AGENTS:$TOT_AGENTS | $TOTcalls| $CIScountTOT| $DNCcountPCT%|$SUMstatusesHTML\n";
+		echo "+----------------------------+--------+--------+--------+$statusesHEAD\n";
+
+		echo "\n\n
"; + } + else + { + $file_output .= "TOTALS,$TOT_AGENTS,$TOTcalls,$CIScountTOT,$DNCcountPCT%,$SUMstatusesFILE\n"; + } + } + +if ($file_download > 0) + { + $FILE_TIME = date("Ymd-His"); + $CSVfilename = "AGENT_STATUS$US$FILE_TIME.csv"; + + // We'll be outputting a TXT file + header('Content-type: application/octet-stream'); + + // It will be called LIST_101_20090209-121212.txt + header("Content-Disposition: attachment; filename=\"$CSVfilename\""); + header('Expires: 0'); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header('Pragma: public'); + ob_clean(); + flush(); + + echo "$file_output"; + + exit; + } + + +echo "
\n"; +echo "
Datas:
"; +echo "\n"; +echo ""; + +?> + + to
"; + +?> + +
Campanhas:
"; +echo "\n"; +echo "
Grupos de Usuário:
"; +echo "\n"; +echo "
Shift:
"; +echo "

\n"; +echo "\n"; +echo "
        "; + +echo "          \n"; +echo " DOWNLOAD | \n"; +echo " RELATÓRIOS \n"; +echo "\n"; +echo "
"; + +echo "
\n\n"; + +echo "
\n"; +echo "\n"; +echo "
\n\n\n\n\n\n\n\n\n\n";
+
+$m=0;
+while ($m < $k)
+	{
+	$sort_split = explode("-----",$TOPsort[$m]);
+	$i = $sort_split[1];
+	$sort_order[$m] = "$i";
+
+	if ( ($TOPsortTALLY[$i] < 1) or ($TOPsortMAX < 1) )
+		{echo "                              \n";}
+	else
+		{
+		echo "                              ";
+		$TOPsortPLOT = ( ($TOPsortTALLY[$i] / $TOPsortMAX) * 110 );
+		$h=0;
+		while ($h <= $TOPsortPLOT)
+			{
+			echo " ";
+			$h++;
+			}
+		echo "\n";
+		}
+	$m++;
+	}
+
+echo "\n";
+
+?>
+
+
\ No newline at end of file
diff --git a/LANG_www/vicidial_br/AST_agent_time_detail.php b/LANG_www/vicidial_br/AST_agent_time_detail.php
new file mode 100644
index 00000000..bc97301f
--- /dev/null
+++ b/LANG_www/vicidial_br/AST_agent_time_detail.php
@@ -0,0 +1,910 @@
+    LICENSE: AGPLv2
+#
+# CHANGES
+# 90522-0723 - First build
+# 90908-1103 - Added DEAD time stats
+# 100203-1147 - Added CUSTOMER time statistics
+# 100214-1421 - Sort menu alphabetically
+# 100216-0042 - Added popup date selector
+#
+
+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["group"]))					{$group=$_GET["group"];}
+	elseif (isset($_POST["group"]))			{$group=$_POST["group"];}
+if (isset($_GET["user_group"]))				{$user_group=$_GET["user_group"];}
+	elseif (isset($_POST["user_group"]))	{$user_group=$_POST["user_group"];}
+if (isset($_GET["shift"]))					{$shift=$_GET["shift"];}
+	elseif (isset($_POST["shift"]))			{$shift=$_POST["shift"];}
+if (isset($_GET["stage"]))					{$stage=$_GET["stage"];}
+	elseif (isset($_POST["stage"]))			{$stage=$_POST["stage"];}
+if (isset($_GET["file_download"]))			{$file_download=$_GET["file_download"];}
+	elseif (isset($_POST["file_download"]))	{$file_download=$_POST["file_download"];}
+if (isset($_GET["DB"]))						{$DB=$_GET["DB"];}
+	elseif (isset($_POST["DB"]))			{$DB=$_POST["DB"];}
+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 (strlen($shift)<2) {$shift='ALL';}
+if (strlen($stage)<2) {$stage='NAME';}
+
+#############################################
+##### 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);
+if ($qm_conf_ct > 0)
+	{
+	$row=mysql_fetch_row($rslt);
+	$non_latin =					$row[0];
+	}
+##### END SETTINGS LOOKUP #####
+###########################################
+
+$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
+$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
+
+$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;
+	}
+
+$MT[0]='';
+$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;}
+if (!isset($end_date)) {$end_date = $NOW_DATE;}
+
+$stmt="select campaign_id from vicidial_campaigns order by campaign_id;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$campaigns_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $campaigns_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$groups[$i] =$row[0];
+	$i++;
+	}
+$stmt="select user_group from vicidial_user_groups order by user_group;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$user_groups_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $user_groups_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$user_groups[$i] =$row[0];
+	$i++;
+	}
+
+$i=0;
+$group_string='|';
+$group_ct = count($group);
+while($i < $group_ct)
+	{
+	$group_string .= "$group[$i]|";
+	$group_SQL .= "'$group[$i]',";
+	$groupQS .= "&group[]=$group[$i]";
+	$i++;
+	}
+if ( (ereg("--ALL--",$group_string) ) or ($group_ct < 1) )
+	{$group_SQL = "";}
+else
+	{
+	$group_SQL = eregi_replace(",$",'',$group_SQL);
+	$group_SQL = "and campaign_id IN($group_SQL)";
+	}
+
+$i=0;
+$user_group_string='|';
+$user_group_ct = count($user_group);
+while($i < $user_group_ct)
+	{
+	$user_group_string .= "$user_group[$i]|";
+	$user_group_SQL .= "'$user_group[$i]',";
+	$user_groupQS .= "&user_group[]=$user_group[$i]";
+	$i++;
+	}
+if ( (ereg("--ALL--",$user_group_string) ) or ($user_group_ct < 1) )
+	{$user_group_SQL = "";}
+else
+	{
+	$user_group_SQL = eregi_replace(",$",'',$user_group_SQL);
+	$user_group_SQL = "and vicidial_agent_log.user_group IN($user_group_SQL)";
+	$TCuser_group_SQL = eregi_replace(",$",'',$TCuser_group_SQL);
+	$TCuser_group_SQL = "and user_group IN($TCuser_group_SQL)";
+	}
+
+if ($DB) {echo "$user_group_string|$user_group_ct|$user_groupQS|$i
";} + +$stmt="select distinct pause_code,pause_code_name from vicidial_pause_codes;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$statha_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $statha_to_print) + { + $row=mysql_fetch_row($rslt); + $pause_code[$i] = "$row[0]"; + $pause_code_name[$i] = "$row[1]"; + $i++; + } + +$LINKbase = "$PHP_SELF?query_date=$query_date&end_date=$end_date$groupQS$user_groupQS&shift=$shift&DB=$DB"; + +if ($file_download < 1) + { + ?> + + + + + + \n"; + echo "\n"; + + echo "\n"; + echo "Agent Time Detail\n"; + echo ""; + + $short_header=1; + + require("admin_header.php"); + + echo "\n"; + echo "\n"; + echo "
\n";
+	}
+
+if ( (strlen($group[0]) < 1) or (strlen($user_group[0]) < 1) )
+	{
+	echo "\n";
+	echo "PLEASE SELECT A CAMPAIGN OR USER GROUP AND DATE-TIME ABOVE AND CLICK SUBMIT\n";
+	echo " NOTE: stats taken from shift specified\n";
+	}
+
+else
+	{
+	if ($shift == 'TEST') 
+		{
+		$time_BEGIN = "09:45:00";  
+		$time_END = "10:00:00";
+		}
+	if ($shift == 'AM') 
+		{
+		$time_BEGIN=$AM_shift_BEGIN;
+		$time_END=$AM_shift_END;
+		if (strlen($time_BEGIN) < 6) {$time_BEGIN = "03:45:00";}   
+		if (strlen($time_END) < 6) {$time_END = "15:15:00";}
+		}
+	if ($shift == 'PM') 
+		{
+		$time_BEGIN=$PM_shift_BEGIN;
+		$time_END=$PM_shift_END;
+		if (strlen($time_BEGIN) < 6) {$time_BEGIN = "15:15:00";}
+		if (strlen($time_END) < 6) {$time_END = "23:15:00";}
+		}
+	if ($shift == 'ALL') 
+		{
+		if (strlen($time_BEGIN) < 6) {$time_BEGIN = "00:00:00";}
+		if (strlen($time_END) < 6) {$time_END = "23:59:59";}
+		}
+	$query_date_BEGIN = "$query_date $time_BEGIN";   
+	$query_date_END = "$end_date $time_END";
+
+	if (strlen($user_group)>0) {$ugSQL="and vicidial_agent_log.user_group='$user_group'";}
+	else {$ugSQL='';}
+
+	if ($file_download < 1)
+		{
+		echo "Agent Time Detail                     $NOW_TIME\n";
+
+		echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
+		}
+	else
+		{
+		$file_output .= "Agent Time Detail                     $NOW_TIME\n";
+		$file_output .= "Time range: $query_date_BEGIN to $query_date_END\n\n";
+		}
+
+
+
+	############################################################################
+	##### BEGIN gathering information from the database section
+	############################################################################
+
+	### BEGIN gather user IDs and names for matching up later
+	$stmt="select full_name,user from vicidial_users order by user limit 100000;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$users_to_print = mysql_num_rows($rslt);
+	$i=0;
+	while ($i < $users_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		$ULname[$i] =	$row[0];
+		$ULuser[$i] =	$row[1];
+		$i++;
+		}
+	### END gather user IDs and names for matching up later
+
+
+	### BEGIN gather timeclock records per agent
+	$stmt="select user,sum(login_sec) from vicidial_timeclock_log where event IN('LOGIN','START') and event_date >= '$query_date_BEGIN' and event_date <= '$query_date_END' $TCuser_group_SQL group by user limit 10000000;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$punches_to_print = mysql_num_rows($rslt);
+	$i=0;
+	while ($i < $punches_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		$TCuser[$i] =	$row[0];
+		$TCtime[$i] =	$row[1];
+		$i++;
+		}
+	### END gather timeclock records per agent
+
+
+	### BEGIN gather pause code information by user IDs
+	$sub_statuses='-';
+	$sub_statusesTXT='';
+	$sub_statusesHEAD='';
+	$sub_statusesHTML='';
+	$sub_statusesFILE='';
+	$sub_statusesARY=$MT;
+	$sub_status_count=0;
+	$PCusers='-';
+	$PCusersARY=$MT;
+	$PCuser_namesARY=$MT;
+	$user_count=0;
+	$stmt="select user,sum(pause_sec),sub_status from vicidial_agent_log where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and pause_sec > 0 and pause_sec < 30000 $group_SQL $user_group_SQL group by user,sub_status order by user,sub_status desc limit 10000000;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$subs_to_print = mysql_num_rows($rslt);
+	$i=0;
+	while ($i < $subs_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		$PCuser[$i] =		$row[0];
+		$PCpause_sec[$i] =	$row[1];
+		$sub_status[$i] =	$row[2];
+
+		if (!eregi("-$sub_status[$i]-", $sub_statuses))
+			{
+			$sub_statusesTXT = sprintf("%10s", $sub_status[$i]);
+			$sub_statusesHEAD .= "------------+";
+			$sub_statusesHTML .= " $sub_statusesTXT |";
+			$sub_statusesFILE .= ",$sub_status[$i]";
+			$sub_statuses .= "$sub_status[$i]-";
+			$sub_statusesARY[$sub_status_count] = $sub_status[$i];
+			$sub_status_count++;
+			}
+		if (!eregi("-$PCuser[$i]-", $PCusers))
+			{
+			$PCusers .= "$PCuser[$i]-";
+			$PCusersARY[$user_count] = $PCuser[$i];
+			$user_count++;
+			}
+
+		$i++;
+		}
+	### END gather pause code information by user IDs
+
+
+	##### BEGIN Gather all agent time records and parse through them in PHP to save on DB load
+	$stmt="select user,wait_sec,talk_sec,dispo_sec,pause_sec,lead_id,status,dead_sec from vicidial_agent_log where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' $group_SQL $user_group_SQL limit 10000000;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$rows_to_print = mysql_num_rows($rslt);
+	$i=0;
+	$j=0;
+	$k=0;
+	$uc=0;
+	while ($i < $rows_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		$user =			$row[0];
+		$wait =			$row[1];
+		$talk =			$row[2];
+		$dispo =		$row[3];
+		$pause =		$row[4];
+		$lead =			$row[5];
+		$status =		$row[6];
+		$dead =			$row[7];
+		if ($wait > 30000) {$wait=0;}
+		if ($talk > 30000) {$talk=0;}
+		if ($dispo > 30000) {$dispo=0;}
+		if ($pause > 30000) {$pause=0;}
+		if ($dead > 30000) {$dead=0;}
+		$customer =		($talk - $dead);
+		if ($customer < 1)
+			{$customer=0;}
+		$TOTwait =	($TOTwait + $wait);
+		$TOTtalk =	($TOTtalk + $talk);
+		$TOTdispo =	($TOTdispo + $dispo);
+		$TOTpause =	($TOTpause + $pause);
+		$TOTdead =	($TOTdead + $dead);
+		$TOTcustomer =	($TOTcustomer + $customer);
+		$TOTALtime = ($TOTALtime + $pause + $dispo + $talk + $wait);
+		if ( ($lead > 0) and ((!eregi("NULL",$status)) and (strlen($status) > 0)) ) {$TOTcalls++;}
+		
+		$user_found=0;
+		if ($uc < 1) 
+			{
+			$Suser[$uc] = $user;
+			$uc++;
+			}
+		$m=0;
+		while ( ($m < $uc) and ($m < 50000) )
+			{
+			if ($user == "$Suser[$m]")
+				{
+				$user_found++;
+
+				$Swait[$m] =	($Swait[$m] + $wait);
+				$Stalk[$m] =	($Stalk[$m] + $talk);
+				$Sdispo[$m] =	($Sdispo[$m] + $dispo);
+				$Spause[$m] =	($Spause[$m] + $pause);
+				$Sdead[$m] =	($Sdead[$m] + $dead);
+				$Scustomer[$m] =	($Scustomer[$m] + $customer);
+				if ( ($lead > 0) and ((!eregi("NULL",$status)) and (strlen($status) > 0)) ) {$Scalls[$m]++;}
+				}
+			$m++;
+			}
+		if ($user_found < 1)
+			{
+			$Scalls[$uc] =	0;
+			$Suser[$uc] =	$user;
+			$Swait[$uc] =	$wait;
+			$Stalk[$uc] =	$talk;
+			$Sdispo[$uc] =	$dispo;
+			$Spause[$uc] =	$pause;
+			$Sdead[$uc] =	$dead;
+			$Scustomer[$uc] =	$customer;
+			if ($lead > 0) {$Scalls[$uc]++;}
+			$uc++;
+			}
+
+		$i++;
+		}
+	if ($DB) {echo "Done gathering $i records, analyzing...
\n";} + ##### END Gather all agent time records and parse through them in PHP to save on DB load + + ############################################################################ + ##### END gathering information from the database section + ############################################################################ + + + + + ##### BEGIN print the output to screen or put into file output variable + if ($file_download < 1) + { + echo "AGENT TIME BREAKDOWN:\n"; + echo "+-----------------+----------+----------+------------+------------+------------+------------+------------+------------+------------+------------+ +$sub_statusesHEAD\n"; + echo "| USER NAME | ID | CALLS | TIME CLOCK | AGENT TIME | WAIT | TALK | DISPO | PAUSE | DEAD | CUSTOMER | |$sub_statusesHTML\n"; + echo "+-----------------+----------+----------+------------+------------+------------+------------+------------+------------+------------+------------+ +$sub_statusesHEAD\n"; + } + else + { + $file_output .= "USER,ID,CALLS,TIME CLOCK,AGENT TIME,WAIT,TALK,DISPO,PAUSE,DEAD,CUSTOMER$sub_statusesFILE\n"; + } + ##### END print the output to screen or put into file output variable + + + + + + ############################################################################ + ##### BEGIN formatting data for output section + ############################################################################ + + ##### BEGIN loop through each user formatting data for output + $AUTOLOGOUTflag=0; + $m=0; + while ( ($m < $uc) and ($m < 50000) ) + { + $SstatusesHTML=''; + $SstatusesFILE=''; + $Stime[$m] = ($Swait[$m] + $Stalk[$m] + $Sdispo[$m] + $Spause[$m]); + $RAWuser = $Suser[$m]; + $RAWcalls = $Scalls[$m]; + $RAWtimeSEC = $Stime[$m]; + + $Swait[$m]= sec_convert($Swait[$m],'H'); + $Stalk[$m]= sec_convert($Stalk[$m],'H'); + $Sdispo[$m]= sec_convert($Sdispo[$m],'H'); + $Spause[$m]= sec_convert($Spause[$m],'H'); + $Sdead[$m]= sec_convert($Sdead[$m],'H'); + $Scustomer[$m]= sec_convert($Scustomer[$m],'H'); + $Stime[$m]= sec_convert($Stime[$m],'H'); + + $RAWtime = $Stime[$m]; + $RAWwait = $Swait[$m]; + $RAWtalk = $Stalk[$m]; + $RAWdispo = $Sdispo[$m]; + $RAWpause = $Spause[$m]; + $RAWdead = $Sdead[$m]; + $RAWcustomer = $Scustomer[$m]; + + $n=0; + $user_name_found=0; + while ($n < $users_to_print) + { + if ($Suser[$m] == "$ULuser[$n]") + { + $user_name_found++; + $RAWname = $ULname[$n]; + $Sname[$m] = $ULname[$n]; + } + $n++; + } + if ($user_name_found < 1) + { + $RAWname = "NOT IN SYSTEM"; + $Sname[$m] = $RAWname; + } + + $n=0; + $punches_found=0; + while ($n < $punches_to_print) + { + if ($Suser[$m] == "$TCuser[$n]") + { + $punches_found++; + $RAWtimeTCsec = $TCtime[$n]; + $TOTtimeTC = ($TOTtimeTC + $TCtime[$n]); + $StimeTC[$m]= sec_convert($TCtime[$n],'H'); + $RAWtimeTC = $StimeTC[$m]; + $StimeTC[$m] = sprintf("%10s", $StimeTC[$m]); + } + $n++; + } + if ($punches_found < 1) + { + $RAWtimeTCsec = "0"; + $StimeTC[$m]= "0:00"; + $RAWtimeTC = $StimeTC[$m]; + $StimeTC[$m] = sprintf("%10s", $StimeTC[$m]); + } + + ### Check if the user had an AUTOLOGOUT timeclock event during the time period + $TCuserAUTOLOGOUT = ' '; + $stmt="select count(*) from vicidial_timeclock_log where event='AUTOLOGOUT' and user='$Suser[$m]' and event_date >= '$query_date_BEGIN' and event_date <= '$query_date_END';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $autologout_results = mysql_num_rows($rslt); + if ($autologout_results > 0) + { + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + { + $TCuserAUTOLOGOUT = '*'; + $AUTOLOGOUTflag++; + } + } + + ### BEGIN loop through each status ### + $n=0; + while ($n < $sub_status_count) + { + $Sstatus=$sub_statusesARY[$n]; + $SstatusTXT=''; + ### BEGIN loop through each stat line ### + $i=0; $status_found=0; + while ( ($i < $subs_to_print) and ($status_found < 1) ) + { + if ( ($Suser[$m]=="$PCuser[$i]") and ($Sstatus=="$sub_status[$i]") ) + { + $USERcodePAUSE_MS = sec_convert($PCpause_sec[$i],'H'); + $pfUSERcodePAUSE_MS = sprintf("%10s", $USERcodePAUSE_MS); + + $SstatusTXT = sprintf("%10s", $pfUSERcodePAUSE_MS); + $SstatusesHTML .= " $SstatusTXT |"; + $SstatusesFILE .= ",$pfUSERcodePAUSE_MS"; + $status_found++; + } + $i++; + } + if ($status_found < 1) + { + $SstatusesHTML .= " 0:00 |"; + } + ### END loop through each stat line ### + $n++; + } + ### END loop through each status ### + + $Swait[$m]= sprintf("%10s", $Swait[$m]); + $Stalk[$m]= sprintf("%10s", $Stalk[$m]); + $Sdispo[$m]= sprintf("%10s", $Sdispo[$m]); + $Spause[$m]= sprintf("%10s", $Spause[$m]); + $Sdead[$m]= sprintf("%10s", $Sdead[$m]); + $Scustomer[$m]= sprintf("%10s", $Scustomer[$m]); + $Scalls[$m]= sprintf("%8s", $Scalls[$m]); + $Stime[$m]= sprintf("%10s", $Stime[$m]); + + if ($non_latin < 1) + { + $Sname[$m]= sprintf("%-15s", $Sname[$m]); + while(strlen($Sname[$m])>15) {$Sname[$m] = substr("$Sname[$m]", 0, -1);} + $Suser[$m] = sprintf("%-8s", $Suser[$m]); + while(strlen($Suser[$m])>8) {$Suser[$m] = substr("$Suser[$m]", 0, -1);} + } + else + { + $Sname[$m]= sprintf("%-45s", $Sname[$m]); + while(mb_strlen($Sname[$m],'utf-8')>15) {$Sname[$m] = mb_substr("$Sname[$m]", 0, -1,'utf-8');} + $Suser[$m] = sprintf("%-24s", $Suser[$m]); + while(mb_strlen($Suser[$m],'utf-8')>8) {$Suser[$m] = mb_substr("$Suser[$m]", 0, -1,'utf-8');} + } + + + if ($file_download < 1) + { + $Toutput = "| $Sname[$m] | $Suser[$m] | $Scalls[$m] | $StimeTC[$m]$TCuserAUTOLOGOUT| $Stime[$m] | $Swait[$m] | $Stalk[$m] | $Sdispo[$m] | $Spause[$m] | $Sdead[$m] | $Scustomer[$m] | |$SstatusesHTML\n"; + } + else + { + $fileToutput = "$RAWname,$RAWuser,$RAWcalls,$RAWtimeTC,$RAWtime,$RAWwait,$RAWtalk,$RAWdispo,$RAWpause,$RAWdead,$RAWcustomer$SstatusesFILE\n"; + } + + $TOPsorted_output[$m] = $Toutput; + $TOPsorted_outputFILE[$m] = $fileToutput; + + if ($stage == 'NAME') + { + $TOPsort[$m] = '' . sprintf("%020s", $RAWname) . '-----' . $m . '-----' . sprintf("%020s", $RAWuser); + $TOPsortTALLY[$m]=$RAWcalls; + } + if ($stage == 'ID') + { + $TOPsort[$m] = '' . sprintf("%08s", $RAWuser) . '-----' . $m . '-----' . sprintf("%020s", $RAWuser); + $TOPsortTALLY[$m]=$RAWcalls; + } + if ($stage == 'LEADS') + { + $TOPsort[$m] = '' . sprintf("%08s", $RAWcalls) . '-----' . $m . '-----' . sprintf("%020s", $RAWuser); + $TOPsortTALLY[$m]=$RAWcalls; + } + if ($stage == 'TIME') + { + $TOPsort[$m] = '' . sprintf("%010s", $RAWtimeSEC) . '-----' . $m . '-----' . sprintf("%020s", $RAWuser); + $TOPsortTALLY[$m]=$RAWtimeSEC; + } + if ($stage == 'TCLOCK') + { + $TOPsort[$m] = '' . sprintf("%010s", $RAWtimeTCsec) . '-----' . $m . '-----' . sprintf("%020s", $RAWuser); + $TOPsortTALLY[$m]=$RAWtimeTCsec; + } + if (!ereg("NAME|ID|TIME|LEADS|TCLOCK",$stage)) + if ($file_download < 1) + {echo "$Toutput";} + else + {$file_output .= "$fileToutput";} + + if ($TOPsortMAX < $TOPsortTALLY[$m]) {$TOPsortMAX = $TOPsortTALLY[$m];} + +# echo "$Suser[$m]|$Sname[$m]|$Swait[$m]|$Stalk[$m]|$Sdispo[$m]|$Spause[$m]|$Scalls[$m]\n"; + $m++; + } + ##### END loop through each user formatting data for output + + + $TOT_AGENTS = sprintf("%4s", $m); + $k=$m; + + if ($DB) {echo "Done analyzing... $TOTwait|$TOTtalk|$TOTdispo|$TOTpause|$TOTdead|$TOTcustomer|$TOTALtime|$TOTcalls|$uc|
\n";} + + + ### BEGIN sort through output to display properly ### + if (ereg("NAME|ID|TIME|LEADS|TCLOCK",$stage)) + { + if (ereg("ID",$stage)) + {sort($TOPsort, SORT_NUMERIC);} + if (ereg("TIME|LEADS|TCLOCK",$stage)) + {rsort($TOPsort, SORT_NUMERIC);} + if (ereg("NAME",$stage)) + {rsort($TOPsort, SORT_STRING);} + + $m=0; + while ($m < $k) + { + $sort_split = explode("-----",$TOPsort[$m]); + $i = $sort_split[1]; + $sort_order[$m] = "$i"; + if ($file_download < 1) + {echo "$TOPsorted_output[$i]";} + else + {$file_output .= "$TOPsorted_outputFILE[$i]";} + $m++; + } + } + ### END sort through output to display properly ### + + ############################################################################ + ##### END formatting data for output section + ############################################################################ + + + + + ############################################################################ + ##### BEGIN last line totals output section + ############################################################################ + $SUMstatusesHTML=''; + $SUMstatusesFILE=''; + $TOTtotPAUSE=0; + $n=0; + while ($n < $sub_status_count) + { + $Scalls=0; + $Sstatus=$sub_statusesARY[$n]; + $SUMstatusTXT=''; + ### BEGIN loop through each stat line ### + $i=0; $status_found=0; + while ($i < $subs_to_print) + { + if ($Sstatus=="$sub_status[$i]") + { + $Scalls = ($Scalls + $PCpause_sec[$i]); + $status_found++; + } + $i++; + } + ### END loop through each stat line ### + if ($status_found < 1) + { + $SUMstatusesHTML .= " 0 |"; + } + else + { + $TOTtotPAUSE = ($TOTtotPAUSE + $Scalls); + + $USERsumstatPAUSE_MS = sec_convert($Scalls,'H'); + $pfUSERsumstatPAUSE_MS = sprintf("%11s", $USERsumstatPAUSE_MS); + + $SUMstatusTXT = sprintf("%10s", $pfUSERsumstatPAUSE_MS); + $SUMstatusesHTML .= "$SUMstatusTXT |"; + $SUMstatusesFILE .= ",$pfUSERsumstatPAUSE_MS"; + } + $n++; + } + ### END loop through each status ### + + ### call function to calculate and print dialable leads + $TOTwait = sec_convert($TOTwait,'H'); + $TOTtalk = sec_convert($TOTtalk,'H'); + $TOTdispo = sec_convert($TOTdispo,'H'); + $TOTpause = sec_convert($TOTpause,'H'); + $TOTdead = sec_convert($TOTdead,'H'); + $TOTcustomer = sec_convert($TOTcustomer,'H'); + $TOTALtime = sec_convert($TOTALtime,'H'); + $TOTtimeTC = sec_convert($TOTtimeTC,'H'); + + $TOTcalls = sprintf("%8s", $TOTcalls); + $TOTwait = sprintf("%11s", $TOTwait); + $TOTtalk = sprintf("%11s", $TOTtalk); + $TOTdispo = sprintf("%11s", $TOTdispo); + $TOTpause = sprintf("%11s", $TOTpause); + $TOTdead = sprintf("%11s", $TOTdead); + $TOTcustomer = sprintf("%11s", $TOTcustomer); + $TOTALtime = sprintf("%11s", $TOTALtime); + $TOTtimeTC = sprintf("%11s", $TOTtimeTC); + ###### END LAST LINE TOTALS FORMATTING ########## + + + + if ($file_download < 1) + { + echo "+-----------------+----------+----------+------------+------------+------------+------------+------------+------------+------------+------------+ +$sub_statusesHEAD\n"; + echo "| TOTALS AGENTS:$TOT_AGENTS | $TOTcalls |$TOTtimeTC |$TOTALtime |$TOTwait |$TOTtalk |$TOTdispo |$TOTpause |$TOTdead |$TOTcustomer | |$SUMstatusesHTML\n"; + echo "+-----------------+----------+----------+------------+------------+------------+------------+------------+------------+------------+------------+ +$sub_statusesHEAD\n"; + if ($AUTOLOGOUTflag > 0) + {echo " * denotes AUTOLOGOUT from timeclock\n";} + echo "\n\n
"; + } + else + { + $file_output .= "TOTALS,$TOT_AGENTS,$TOTcalls,$TOTtimeTC,$TOTALtime,$TOTwait,$TOTtalk,$TOTdispo,$TOTpause,$TOTdead,$TOTcustomer$SUMstatusesFILE\n"; + } + } + + ############################################################################ + ##### END formatting data for output section + ############################################################################ + + + + + +if ($file_download > 0) + { + $FILE_TIME = date("Ymd-His"); + $CSVfilename = "AGENT_TIME$US$FILE_TIME.csv"; + + // We'll be outputting a TXT file + header('Content-type: application/octet-stream'); + + // It will be called LIST_101_20090209-121212.txt + header("Content-Disposition: attachment; filename=\"$CSVfilename\""); + header('Expires: 0'); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header('Pragma: public'); + ob_clean(); + flush(); + + echo "$file_output"; + + exit; + } + + +############################################################################ +##### BEGIN HTML form section +############################################################################ +echo "
\n"; +echo "
Dates:
"; +echo "\n"; +echo ""; + +?> + + to
"; + +?> + +
Campaigns:
"; +echo "\n"; +echo "
User Groups:
"; +echo "\n"; +echo "
Shift:
"; +echo "

\n"; +echo "\n"; +echo "
        "; + +echo "          \n"; +echo " DOWNLOAD | \n"; +echo " REPORTS \n"; +echo "\n"; +echo "
"; + +echo "
\n\n"; +############################################################################ +##### END HTML form section +############################################################################ + + +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $STARTtime); +echo "$RUNtime\n"; + + +##### BEGIN horizontal yellow transparent bar graph overlay on top of agent stats +echo "
\n"; +echo "\n"; +echo "
\n\n\n\n\n\n\n\n";
+
+if ($stage == 'NAME') {$k=0;}
+$m=0;
+while ($m < $k)
+	{
+	$sort_split = explode("-----",$TOPsort[$m]);
+	$i = $sort_split[1];
+	$sort_order[$m] = "$i";
+
+	if ( ($TOPsortTALLY[$i] < 1) or ($TOPsortMAX < 1) )
+		{echo "                              \n";}
+	else
+		{
+		echo "                              ";
+		$TOPsortPLOT = ( ($TOPsortTALLY[$i] / $TOPsortMAX) * 110 );
+		$h=0;
+		while ($h <= $TOPsortPLOT)
+			{
+			echo " ";
+			$h++;
+			}
+		echo "\n";
+		}
+	$m++;
+	}
+
+echo "\n";
+##### END horizontal yellow transparent bar graph overlay on top of agent stats
+
+?>
+
+
diff --git a/LANG_www/vicidial_br/AST_agent_time_sheet.php b/LANG_www/vicidial_br/AST_agent_time_sheet.php
new file mode 100644
index 00000000..b5c0e6fb
--- /dev/null
+++ b/LANG_www/vicidial_br/AST_agent_time_sheet.php
@@ -0,0 +1,311 @@
+    LICENSE: AGPLv2
+#
+# CHANGES
+#
+# 60619-1729 - Added variable filtering to eliminate SQL injection attack threat
+#            - Added required user/pass to gain access to this page
+# 80624-0132 - Added vicidial_timeclock entries
+# 90310-0745 - Added admin header
+# 90508-0644 - Changed to PHP long tags
+# 90524-2231 - Changed to use functions.php for seconds to HH:MM:SS conversion
+#
+
+require("dbconnect.php");
+require("functions.php");
+
+#############################################
+##### START SYSTEM_SETTINGS LOOKUP #####
+$stmt = "SELECT use_non_latin,outbound_autodial_active,user_territories_active FROM system_settings;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$ss_conf_ct = mysql_num_rows($rslt);
+if ($ss_conf_ct > 0)
+	{
+	$row=mysql_fetch_row($rslt);
+	$non_latin =						$row[0];
+	$SSoutbound_autodial_active =		$row[1];
+	$user_territories_active =			$row[2];
+	}
+##### END SETTINGS LOOKUP #####
+###########################################
+
+$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
+$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
+$PHP_SELF=$_SERVER['PHP_SELF'];
+if (isset($_GET["agent"]))				{$agent=$_GET["agent"];}
+	elseif (isset($_POST["agent"]))		{$agent=$_POST["agent"];}
+if (isset($_GET["query_date"]))				{$query_date=$_GET["query_date"];}
+	elseif (isset($_POST["query_date"]))	{$query_date=$_POST["query_date"];}
+if (isset($_GET["calls_summary"]))			{$calls_summary=$_GET["calls_summary"];}
+	elseif (isset($_POST["calls_summary"]))	{$calls_summary=$_POST["calls_summary"];}
+if (isset($_GET["submit"]))				{$submit=$_GET["submit"];}
+	elseif (isset($_POST["submit"]))	{$submit=$_POST["submit"];}
+if (isset($_GET["ENVIAR"]))				{$ENVIAR=$_GET["ENVIAR"];}
+	elseif (isset($_POST["ENVIAR"]))	{$ENVIAR=$_POST["ENVIAR"];}
+
+$user=$agent;
+
+$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
+$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
+
+$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 "Nome ou Senha inválidos: |$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($query_date)) {$query_date = $NOW_DATE;}
+
+?>
+
+
+
+
+
+\n";
+echo "Agent Planilha de Tempo";
+
+
+##### BEGIN Set variables to make header show properly #####
+$ADD =					'3';
+$hh =					'users';
+$LOGast_admin_access =	'1';
+$ADMIN =				'admin.php';
+$page_width='770';
+$section_width='750';
+$header_font_size='3';
+$subheader_font_size='2';
+$subcamp_font_size='2';
+$header_selected_bold='<b>';
+$header_nonselected_bold='';
+$users_color =		'#FFFF99';
+$users_font =		'BLACK';
+$users_color =		'#E6E6E6';
+$subcamp_color =	'#C6C6C6';
+##### END Set variables to make header show properly #####
+
+require("admin_header.php");
+
+echo "<TABLE WIDTH=$page_width BGCOLOR=\"#F0F5FE\" cellpadding=2 cellspacing=0><TR BGCOLOR=\"#F0F5FE\"><TD>\n";
+
+echo "AgentPlanilha de Horáriofor: $user\n";
+echo "<BR>\n";
+echo "<FORM ACTION=\"$PHP_SELF\" METHOD=GET>   \n";
+echo "Date: <INPUT TYPE=TEXT NAME=query_date SIZE=19 MAXLENGTH=19 VALUE=\"$query_date\">\n";
+echo "Usuário ID: <INPUT TYPE=TEXT NAME=agent SIZE=10 MAXLENGTH=20 VALUE=\"$agent\">\n";
+echo "<INPUT TYPE=Submit NAME=ENVIAR VALUE=ENVIAR>\n";
+echo "</FORM>\n\n";
+
+echo "<PRE><FONT SIZE=3>\n";
+
+
+if (!$agent)
+{
+echo "\n";
+echo "PLEASE SELECT AN AGENTE ID AND DATE-TIME ABOVE AND CLICK ENVIAR\n";
+echo " NOTE: stats taken from available agent log data\n";
+}
+
+else
+{
+$query_date_BEGIN = "$query_date 00:00:00";   
+$query_date_END = "$query_date 23:59:59";
+$time_BEGIN = "00:00:00";   
+$time_END = "23:59:59";
+
+$stmt="select full_name from vicidial_users where user='$agent';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$full_name = $row[0];
+
+echo "AgentPlanilha de Horário                            $NOW_TIME\n";
+
+echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
+echo "---------- AGENTE TIME SHEET: $agent - $full_name -------------\n\n";
+
+if ($calls_summary)
+	{
+	$stmt="select count(*) as calls,sum(talk_sec) as talk,avg(talk_sec),sum(pause_sec),avg(pause_sec),sum(wait_sec),avg(wait_sec),sum(dispo_sec),avg(dispo_sec) from vicidial_agent_log where event_time <= '" . mysql_real_escape_string($query_date_END) . "' and event_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and user='" . mysql_real_escape_string($agent) . "' and pause_sec<48800 and wait_sec<48800 and talk_sec<48800 and dispo_sec<48800 limit 1;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+
+	$TOTAL_TIME = ($row[1] + $row[3] + $row[5] + $row[7]);
+
+	$TOTAL_TIME_HMS =		sec_convert($TOTAL_TIME,'H'); 
+	$TALK_TIME_HMS =		sec_convert($row[1],'H'); 
+	$PAUSE_TIME_HMS =		sec_convert($row[3],'H'); 
+	$WAIT_TIME_HMS =		sec_convert($row[5],'H'); 
+	$WRAPUP_TIME_HMS =		sec_convert($row[7],'H'); 
+	$TALK_AVG_MS =			sec_convert($row[2],'H'); 
+	$PAUSE_AVG_MS =			sec_convert($row[4],'H'); 
+	$WAIT_AVG_MS =			sec_convert($row[6],'H'); 
+	$WRAPUP_AVG_MS =		sec_convert($row[8],'H'); 
+
+	$pfTOTAL_TIME_HMS =		sprintf("%8s", $TOTAL_TIME_HMS);
+	$pfTALK_TIME_HMS =		sprintf("%8s", $TALK_TIME_HMS);
+	$pfPAUSE_TIME_HMS =		sprintf("%8s", $PAUSE_TIME_HMS);
+	$pfWAIT_TIME_HMS =		sprintf("%8s", $WAIT_TIME_HMS);
+	$pfWRAPUP_TIME_HMS =	sprintf("%8s", $WRAPUP_TIME_HMS);
+	$pfTALK_AVG_MS =		sprintf("%6s", $TALK_AVG_MS);
+	$pfPAUSE_AVG_MS =		sprintf("%6s", $PAUSE_AVG_MS);
+	$pfWAIT_AVG_MS =		sprintf("%6s", $WAIT_AVG_MS);
+	$pfWRAPUP_AVG_MS =		sprintf("%6s", $WRAPUP_AVG_MS);
+
+	echo "TOTAL DE CHAMADAS TAKEN: $row[0]\n";
+	echo "TALK TIME:               $pfTALK_TIME_HMS     AVERAGE: $pfTALK_AVG_MS\n";
+	echo "PAUSE TIME:              $pfPAUSE_TIME_HMS     AVERAGE: $pfPAUSE_AVG_MS\n";
+	echo "WAIT TIME:               $pfWAIT_TIME_HMS     AVERAGE: $pfWAIT_AVG_MS\n";
+	echo "WRAPUP TIME:             $pfWRAPUP_TIME_HMS     AVERAGE: $pfWRAPUP_AVG_MS\n";
+	echo "----------------------------------------------------------------\n";
+	echo "TOTAL ACTIVE AGENTE TIME: $pfTOTAL_TIME_HMS\n";
+
+	echo "\n";
+	}
+else
+	{
+	echo "<a href=\"$PHP_SELF?calls_summary=1&agent=$agent&query_date=$query_date\">Call Activity Summary</a>\n\n";
+
+	}
+
+$stmt="select event_time,UNIX_TIMESTAMP(event_time) from vicidial_agent_log where event_time <= '" . mysql_real_escape_string($query_date_END) . "' and event_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and user='" . mysql_real_escape_string($agent) . "' order by event_time limit 1;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+echo "FIRST LOGIN:          $row[0]\n";
+$start = $row[1];
+
+$stmt="select event_time,UNIX_TIMESTAMP(event_time) from vicidial_agent_log where event_time <= '" . mysql_real_escape_string($query_date_END) . "' and event_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and user='" . mysql_real_escape_string($agent) . "' order by event_time desc limit 1;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+echo "LAST LOG ACTIVITY:    $row[0]\n";
+$end = $row[1];
+
+$login_time = ($end - $start);
+$LOGIN_TIME_HMS =		sec_convert($login_time,'H'); 
+$pfLOGIN_TIME_HMS =		sprintf("%8s", $LOGIN_TIME_HMS);
+
+echo "-----------------------------------------\n";
+echo "TOTAL LOGGED-IN TIME:            $pfLOGIN_TIME_HMS\n";
+
+
+### timeclock records
+
+
+##### vicidial_timeclock log records for user #####
+
+$total_login_time=0;
+$SQday_ARY =	explode('-',$query_date_BEGIN);
+$EQday_ARY =	explode('-',$query_date_END);
+$SQepoch = mktime(0, 0, 0, $SQday_ARY[1], $SQday_ARY[2], $SQday_ARY[0]);
+$EQepoch = mktime(23, 59, 59, $EQday_ARY[1], $EQday_ARY[2], $EQday_ARY[0]);
+
+echo "\n";
+
+echo "<B>TIMECLOCK HORÁRIO DE LOGIN/LOGOUT:</B>\n";
+echo "<TABLE width=550 cellspacing=0 cellpadding=1>\n";
+echo "<tr><td><font size=2>ID </td><td><font size=2>EDIT </td><td align=right><font size=2>EVENTO</td><td align=right><font size=2> DATA</td><td align=right><font size=2> IP ADDRESS</td><td align=right><font size=2> GROUP</td><td align=right><font size=2>HORAS:MINUTOS</td></tr>\n";
+
+	$stmt="SELECT event,event_epoch,user_group,login_sec,ip_address,timeclock_id,manager_user from vicidial_timeclock_log where user='$agent' and event_epoch >= '$SQepoch'  and event_epoch <= '$EQepoch';";
+	if ($DB>0) {echo "|$stmt|";}
+	$rslt=mysql_query($stmt, $link);
+	$events_to_print = mysql_num_rows($rslt);
+
+	$total_logs=0;
+	$o=0;
+	while ($events_to_print > $o) {
+		$row=mysql_fetch_row($rslt);
+		if ( ($row[0]=='START') or ($row[0]=='LOGIN') )
+			{$bgcolor='bgcolor="#B9CBFD"';} 
+		else
+			{$bgcolor='bgcolor="#9BB9FB"';}
+
+		$TC_log_date = date("Y-m-d H:i:s", $row[1]);
+
+		$manager_edit='';
+		if (strlen($row[6])>0) {$manager_edit = ' * ';}
+
+		if (ereg("LOGIN", $row[0]))
+			{
+			$login_sec='';
+			echo "<tr $bgcolor><td><font size=2><A HREF=\"./timeclock_edit.php?timeclock_id=$row[5]\">$row[5]</A></td>";
+			echo "<td align=right><font size=2>$manager_edit</td>";
+			echo "<td align=right><font size=2>$row[0]</td>";
+			echo "<td align=right><font size=2> $TC_log_date</td>\n";
+			echo "<td align=right><font size=2> $row[4]</td>\n";
+			echo "<td align=right><font size=2> $row[2]</td>\n";
+			echo "<td align=right><font size=2> </td></tr>\n";
+			}
+		if (ereg("LOGOUT", $row[0]))
+			{
+			$login_sec = $row[3];
+			$total_login_time = ($total_login_time + $login_sec);
+			$event_hours_minutes =		sec_convert($login_sec,'H'); 
+
+			echo "<tr $bgcolor><td><font size=2><A HREF=\"./timeclock_edit.php?timeclock_id=$row[5]\">$row[5]</A></td>";
+			echo "<td align=right><font size=2>$manager_edit</td>";
+			echo "<td align=right><font size=2>$row[0]</td>";
+			echo "<td align=right><font size=2> $TC_log_date</td>\n";
+			echo "<td align=right><font size=2> $row[4]</td>\n";
+			echo "<td align=right><font size=2> $row[2]</td>\n";
+			echo "<td align=right><font size=2> $event_hours_minutes";
+			if ($DB) {echo " - $total_login_time - $login_sec";}
+			echo "</td></tr>\n";
+			}
+		$o++;
+	}
+if (strlen($login_sec)<1)
+	{
+	$login_sec = ($STARTtime - $row[1]);
+	$total_login_time = ($total_login_time + $login_sec);
+		if ($DB) {echo "LOGIN ONLY - $total_login_time - $login_sec";}
+	}
+$total_login_hours_minutes =		sec_convert($total_login_time,'H'); 
+
+	if ($DB) {echo " - $total_login_time - $login_sec";}
+
+echo "<tr><td align=right><font size=2> </td>";
+echo "<td align=right><font size=2> </td>\n";
+echo "<td align=right><font size=2> </td>\n";
+echo "<td align=right><font size=2> </td>\n";
+echo "<td align=right colspan=2><font size=2><font size=2>TOTAL </td>\n";
+echo "<td align=right><font size=2> $total_login_hours_minutes  </td></tr>\n";
+
+echo "</TABLE>\n";
+
+
+
+}
+
+
+
+?>
+
+</BODY></HTML>
diff --git a/LANG_www/vicidial_br/AST_agent_timeclock_detail.php b/LANG_www/vicidial_br/AST_agent_timeclock_detail.php
new file mode 100644
index 00000000..e3d7b036
--- /dev/null
+++ b/LANG_www/vicidial_br/AST_agent_timeclock_detail.php
@@ -0,0 +1,692 @@
+<?php 
+# AST_agent_timeclock_detail.php
+# 
+# Pulls all timeclock records for an agent
+#
+# Copyright (C) 2010  Matt Florell <vicidial@gmail.com>    LICENSE: AGPLv2
+#
+# CHANGES
+# 90602-2244 - First build
+# 100301-1401 - Added popup date selector
+#
+
+
+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["group"]))					{$group=$_GET["group"];}
+	elseif (isset($_POST["group"]))			{$group=$_POST["group"];}
+if (isset($_GET["user_group"]))				{$user_group=$_GET["user_group"];}
+	elseif (isset($_POST["user_group"]))	{$user_group=$_POST["user_group"];}
+if (isset($_GET["shift"]))					{$shift=$_GET["shift"];}
+	elseif (isset($_POST["shift"]))			{$shift=$_POST["shift"];}
+if (isset($_GET["stage"]))					{$stage=$_GET["stage"];}
+	elseif (isset($_POST["stage"]))			{$stage=$_POST["stage"];}
+if (isset($_GET["file_download"]))			{$file_download=$_GET["file_download"];}
+	elseif (isset($_POST["file_download"]))	{$file_download=$_POST["file_download"];}
+if (isset($_GET["DB"]))						{$DB=$_GET["DB"];}
+	elseif (isset($_POST["DB"]))			{$DB=$_POST["DB"];}
+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 (strlen($shift)<2) {$shift='ALL';}
+if (strlen($stage)<2) {$stage='ID';}
+
+#############################################
+##### 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);
+if ($qm_conf_ct > 0)
+	{
+	$row=mysql_fetch_row($rslt);
+	$non_latin =					$row[0];
+	}
+##### END SETTINGS LOOKUP #####
+###########################################
+
+$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
+$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
+
+$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;
+	}
+
+$MT[0]='';
+$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";}
+$query_dateURL = ereg_replace(' ','+',$query_date);
+$end_dateURL = ereg_replace(' ','+',$end_date);
+
+$query_dateARRAY = explode(" ",$query_date);
+$query_date_D = $query_dateARRAY[0];
+$query_date_T = $query_dateARRAY[1];
+$end_dateARRAY = explode(" ",$end_date);
+$end_date_D = $end_dateARRAY[0];
+$end_date_T = $end_dateARRAY[1];
+
+$stmt="select campaign_id from vicidial_campaigns;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$campaigns_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $campaigns_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$groups[$i] =$row[0];
+	$i++;
+	}
+$stmt="select user_group from vicidial_user_groups;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$user_groups_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $user_groups_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$user_groups[$i] =$row[0];
+	$i++;
+	}
+
+$i=0;
+$group_string='|';
+$group_ct = count($group);
+while($i < $group_ct)
+	{
+	$group_string .= "$group[$i]|";
+	$group_SQL .= "'$group[$i]',";
+	$groupQS .= "&group[]=$group[$i]";
+	$i++;
+	}
+if ( (ereg("--ALL--",$group_string) ) or ($group_ct < 1) )
+	{$group_SQL = "";}
+else
+	{
+	$group_SQL = eregi_replace(",$",'',$group_SQL);
+	$group_SQL = "and campaign_id IN($group_SQL)";
+	}
+
+$i=0;
+$user_group_string='|';
+$user_group_ct = count($user_group);
+while($i < $user_group_ct)
+	{
+	$user_group_string .= "$user_group[$i]|";
+	$user_group_SQL .= "'$user_group[$i]',";
+	$user_groupQS .= "&user_group[]=$user_group[$i]";
+	$i++;
+	}
+if ( (ereg("--ALL--",$user_group_string) ) or ($user_group_ct < 1) )
+	{$user_group_SQL = "";}
+else
+	{
+	$TCuser_group_SQL = $user_group_SQL;
+	$user_group_SQL = eregi_replace(",$",'',$user_group_SQL);
+	$user_group_SQL = "and vicidial_agent_log.user_group IN($user_group_SQL)";
+	$TCuser_group_SQL = eregi_replace(",$",'',$TCuser_group_SQL);
+	$TCuser_group_SQL = "and user_group IN($TCuser_group_SQL)";
+	}
+
+if ($DB) {echo "$user_group_string|$user_group_ct|$user_groupQS|$i<BR>";}
+
+$stmt="select distinct pause_code,pause_code_name from vicidial_pause_codes;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$statha_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $statha_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$pause_code[$i] =		"$row[0]";
+	$pause_code_name[$i] =	"$row[1]";
+	$i++;
+	}
+
+$LINKbase = "$PHP_SELF?query_date=$query_dateURL&end_date=$end_dateURL$groupQS$user_groupQS&shift=$shift&DB=$DB";
+
+if ($file_download < 1)
+	{
+	?>
+
+	<HTML>
+	<HEAD>
+	<STYLE type="text/css">
+	<!--
+	   .yellow {color: white; background-color: yellow}
+	   .red {color: white; background-color: red}
+	   .blue {color: white; background-color: blue}
+	   .purple {color: white; background-color: purple}
+	-->
+	 </STYLE>
+
+	<script language="JavaScript" src="calendar_db.js"></script>
+	<link rel="stylesheet" href="calendar.css">
+
+	<?php
+	echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
+	echo "<TITLE>User Time-Clock Detail\n";
+	echo "";
+
+	$short_header=1;
+
+	require("admin_header.php");
+
+	echo "\n";
+	echo "\n";
+	echo "
\n";
+	}
+
+if (strlen($user_group[0]) < 1)
+	{
+	echo "\n";
+	echo "PLEASE SELECT A CAMPAIGN OR USER GROUP AND DATE-TIME ABOVE AND CLICK SUBMIT\n";
+	echo " NOTE: stats taken from shift specified\n";
+	}
+
+else
+	{
+	if ($shift == 'TEST') 
+		{
+		$time_BEGIN = "09:45:00";  
+		$time_END = "10:00:00";
+		}
+	if ($shift == 'AM') 
+		{
+		$time_BEGIN=$AM_shift_BEGIN;
+		$time_END=$AM_shift_END;
+		if (strlen($time_BEGIN) < 6) {$time_BEGIN = "03:45:00";}   
+		if (strlen($time_END) < 6) {$time_END = "15:15:00";}
+		}
+	if ($shift == 'PM') 
+		{
+		$time_BEGIN=$PM_shift_BEGIN;
+		$time_END=$PM_shift_END;
+		if (strlen($time_BEGIN) < 6) {$time_BEGIN = "15:15:00";}
+		if (strlen($time_END) < 6) {$time_END = "23:15:00";}
+		}
+	if ($shift == 'ALL') 
+		{
+		if (strlen($time_BEGIN) < 6) {$time_BEGIN = "00:00:00";}
+		if (strlen($time_END) < 6) {$time_END = "23:59:59";}
+		}
+	$query_date_BEGIN = "$query_date";   
+	$query_date_END = "$end_date";
+
+	if (strlen($user_group)>0) {$ugSQL="and vicidial_agent_log.user_group='$user_group'";}
+	else {$ugSQL='';}
+
+	if ($file_download < 1)
+		{
+		echo "User Time-Clock Detail                     $NOW_TIME\n";
+
+		echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
+		}
+	else
+		{
+		$file_output .= "User Time-Clock Detail                     $NOW_TIME\n";
+		$file_output .= "Time range: $query_date_BEGIN to $query_date_END\n\n";
+		}
+
+
+
+	############################################################################
+	##### BEGIN gathering information from the database section
+	############################################################################
+
+	### BEGIN gather user IDs and names for matching up later
+	$stmt="select full_name,user,user_group from vicidial_users order by user limit 100000;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$users_to_print = mysql_num_rows($rslt);
+	$i=0;
+	while ($i < $users_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		$ULname[$i] =	$row[0];
+		$ULuser[$i] =	$row[1];
+		$ULgroup[$i] =	$row[2];
+		$i++;
+		}
+	### END gather user IDs and names for matching up later
+
+
+	### BEGIN gather timeclock time totals per agent
+	$stmt="select user,sum(login_sec) from vicidial_timeclock_log where event IN('LOGIN','START') and event_date >= '$query_date_BEGIN' and event_date <= '$query_date_END' $TCuser_group_SQL group by user limit 10000000;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$punches_to_print = mysql_num_rows($rslt);
+	$i=0;
+	while ($i < $punches_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		$TCuser[$i] =	$row[0];
+		$TCtime[$i] =	$row[1];
+		$uc++;
+		$i++;
+		}
+	### END gather timeclock records per agent
+
+	############################################################################
+	##### END gathering information from the database section
+	############################################################################
+
+
+
+
+	##### BEGIN print the output to screen or put into file output variable
+	if ($file_download < 1)
+		{
+		echo "AGENT TIME-CLOCK DETAIL:\n";
+		echo "+-----------------+----------+----------------------+------------+--------------------\n";
+		echo "| USER NAME       | ID       | USER GROUP           | TIME CLOCK | TIME CLOCK PUNCHES\n";
+		echo "+-----------------+----------+----------------------+------------+--------------------\n";
+		}
+	else
+		{
+		$file_output .= "USER,ID,GROUP,TIME CLOCK,TIME CLOCK PUNCHES\n";
+		}
+	##### END print the output to screen or put into file output variable
+
+
+
+
+
+	############################################################################
+	##### BEGIN formatting data for output section
+	############################################################################
+
+	##### BEGIN loop through each user formatting data for output
+	$AUTOLOGOUTflag=0;
+	$m=0;
+	while ( ($m < $uc) and ($m < 50000) )
+		{
+		$TCdetail='';
+		$rawTCdetail='';
+		$n=0;
+		$user_name_found=0;
+		$RAWuser=$TCuser[$m];
+		while ($n < $users_to_print)
+			{
+			if ($TCuser[$m] == "$ULuser[$n]")
+				{
+				$user_name_found++;
+				$RAWname = $ULname[$n];
+				$RAWgroup = $ULgroup[$n];
+				$Sname[$m] = $ULname[$n];
+				$Sgroup[$m] = $ULgroup[$n];
+				}
+			$n++;
+			}
+		if ($user_name_found < 1)
+			{
+			$RAWname =		"NOT IN SYSTEM";
+			$RAWgroup =		"GROUP NOT IN SYSTEM";
+			$Sname[$m] =	$RAWname;
+			}
+
+		$n=0;
+		$punches_found=0;
+		while ($n < $punches_to_print)
+			{
+			if ($RAWuser == "$TCuser[$n]")
+				{
+				$punches_found++;
+				$RAWtimeTCsec =		$TCtime[$n];
+				$TOTtimeTC =		($TOTtimeTC + $TCtime[$n]);
+				$StimeTC[$m]=		sec_convert($TCtime[$n],'H'); 
+				$RAWtimeTC =		$StimeTC[$m];
+				$StimeTC[$m] =		sprintf("%10s", $StimeTC[$m]);
+				}
+			$n++;
+			}
+		if ($punches_found < 1)
+			{
+			$RAWtimeTCsec =		"0";
+			$StimeTC[$m]=		"0:00"; 
+			$RAWtimeTC =		$StimeTC[$m];
+			$StimeTC[$m] =		sprintf("%10s", $StimeTC[$m]);
+			}
+
+		### Check if the user had an AUTOLOGOUT timeclock event during the time period
+		$TCuserAUTOLOGOUT = ' ';
+		$stmt="select event_epoch,event_date,login_sec,event,user_group from vicidial_timeclock_log where event_date <= '$query_date_END' and event_date >= '$query_date_BEGIN' and user='$TCuser[$m]' $TCuser_group_SQL order by event_date limit 10000000;";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$TC_results = mysql_num_rows($rslt);
+		$k=0;
+		while ($TC_results > $k)
+			{
+			$TCentryAUTOLOGOUT = ' ';
+			$row=mysql_fetch_row($rslt);
+			$event_epoch =	$row[0];
+			$event_date =	$row[1];
+			$login_sec =	$row[2];
+			$event =		$row[3];
+			$user_group =	$row[4];
+			$date_detail = explode(' ',$event_date);
+
+			if ($event == 'AUTOLOGOUT')
+				{
+				$TCentryAUTOLOGOUT = '*';
+				$TCuserAUTOLOGOUT =	'*';
+				$AUTOLOGOUTflag++;
+				}
+			$TCdetail .= "$date_detail[1]$TCentryAUTOLOGOUT ";
+			$rawTCdetail .= "$date_detail[1],";
+			$k++;
+			}
+
+		if ($TC_results > 0)
+			{$rawTCdetail = ereg_replace(",$",'',$rawTCdetail);}
+
+		$Stime[$m] =	sprintf("%10s", $Stime[$m]); 
+		$SORTname =	sprintf("%-20s", $Sname[$m]);
+		$SORTgroup =	sprintf("%-20s", $Sgroup[$m]);
+		$Sgroup[$m] =	sprintf("%-20s", $Sgroup[$m]); 
+		$SORTgroup = ereg_replace(" ",'0',$SORTgroup);
+		$SORTname = ereg_replace(" ",'0',$SORTname);
+
+		if ($non_latin < 1)
+			{
+			$Sname[$m]=	sprintf("%-15s", $Sname[$m]); 
+			while(strlen($Sname[$m])>15) {$Sname[$m] = substr("$Sname[$m]", 0, -1);}
+			$Suser[$m] =		sprintf("%-8s", $TCuser[$m]);
+			while(strlen($Suser[$m])>8) {$Suser[$m] = substr("$Suser[$m]", 0, -1);}
+			}
+		else
+			{	
+			$Sname[$m]=	sprintf("%-45s", $Sname[$m]); 
+			while(mb_strlen($Sname[$m],'utf-8')>15) {$Sname[$m] = mb_substr("$Sname[$m]", 0, -1,'utf-8');}
+			$Suser[$m] =	sprintf("%-24s", $TCuser[$m]);
+			while(mb_strlen($Suser[$m],'utf-8')>8) {$Suser[$m] = mb_substr("$Suser[$m]", 0, -1,'utf-8');}
+			}
+
+
+		if ($file_download < 1)
+			{
+			$Toutput = "| $Sname[$m] | $Suser[$m] | $Sgroup[$m] | $StimeTC[$m]$TCuserAUTOLOGOUT| $TCdetail\n";
+			}
+		else
+			{
+			$fileToutput = "$RAWname,$RAWuser,$RAWgroup,$RAWtimeTC,$rawTCdetail\n";
+			}
+
+		$TOPsorted_output[$m] = $Toutput;
+		$TOPsorted_outputFILE[$m] = $fileToutput;
+
+		if ($stage == 'NAME')
+			{
+			$TOPsort[$m] =	'' . sprintf("%020s", $SORTname) . '-----' . $m . '-----' . sprintf("%020s", $RAWuser);
+			$TOPsortTALLY[$m]=$RAWcalls;
+			}
+		if ($stage == 'ID')
+			{
+			$TOPsort[$m] =	'' . sprintf("%08s", $RAWuser) . '-----' . $m . '-----' . sprintf("%020s", $RAWuser);
+			$TOPsortTALLY[$m]=$RAWcalls;
+			}
+		if ($stage == 'TCLOCK')
+			{
+			$TOPsort[$m] =	'' . sprintf("%010s", $RAWtimeTCsec) . '-----' . $m . '-----' . sprintf("%020s", $RAWuser);
+			$TOPsortTALLY[$m]=$RAWtimeTCsec;
+			}
+		if ($stage == 'GROUP')
+			{
+			$TOPsort[$m] =	'' . sprintf("%020s", $SORTgroup) . '-----' . $m . '-----' . sprintf("%020s", $RAWuser);
+			$TOPsortTALLY[$m]=$SORTgroup;
+			}
+		if (!ereg("NAME|ID|TCLOCK|GROUP",$stage))
+			if ($file_download < 1)
+				{echo "$Toutput";}
+			else
+				{$file_output .= "$fileToutput";}
+
+		if ($TOPsortMAX < $TOPsortTALLY[$m]) {$TOPsortMAX = $TOPsortTALLY[$m];}
+
+#		echo "$Suser[$m]|$Sname[$m]|$Swait[$m]|$Stalk[$m]|$Sdispo[$m]|$Spause[$m]|$Scalls[$m]\n";
+		$m++;
+		}
+	##### END loop through each user formatting data for output
+
+
+	$TOT_AGENTS = sprintf("%4s", $m);
+	$k=$m;
+
+	if ($DB) {echo "Done analyzing...   $TOTwait|$TOTtalk|$TOTdispo|$TOTpause|$TOTALtime|$TOTcalls|$uc|
\n";} + + + ### BEGIN sort through output to display properly ### + if ( (ereg("NAME|ID|TCLOCK|GROUP",$stage)) and ($k > 0) ) + { + if (ereg("ID",$stage)) + {sort($TOPsort, SORT_NUMERIC);} + if (ereg("TCLOCK",$stage)) + {rsort($TOPsort, SORT_NUMERIC);} + if (ereg("GROUP",$stage)) + {sort($TOPsort, SORT_REGULAR);} + if (ereg("NAME",$stage)) + {sort($TOPsort, SORT_STRING);} + + $m=0; + while ($m < $k) + { + $sort_split = explode("-----",$TOPsort[$m]); + $i = $sort_split[1]; + $sort_order[$m] = "$i"; + if ($file_download < 1) + {echo "$TOPsorted_output[$i]";} + else + {$file_output .= "$TOPsorted_outputFILE[$i]";} + $m++; + } + } + ### END sort through output to display properly ### + + ############################################################################ + ##### END formatting data for output section + ############################################################################ + + + + + ############################################################################ + ##### BEGIN last line totals output section + ############################################################################ + + ### call function to calculate and print dialable leads + $TOTtimeTC = sec_convert($TOTtimeTC,'H'); + + $TOTtimeTC = sprintf("%11s", $TOTtimeTC); + ###### END LAST LINE TOTALS FORMATTING ########## + + + + if ($file_download < 1) + { + echo "+-----------------+----------+----------------------+------------+--------------------\n"; + echo "| TOTALS AGENTS:$TOT_AGENTS | |$TOTtimeTC |\n"; + echo "+----------------------------+ +------------+\n"; + if ($AUTOLOGOUTflag > 0) + {echo " * denotes AUTOLOGOUT from timeclock\n";} + echo "\n\n
"; + } + else + { + $file_output .= "TOTALS,$TOT_AGENTS,,$TOTtimeTC\n"; + } + } + + ############################################################################ + ##### END formatting data for output section + ############################################################################ + + + + + +if ($file_download > 0) + { + $FILE_TIME = date("Ymd-His"); + $CSVfilename = "AGENT_TIME$US$FILE_TIME.csv"; + + // We'll be outputting a TXT file + header('Content-type: application/octet-stream'); + + // It will be called LIST_101_20090209-121212.txt + header("Content-Disposition: attachment; filename=\"$CSVfilename\""); + header('Expires: 0'); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header('Pragma: public'); + ob_clean(); + flush(); + + echo "$file_output"; + + exit; + } + + +############################################################################ +##### BEGIN HTML form section +############################################################################ +echo "
\n"; +echo "
Dates:
"; +echo "\n"; +echo "\n"; +echo "\n"; +echo ""; + +?> + +"; + +echo "
to
"; + +?> + +"; + +# echo "
Campaigns:
"; +# echo "\n"; + +echo "
User Groups:
"; +echo "\n"; +echo "
Shift:
"; +echo "

\n"; + + +?> + + + +
        "; + +echo "          \n"; +echo " DOWNLOAD | \n"; +echo " REPORTS \n"; +echo "\n"; +echo "
"; + +echo "
\n\n"; +############################################################################ +##### END HTML form section +############################################################################ + + +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $STARTtime); +echo "$RUNtime\n"; + +?> + + diff --git a/LANG_www/vicidial_br/AST_inboundEXTstats.php b/LANG_www/vicidial_br/AST_inboundEXTstats.php new file mode 100644 index 00000000..e90f463b --- /dev/null +++ b/LANG_www/vicidial_br/AST_inboundEXTstats.php @@ -0,0 +1,401 @@ + LICENSE: AGPLv2 +# +# CHANGES +# 60421-1450 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60620-1322 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# 90508-0644 - Changed to PHP long tags +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $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";} + $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 "Nome ou Senha inválidos: |$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($query_date)) {$query_date = $NOW_DATE;} +if (!isset($server_ip)) {$server_ip = '10.10.11.20';} + +$stmt="select extension,full_number,inbound_name from inbound_numbers where server_ip='" . mysql_real_escape_string($server_ip) . "';"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$inbound_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $inbound_to_print) + { + $row=mysql_fetch_row($rslt); + $inbound[$i] =$row[0]; + $fullnum[$i] =$row[1]; + $inbname[$i] =$row[2]; + $i++; + } +?> + + + + + +\n"; +#echo"\n"; +echo "ASTERISK: Estatística das chamadas entrantes\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n\n"; + +echo "
\n\n";
+
+
+if (!$group)
+{
+echo "\n\n";
+echo "POR FAVOR SELECIONE UM NÚMERO E UMA DATA ACIMA E CLIQUE EM ENVIAR\n";
+}
+
+else
+{
+
+
+echo "ASTERISK: Estatística das chamadas entrantes                      $NOW_TIME\n";
+
+echo "\n";
+echo "---------- TOTALS\n";
+
+$extenSQL = "and extension='" . mysql_real_escape_string($group) . "'";
+if (eregi("\*",$group))
+	{$extenSQL = "and extension LIKE \"%$group\"";}
+$stmt="select count(*),sum(length_in_sec) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$TOTALcalls =	sprintf("%10s", $row[0]);
+$average_hold_seconds = ($row[1] / $row[0]);
+$average_hold_seconds = round($average_hold_seconds, 0);
+$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+
+echo "Total de chamadas que entraram por esse número:       $TOTALcalls\n";
+echo "Average Call Length(seconds) for all Calls:   $average_hold_seconds\n";
+
+echo "\n";
+echo "---------- DERRUBADAS\n";
+
+$stmt="select count(*),sum(length_in_sec) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$DROPcalls =	sprintf("%10s", $row[0]);
+$DROPpercent = (($DROPcalls / $TOTALcalls) * 100);
+$DROPpercent = round($DROPpercent, 0);
+
+if ($row[0])
+	{
+	$average_hold_seconds = ($row[1] / $row[0]);
+	$average_hold_seconds = round($average_hold_seconds, 0);
+	$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+	}
+else {$DROPpercent=0;   $average_hold_seconds=0;}
+echo "Total DROP Calls:   (less than 10 seconds)    $DROPcalls  $DROPpercent%\n";
+echo "Average Call Length(seconds) for DROP Calls:  $average_hold_seconds\n";
+
+
+##############################
+#########  CALLS STATS
+
+echo "\n";
+echo "---------- CALL LISTINGS\n";
+echo "+----------------------+----------------------+--------+---------------------+\n";
+echo "| CALLERID             | CALLERIDNAME         | LENGTH | DATE TIME           |\n";
+echo "+----------------------+----------------------+--------+---------------------+\n";
+
+$stmt="select number_dialed,caller_code,length_in_sec,start_time from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$users_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $users_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+
+	$CID =			sprintf("%-20s", $row[0]);
+	$CIDname =		sprintf("%-20s", $row[1]); while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);}
+	$datetime =		sprintf("%-19s", $row[3]);
+	$USERavgTALK =	$row[2];
+
+	$USERavgTALK_M = ($USERavgTALK / 60);
+	$USERavgTALK_M = round($USERavgTALK_M, 2);
+	$USERavgTALK_M_int = intval("$USERavgTALK_M");
+	$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
+	$USERavgTALK_S = ($USERavgTALK_S * 60);
+	$USERavgTALK_S = round($USERavgTALK_S, 0);
+	if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
+	$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
+	$USERavgTALK_MS =		sprintf("%6s", $USERavgTALK_MS);
+
+	echo "| $CID | $CIDname | $USERavgTALK_MS | $datetime |\n";
+
+	$i++;
+	}
+
+echo "+----------------------+----------------------+--------+---------------------+\n";
+
+##############################
+#########  TIME STATS
+
+if ($output == 'FULL')
+	{
+
+	echo "\n";
+	echo "---------- ESTATÍSTICAS DE TEMPO\n";
+
+	echo "\n";
+
+	$hi_hour_count=0;
+	$last_full_record=0;
+	$i=0;
+	$h=0;
+	while ($i <= 96)
+		{
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:00:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:14:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$hour_count[$i] = $row[0];
+		if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+		if ($hour_count[$i] > 0) {$last_full_record = $i;}
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:00:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:14:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$drop_count[$i] = $row[0];
+		$i++;
+
+
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:15:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:29:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$hour_count[$i] = $row[0];
+		if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+		if ($hour_count[$i] > 0) {$last_full_record = $i;}
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:15:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:29:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$drop_count[$i] = $row[0];
+		$i++;
+
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:30:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:44:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$hour_count[$i] = $row[0];
+		if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+		if ($hour_count[$i] > 0) {$last_full_record = $i;}
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:30:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:44:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$drop_count[$i] = $row[0];
+		$i++;
+
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:45:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$hour_count[$i] = $row[0];
+		if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+		if ($hour_count[$i] > 0) {$last_full_record = $i;}
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:45:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$drop_count[$i] = $row[0];
+		$i++;
+		$h++;
+		}
+
+	$hour_multiplier = (100 / $hi_hour_count);
+	#$hour_multiplier = round($hour_multiplier, 0);
+
+	echo "\n";
+	echo "GRÁFICO TOTAL DE CHAMADAS A CADA 15 MINUTOS\n";
+
+	$k=1;
+	$Mk=0;
+	$call_scale = '0';
+	while ($k <= 102) 
+		{
+		if ($Mk >= 5) 
+			{
+			$Mk=0;
+			$scale_num=($k / $hour_multiplier);
+			$scale_num = round($scale_num, 0);
+			$LENscale_num = (strlen($scale_num));
+			$k = ($k + $LENscale_num);
+			$call_scale .= "$scale_num";
+			}
+		else
+			{
+			$call_scale .= " ";
+			$k++;   $Mk++;
+			}
+		}
+
+
+	echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+	#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP                                  | DROPS | TOTAL |\n";
+	echo "| HOUR |$call_scale| DROPS | TOTAL |\n";
+	echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+	$ZZ = '00';
+	$i=0;
+	$h=4;
+	$hour= -1;
+	$no_lines_yet=1;
+
+	while ($i <= 96)
+		{
+		$char_counter=0;
+		$time = '      ';
+		if ($h >= 4) 
+			{
+			$hour++;
+			$h=0;
+			if ($hour < 10) {$hour = "0$hour";}
+			$time = "+$hour$ZZ+";
+			}
+		if ($h == 1) {$time = "   15 ";}
+		if ($h == 2) {$time = "   30 ";}
+		if ($h == 3) {$time = "   45 ";}
+		$Ghour_count = $hour_count[$i];
+		if ($Ghour_count < 1) 
+			{
+			if ( ($no_lines_yet) or ($i > $last_full_record) )
+				{
+				$do_nothing=1;
+				}
+			else
+				{
+				$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+				echo "|$time|";
+				$k=0;   while ($k <= 102) {echo " ";   $k++;}
+				echo "| $hour_count[$i] |\n";
+				}
+			}
+		else
+			{
+			$no_lines_yet=0;
+			$Xhour_count = ($Ghour_count * $hour_multiplier);
+			$Yhour_count = (99 - $Xhour_count);
+
+			$Gdrop_count = $drop_count[$i];
+			if ($Gdrop_count < 1) 
+				{
+				$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+
+				echo "|$time|";
+				$k=0;   while ($k <= $Xhour_count) {echo "*";   $k++;   $char_counter++;}
+				echo "*X";   $char_counter++;
+				$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+					while ($char_counter <= 101) {echo " ";   $char_counter++;}
+				echo "| 0     | $hour_count[$i] |\n";
+
+				}
+			else
+				{
+				$Xdrop_count = ($Gdrop_count * $hour_multiplier);
+
+			#	if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
+
+				$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
+
+				$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+				$drop_count[$i] =	sprintf("%-5s", $drop_count[$i]);
+
+				echo "|$time|";
+				$k=0;   while ($k <= $Xdrop_count) {echo ">";   $k++;   $char_counter++;}
+				echo "D";   $char_counter++;
+				$k=0;   while ($k <= $XXhour_count) {echo "*";   $k++;   $char_counter++;}
+				echo "X";   $char_counter++;
+				$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+					while ($char_counter <= 102) {echo " ";   $char_counter++;}
+				echo "| $drop_count[$i] | $hour_count[$i] |\n";
+				}
+			}
+		
+		
+		$i++;
+		$h++;
+		}
+
+
+	echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+
+	}
+
+
+
+
+}
+
+
+
+?>
+
+ + \ No newline at end of file diff --git a/LANG_www/vicidial_br/AST_server_performance.php b/LANG_www/vicidial_br/AST_server_performance.php new file mode 100644 index 00000000..915c1eb6 --- /dev/null +++ b/LANG_www/vicidial_br/AST_server_performance.php @@ -0,0 +1,347 @@ + LICENSE: AGPLv2 +# +# CHANGES +# +# 60619-1732 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# 70417-1106 - Changed time frame to be definable per time range on a single day +# - Fixed vertical scaling issues +# 80118-1508 - Fixed horizontal scale marking issues +# 90310-2151 - Added admin header +# 90508-0644 - Changed to PHP long tags +# 100214-1421 - Sort menu alphabetically +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["begin_query_time"])) {$begin_query_time=$_GET["begin_query_time"];} + elseif (isset($_POST["begin_query_time"])) {$begin_query_time=$_POST["begin_query_time"];} +if (isset($_GET["end_query_time"])) {$end_query_time=$_GET["end_query_time"];} + elseif (isset($_POST["end_query_time"])) {$end_query_time=$_POST["end_query_time"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6 and view_reports='1' and modify_servers='1';"; +if ($DB) {echo "|$stmt|\n";} +$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 "Nome ou Senha inválidos: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +# path from root to where ploticus files will be stored +$PLOTroot = "vicidial/ploticus"; +$DOCroot = "$WeBServeRRooT/$PLOTroot/"; + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); + +if (!isset($begin_query_time)) {$begin_query_time = "$NOW_DATE 09:00:00";} +if (!isset($end_query_time)) {$end_query_time = "$NOW_DATE 15:30:00";} +if (!isset($group)) {$group = '';} + +$stmt="select server_ip from servers order by server_ip;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$servers_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $servers_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } +?> + + + + + +\n"; +echo "Server Performance Report\n"; + + $short_header=1; + + require("admin_header.php"); + +echo "
"; + + +echo "
\n"; +echo "Date/Time Range: \n"; +echo "to \n"; +echo "Server: \n"; +echo "\n"; +echo "             RELATÓRIOS \n"; +echo "
\n\n"; + +echo "
\n";
+
+
+if (!$group)
+{
+echo "\n";
+echo "PLEASE SELECT A SERVIDOR AND DATE/TIME RANGE ABOVE AND CLICK ENVIAR\n";
+}
+
+else
+{
+
+$query_date_BEGIN = $begin_query_time;   
+$query_date_END = $end_query_time;
+
+
+echo "Server Performance Report                            $NOW_TIME\n";
+
+echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
+echo "---------- TOTALS, PEAKS and AVERAGES\n";
+
+$stmt="select AVG(sysload),AVG(channels_total),MAX(sysload),MAX(channels_total),MAX(processes) from server_performance where start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$AVGload =	sprintf("%10s", $row[0]);
+$AVGchannels =	sprintf("%10s", $row[1]);
+$HIGHload =	$row[2];
+	$HIGHmulti = intval($HIGHload / 100);
+$HIGHchannels =	$row[3];
+$HIGHprocesses =$row[4];
+if ($row[2] > $row[3]) {$HIGHlimit = $row[2];}
+else {$HIGHlimit = $row[3];}
+if ($HIGHlimit < $row[4]) {$HIGHlimit = $row[4];}
+
+$stmt="select AVG(cpu_user_percent),AVG(cpu_system_percent),AVG(cpu_idle_percent) from server_performance where start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$AVGcpuUSER =	sprintf("%10s", $row[0]);
+$AVGcpuSYSTEM =	sprintf("%10s", $row[1]);
+$AVGcpuIDLE =	sprintf("%10s", $row[2]);
+
+$stmt="select count(*),SUM(length_in_min) from call_log where extension NOT IN('8365','8366','8367') and  start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$TOTALcalls =	sprintf("%10s", $row[0]);
+$OFFHOOKtime =	sprintf("%10s", $row[1]);
+
+
+echo "Total Calls in/out on this server:        $TOTALcalls\n";
+echo "Total Off-Hook time on this server (min): $OFFHOOKtime\n";
+echo "Average/Peak channels in use for server:  $AVGchannels / $HIGHchannels\n";
+echo "Average/Peak load for server:             $AVGload / $HIGHload\n";
+echo "Average USER process cpu percentage:      $AVGcpuUSER %\n";
+echo "Average SYSTEM process cpu percentage:    $AVGcpuSYSTEM %\n";
+echo "Average IDLE process cpu percentage:      $AVGcpuIDLE %\n";
+
+echo "\n";
+echo "---------- LINE GRAPH:\n";
+
+
+
+##############################
+#########  Graph stats
+
+$DAT = '.dat';
+$HTM = '.htm';
+$PNG = '.png';
+$filedate = date("Y-m-d_His");
+$DATfile = "$group$query_date$shift$filedate$DAT";
+$HTMfile = "$group$query_date$shift$filedate$HTM";
+$PNGfile = "$group$query_date$shift$filedate$PNG";
+
+$HTMfp = fopen ("$DOCroot/$HTMfile", "a");
+$DATfp = fopen ("$DOCroot/$DATfile", "a");
+
+$stmt="select DATE_FORMAT(start_time,'%Y-%m-%d.%H:%i:%s') as timex,sysload,processes,channels_total,live_recordings,cpu_user_percent,cpu_system_percent from server_performance where server_ip='" . mysql_real_escape_string($group) . "' and start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' order by timex limit 99999;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$rows_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $rows_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	if ($i<1) {$time_BEGIN = $row[0];}
+	$time_END = $row[0];
+	$row[5] = intval(($row[5] + $row[6]) * $HIGHmulti);
+	$row[6] = intval($row[6] * $HIGHmulti);
+	if ($rows_to_print > 9999)
+		{
+		if ($rows_to_print <= 19999)
+			{
+			if (preg_match("/0$|2$|4$|6$|8$/",$i))
+				{
+				fwrite ($DATfp, "$row[5]\t$row[6]\t$row[0]\t$row[1]\t$row[2]\t$row[3]\n");
+				}
+			}
+		if ( ($rows_to_print > 19999) and ($rows_to_print <= 49999) )
+			{
+			if (preg_match("/0$|5$/",$i))
+				{
+				fwrite ($DATfp, "$row[5]\t$row[6]\t$row[0]\t$row[1]\t$row[2]\t$row[3]\n");
+				}
+			}
+		if ( ($rows_to_print > 49999) and ($rows_to_print <= 99999) )
+			{
+			if (preg_match("/0$/",$i))
+				{
+				fwrite ($DATfp, "$row[5]\t$row[6]\t$row[0]\t$row[1]\t$row[2]\t$row[3]\n");
+				}
+			}
+		}
+	else
+		{
+		fwrite ($DATfp, "$row[5]\t$row[6]\t$row[0]\t$row[1]\t$row[2]\t$row[3]\n");
+		}
+	$i++;
+	}
+fclose($DATfp);
+
+$rows_to_max = ($rows_to_print + 100);
+
+$time_scale_abb = '5 minutes';
+$time_scale_tick = '1 minute';
+if ($i > 1000) {$time_scale_abb = '10 minutes';   $time_scale_tick = '2 minutes';}
+if ($i > 1500) {$time_scale_abb = '15 minutes';   $time_scale_tick = '3 minutes';}
+if ($i > 2000) {$time_scale_abb = '20 minutes';   $time_scale_tick = '4 minutes';}
+if ($i > 3000) {$time_scale_abb = '30 minutes';   $time_scale_tick = '5 minutes';}
+if ($i > 4000) {$time_scale_abb = '40 minutes';   $time_scale_tick = '10 minutes';}
+if ($i > 5000) {$time_scale_abb = '60 minutes';   $time_scale_tick = '15 minutes';}
+if ($i > 6000) {$time_scale_abb = '90 minutes';   $time_scale_tick = '15 minutes';}
+if ($i > 7000) {$time_scale_abb = '120 minutes';   $time_scale_tick = '30 minutes';}
+
+print "rows: $i   tick: $time_scale_abb   scale: $time_scale_tick\n";
+
+$HTMcontent  = '';
+$HTMcontent .= "#proc page\n";
+$HTMcontent .= "#if @DEVICE in png,gif\n";
+$HTMcontent .= "   scale: 0.6\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#endif\n";
+$HTMcontent .= "#proc getdata\n";
+$HTMcontent .= "file: $DOCroot/$DATfile\n";
+$HTMcontent .= "fieldnames: userproc sysproc datetime load processes channels\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc areadef\n";
+$HTMcontent .= "title: Server $group   $query_date_BEGIN to $query_date_END\n";
+$HTMcontent .= "titledetails: size=14  align=C\n";
+$HTMcontent .= "rectangle: 1 1 12 7\n";
+$HTMcontent .= "xscaletype: datetime yyyy-mm-dd.hh:mm:ss\n";
+$HTMcontent .= "xrange: $time_BEGIN $time_END\n";
+$HTMcontent .= "yrange: 0 $HIGHlimit\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc xaxis\n";
+$HTMcontent .= "stubs: inc $time_scale_abb\n";
+$HTMcontent .= "minorticinc: $time_scale_tick\n";
+$HTMcontent .= "stubformat: hh:mma\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc yaxis\n";
+$HTMcontent .= "stubs: inc 50\n";
+$HTMcontent .= "grid: color=yellow\n";
+$HTMcontent .= "gridskip: min\n";
+$HTMcontent .= "ticincrement: 100 1000\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc lineplot\n";
+$HTMcontent .= "xfield: datetime\n";
+$HTMcontent .= "yfield: userproc\n";
+$HTMcontent .= "linedetails: color=purple width=.5\n";
+$HTMcontent .= "fill: lavender\n";
+$HTMcontent .= "legendlabel: user proc%\n";
+$HTMcontent .= "maxinpoints: $rows_to_max\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc lineplot\n";
+$HTMcontent .= "xfield: datetime\n";
+$HTMcontent .= "yfield: sysproc\n";
+$HTMcontent .= "linedetails: color=yelloworange width=.5\n";
+$HTMcontent .= "fill: dullyellow\n";
+$HTMcontent .= "legendlabel: system proc%\n";
+$HTMcontent .= "maxinpoints: $rows_to_max\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc curvefit\n";
+$HTMcontent .= "xfield: datetime\n";
+$HTMcontent .= "yfield: load\n";
+$HTMcontent .= "linedetails: color=blue width=.5\n";
+$HTMcontent .= "legendlabel: load\n";
+$HTMcontent .= "maxinpoints: $rows_to_max\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc curvefit\n";
+$HTMcontent .= "xfield: datetime\n";
+$HTMcontent .= "yfield: processes\n";
+$HTMcontent .= "linedetails: color=red width=.5\n";
+$HTMcontent .= "legendlabel: processes\n";
+$HTMcontent .= "maxinpoints: $rows_to_max\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc curvefit\n";
+$HTMcontent .= "xfield: datetime\n";
+$HTMcontent .= "yfield: channels\n";
+$HTMcontent .= "linedetails: color=green width=.5\n";
+$HTMcontent .= "legendlabel: channels\n";
+$HTMcontent .= "maxinpoints: $rows_to_max\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc legend\n";
+$HTMcontent .= "location: max-1 max\n";
+$HTMcontent .= "seglen: 0.2\n";
+$HTMcontent .= "\n";
+
+fwrite ($HTMfp, "$HTMcontent");
+fclose($HTMfp);
+
+
+passthru("/usr/local/bin/pl -png $DOCroot/$HTMfile -o $DOCroot/$PNGfile");
+
+sleep(1);
+
+echo "
"; +echo "\n"; +echo "\n"; + + +echo ""; + +} + + + +?> + +
+ + \ No newline at end of file diff --git a/LANG_www/vicidial_br/AST_timeonVDAD.php b/LANG_www/vicidial_br/AST_timeonVDAD.php new file mode 100644 index 00000000..6598ba48 --- /dev/null +++ b/LANG_www/vicidial_br/AST_timeonVDAD.php @@ -0,0 +1,445 @@ + LICENSE: AGPLv2 +# +# live real-time stats for the VICIDIAL Auto-Dialer +# +# CHANGES +# +# 60620-1037 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# 61114-2004 - Changed to display CLOSER and DEFAULT, added trunk shortage +# 80422-0305 - Added phone login to display, lower font size to 2 +# 81013-2227 - Fixed Remote Agent display bug +# 90310-1945 - Admin header +# 90508-0644 - Changed to PHP long tags +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];} + elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} +if (isset($_GET["closer_display"])) {$closer_display=$_GET["closer_display"];} + elseif (isset($_POST["closer_display"])) {$closer_display=$_POST["closer_display"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $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";} + $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 "Nome ou Senha inválidos: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +$epochSIXhoursAGO = ($STARTtime - 21600); +$timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO); + +$reset_counter++; + +if ($reset_counter > 7) + { + $reset_counter=0; + + $stmt="update park_log set status='HUNGUP' where hangup_time is not null;"; +# $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + + if ($DB) + { + $stmt="delete from park_log where grab_time < '$timeSIXhoursAGO' and (hangup_time is null or hangup_time='');"; +# $rslt=mysql_query($stmt, $link); + echo "$stmt\n"; + } + } + +?> + + + +\n"; +echo " + + +\n"; +echo"\n"; +echo "Server-Specific Tempo Real Report\n"; + +$short_header=1; + +require("admin_header.php"); + +echo "
"; + +echo "
";
+
+###################################################################################
+###### SERVER INFORMATION
+###################################################################################
+
+$stmt="select sum(local_trunk_shortage) from vicidial_campaign_server_stats where server_ip='" . mysql_real_escape_string($server_ip) . "';";
+$rslt=mysql_query($stmt, $link);
+$row=mysql_fetch_row($rslt);
+$balanceSHORT = $row[0];
+
+echo "SERVER: $server_ip\n";
+
+
+
+###################################################################################
+###### TIME ON SYSTEM
+###################################################################################
+
+if ($closer_display>0) {$closer_display_reverse=0;   $closer_reverse_link='DEFAULT';}
+else {$closer_display_reverse=1;   $closer_reverse_link='CLOSER';}
+
+echo "Agentes Time On Calls           $NOW_TIME    $closer_reverse_link | RELATÓRIOS\n\n";
+
+if ($closer_display>0)
+{
+echo "+------------+------------+--------+-----------+---------------------+--------+----------+---------+--------------+--------+\n";
+echo "| STATION    | PHONE      | USER   | SESSIONID | CHANNEL             | STATUS | CALLTIME | MINUTES | CAMPANHA     | FRONT  |\n";
+echo "+------------+------------+--------+-----------+---------------------+--------+----------+---------+--------------+--------+\n";
+}
+else
+{
+echo "+------------+------------+--------+-----------+---------------------+--------+----------+---------+\n";
+echo "| STATION    | PHONE      | USER   | SESSIONID | CHANNEL             | STATUS | CALLTIME | MINUTES |\n";
+echo "+------------+------------+--------+-----------+---------------------+--------+----------+---------+\n";
+}
+
+$stmt="select extension,user,conf_exten,channel,status,last_call_time,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish),uniqueid,lead_id from vicidial_live_agents where status NOT IN('PAUSED') and server_ip='" . mysql_real_escape_string($server_ip) . "' order by extension;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$talking_to_print = mysql_num_rows($rslt);
+	if ($talking_to_print > 0)
+	{
+	$i=0;
+	while ($i < $talking_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		$Sextension[$i] =		$row[0];
+		$Suser[$i] =			$row[1];
+		$Ssessionid[$i] =		$row[2];
+		$Schannel[$i] =			$row[3];
+		$Sstatus[$i] =			$row[4];
+		$Sstart_time[$i] =		$row[5];
+		$Scall_time[$i] =		$row[6];
+		$Sfinish_time[$i] =		$row[7];
+		$Suniqueid[$i] =		$row[8];
+		$Slead_id[$i] =			$row[9];
+		$i++;
+		}
+
+	$i=0;
+	while ($i < $talking_to_print)
+		{
+		$phone[$i]='          ';
+		if (eregi("R/",$Sextension[$i])) 
+			{
+			$protocol = 'EXTERNAL';
+			$dialplan = eregi_replace('R/',"",$Sextension[$i]);
+			$dialplan = eregi_replace("\@.*",'',$dialplan);
+			$exten = "dialplan_number='$dialplan'";
+			}
+		if (eregi("Local/",$Sextension[$i])) 
+			{
+			$protocol = 'EXTERNAL';
+			$dialplan = eregi_replace('Local/',"",$Sextension[$i]);
+			$dialplan = eregi_replace("\@.*",'',$dialplan);
+			$exten = "dialplan_number='$dialplan'";
+			}
+		if (eregi('SIP/',$Sextension[$i])) 
+			{
+			$protocol = 'SIP';
+			$dialplan = eregi_replace('SIP/',"",$Sextension[$i]);
+			$dialplan = eregi_replace("-.*",'',$dialplan);
+			$exten = "extension='$dialplan'";
+			}
+		if (eregi('IAX2/',$Sextension[$i])) 
+			{
+			$protocol = 'IAX2';
+			$dialplan = eregi_replace('IAX2/',"",$Sextension[$i]);
+			$dialplan = eregi_replace("-.*",'',$dialplan);
+			$exten = "extension='$dialplan'";
+			}
+		if (eregi('Zap/',$Sextension[$i])) 
+			{
+			$protocol = 'Zap';
+			$dialplan = eregi_replace('Zap/',"",$Sextension[$i]);
+			$exten = "extension='$dialplan'";
+			}
+
+		$stmt="select login from phones where server_ip='" . mysql_real_escape_string($server_ip) . "' and $exten and protocol='$protocol';";
+		$rslt=mysql_query($stmt, $link);
+		$row=mysql_fetch_row($rslt);
+		$login = $row[0];
+
+		$phone[$i] =			sprintf("%-10s", $login);
+
+		if (eregi("READY|PAUSED|CLOSER",$Sstatus[$i]))
+			{
+			$Schannel[$i]='';
+			$Sstart_time[$i]='- WAIT -';
+			$Scall_time[$i]=$Sfinish_time[$i];
+			}
+		$extension[$i] = eregi_replace('Local/',"",$Sextension[$i]);
+		$extension[$i] =		sprintf("%-10s", $extension[$i]);
+			while(strlen($extension[$i])>10) {$extension[$i] = substr("$extension[$i]", 0, -1);}
+		$user[$i] =				sprintf("%-6s", $Suser[$i]);
+		$sessionid[$i] =		sprintf("%-9s", $Ssessionid[$i]);
+		$channel[$i] =			sprintf("%-19s", $Schannel[$i]);
+			$cc[$i]=0;
+		while ( (strlen($channel[$i]) > 19) and ($cc[$i] < 100) )
+			{
+			$channel[$i] = eregi_replace(".$","",$channel[$i]);   
+			$cc[$i]++;
+			if (strlen($channel[$i]) <= 19) {$cc[$i]=101;}
+			}
+		$status[$i] =			sprintf("%-6s", $Sstatus[$i]);
+		$start_time[$i] =		sprintf("%-8s", $Sstart_time[$i]);
+			$cd[$i]=0;
+		while ( (strlen($start_time[$i]) > 8) and ($cd[$i] < 100) )
+			{
+			$start_time[$i] = eregi_replace("^.","",$start_time[$i]);   
+			$cd[$i]++;
+			if (strlen($start_time[$i]) <= 8) {$cd[$i]=101;}
+			}
+		$uniqueid[$i] =			$Suniqueid[$i];
+		$lead_id[$i] =			$Slead_id[$i];
+		$closer[$i] =			$Suser[$i];
+		$call_time_S[$i] = ($STARTtime - $Scall_time[$i]);
+
+		$call_time_M[$i] = ($call_time_S[$i] / 60);
+		$call_time_M[$i] = round($call_time_M[$i], 2);
+		$call_time_M_int[$i] = intval("$call_time_M[$i]");
+		$call_time_SEC[$i] = ($call_time_M[$i] - $call_time_M_int[$i]);
+		$call_time_SEC[$i] = ($call_time_SEC[$i] * 60);
+		$call_time_SEC[$i] = round($call_time_SEC[$i], 0);
+		if ($call_time_SEC[$i] < 10) {$call_time_SEC[$i] = "0$call_time_SEC[$i]";}
+		$call_time_MS[$i] = "$call_time_M_int[$i]:$call_time_SEC[$i]";
+		$call_time_MS[$i] =		sprintf("%7s", $call_time_MS[$i]);
+
+		if ($closer_display<1)
+			{
+			$G = '';		$EG = '';
+			if ($call_time_M_int[$i] >= 5) {$G=''; $EG='';}
+			if ($call_time_M_int[$i] >= 10) {$G=''; $EG='';}
+			if (eregi("PAUSED",$Sstatus[$i])) 
+				{
+				if ($call_time_M_int >= 1) 
+					{$i++; continue;} 
+				else
+					{$G=''; $EG='';}
+				}
+			$agentcount++;
+			echo "| $G$extension[$i]$EG | $G$phone[$i]$EG | $G$user[$i]$EG | $G$sessionid[$i]$EG | $G$channel[$i]$EG | $G$status[$i]$EG | $G$start_time[$i]$EG | $G$call_time_MS[$i]$EG |\n";
+			}
+		$i++;
+		}
+
+		if ($closer_display>0)
+		{
+
+			$ext_count = $i;
+			$i=0;
+		while ($i < $ext_count)
+			{
+
+			$stmt="select campaign_id from vicidial_auto_calls where lead_id='$lead_id[$i]' and server_ip='" . mysql_real_escape_string($server_ip) . "';";
+			$rslt=mysql_query($stmt, $link);
+			if ($DB) {echo "$stmt\n";}
+			$camp_to_print = mysql_num_rows($rslt);
+			if ($camp_to_print > 0)
+				{
+				$row=mysql_fetch_row($rslt);
+				$campaign = sprintf("%-12s", $row[0]);
+				$camp_color = $row[0];
+				}
+			else
+				{$campaign = 'DEAD        ';   	$camp_color = 'DEAD';}
+			if (eregi("READY|PAUSED|CLOSER",$status[$i]))
+				{$campaign = '            ';   	$camp_color = '';}
+
+			$stmt="select user from vicidial_xfer_log where lead_id='$lead_id[$i]' and closer='$closer[$i]' order by call_date desc limit 1;";
+			$rslt=mysql_query($stmt, $link);
+			if ($DB) {echo "$stmt\n";}
+			$xfer_to_print = mysql_num_rows($rslt);
+			if ($xfer_to_print > 0)
+				{
+				$row=mysql_fetch_row($rslt);
+				$fronter = sprintf("%-6s", $row[0]);
+				}
+			else
+				{$fronter = '      ';}
+
+			$G = '';		$EG = '';
+			$G=""; $EG='';
+		#	if ($call_time_M_int[$i] >= 5) {$G=''; $EG='';}
+		#	if ($call_time_M_int[$i] >= 10) {$G=''; $EG='';}
+
+			echo "| $G$extension[$i]$EG | $G$phone[$i]$EG | $G$user[$i]$EG | $G$sessionid[$i]$EG | $G$channel[$i]$EG | $G$status[$i]$EG | $G$start_time[$i]$EG | $G$call_time_MS[$i]$EG | $G$campaign$EG | $G$fronter$EG |\n";
+
+			$i++;
+			}
+		echo "+------------+------------+--------+-----------+---------------------+--------+----------+---------+--------------+--------+\n";
+		echo "  $i agentes conectados ao servidor $server_ip\n\n";
+	#	echo "             - Acima de 5 minutos em chamada\n";
+	#	echo "             - Acima de 10 minutos em chamada\n";
+		}
+	else
+		{
+		echo "+------------+------------+--------+-----------+---------------------+--------+----------+---------+\n";
+		echo "  $agentcount agentes conectados ao servidor $server_ip\n\n";
+
+		echo "             - Agentes em pausa\n";
+		echo "             - Acima de 5 minutos em chamada\n";
+		echo "             - Acima de 10 minutos em chamada\n";
+		}
+
+	}
+	else
+	{
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	echo "*********************************AGENTES SEM CHAMADAS*********************************\n";
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	}
+
+
+###################################################################################
+###### OUTBOUND CALLS
+###################################################################################
+#echo "\n\n";
+echo "----------------------------------------------------------------------------------------";
+echo "\n\n";
+echo "Server-Specific Tempo Real Report        TRUNK SHORT: $balanceSHORT          $NOW_TIME\n\n";
+echo "+---------------------+--------+--------------+--------------------+----------+---------+\n";
+echo "| CHANNEL             | STATUS | CAMPANHA     | PHONE NUMBER       | CALLTIME | MINUTES |\n";
+echo "+---------------------+--------+--------------+--------------------+----------+---------+\n";
+
+$stmt="select channel,status,campaign_id,phone_code,phone_number,call_time,UNIX_TIMESTAMP(call_time) from vicidial_auto_calls where status NOT IN('XFER') and server_ip='" . mysql_real_escape_string($server_ip) . "' order by auto_call_id desc;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$parked_to_print = mysql_num_rows($rslt);
+	if ($parked_to_print > 0)
+	{
+	$i=0;
+	while ($i < $parked_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+
+		$channel =			sprintf("%-19s", $row[0]);
+			$cc=0;
+		while ( (strlen($channel) > 19) and ($cc < 100) )
+			{
+			$channel = eregi_replace(".$","",$channel);   
+			$cc++;
+			if (strlen($channel) <= 19) {$cc=101;}
+			}
+		$start_time =		sprintf("%-8s", $row[5]);
+			$cd=0;
+		while ( (strlen($start_time) > 8) and ($cd < 100) )
+			{
+			$start_time = eregi_replace("^.","",$start_time);   
+			$cd++;
+			if (strlen($start_time) <= 8) {$cd=101;}
+			}
+		$status =			sprintf("%-6s", $row[1]);
+		$campaign =			sprintf("%-12s", $row[2]);
+			$all_phone = "$row[3]$row[4]";
+		$number_dialed =	sprintf("%-18s", $all_phone);
+		$call_time_S = ($STARTtime - $row[6]);
+
+		$call_time_M = ($call_time_S / 60);
+		$call_time_M = round($call_time_M, 2);
+		$call_time_M_int = intval("$call_time_M");
+		$call_time_SEC = ($call_time_M - $call_time_M_int);
+		$call_time_SEC = ($call_time_SEC * 60);
+		$call_time_SEC = round($call_time_SEC, 0);
+		if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+		$call_time_MS = "$call_time_M_int:$call_time_SEC";
+		$call_time_MS =		sprintf("%7s", $call_time_MS);
+		$G = '';		$EG = '';
+		if (eregi("LIVE",$status)) {$G=''; $EG='';}
+	#	if ($call_time_M_int >= 6) {$G=''; $EG='';}
+
+		echo "| $G$channel$EG | $G$status$EG | $G$campaign$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+		$i++;
+		}
+
+		echo "+---------------------+--------+--------------+--------------------+----------+---------+\n";
+		echo "  $i chamadas sendo efetuadas $server_ip\n\n";
+
+		echo "             - CHAMADAS EM ESPERA\n";
+	#	echo "             - Over 5 minutes on hold\n";
+
+		}
+	else
+	{
+	echo "***************************************************************************************\n";
+	echo "***************************************************************************************\n";
+	echo "*******************************SEM CHAMADAS EM ESPERA*********************************\n";
+	echo "***************************************************************************************\n";
+	echo "***************************************************************************************\n";
+	}
+
+
+?>
+
+
+ + \ No newline at end of file diff --git a/LANG_www/vicidial_br/AST_timeonVDADall.php b/LANG_www/vicidial_br/AST_timeonVDADall.php new file mode 100644 index 00000000..cceb0a6b --- /dev/null +++ b/LANG_www/vicidial_br/AST_timeonVDADall.php @@ -0,0 +1,2347 @@ + LICENSE: AGPLv2 +# +# live real-time stats for the VICIDIAL Auto-Dialer all servers +# +# STOP=4000, SLOW=40, GO=4 seconds refresh interval +# +# CHANGELOG: +# 50406-0920 - Added Paused agents < 1 min +# 51130-1218 - Modified layout and info to show all servers in a vicidial system +# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60511-1343 - Added leads and drop info at the top of the screen +# 60608-1539 - Fixed CLOSER tallies for active calls +# 60619-1658 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# 60626-1453 - Added display of system load to bottom (Angelito Manansala) +# 60901-1123 - Changed display elements at the top of the screen +# 60905-1342 - Fixed non INCALL|QUEUE timer column +# 61002-1642 - Added TRUNK SHORT/FILL stats +# 61101-1318 - Added SIP and IAX Listen and Barge links option +# 61101-1647 - Added Usergroup column and user name option as well as sorting +# 61102-1155 - Made display of columns more modular, added ability to hide server info +# 61215-1131 - Added answered calls and drop percent taken from answered calls +# 70111-1600 - Added ability to use BLEND/INBND/*_C/*_B/*_I as closer campaigns +# 70123-1151 - Added non_latin options for substr in display variables, thanks Marin Blu +# 70206-1140 - Added call-type statuses to display(A-Auto, M-Manual, I-Inbound/Closer) +# 70619-1339 - Added Status Category tally display +# 71029-1900 - Changed CLOSER-type to not require campaign_id restriction +# 80227-0418 - Added priority to waiting calls display +# 80311-1550 - Added calls_today on all agents and wait time/in-group for inbound calls +# 80422-0033 - Added phonediaplay option, allow for toggle-sorting on sortable fields +# 80422-1001 - Fixed sort by phone login +# 80424-0515 - Added non_latin lookup from system_settings +# 80525-1040 - Added IVR status display and summary for inbound calls +# 80619-2047 - Added DISPO status for post-call-work while paused +# 80704-0543 - Added DEAD status for agents INCALL with no live call +# 80822-1222 - Added option for display of customer phone number +# 81011-0335 - Fixed remote agent display bug +# 81022-1500 - Added inbound call stats display option +# 81029-1023 - Changed drop percent calculation for multi-stat reports +# 81029-1706 - Added pause code display if enabled per campaign +# 81108-2337 - Added inbound-only section +# 90105-1153 - Changed monitor links to use 0 prefix instead of 6 +# 90202-0108 - Changed options to pop-out frame, added outbound_autodial_active option +# 90310-0906 - Added admin header +# 90428-0727 - Changed listen and barge to use the API and manager must enter phone +# 90508-0623 - Changed to PHP long tags +# 90518-0930 - Fixed $CALLSdisplay static assignment bug for some links(bug #210) +# 90524-2231 - Changed to use functions.php for seconds to HH:MM:SS conversion +# 90602-0405 - Added list mix display in statuses and order if active +# 90603-1845 - Fixed color coding bug +# 90627-0608 - Some Formatting changes, added in-group name display +# 90701-0657 - Fixed inbound=No calculation issues +# 90808-0212 - Fixed inbound only non-ALL bug, changed times to use agent last_state_change +# 90907-0915 - Added PARK status +# 90914-1154 - Added AgentOnly display column to waiting calls section +# 91102-2013 - Changed in-group color styles for incoming calls waiting +# 91204-1548 - Added ability to change agent in-groups and blended +# 100214-1127 - Added no-dialable-leads alert and in-groups stats option +# 100301-1229 - Added 3-WAY status for consultative transfer agents +# 100303-0930 - Added carrier stats display option +# + +$version = '2.2.0-52'; +$build = '100303-0930'; + +header ("Content-type: text/html; charset=utf-8"); + +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["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["RR"])) {$RR=$_GET["RR"];} + elseif (isset($_POST["RR"])) {$RR=$_POST["RR"];} +if (isset($_GET["inbound"])) {$inbound=$_GET["inbound"];} + elseif (isset($_POST["inbound"])) {$inbound=$_POST["inbound"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["groups"])) {$groups=$_GET["groups"];} + elseif (isset($_POST["groups"])) {$groups=$_POST["groups"];} +if (isset($_GET["usergroup"])) {$usergroup=$_GET["usergroup"];} + elseif (isset($_POST["usergroup"])) {$usergroup=$_POST["usergroup"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["adastats"])) {$adastats=$_GET["adastats"];} + elseif (isset($_POST["adastats"])) {$adastats=$_POST["adastats"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} +if (isset($_GET["SIPmonitorLINK"])) {$SIPmonitorLINK=$_GET["SIPmonitorLINK"];} + elseif (isset($_POST["SIPmonitorLINK"])) {$SIPmonitorLINK=$_POST["SIPmonitorLINK"];} +if (isset($_GET["IAXmonitorLINK"])) {$IAXmonitorLINK=$_GET["IAXmonitorLINK"];} + elseif (isset($_POST["IAXmonitorLINK"])) {$IAXmonitorLINK=$_POST["IAXmonitorLINK"];} +if (isset($_GET["UGdisplay"])) {$UGdisplay=$_GET["UGdisplay"];} + elseif (isset($_POST["UGdisplay"])) {$UGdisplay=$_POST["UGdisplay"];} +if (isset($_GET["UidORname"])) {$UidORname=$_GET["UidORname"];} + elseif (isset($_POST["UidORname"])) {$UidORname=$_POST["UidORname"];} +if (isset($_GET["orderby"])) {$orderby=$_GET["orderby"];} + elseif (isset($_POST["orderby"])) {$orderby=$_POST["orderby"];} +if (isset($_GET["SERVdisplay"])) {$SERVdisplay=$_GET["SERVdisplay"];} + elseif (isset($_POST["SERVdisplay"])) {$SERVdisplay=$_POST["SERVdisplay"];} +if (isset($_GET["CALLSdisplay"])) {$CALLSdisplay=$_GET["CALLSdisplay"];} + elseif (isset($_POST["CALLSdisplay"])) {$CALLSdisplay=$_POST["CALLSdisplay"];} +if (isset($_GET["PHONEdisplay"])) {$PHONEdisplay=$_GET["PHONEdisplay"];} + elseif (isset($_POST["PHONEdisplay"])) {$PHONEdisplay=$_POST["PHONEdisplay"];} +if (isset($_GET["CUSTPHONEdisplay"])) {$CUSTPHONEdisplay=$_GET["CUSTPHONEdisplay"];} + elseif (isset($_POST["CUSTPHONEdisplay"])) {$CUSTPHONEdisplay=$_POST["CUSTPHONEdisplay"];} +if (isset($_GET["NOLEADSalert"])) {$NOLEADSalert=$_GET["NOLEADSalert"];} + elseif (isset($_POST["NOLEADSalert"])) {$NOLEADSalert=$_POST["NOLEADSalert"];} +if (isset($_GET["DROPINGROUPstats"])) {$DROPINGROUPstats=$_GET["DROPINGROUPstats"];} + elseif (isset($_POST["DROPINGROUPstats"])) {$DROPINGROUPstats=$_POST["DROPINGROUPstats"];} +if (isset($_GET["ALLINGROUPstats"])) {$ALLINGROUPstats=$_GET["ALLINGROUPstats"];} + elseif (isset($_POST["ALLINGROUPstats"])) {$ALLINGROUPstats=$_POST["ALLINGROUPstats"];} +if (isset($_GET["with_inbound"])) {$with_inbound=$_GET["with_inbound"];} + elseif (isset($_POST["with_inbound"])) {$with_inbound=$_POST["with_inbound"];} +if (isset($_GET["monitor_active"])) {$monitor_active=$_GET["monitor_active"];} + elseif (isset($_POST["monitor_active"])) {$monitor_active=$_POST["monitor_active"];} +if (isset($_GET["monitor_phone"])) {$monitor_phone=$_GET["monitor_phone"];} + elseif (isset($_POST["monitor_phone"])) {$monitor_phone=$_POST["monitor_phone"];} +if (isset($_GET["CARRIERstats"])) {$CARRIERstats=$_GET["CARRIERstats"];} + elseif (isset($_POST["CARRIERstats"])) {$CARRIERstats=$_POST["CARRIERstats"];} + + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin,outbound_autodial_active FROM system_settings;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$qm_conf_ct = mysql_num_rows($rslt); +if ($qm_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $non_latin = $row[0]; + $outbound_autodial_active = $row[1]; + } +##### END SETTINGS LOOKUP ##### +########################################### + +if (!isset($DB)) {$DB=0;} +if (!isset($RR)) {$RR=40;} +if (!isset($group)) {$group='';} +if (!isset($usergroup)) {$usergroup='';} +if (!isset($UGdisplay)) {$UGdisplay=0;} # 0=no, 1=yes +if (!isset($UidORname)) {$UidORname=1;} # 0=id, 1=name +if (!isset($orderby)) {$orderby='timeup';} +if (!isset($SERVdisplay)) {$SERVdisplay=0;} # 0=no, 1=yes +if (!isset($CALLSdisplay)) {$CALLSdisplay=1;} # 0=no, 1=yes +if (!isset($PHONEdisplay)) {$PHONEdisplay=0;} # 0=no, 1=yes +if (!isset($CUSTPHONEdisplay)) {$CUSTPHONEdisplay=0;} # 0=no, 1=yes +if (!isset($PAUSEcodes)) {$PAUSEcodes='N';} # 0=no, 1=yes +if (!isset($with_inbound)) + { + if ($outbound_autodial_active > 0) + {$with_inbound='Y';} # N=no, Y=yes, O=only + else + {$with_inbound='O';} # N=no, Y=yes, O=only + } +$ingroup_detail=''; + +if (strlen($group)>1) {$groups[0] = $group; $RR=40;} +else {$group = $groups[0];} + +function get_server_load($windows = false) + { + $os = strtolower(PHP_OS); + if(strpos($os, "win") === false) + { + if(file_exists("/proc/loadavg")) + { + $load = file_get_contents("/proc/loadavg"); + $load = explode(' ', $load); + return $load[0] . ' ' . $load[1] . ' ' . $load[2]; + } + elseif(function_exists("shell_exec")) + { + $load = explode(' ', `uptime`); + return $load[count($load)-3] . ' ' . $load[count($load)-2] . ' ' . $load[count($load)-1]; + } + else + { + return false; + } + } + elseif($windows) + { + if(class_exists("COM")) + { + $wmi = new COM("WinMgmts:\\\\."); + $cpus = $wmi->InstancesOf("Win32_Processor"); + + $cpuload = 0; + $i = 0; + while ($cpu = $cpus->Next()) + { + $cpuload += $cpu->LoadPercentage; + $i++; + } + + $cpuload = round($cpuload / $i, 2); + return "$cpuload%"; + } + else + { + return false; + } + } + } + +$load_ave = get_server_load(true); + +$NOW_TIME = date("Y-m-d H:i:s"); +$NOW_DAY = date("Y-m-d"); +$NOW_HOUR = date("H:i:s"); +$STARTtime = date("U"); +$epochONEminuteAGO = ($STARTtime - 60); +$timeONEminuteAGO = date("Y-m-d H:i:s",$epochONEminuteAGO); +$epochFIVEminutesAGO = ($STARTtime - 300); +$timeFIVEminutesAGO = date("Y-m-d H:i:s",$epochFIVEminutesAGO); +$epochFIFTEENminutesAGO = ($STARTtime - 900); +$timeFIFTEENminutesAGO = date("Y-m-d H:i:s",$epochFIFTEENminutesAGO); +$epochONEhourAGO = ($STARTtime - 3600); +$timeONEhourAGO = date("Y-m-d H:i:s",$epochONEhourAGO); +$epochSIXhoursAGO = ($STARTtime - 21600); +$timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO); +$epochTWENTYFOURhoursAGO = ($STARTtime - 86400); +$timeTWENTYFOURhoursAGO = date("Y-m-d H:i:s",$epochTWENTYFOURhoursAGO); + + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6 and view_reports='1' and active='Y';"; +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 "Nome ou Senha inválidos: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } +# and (preg_match("/MONITOR|BARGE|HIJACK/",$monitor_active) ) ) +if ( (!isset($monitor_phone)) or (strlen($monitor_phone)<1) ) + { + $stmt="select phone_login from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active='Y';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $monitor_phone = $row[0]; + } + +$stmt="select campaign_id,campaign_name from vicidial_campaigns where active='Y' order by campaign_id;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +$LISTgroups[$i]='ALL-ACTIVE'; +$i++; +$groups_to_print++; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $LISTgroups[$i] =$row[0]; + $LISTnames[$i] =$row[1]; + $i++; + } + +$i=0; +$group_string='|'; +$group_ct = count($groups); +while($i < $group_ct) + { + $group_string .= "$groups[$i]|"; + $group_SQL .= "'$groups[$i]',"; + $groupQS .= "&groups[]=$groups[$i]"; + $i++; + } +$group_SQL = eregi_replace(",$",'',$group_SQL); + +### if no campaigns selected, display all +if ($group_ct < 1) + { + $groups[0] = 'ALL-ACTIVE'; + $group_string = 'ALL-ACTIVE'; + $group = 'ALL-ACTIVE'; + $groupQS .= "&groups[]=ALL-ACTIVE"; + } + +if ( (ereg("--NONE--",$group_string) ) or ($group_ct < 1) ) + { + $all_active = 0; + $group_SQL = "''"; + $group_SQLand = "and FALSE"; + $group_SQLwhere = "where FALSE"; + } +elseif ( eregi('ALL-ACTIVE',$group_string) ) + { + $all_active = 1; + $group_SQL = "''"; + $group_SQLand = ""; + $group_SQLwhere = ""; + } +else + { + $all_active = 0; + $group_SQLand = "and campaign_id IN($group_SQL)"; + $group_SQLwhere = "where campaign_id IN($group_SQL)"; + } + + +$stmt="select user_group from vicidial_user_groups;"; +$rslt=mysql_query($stmt, $link); +if (!isset($DB)) {$DB=0;} +if ($DB) {echo "$stmt\n";} +$usergroups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $usergroups_to_print) + { + $row=mysql_fetch_row($rslt); + $usergroups[$i] =$row[0]; + $i++; + } + +if (!isset($RR)) {$RR=4;} + +$NFB = ''; +$NFE = ''; +$F=''; $FG=''; $B=''; $BG=''; + +$select_list = "
Select Campanhas:
"; +$select_list .= ""; +$select_list .= "
(Para selecionar mais de 1 campanha, aperte Ctrl e clique)"; +$select_list .= "
"; +$select_list .= "Fechar Painel

"; +$select_list .= ""; + +$select_list .= ""; +$select_list .= ""; + +if ($UGdisplay > 0) + { + $select_list .= ""; + } + +$select_list .= ""; +$select_list .= ""; +$select_list .= "
"; +$select_list .= "Inbound:
 
"; + $select_list .= "Select Grupo do Usuário: "; + $select_list .= "
"; +$select_list .= "Dialable Leads Alert:
"; +$select_list .= "   "; +$select_list .= ""; +$select_list .= "VERSÃO: $version   BUILD: $build"; +$select_list .= "
"; + +$open_list = "
Escolher Opções do Relat.
"; + +?> + + + + + + +\n"; + +$stmt = "select count(*) from vicidial_campaigns where active='Y' and campaign_allow_inbound='Y' $group_SQLand;"; +$rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $campaign_allow_inbound = $row[0]; + +echo "\n"; +echo"\n"; +echo "Tempo Real Report: $group\n"; + + $short_header=1; + + require("admin_header.php"); + +echo ""; + $DROPINGROUPstatsHTML .= ""; + $DROPINGROUPstatsHTML .= ""; + $DROPINGROUPstatsHTML .= ""; + $DROPINGROUPstatsHTML .= ""; + $DROPINGROUPstatsHTML .= ""; + } + + +##### CARRIER STATS TOTALS ### +$CARRIERstatsHTML=''; +if ($CARRIERstats > 0) + { + $stmtB="select dialstatus,count(*) from vicidial_carrier_log where call_date >= \"$timeTWENTYFOURhoursAGO\" group by dialstatus;"; + if ($DB > 0) {echo "\n|$stmtB|\n";} + $rslt=mysql_query($stmtB, $link); + $car_to_print = mysql_num_rows($rslt); + $ctp=0; + while ($car_to_print > $ctp) + { + $row=mysql_fetch_row($rslt); + $TFhour_status[$ctp] = $row[0]; + $TFhour_count[$ctp] = $row[1]; + $dialstatuses .= "'$row[0]',"; + $ctp++; + } + $dialstatuses = preg_replace("/,$/",'',$dialstatuses); + + $CARRIERstatsHTML .= ""; + } + +# http://svn.eflo.net:40080/vicidial/AST_timeonVDADall.php?&groups[]=ALL-ACTIVE&RR=4000&DB=0&adastats=&SIPmonitorLINK=&IAXmonitorLINK=&usergroup=&UGdisplay=1&UidORname=1&orderby=timeup&SERVdisplay=0&CALLSdisplay=1&PHONEdisplay=0&CUSTPHONEdisplay=0&with_inbound=Y&monitor_active=&monitor_phone=350a&ALLINGROUPstats=1&DROPINGROUPstats=0&NOLEADSalert=&CARRIERstats=1 + +##### INBOUND ONLY ### +if (ereg('O',$with_inbound)) + { + $multi_drop++; + + $stmt="select agent_pause_codes_active from vicidial_campaigns $group_SQLwhere;"; + + $stmtB="select sum(calls_today),sum(drops_today),sum(answers_today),max(status_category_1),sum(status_category_count_1),max(status_category_2),sum(status_category_count_2),max(status_category_3),sum(status_category_count_3),max(status_category_4),sum(status_category_count_4),sum(hold_sec_stat_one),sum(hold_sec_stat_two),sum(hold_sec_answer_calls),sum(hold_sec_drop_calls),sum(hold_sec_queue_calls) from vicidial_campaign_stats where campaign_id IN ($closer_campaignsSQL);"; + + if (eregi('ALL-ACTIVE',$group_string)) + { + $inboundSQL = "where campaign_id IN ($ALLcloser_campaignsSQL)"; + $stmtB="select sum(calls_today),sum(drops_today),sum(answers_today),max(status_category_1),sum(status_category_count_1),max(status_category_2),sum(status_category_count_2),max(status_category_3),sum(status_category_count_3),max(status_category_4),sum(status_category_count_4),sum(hold_sec_stat_one),sum(hold_sec_stat_two),sum(hold_sec_answer_calls),sum(hold_sec_drop_calls),sum(hold_sec_queue_calls) from vicidial_campaign_stats $inboundSQL;"; + } + + $stmtC="select agent_non_pause_sec from vicidial_campaign_stats $group_SQLwhere;"; + + + if ($DB > 0) {echo "\n|$stmt|$stmtB|$stmtC|\n";} + + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $agent_pause_codes_active = $row[0]; + + $rslt=mysql_query($stmtC, $link); + $row=mysql_fetch_row($rslt); + $agent_non_pause_sec = $row[0]; + + $rslt=mysql_query($stmtB, $link); + $row=mysql_fetch_row($rslt); + $callsTODAY = $row[0]; + $dropsTODAY = $row[1]; + $answersTODAY = $row[2]; + $VSCcat1 = $row[3]; + $VSCcat1tally = $row[4]; + $VSCcat2 = $row[5]; + $VSCcat2tally = $row[6]; + $VSCcat3 = $row[7]; + $VSCcat3tally = $row[8]; + $VSCcat4 = $row[9]; + $VSCcat4tally = $row[10]; + $hold_sec_stat_one = $row[11]; + $hold_sec_stat_two = $row[12]; + $hold_sec_answer_calls = $row[13]; + $hold_sec_drop_calls = $row[14]; + $hold_sec_queue_calls = $row[15]; + if ( ($dropsTODAY > 0) and ($answersTODAY > 0) ) + { + $drpctTODAY = ( ($dropsTODAY / $answersTODAY) * 100); + $drpctTODAY = round($drpctTODAY, 2); + $drpctTODAY = sprintf("%01.2f", $drpctTODAY); + } + else + {$drpctTODAY=0;} + + if ($callsTODAY > 0) + { + $AVGhold_sec_queue_calls = ($hold_sec_queue_calls / $callsTODAY); + $AVGhold_sec_queue_calls = round($AVGhold_sec_queue_calls, 0); + } + else + {$AVGhold_sec_queue_calls=0;} + + if ($dropsTODAY > 0) + { + $AVGhold_sec_drop_calls = ($hold_sec_drop_calls / $dropsTODAY); + $AVGhold_sec_drop_calls = round($AVGhold_sec_drop_calls, 0); + } + else + {$AVGhold_sec_drop_calls=0;} + + if ($answersTODAY > 0) + { + $PCThold_sec_stat_one = ( ($hold_sec_stat_one / $answersTODAY) * 100); + $PCThold_sec_stat_one = round($PCThold_sec_stat_one, 2); + $PCThold_sec_stat_one = sprintf("%01.2f", $PCThold_sec_stat_one); + $PCThold_sec_stat_two = ( ($hold_sec_stat_two / $answersTODAY) * 100); + $PCThold_sec_stat_two = round($PCThold_sec_stat_two, 2); + $PCThold_sec_stat_two = sprintf("%01.2f", $PCThold_sec_stat_two); + $AVGhold_sec_answer_calls = ($hold_sec_answer_calls / $answersTODAY); + $AVGhold_sec_answer_calls = round($AVGhold_sec_answer_calls, 0); + if ($agent_non_pause_sec > 0) + { + $AVG_RESPOSTAagent_non_pause_sec = (($answersTODAY / $agent_non_pause_sec) * 60); + $AVG_RESPOSTAagent_non_pause_sec = round($AVG_RESPOSTAagent_non_pause_sec, 2); + $AVG_RESPOSTAagent_non_pause_sec = sprintf("%01.2f", $AVG_RESPOSTAagent_non_pause_sec); + } + else + {$AVG_RESPOSTAagent_non_pause_sec=0;} + } + else + { + $PCThold_sec_stat_one=0; + $PCThold_sec_stat_two=0; + $AVGhold_sec_answer_calls=0; + $AVG_RESPOSTAagent_non_pause_sec=0; + } + + echo "
"; + +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "Tempo Real Report                                                                               \n"; +echo "\n"; +echo "
\n"; +echo "Escolher Opções do Relat."; +echo "
\n"; +echo "
\n"; +echo "\n"; +echo "   "; +echo "\n"; +echo "STOP | "; +echo "SLOW | "; +echo "GO"; +if (eregi('ALL-ACTIVE',$group_string)) + { + echo "       ALTERAR | \n"; + } +else + { + echo "       ALTERAR | \n"; + } +echo "SUMMARY \n"; +echo "\n\n"; + + +if (!$group) + {echo "

please select a campaign from the pulldown above
\n"; exit;} +else +{ +$multi_drop=0; +### Gather list of all Closer group ids for exclusion from stats +$stmt = "select group_id from vicidial_inbound_groups;"; +$rslt=mysql_query($stmt, $link); +$ingroups_to_print = mysql_num_rows($rslt); +while ($ingroups_to_print > $c) + { + $row=mysql_fetch_row($rslt); + $ALLcloser_campaignsSQL .= "'$row[0]',"; + $c++; + } +$ALLcloser_campaignsSQL = preg_replace("/,$/","",$ALLcloser_campaignsSQL); +if (strlen($ALLcloser_campaignsSQL)<2) + {$ALLcloser_campaignsSQL="''";} +if ($DB > 0) {echo "\n|$ALLcloser_campaignsSQL|$stmt|\n";} + + +##### INBOUND ##### +if ( ( ereg('Y',$with_inbound) or ereg('O',$with_inbound) ) and ($campaign_allow_inbound > 0) ) + { + ### Gather list of Closer group ids + $stmt = "select closer_campaigns from vicidial_campaigns where active='Y' $group_SQLand;"; + $rslt=mysql_query($stmt, $link); + $ccamps_to_print = mysql_num_rows($rslt); + $c=0; + while ($ccamps_to_print > $c) + { + $row=mysql_fetch_row($rslt); + $closer_campaigns = $row[0]; + $closer_campaigns = preg_replace("/^ | -$/","",$closer_campaigns); + $closer_campaigns = preg_replace("/ /","','",$closer_campaigns); + $closer_campaignsSQL .= "'$closer_campaigns',"; + $c++; + } + $closer_campaignsSQL = preg_replace("/,$/","",$closer_campaignsSQL); + } +else + { + $closer_campaignsSQL = "''"; + } +if ($DB > 0) {echo "\n|$closer_campaigns|$closer_campaignsSQL|$stmt|\n";} + + +##### SHOW IN-GROUP STATS OR INBOUND ONLY WITH VIEW-MORE ### +if ( ($ALLINGROUPstats > 0) or ( (ereg('O',$with_inbound)) and ($adastats > 1) ) ) + { + $stmtB="select calls_today,drops_today,answers_today,status_category_1,status_category_count_1,status_category_2,status_category_count_2,status_category_3,status_category_count_3,status_category_4,status_category_count_4,hold_sec_stat_one,hold_sec_stat_two,hold_sec_answer_calls,hold_sec_drop_calls,hold_sec_queue_calls,campaign_id from vicidial_campaign_stats where campaign_id IN ($closer_campaignsSQL) order by campaign_id;"; + + if ($DB > 0) {echo "\n|$stmtB|\n";} + + $r=0; + $rslt=mysql_query($stmtB, $link); + $ingroups_to_print = mysql_num_rows($rslt); + if ($ingroups_to_print > 0) + {$ingroup_detail .= "";} + while ($ingroups_to_print > $r) + { + $row=mysql_fetch_row($rslt); + $callsTODAY = $row[0]; + $dropsTODAY = $row[1]; + $answersTODAY = $row[2]; + $VSCcat1 = $row[3]; + $VSCcat1tally = $row[4]; + $VSCcat2 = $row[5]; + $VSCcat2tally = $row[6]; + $VSCcat3 = $row[7]; + $VSCcat3tally = $row[8]; + $VSCcat4 = $row[9]; + $VSCcat4tally = $row[10]; + $hold_sec_stat_one = $row[11]; + $hold_sec_stat_two = $row[12]; + $hold_sec_answer_calls = $row[13]; + $hold_sec_drop_calls = $row[14]; + $hold_sec_queue_calls = $row[15]; + $ingroupdetail = $row[16]; + if ( ($dropsTODAY > 0) and ($answersTODAY > 0) ) + { + $drpctTODAY = ( ($dropsTODAY / $answersTODAY) * 100); + $drpctTODAY = round($drpctTODAY, 2); + $drpctTODAY = sprintf("%01.2f", $drpctTODAY); + } + else + {$drpctTODAY=0;} + + if ($callsTODAY > 0) + { + $AVGhold_sec_queue_calls = ($hold_sec_queue_calls / $callsTODAY); + $AVGhold_sec_queue_calls = round($AVGhold_sec_queue_calls, 0); + } + else + {$AVGhold_sec_queue_calls=0;} + + if ($dropsTODAY > 0) + { + $AVGhold_sec_drop_calls = ($hold_sec_drop_calls / $dropsTODAY); + $AVGhold_sec_drop_calls = round($AVGhold_sec_drop_calls, 0); + } + else + {$AVGhold_sec_drop_calls=0;} + + if ($answersTODAY > 0) + { + $PCThold_sec_stat_one = ( ($hold_sec_stat_one / $answersTODAY) * 100); + $PCThold_sec_stat_one = round($PCThold_sec_stat_one, 2); + $PCThold_sec_stat_one = sprintf("%01.2f", $PCThold_sec_stat_one); + $PCThold_sec_stat_two = ( ($hold_sec_stat_two / $answersTODAY) * 100); + $PCThold_sec_stat_two = round($PCThold_sec_stat_two, 2); + $PCThold_sec_stat_two = sprintf("%01.2f", $PCThold_sec_stat_two); + $AVGhold_sec_answer_calls = ($hold_sec_answer_calls / $answersTODAY); + $AVGhold_sec_answer_calls = round($AVGhold_sec_answer_calls, 0); + if ($agent_non_pause_sec > 0) + { + $AVG_RESPOSTAagent_non_pause_sec = (($answersTODAY / $agent_non_pause_sec) * 60); + $AVG_RESPOSTAagent_non_pause_sec = round($AVG_RESPOSTAagent_non_pause_sec, 2); + $AVG_RESPOSTAagent_non_pause_sec = sprintf("%01.2f", $AVG_RESPOSTAagent_non_pause_sec); + } + else + {$AVG_RESPOSTAagent_non_pause_sec=0;} + } + else + { + $PCThold_sec_stat_one=0; + $PCThold_sec_stat_two=0; + $AVGhold_sec_answer_calls=0; + $AVG_RESPOSTAagent_non_pause_sec=0; + } + + if (ereg("0$|2$|4$|6$|8$",$r)) {$bgcolor='#E6E6E6';} + else {$bgcolor='white';} + $ingroup_detail .= ""; + $ingroup_detail .= ""; + $ingroup_detail .= ""; + $ingroup_detail .= ""; + $ingroup_detail .= ""; + $ingroup_detail .= ""; + $ingroup_detail .= ""; + $ingroup_detail .= ""; + $ingroup_detail .= ""; + $ingroup_detail .= ""; + $ingroup_detail .= ""; + $ingroup_detail .= ""; + $ingroup_detail .= ""; + $ingroup_detail .= ""; + $ingroup_detail .= ""; + $ingroup_detail .= ""; + $ingroup_detail .= ""; + $ingroup_detail .= ""; + $ingroup_detail .= ""; + + $r++; + } + + if ($ingroups_to_print > 0) + {$ingroup_detail .= "
        $ingroupdetail   CALLS TODAY:  $callsTODAY    TMA 1:  $PCThold_sec_stat_one%     Average Hold time for Answered Calls:  $AVGhold_sec_answer_calls  
DROPS TODAY:  $dropsTODAY    TMA 2:  $PCThold_sec_stat_two%     Average Hold time for Dropped Calls:  $AVGhold_sec_drop_calls  
RESPOSTAS TODAY:  $answersTODAY    DROP PERCENT:  $drpctTODAY%    Average Hold time for All Calls:  $AVGhold_sec_queue_calls  
";} + } + + +##### DROP IN-GROUP ONLY TOTALS ROW ### +$DROPINGROUPstatsHTML=''; +if ( ($DROPINGROUPstats > 0) and (!preg_match("/ALL-ACTIVE/",$group_string)) ) + { + $DIGcampaigns=''; + $stmtB="select drop_inbound_group from vicidial_campaigns where campaign_id IN($group_SQL) and drop_inbound_group NOT IN('---NONE---','');"; + if ($DB > 0) {echo "\n|$stmtB|\n";} + $rslt=mysql_query($stmtB, $link); + $dig_to_print = mysql_num_rows($rslt); + $dtp=0; + while ($dig_to_print > $dtp) + { + $row=mysql_fetch_row($rslt); + $DIGcampaigns .= "'$row[0]',"; + $dtp++; + } + $DIGcampaigns = preg_replace("/,$/",'',$DIGcampaigns); + if (strlen($DIGcampaigns) < 2) {$DIGcampaigns = "''";} + + $stmtB="select sum(calls_today),sum(drops_today),sum(answers_today) from vicidial_campaign_stats where campaign_id IN($DIGcampaigns);"; + if ($DB > 0) {echo "\n|$stmtB|\n";} + + $rslt=mysql_query($stmtB, $link); + $row=mysql_fetch_row($rslt); + $callsTODAY = $row[0]; + $dropsTODAY = $row[1]; + $answersTODAY = $row[2]; + if ( ($dropsTODAY > 0) and ($callsTODAY > 0) ) + { + $drpctTODAY = ( ($dropsTODAY / $callsTODAY) * 100); + $drpctTODAY = round($drpctTODAY, 2); + $drpctTODAY = sprintf("%01.2f", $drpctTODAY); + } + else + {$drpctTODAY=0;} + + $DROPINGROUPstatsHTML .= "
DROP IN-GROUP STATS -DROP PERCENT:  $drpctTODAY%     CALLS:  $callsTODAY     DROPS/RESPOSTAS:  $dropsTODAY / $answersTODAY    
"; + $CARRIERstatsHTML .= ""; + $CARRIERstatsHTML .= ""; + $CARRIERstatsHTML .= ""; + $CARRIERstatsHTML .= ""; + $CARRIERstatsHTML .= ""; + $CARRIERstatsHTML .= ""; + $CARRIERstatsHTML .= ""; + $CARRIERstatsHTML .= ""; + $CARRIERstatsHTML .= ""; + $CARRIERstatsHTML .= ""; + $CARRIERstatsHTML .= ""; + + if (strlen($dialstatuses) > 1) + { + $stmtB="select dialstatus,count(*) from vicidial_carrier_log where call_date >= \"$timeSIXhoursAGO\" group by dialstatus;"; + if ($DB > 0) {echo "\n|$stmtB|\n";} + $rslt=mysql_query($stmtB, $link); + $scar_to_print = mysql_num_rows($rslt); + $print_sctp=0; + while ($scar_to_print > $print_sctp) + { + $row=mysql_fetch_row($rslt); + $print_ctp=0; + while ($print_ctp < $ctp) + { + if ($TFhour_status[$print_ctp] == $row[0]) + {$SIXhour_count[$print_ctp] = $row[1];} + $print_ctp++; + } + $print_sctp++; + } + + $stmtB="select dialstatus,count(*) from vicidial_carrier_log where call_date >= \"$timeONEhourAGO\" group by dialstatus;"; + if ($DB > 0) {echo "\n|$stmtB|\n";} + $rslt=mysql_query($stmtB, $link); + $scar_to_print = mysql_num_rows($rslt); + $print_sctp=0; + while ($scar_to_print > $print_sctp) + { + $row=mysql_fetch_row($rslt); + $print_ctp=0; + while ($print_ctp < $ctp) + { + if ($TFhour_status[$print_ctp] == $row[0]) + {$ONEhour_count[$print_ctp] = $row[1];} + $print_ctp++; + } + $print_sctp++; + } + + $stmtB="select dialstatus,count(*) from vicidial_carrier_log where call_date >= \"$timeFIFTEENminutesAGO\" group by dialstatus;"; + if ($DB > 0) {echo "\n|$stmtB|\n";} + $rslt=mysql_query($stmtB, $link); + $scar_to_print = mysql_num_rows($rslt); + $print_sctp=0; + while ($scar_to_print > $print_sctp) + { + $row=mysql_fetch_row($rslt); + $print_ctp=0; + while ($print_ctp < $ctp) + { + if ($TFhour_status[$print_ctp] == $row[0]) + {$FTminute_count[$print_ctp] = $row[1];} + $print_ctp++; + } + $print_sctp++; + } + + $stmtB="select dialstatus,count(*) from vicidial_carrier_log where call_date >= \"$timeFIVEminutesAGO\" group by dialstatus;"; + if ($DB > 0) {echo "\n|$stmtB|\n";} + $rslt=mysql_query($stmtB, $link); + $scar_to_print = mysql_num_rows($rslt); + $print_sctp=0; + while ($scar_to_print > $print_sctp) + { + $row=mysql_fetch_row($rslt); + $print_ctp=0; + while ($print_ctp < $ctp) + { + if ($TFhour_status[$print_ctp] == $row[0]) + {$FIVEminute_count[$print_ctp] = $row[1];} + $print_ctp++; + } + $print_sctp++; + } + + $stmtB="select dialstatus,count(*) from vicidial_carrier_log where call_date >= \"$timeONEminuteAGO\" group by dialstatus;"; + if ($DB > 0) {echo "\n|$stmtB|\n";} + $rslt=mysql_query($stmtB, $link); + $scar_to_print = mysql_num_rows($rslt); + $print_sctp=0; + while ($scar_to_print > $print_sctp) + { + $row=mysql_fetch_row($rslt); + $print_ctp=0; + while ($print_ctp < $ctp) + { + if ($TFhour_status[$print_ctp] == $row[0]) + {$ONEminute_count[$print_ctp] = $row[1];} + $print_ctp++; + } + $print_sctp++; + } + + + $print_ctp=0; + while ($print_ctp < $ctp) + { + if (strlen($TFhour_count[$print_ctp])<1) {$TFhour_count[$print_ctp]=0;} + if (strlen($SIXhour_count[$print_ctp])<1) {$SIXhour_count[$print_ctp]=0;} + if (strlen($ONEhour_count[$print_ctp])<1) {$ONEhour_count[$print_ctp]=0;} + if (strlen($FTminute_count[$print_ctp])<1) {$FTminute_count[$print_ctp]=0;} + if (strlen($FIVEminute_count[$print_ctp])<1) {$FIVEminute_count[$print_ctp]=0;} + if (strlen($ONEminute_count[$print_ctp])<1) {$ONEminute_count[$print_ctp]=0;} + + $CARRIERstatsHTML .= ""; + $CARRIERstatsHTML .= ""; + $CARRIERstatsHTML .= ""; + $CARRIERstatsHTML .= ""; + $CARRIERstatsHTML .= ""; + $CARRIERstatsHTML .= ""; + $CARRIERstatsHTML .= ""; + $CARRIERstatsHTML .= ""; + $CARRIERstatsHTML .= ""; + $CARRIERstatsHTML .= ""; + $print_ctp++; + } + } + else + { + $CARRIERstatsHTML .= ""; + } + $CARRIERstatsHTML .= "
CARRIER STATS:                 HANGUP STATUS     24 HOURS     6 HOURS     1 HOUR     15 MIN     5 MIN     1 MIN  
     $TFhour_status[$print_ctp] $TFhour_count[$print_ctp] $SIXhour_count[$print_ctp] $ONEhour_count[$print_ctp] $FTminute_count[$print_ctp] $FIVEminute_count[$print_ctp] $ONEminute_count[$print_ctp]
no log entries
"; + $CARRIERstatsHTML .= "
"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + +##### NOT INBOUND ONLY ### +else + { + if (eregi('ALL-ACTIVE',$group_string)) + { + $non_inboundSQL=''; + if (ereg('N',$with_inbound)) + {$non_inboundSQL = "where campaign_id NOT IN ($ALLcloser_campaignsSQL)";} + $multi_drop++; + $stmt="select avg(auto_dial_level),min(dial_status_a),min(dial_status_b),min(dial_status_c),min(dial_status_d),min(dial_status_e),min(lead_order),min(lead_filter_id),sum(hopper_level),min(dial_method),avg(adaptive_maximum_level),avg(adaptive_dropped_percentage),avg(adaptive_dl_diff_target),avg(adaptive_intensity),min(available_only_ratio_tally),min(adaptive_latest_server_time),min(local_call_time),avg(dial_timeout),min(dial_statuses),max(agent_pause_codes_active),max(list_order_mix) from vicidial_campaigns where active='Y';"; + + $stmtB="select sum(dialable_leads),sum(calls_today),sum(drops_today),avg(drops_answers_today_pct),avg(differential_onemin),avg(agents_average_onemin),sum(balance_trunk_fill),sum(answers_today),max(status_category_1),sum(status_category_count_1),max(status_category_2),sum(status_category_count_2),max(status_category_3),sum(status_category_count_3),max(status_category_4),sum(status_category_count_4) from vicidial_campaign_stats $non_inboundSQL;"; + } + else + { + if ($DB > 0) {echo "\n|$with_inbound|$campaign_allow_inbound|\n";} + + if ( (ereg('Y',$with_inbound)) and ($campaign_allow_inbound > 0) ) + { + $multi_drop++; + if ($DB) {echo "with_inbound|$with_inbound|$campaign_allow_inbound\n";} + + $stmt="select auto_dial_level,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,lead_filter_id,hopper_level,dial_method,adaptive_maximum_level,adaptive_dropped_percentage,adaptive_dl_diff_target,adaptive_intensity,available_only_ratio_tally,adaptive_latest_server_time,local_call_time,dial_timeout,dial_statuses,agent_pause_codes_active,list_order_mix from vicidial_campaigns where campaign_id IN ($group_SQL,$closer_campaignsSQL);"; + + $stmtB="select sum(dialable_leads),sum(calls_today),sum(drops_today),avg(drops_answers_today_pct),avg(differential_onemin),avg(agents_average_onemin),sum(balance_trunk_fill),sum(answers_today),max(status_category_1),sum(status_category_count_1),max(status_category_2),sum(status_category_count_2),max(status_category_3),sum(status_category_count_3),max(status_category_4),sum(status_category_count_4) from vicidial_campaign_stats where campaign_id IN ($group_SQL,$closer_campaignsSQL);"; + } + else + { + $stmt="select avg(auto_dial_level),max(dial_status_a),max(dial_status_b),max(dial_status_c),max(dial_status_d),max(dial_status_e),max(lead_order),max(lead_filter_id),max(hopper_level),max(dial_method),max(adaptive_maximum_level),avg(adaptive_dropped_percentage),avg(adaptive_dl_diff_target),avg(adaptive_intensity),max(available_only_ratio_tally),max(adaptive_latest_server_time),max(local_call_time),max(dial_timeout),max(dial_statuses),max(agent_pause_codes_active),max(list_order_mix) from vicidial_campaigns where campaign_id IN($group_SQL);"; + + $stmtB="select sum(dialable_leads),sum(calls_today),sum(drops_today),avg(drops_answers_today_pct),avg(differential_onemin),avg(agents_average_onemin),sum(balance_trunk_fill),sum(answers_today),max(status_category_1),sum(status_category_count_1),max(status_category_2),sum(status_category_count_2),max(status_category_3),sum(status_category_count_3),max(status_category_4),sum(status_category_count_4) from vicidial_campaign_stats where campaign_id IN($group_SQL);"; + } + } + if ($DB > 0) {echo "\n|$stmt|$stmtB|\n";} + + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $DIALlev = $row[0]; + $DIALstatusA = $row[1]; + $DIALstatusB = $row[2]; + $DIALstatusC = $row[3]; + $DIALstatusD = $row[4]; + $DIALstatusE = $row[5]; + $DIALorder = $row[6]; + $DIALfilter = $row[7]; + $HOPlev = $row[8]; + $DIALmethod = $row[9]; + $maxDIALlev = $row[10]; + $DROPmax = $row[11]; + $targetDIFF = $row[12]; + $ADAintense = $row[13]; + $ADAavailonly = $row[14]; + $TAPERtime = $row[15]; + $CALLtime = $row[16]; + $DIALtimeout = $row[17]; + $DIALstatuses = $row[18]; + $agent_pause_codes_active = $row[19]; + $DIALmix = $row[20]; + + + $stmt="select count(*) from vicidial_hopper $group_SQLwhere;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $VDhop = $row[0]; + + $rslt=mysql_query($stmtB, $link); + $row=mysql_fetch_row($rslt); + $DAleads = $row[0]; + $callsTODAY = $row[1]; + $dropsTODAY = $row[2]; + $drpctTODAY = $row[3]; + $diffONEMIN = $row[4]; + $agentsONEMIN = $row[5]; + $balanceFILL = $row[6]; + $answersTODAY = $row[7]; + if ($multi_drop > 0) + { + if ( ($dropsTODAY > 0) and ($answersTODAY > 0) ) + { + $drpctTODAY = ( ($dropsTODAY / $answersTODAY) * 100); + $drpctTODAY = round($drpctTODAY, 2); + $drpctTODAY = sprintf("%01.2f", $drpctTODAY); + } + else + {$drpctTODAY=0;} + } + $VSCcat1 = $row[8]; + $VSCcat1tally = $row[9]; + $VSCcat2 = $row[10]; + $VSCcat2tally = $row[11]; + $VSCcat3 = $row[12]; + $VSCcat3tally = $row[13]; + $VSCcat4 = $row[14]; + $VSCcat4tally = $row[15]; + + if ( ($diffONEMIN != 0) and ($agentsONEMIN > 0) ) + { + $diffpctONEMIN = ( ($diffONEMIN / $agentsONEMIN) * 100); + $diffpctONEMIN = sprintf("%01.2f", $diffpctONEMIN); + } + else {$diffpctONEMIN = '0.00';} + + $stmt="select sum(local_trunk_shortage) from vicidial_campaign_server_stats $group_SQLwhere;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $balanceSHORT = $row[0]; + + if (ereg('DISABLED',$DIALmix)) + { + $DIALstatuses = (preg_replace("/ -$|^ /","",$DIALstatuses)); + $DIALstatuses = (ereg_replace(' ',', ',$DIALstatuses)); + } + else + { + $stmt="select vcl_id from vicidial_campaigns_list_mix where status='ACTIVE' $groupSQLand limit 1;"; + $rslt=mysql_query($stmt, $link); + $Lmix_to_print = mysql_num_rows($rslt); + if ($Lmix_to_print > 0) + { + $row=mysql_fetch_row($rslt); + $DIALstatuses = "Mesclagem de Lista: $row[0]"; + $DIALorder = "Mesclagem de Lista: $row[0]"; + } + } + + echo "
CALLS TODAY:  $callsTODAY    TMA 1:  $PCThold_sec_stat_one%     Average Hold time for Answered Calls:  $AVGhold_sec_answer_calls   TIME:   $NOW_TIME
DROPS TODAY:  $dropsTODAY    TMA 2:  $PCThold_sec_stat_two%     Average Hold time for Dropped Calls:  $AVGhold_sec_drop_calls  
RESPOSTAS TODAY:  $answersTODAY    (Agent non-pause time / Answers)Average Hold time for All Calls:  $AVGhold_sec_queue_calls  
DROP PERCENT:  $drpctTODAY%    PRODUCTIVITY:  $AVG_RESPOSTAagent_non_pause_sec    
"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + if ($adastats>1) + { + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + echo ""; + echo ""; + echo ""; + + + echo ""; + echo ""; + echo ""; + + echo "$DROPINGROUPstatsHTML\n"; + echo "$CARRIERstatsHTML\n"; + } + +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo "
DIAL NÍVEL:  $DIALlev    TRUNK SHORT/FILL:  $balanceSHORT / $balanceFILL     FILTER:  $DIALfilter   TIME:   $NOW_TIME
- min   MAX NÍVEL:  $maxDIALlev   DROPPED MAX:  $DROPmax%    TARGET DIFF:  $targetDIFF     INTENSITY:  $ADAintense    
DIAL TIMEOUT:  $DIALtimeout  TAPER TIME:  $TAPERtime  LOCAL TIME:  $CALLtime  AVAIL ONLY:  $ADAavailonly  
DIALABLE LEADS:  $DAleads     CALLS TODAY:  $callsTODAY     AVG AGENTS:  $agentsONEMIN     MÉTODO DE DISC.:  $DIALmethod    
HOPPER NÍVEL:  $HOPlev     DROPPED / RESPOSTAED:  $dropsTODAY / $answersTODAY   DL DIFF:  $diffONEMIN     STATUS:  $DIALstatuses    
LEADS IN HOPPER:  $VDhop     DROPPED PERCENT:  "; + if ($drpctTODAY >= $DROPmax) + {echo "$drpctTODAY%";} + else + {echo "$drpctTODAY%";} + echo "    DIFF:  $diffpctONEMIN%     ORDER:  $DIALorder    
"; +if ( (!eregi('NULL',$VSCcat1)) and (strlen($VSCcat1)>0) ) + {echo "$VSCcat1:   $VSCcat1tally       \n";} +if ( (!eregi('NULL',$VSCcat2)) and (strlen($VSCcat2)>0) ) + {echo "$VSCcat2:   $VSCcat2tally       \n";} +if ( (!eregi('NULL',$VSCcat3)) and (strlen($VSCcat3)>0) ) + {echo "$VSCcat3:   $VSCcat3tally       \n";} +if ( (!eregi('NULL',$VSCcat4)) and (strlen($VSCcat4)>0) ) + {echo "$VSCcat4:   $VSCcat4tally       \n";} +echo "
"; + +echo "$ingroup_detail"; + +if ($adastats<2) + { + echo "+ VIEW MORE"; + } +else + { + echo "+ VIEW LESS"; + } +if ($UGdisplay>0) + { + echo "       ESCONDER GRUPO DE USUÁRIOS"; + } +else + { + echo "       VIEW GRUPO DE USUÁRIOS"; + } +if ($SERVdisplay>0) + { + echo "       ESCONDER SERVIDOR INFO"; + } +else + { + echo "       MOSTRAR SERVIDOR INFO"; + } +if ($CALLSdisplay>0) + { + echo "       ESCONDER WAITING CALLS"; + } +else + { + echo "       MOSTRAR WAITING CALLS"; + } + +if ($ALLINGROUPstats>0) + { + echo "       ESCONDER IN-GROUP STATS"; + } +else + { + echo "       MOSTRAR IN-GROUP STATS"; + } +if ($PHONEdisplay>0) + { + echo "       ESCONDER PHONES"; + } +else + { + echo "       MOSTRAR PHONES"; + } +if ($CUSTPHONEdisplay>0) + { + echo "       ESCONDER CUSTPHONES"; + } +else + { + echo "       MOSTRAR CUSTPHONES"; + } +echo "
"; + +echo "\n\n"; + +##### check for campaigns with no dialable leads if enabled ##### +if ( ($with_inbound != 'O') and ($NOLEADSalert == 'YES') ) + { + $NDLcampaigns=''; + $stmtB="select campaign_id from vicidial_campaign_stats where campaign_id IN($group_SQL) and dialable_leads < 1 order by campaign_id;"; + if ($DB > 0) {echo "\n|$stmt|$stmtB|\n";} + $rslt=mysql_query($stmtB, $link); + $campaigns_to_print = mysql_num_rows($rslt); + $ctp=0; + while ($campaigns_to_print > $ctp) + { + $row=mysql_fetch_row($rslt); + $NDLcampaigns .= " $row[0]   "; + $ctp++; + if (preg_match("/0$|5$/",$ctp)) + {$NDLcampaigns .= "
";} + } + if ($ctp > 0) + { + echo "\n"; + echo "
\n"; + echo "



Close Alert"; + echo "




Campanhas with no dialable leads:

$NDLcampaigns
"; + echo "










  "; + echo "
\n"; + echo "
\n"; + } + } +} + + + +################################################################################### +###### INBOUND/OUTBOUND CALLS +################################################################################### +if ($campaign_allow_inbound > 0) + { + if (eregi('ALL-ACTIVE',$group_string)) + { + $stmt="select closer_campaigns from vicidial_campaigns $group_SQLwhere"; + $rslt=mysql_query($stmt, $link); + $closer_campaigns=""; + while ($row=mysql_fetch_row($rslt)) + { + $closer_campaigns.="$row[0]"; + } + $closer_campaigns = preg_replace("/^ | -$/","",$closer_campaigns); + $closer_campaigns = preg_replace("/ - /"," ",$closer_campaigns); + $closer_campaigns = preg_replace("/ /","','",$closer_campaigns); + $closer_campaignsSQL = "'$closer_campaigns'"; + } + $stmtB="from vicidial_auto_calls where status NOT IN('XFER') and ( (call_type='IN' and campaign_id IN($closer_campaignsSQL)) or (call_type IN('OUT','OUTBALANCE') $group_SQLand) ) order by queue_priority desc,campaign_id,call_time;"; + } +else + { + $stmtB="from vicidial_auto_calls where status NOT IN('XFER') $group_SQLand order by queue_priority desc,campaign_id,call_time;"; + } +if ($CALLSdisplay > 0) + { + $stmtA = "SELECT status,campaign_id,phone_number,server_ip,UNIX_TIMESTAMP(call_time),call_type,queue_priority,agent_only"; + } +else + { + $stmtA = "SELECT status"; + } + + +$k=0; +$agentonlycount=0; +$stmt = "$stmtA $stmtB"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$parked_to_print = mysql_num_rows($rslt); + if ($parked_to_print > 0) + { + $i=0; + $out_total=0; + $out_ring=0; + $out_live=0; + $in_ivr=0; + while ($i < $parked_to_print) + { + $row=mysql_fetch_row($rslt); + + if (eregi("LIVE",$row[0])) + { + $out_live++; + + if ($CALLSdisplay > 0) + { + $CDstatus[$k] = $row[0]; + $CDcampaign_id[$k] = $row[1]; + $CDphone_number[$k] = $row[2]; + $CDserver_ip[$k] = $row[3]; + $CDcall_time[$k] = $row[4]; + $CDcall_type[$k] = $row[5]; + $CDqueue_priority[$k] = $row[6]; + $CDagent_only[$k] = $row[7]; + if (strlen($CDagent_only[$k]) > 0) {$agentonlycount++;} + $k++; + } + } + else + { + if (eregi("IVR",$row[0])) + { + $in_ivr++; + + if ($CALLSdisplay > 0) + { + $CDstatus[$k] = $row[0]; + $CDcampaign_id[$k] = $row[1]; + $CDphone_number[$k] = $row[2]; + $CDserver_ip[$k] = $row[3]; + $CDcall_time[$k] = $row[4]; + $CDcall_type[$k] = $row[5]; + $CDqueue_priority[$k] = $row[6]; + $CDagent_only[$k] = $row[7]; + if (strlen($CDagent_only[$k]) > 0) {$agentonlycount++;} + $k++; + } + } + if (eregi("CLOSER",$row[0])) + {$nothing=1;} + else + {$out_ring++;} + } + + $out_total++; + $i++; + } + + ##### MIDI alert audio file test ##### + # $test_midi=1; + # if ($test_midi > 0) + # { + # # echo ""; + # # echo ""; + # echo ""; + # echo " "; + # echo " "; + # echo " "; + # echo " "; + # echo " alt : test.mid"; + # echo ""; + # } + + if ($out_live > 0) {$F=''; $FG='';} + if ($out_live > 4) {$F=''; $FG='';} + if ($out_live > 9) {$F=''; $FG='';} + if ($out_live > 14) {$F=''; $FG='';} + + if ($campaign_allow_inbound > 0) + {echo "$NFB$out_total$NFE current active calls      \n";} + else + {echo "$NFB$out_total$NFE calls being placed       \n";} + + echo "$NFB$out_ring$NFE calls ringing         \n"; + echo "$NFB$F  $out_live $FG$NFE calls waiting for agents       \n"; + echo "$NFB  $in_ivr$NFE calls in IVR       \n"; + } + else + { + echo "SEM CHAMADAS EM ESPERA\n"; + } + + + +################################################################################### +###### CALLS WAITING +################################################################################### +$agentonlyheader = ''; +if ($agentonlycount > 0) + {$agentonlyheader = 'AGENTONLY';} +$Cecho = ''; +$Cecho .= "VICIDIAL: Calls Waiting $NOW_TIME\n"; +$Cecho .= "+--------+----------------------+--------------+-----------------+---------+------------+----------+\n"; +$Cecho .= "| STATUS | CAMPANHA | PHONE NUMBER | SERVER_IP | DIALTIME| CALL TYPE | PRIORIDADE | $agentonlyheader\n"; +$Cecho .= "+--------+----------------------+--------------+-----------------+---------+------------+----------+\n"; + +$p=0; +while($p<$k) + { + $Cstatus = sprintf("%-6s", $CDstatus[$p]); + $Ccampaign_id = sprintf("%-20s", $CDcampaign_id[$p]); + $Cphone_number = sprintf("%-12s", $CDphone_number[$p]); + $Cserver_ip = sprintf("%-15s", $CDserver_ip[$p]); + $Ccall_type = sprintf("%-10s", $CDcall_type[$p]); + $Cqueue_priority = sprintf("%8s", $CDqueue_priority[$p]); + $Cagent_only = sprintf("%8s", $CDagent_only[$p]); + + $Ccall_time_S = ($STARTtime - $CDcall_time[$p]); + $Ccall_time_MS = sec_convert($Ccall_time_S,'M'); + $Ccall_time_MS = sprintf("%7s", $Ccall_time_MS); + + $G = ''; $EG = ''; + if ($CDcall_type[$p] == 'IN') + { + $G=""; $EG=''; + } + if (strlen($CDagent_only[$p]) > 0) + {$Gcalltypedisplay = "$G$Cagent_only$EG";} + else + {$Gcalltypedisplay = '';} + + $Cecho .= "| $G$Cstatus$EG | $G$Ccampaign_id$EG | $G$Cphone_number$EG | $G$Cserver_ip$EG | $G$Ccall_time_MS$EG | $G$Ccall_type$EG | $G$Cqueue_priority$EG | $Gcalltypedisplay \n"; + + $p++; + } +$Cecho .= "+--------+----------------------+--------------+-----------------+---------+------------+----------+\n"; + +if ($p<1) + {$Cecho='';} + +################################################################################### +###### AGENT TIME ON SYSTEM +################################################################################### + +$agent_incall=0; +$agent_ready=0; +$agent_paused=0; +$agent_dead=0; +$agent_total=0; + +$phoneord=$orderby; +$userord=$orderby; +$groupord=$orderby; +$timeord=$orderby; +$campaignord=$orderby; + +if ($phoneord=='phoneup') {$phoneord='phonedown';} + else {$phoneord='phoneup';} +if ($userord=='userup') {$userord='userdown';} + else {$userord='userup';} +if ($groupord=='groupup') {$groupord='groupdown';} + else {$groupord='groupup';} +if ($timeord=='timeup') {$timeord='timedown';} + else {$timeord='timeup';} +if ($campaignord=='campaignup') {$campaignord='campaigndown';} + else {$campaignord='campaignup';} + +$Aecho = ''; +$Aecho .= "VICIDIAL: Agentes Time On Calls Campanha: $group_string $NOW_TIME\n"; + + +$HDbegin = "+"; +$HTbegin = "|"; +$HDstation = "----------------+"; +$HTstation = " STATION |"; +$HDphone = "-------------+"; +$HTphone = " PHONE |"; +$HDuser = "------------------------+"; + + +$HTuser = " USER "; +if ($UidORname>0) + { + $HTuser .= "MOSTRAR ID "; + } +else + { + $HTuser .= "MOSTRAR NAME"; + } + +$HTuser .= " INFO |"; + + +$HDusergroup = "--------------+"; +$HTusergroup = " GRUPO DE USUÁRIOS |"; +$HDsessionid = "------------------+"; +$HTsessionid = " SESSIONID |"; +$HDbarge = "-------+"; +$HTbarge = " BARGE |"; +$HDstatus = "----------+"; +$HTstatus = " STATUS |"; +$HDcustphone = "-------------+"; +$HTcustphone = " CUST PHONE |"; +$HDserver_ip = "-----------------+"; +$HTserver_ip = " SERVIDOR IP |"; +$HDcall_server_ip = "-----------------+"; +$HTcall_server_ip = " CALL SERVIDOR IP |"; +$HDtime = "---------+"; +$HTtime = " MM:SS |"; +$HDcampaign = "------------+"; +$HTcampaign = " CAMPANHA |"; +$HDcalls = "-------+"; +$HTcalls = " CALLS |"; +$HDpause = ''; +$HTpause = ''; +$HDigcall = "------+------------------"; +$HTigcall = " HOLD | IN-GROUP "; + +if (!ereg("N",$agent_pause_codes_active)) + { + $HDstatus = "----------"; + $HTstatus = " STATUS "; + $HDpause = "-------+"; + $HTpause = " PAUSE |"; + } +if ($PHONEdisplay < 1) + { + $HDphone = ''; + $HTphone = ''; + } +if ($CUSTPHONEdisplay < 1) + { + $HDcustphone = ''; + $HTcustphone = ''; + } +if ($UGdisplay < 1) + { + $HDusergroup = ''; + $HTusergroup = ''; + } +if ( ($SIPmonitorLINK<1) and ($IAXmonitorLINK<1) and (!preg_match("/MONITOR|BARGE/",$monitor_active) ) ) + { + $HDsessionid = "-----------+"; + $HTsessionid = " SESSIONID |"; + } +if ( ($SIPmonitorLINK<2) and ($IAXmonitorLINK<2) and (!preg_match("/BARGE/",$monitor_active) ) ) + { + $HDbarge = ''; + $HTbarge = ''; + } +if ($SERVdisplay < 1) + { + $HDserver_ip = ''; + $HTserver_ip = ''; + $HDcall_server_ip = ''; + $HTcall_server_ip = ''; + } + + + +$Aline = "$HDbegin$HDstation$HDphone$HDuser$HDusergroup$HDsessionid$HDbarge$HDstatus$HDpause$HDcustphone$HDserver_ip$HDcall_server_ip$HDtime$HDcampaign$HDcalls$HDigcall\n"; +$Bline = "$HTbegin$HTstation$HTphone$HTuser$HTusergroup$HTsessionid$HTbarge$HTstatus$HTpause$HTcustphone$HTserver_ip$HTcall_server_ip$HTtime$HTcampaign$HTcalls$HTigcall\n"; +$Aecho .= "$Aline"; +$Aecho .= "$Bline"; +$Aecho .= "$Aline"; + +if ($orderby=='timeup') {$orderSQL='vicidial_live_agents.status,last_call_time';} +if ($orderby=='timedown') {$orderSQL='vicidial_live_agents.status desc,last_call_time desc';} +if ($orderby=='campaignup') {$orderSQL='vicidial_live_agents.campaign_id,vicidial_live_agents.status,last_call_time';} +if ($orderby=='campaigndown') {$orderSQL='vicidial_live_agents.campaign_id desc,vicidial_live_agents.status desc,last_call_time desc';} +if ($orderby=='groupup') {$orderSQL='user_group,vicidial_live_agents.status,last_call_time';} +if ($orderby=='groupdown') {$orderSQL='user_group desc,vicidial_live_agents.status desc,last_call_time desc';} +if ($orderby=='phoneup') {$orderSQL='extension,server_ip';} +if ($orderby=='phonedown') {$orderSQL='extension desc,server_ip desc';} +if ($UidORname > 0) + { + if ($orderby=='userup') {$orderSQL='full_name,status,last_call_time';} + if ($orderby=='userdown') {$orderSQL='full_name desc,status desc,last_call_time desc';} + } +else + { + if ($orderby=='userup') {$orderSQL='vicidial_live_agents.user';} + if ($orderby=='userdown') {$orderSQL='vicidial_live_agents.user desc';} + } + +if (eregi('ALL-ACTIVE',$group_string)) {$UgroupSQL = '';} +else {$UgroupSQL = " and vicidial_live_agents.campaign_id IN($group_SQL)";} +if (strlen($usergroup)<1) {$usergroupSQL = '';} +else {$usergroupSQL = " and user_group='" . mysql_real_escape_string($usergroup) . "'";} + +$stmt="select extension,vicidial_live_agents.user,conf_exten,vicidial_live_agents.status,vicidial_live_agents.server_ip,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish),call_server_ip,vicidial_live_agents.campaign_id,vicidial_users.user_group,vicidial_users.full_name,vicidial_live_agents.comments,vicidial_live_agents.calls_today,vicidial_live_agents.callerid,lead_id,UNIX_TIMESTAMP(last_state_change) from vicidial_live_agents,vicidial_users where vicidial_live_agents.user=vicidial_users.user $UgroupSQL $usergroupSQL order by $orderSQL;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$talking_to_print = mysql_num_rows($rslt); + if ($talking_to_print > 0) + { + $i=0; + while ($i < $talking_to_print) + { + $row=mysql_fetch_row($rslt); + + $Aextension[$i] = $row[0]; + $Auser[$i] = $row[1]; + $Asessionid[$i] = $row[2]; + $Astatus[$i] = $row[3]; + $Aserver_ip[$i] = $row[4]; + $Acall_time[$i] = $row[5]; + $Acall_finish[$i] = $row[6]; + $Acall_server_ip[$i] = $row[7]; + $Acampaign_id[$i] = $row[8]; + $Auser_group[$i] = $row[9]; + $Afull_name[$i] = $row[10]; + $Acomments[$i] = $row[11]; + $Acalls_today[$i] = $row[12]; + $Acallerid[$i] = $row[13]; + $Alead_id[$i] = $row[14]; + $Astate_change[$i] = $row[15]; + + ### 3-WAY Check ### + if ($Alead_id[$i]!=0) + { + $threewaystmt="select UNIX_TIMESTAMP(last_call_time) from vicidial_live_agents where lead_id='$Alead_id[$i]' and status='INCALL' order by UNIX_TIMESTAMP(last_call_time) desc"; + $threewayrslt=mysql_query($threewaystmt, $link); + if (mysql_num_rows($threewayrslt)>1) + { + $Astatus[$i]="3-WAY"; + $srow=mysql_fetch_row($threewayrslt); + $Acall_mostrecent[$i]=$srow[0]; + } + } + ### END 3-WAY Check ### + + $i++; + } + +$callerids=''; +$pausecode=''; +$stmt="select callerid,lead_id,phone_number from vicidial_auto_calls;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$calls_to_list = mysql_num_rows($rslt); + if ($calls_to_list > 0) + { + $i=0; + while ($i < $calls_to_list) + { + $row=mysql_fetch_row($rslt); + $callerids .= "$row[0]|"; + $VAClead_ids[$i] = $row[1]; + $VACphones[$i] = $row[2]; + $i++; + } + } + +### Lookup phone logins + $i=0; + while ($i < $talking_to_print) + { + if (eregi("R/",$Aextension[$i])) + { + $protocol = 'EXTERNAL'; + $dialplan = eregi_replace('R/',"",$Aextension[$i]); + $dialplan = eregi_replace("\@.*",'',$dialplan); + $exten = "dialplan_number='$dialplan'"; + } + if (eregi("Local/",$Aextension[$i])) + { + $protocol = 'EXTERNAL'; + $dialplan = eregi_replace('Local/',"",$Aextension[$i]); + $dialplan = eregi_replace("\@.*",'',$dialplan); + $exten = "dialplan_number='$dialplan'"; + } + if (eregi('SIP/',$Aextension[$i])) + { + $protocol = 'SIP'; + $dialplan = eregi_replace('SIP/',"",$Aextension[$i]); + $dialplan = eregi_replace("-.*",'',$dialplan); + $exten = "extension='$dialplan'"; + } + if (eregi('IAX2/',$Aextension[$i])) + { + $protocol = 'IAX2'; + $dialplan = eregi_replace('IAX2/',"",$Aextension[$i]); + $dialplan = eregi_replace("-.*",'',$dialplan); + $exten = "extension='$dialplan'"; + } + if (eregi('Zap/',$Aextension[$i])) + { + $protocol = 'Zap'; + $dialplan = eregi_replace('Zap/',"",$Aextension[$i]); + $exten = "extension='$dialplan'"; + } + if (eregi('DAHDI/',$Aextension[$i])) + { + $protocol = 'Zap'; + $dialplan = eregi_replace('DAHDI/',"",$Aextension[$i]); + $exten = "extension='$dialplan'"; + } + + $stmt="select login from phones where server_ip='$Aserver_ip[$i]' and $exten and protocol='$protocol';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $phones_to_print = mysql_num_rows($rslt); + if ($phones_to_print > 0) + { + $row=mysql_fetch_row($rslt); + $Alogin[$i] = "$row[0]-----$i"; + } + else + { + $Alogin[$i] = "$Aextension[$i]-----$i"; + } + $i++; + } + +### Sort by phone if selected + if ($orderby=='phoneup') + { + sort($Alogin); + } + if ($orderby=='phonedown') + { + rsort($Alogin); + } + +### Run through the loop to display agents + $j=0; + $agentcount=0; + while ($j < $talking_to_print) + { + $n=0; + $custphone=''; + while ($n < $calls_to_list) + { + if ( (ereg("$VAClead_ids[$n]", $Alead_id[$j])) and (strlen($VAClead_ids[$n]) == strlen($Alead_id[$j])) ) + {$custphone = $VACphones[$n];} + $n++; + } + + $phone_split = explode("-----",$Alogin[$j]); + $i = $phone_split[1]; + + if (eregi("READY|PAUSED",$Astatus[$i])) + { + $Acall_time[$i]=$Astate_change[$i]; + + if ($Alead_id[$i] > 0) + { + $Astatus[$i] = 'DISPO'; + $Lstatus = 'DISPO'; + $status = ' DISPO'; + } + } + if ($non_latin < 1) + { + $extension = eregi_replace('Local/',"",$Aextension[$i]); + $extension = sprintf("%-14s", $extension); + while(strlen($extension)>14) {$extension = substr("$extension", 0, -1);} + } + else + { + $extension = eregi_replace('Local/',"",$Aextension[$i]); + $extension = sprintf("%-48s", $extension); + while(mb_strlen($extension, 'utf-8')>14) {$extension = mb_substr("$extension", 0, -1,'utf8');} + } + + $phone = sprintf("%-12s", $phone_split[0]); + $custphone = sprintf("%-11s", $custphone); + $Luser = $Auser[$i]; + $user = sprintf("%-20s", $Auser[$i]); + $Lsessionid = $Asessionid[$i]; + $sessionid = sprintf("%-9s", $Asessionid[$i]); + $Lstatus = $Astatus[$i]; + $status = sprintf("%-6s", $Astatus[$i]); + $Lserver_ip = $Aserver_ip[$i]; + $server_ip = sprintf("%-15s", $Aserver_ip[$i]); + $call_server_ip = sprintf("%-15s", $Acall_server_ip[$i]); + $campaign_id = sprintf("%-10s", $Acampaign_id[$i]); + $comments= $Acomments[$i]; + $calls_today = sprintf("%-5s", $Acalls_today[$i]); + + if (!ereg("N",$agent_pause_codes_active)) + {$pausecode=' ';} + else + {$pausecode='';} + + if (eregi("INCALL",$Lstatus)) + { + $stmtP="select count(*) from parked_channels where channel_group='$Acallerid[$i]';"; + $rsltP=mysql_query($stmtP,$link); + $rowP=mysql_fetch_row($rsltP); + $parked_channel = $rowP[0]; + + if ($parked_channel > 0) + { + $Astatus[$i] = 'PARK'; + $Lstatus = 'PARK'; + $status = ' PARK '; + } + else + { + if (!ereg("$Acallerid[$i]\|",$callerids)) + { + $Acall_time[$i]=$Astate_change[$i]; + + $Astatus[$i] = 'DEAD'; + $Lstatus = 'DEAD'; + $status = ' DEAD '; + } + } + + if ( (eregi("AUTO",$comments)) or (strlen($comments)<1) ) + {$CM='A';} + else + { + if (eregi("ENTRANTE",$comments)) + {$CM='I';} + else + {$CM='M';} + } + } + else {$CM=' ';} + + if ($UGdisplay > 0) + { + if ($non_latin < 1) + { + $user_group = sprintf("%-12s", $Auser_group[$i]); + while(strlen($user_group)>12) {$user_group = substr("$user_group", 0, -1);} + } + else + { + $user_group = sprintf("%-40s", $Auser_group[$i]); + while(mb_strlen($user_group, 'utf-8')>12) {$user_group = mb_substr("$user_group", 0, -1,'utf8');} + } + } + if ($UidORname > 0) + { + if ($non_latin < 1) + { + $user = sprintf("%-20s", $Afull_name[$i]); + while(strlen($user)>20) {$user = substr("$user", 0, -1);} + } + else + { + $user = sprintf("%-60s", $Afull_name[$i]); + while(mb_strlen($user, 'utf-8')>20) {$user = mb_substr("$user", 0, -1,'utf8');} + } + } + if (!eregi("INCALL|QUEUE|PARK|3-WAY",$Astatus[$i])) + {$call_time_S = ($STARTtime - $Astate_change[$i]);} + else if (eregi("3-WAY",$Astatus[$i])) + {$call_time_S = ($STARTtime - $Acall_mostrecent[$i]);} + else + {$call_time_S = ($STARTtime - $Acall_time[$i]);} + + $call_time_MS = sec_convert($call_time_S,'M'); + $call_time_MS = sprintf("%7s", $call_time_MS); + $G = ''; $EG = ''; + if ( ($Lstatus=='INCALL') or ($Lstatus=='PARK') ) + { + if ($call_time_S >= 10) {$G=''; $EG='';} + if ($call_time_S >= 60) {$G=''; $EG='';} + if ($call_time_S >= 300) {$G=''; $EG='';} + # if ($call_time_S >= 600) {$G=''; $EG='';} + } + if ($Lstatus=='3-WAY') + { + if ($call_time_S >= 10) {$G=''; $EG='';} + } + if ($Lstatus=='DEAD') + { + if ($call_time_S >= 21600) + {$j++; continue;} + else + { + $agent_dead++; $agent_total++; + $G=''; $EG=''; + if ($call_time_S >= 10) {$G=''; $EG='';} + } + } + if ($Lstatus=='DISPO') + { + if ($call_time_S >= 21600) + {$j++; continue;} + else + { + $agent_paused++; $agent_total++; + $G=''; $EG=''; + if ($call_time_S >= 10) {$G=''; $EG='';} + if ($call_time_S >= 60) {$G=''; $EG='';} + if ($call_time_S >= 300) {$G=''; $EG='';} + } + } + if ($Lstatus=='PAUSED') + { + if (!ereg("N",$agent_pause_codes_active)) + { + $stmtC="select sub_status from vicidial_agent_log where user='$Luser' order by agent_log_id desc limit 1;"; + $rsltC=mysql_query($stmtC,$link); + $rowC=mysql_fetch_row($rsltC); + $pausecode = sprintf("%-6s", $rowC[0]); + $pausecode = "$pausecode "; + } + else + {$pausecode='';} + + if ($call_time_S >= 21600) + {$j++; continue;} + else + { + $agent_paused++; $agent_total++; + $G=''; $EG=''; + if ($call_time_S >= 10) {$G=''; $EG='';} + if ($call_time_S >= 60) {$G=''; $EG='';} + if ($call_time_S >= 300) {$G=''; $EG='';} + } + } +# if ( (strlen($Acall_server_ip[$i])> 4) and ($Acall_server_ip[$i] != "$Aserver_ip[$i]") ) +# {$G=''; $EG='';} + + if ( (eregi("INCALL",$status)) or (eregi("QUEUE",$status)) or (eregi("3-WAY",$status)) or (eregi("PARK",$status))) {$agent_incall++; $agent_total++;} + if ( (eregi("READY",$status)) or (eregi("CLOSER",$status)) ) {$agent_ready++; $agent_total++;} + if ( (eregi("READY",$status)) or (eregi("CLOSER",$status)) ) + { + $G=''; $EG=''; + if ($call_time_S >= 60) {$G=''; $EG='';} + if ($call_time_S >= 300) {$G=''; $EG='';} + } + + $L=''; + $R=''; + if ($SIPmonitorLINK>0) {$L=" LISTEN"; $R='';} + if ($IAXmonitorLINK>0) {$L=" LISTEN"; $R='';} + if ($SIPmonitorLINK>1) {$R=" | BARGE";} + if ($IAXmonitorLINK>1) {$R=" | BARGE";} + if ( (strlen($monitor_phone)>1) and (preg_match("/MONITOR|BARGE/",$monitor_active) ) ) + {$L=" LISTEN"; $R='';} + if ( (strlen($monitor_phone)>1) and (preg_match("/BARGE/",$monitor_active) ) ) + {$R=" | BARGE";} + + if ($CUSTPHONEdisplay > 0) {$CP = " $G$custphone$EG |";} + else {$CP = "";} + + if ($UGdisplay > 0) {$UGD = " $G$user_group$EG |";} + else {$UGD = "";} + + if ($SERVdisplay > 0) {$SVD = "$G$server_ip$EG | $G$call_server_ip$EG | ";} + else {$SVD = "";} + + if ($PHONEdisplay > 0) {$phoneD = "$G$phone$EG | ";} + else {$phoneD = " ";} + + $vac_stage=''; + $vac_campaign=''; + $INGRP=''; + if ($CM == 'I') + { + $stmt="select vac.campaign_id,vac.stage,vig.group_name from vicidial_auto_calls vac,vicidial_inbound_groups vig where vac.callerid='$Acallerid[$i]' and vac.campaign_id=vig.group_id LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $ingrp_to_print = mysql_num_rows($rslt); + if ($ingrp_to_print > 0) + { + $row=mysql_fetch_row($rslt); + $vac_campaign = sprintf("%-20s", "$row[0] - $row[2]"); + $row[1] = eregi_replace(".*-",'',$row[1]); + $vac_stage = sprintf("%-4s", $row[1]); + } + + $INGRP = " $G$vac_stage$EG | $G$vac_campaign$EG "; + } + + $agentcount++; + + $Aecho .= "| $G$extension$EG |$phoneD$G$user$EG + |$UGD $G$sessionid$EG$L$R | $G$status$EG $CM $pausecode| $CP$SVD$G$call_time_MS$EG | $G$campaign_id$EG | $G$calls_today$EG |$INGRP\n"; + + $j++; + } + + $Aecho .= "$Aline"; + $Aecho .= " $agentcount agents logged in on all servers\n"; + $Aecho .= " Carga do Sistema Average: $load_ave\n\n"; + + # $Aecho .= " - Balanced call\n"; + $Aecho .= " - Agent waiting for call\n"; + $Aecho .= " - Agent waiting for call > 1 minute\n"; + $Aecho .= " - Agent waiting for call > 5 minutes\n"; + $Aecho .= " - Agent on call > 10 seconds\n"; + $Aecho .= " - Agent on call > 1 minute\n"; + $Aecho .= " - Agent on call > 5 minutes\n"; + $Aecho .= " - Agent Paused > 10 seconds\n"; + $Aecho .= " - Agent Paused > 1 minute\n"; + $Aecho .= " - Agent Paused > 5 minutes\n"; + $Aecho .= " - Agent in 3-WAY > 10 seconds\n"; + $Aecho .= " - Agent on a dead call\n"; + + if ($agent_ready > 0) {$B=''; $BG='';} + if ($agent_ready > 4) {$B=''; $BG='';} + if ($agent_ready > 9) {$B=''; $BG='';} + if ($agent_ready > 14) {$B=''; $BG='';} + + + echo "\n
\n"; + + echo "$NFB$agent_total$NFE agents logged in         \n"; + echo "$NFB$agent_incall$NFE agents in calls       \n"; + echo "$NFB$B  $agent_ready $BG$NFE agents waiting       \n"; + echo "$NFB$agent_paused$NFE paused agents       \n"; + echo "$NFB$agent_dead$NFE agentes em chamadas perdidas      \n"; + + echo "
";
+		echo "";
+		echo "$Cecho";
+		echo "$Aecho";
+	}
+	else
+	{
+	echo "AGENTES SEM CHAMADAS\n";
+	echo "
$Cecho";
+	}
+
+?>
+
+
+ + diff --git a/LANG_www/vicidial_br/AST_timeonVDADallSUMMARY.php b/LANG_www/vicidial_br/AST_timeonVDADallSUMMARY.php new file mode 100644 index 00000000..652f014e --- /dev/null +++ b/LANG_www/vicidial_br/AST_timeonVDADallSUMMARY.php @@ -0,0 +1,457 @@ + LICENSE: AGPLv2 +# +# Summary for all campaigns live real-time stats for the VICIDIAL Auto-Dialer all servers +# +# STOP=4000, SLOW=40, GO=4 seconds refresh interval +# +# changes: +# 61102-1616 - first build +# 61215-1131 - added answered calls and drop percent taken from answered calls +# 70111-1600 - added ability to use BLEND/INBND/*_C/*_B/*_I as closer campaigns +# 70619-1339 - Added Status Category tally display +# 71029-1900 - Changed CLOSER-type to not require campaign_id restriction +# 80525-1040 - Added IVR status summary display for inbound calls +# 90310-2119 - Added admin header +# 90508-0644 - Changed to PHP long tags +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["RR"])) {$RR=$_GET["RR"];} + elseif (isset($_POST["RR"])) {$RR=$_POST["RR"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["adastats"])) {$adastats=$_GET["adastats"];} + elseif (isset($_POST["adastats"])) {$adastats=$_POST["adastats"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} + +if (!isset($RR)) {$gRRroup=4;} + + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $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";} + $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 "Nome ou Senha inválidos: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); + +$stmt="select campaign_id from vicidial_campaigns where active='Y';"; +$rslt=mysql_query($stmt, $link); +if (!isset($DB)) {$DB=0;} +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } + +if (!isset($RR)) {$RR=4;} + +?> + + + + + +\n"; +echo "Tempo Real All Campanhas Summary\n"; + + $short_header=1; + + require("admin_header.php"); + +echo "
"; + +echo "Tempo Real All Campanhas Summary           \n"; +echo "STOP | "; +echo "SLOW | "; +echo "GO "; +echo "       \n"; +if ($adastats<2) + { + echo "+ VIEW MORE SETTINGS"; + } +else + { + echo "- VIEW LESS SETTINGS"; + } +echo "       RELATÓRIOS"; +echo "

\n\n"; + +$k=0; +while($k<$groups_to_print) +{ +$NFB = ''; +$NFE = ''; +$F=''; $FG=''; $B=''; $BG=''; + +$group = $groups[$k]; +echo "$group   -   "; +echo "Modify\n"; + + +$stmt = "select count(*) from vicidial_campaigns where campaign_id='$group' and campaign_allow_inbound='Y';"; +$rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $campaign_allow_inbound = $row[0]; + +$stmt="select auto_dial_level,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,lead_filter_id,hopper_level,dial_method,adaptive_maximum_level,adaptive_dropped_percentage,adaptive_dl_diff_target,adaptive_intensity,available_only_ratio_tally,adaptive_latest_server_time,local_call_time,dial_timeout,dial_statuses from vicidial_campaigns where campaign_id='" . mysql_real_escape_string($group) . "';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$DIALlev = $row[0]; +$DIALstatusA = $row[1]; +$DIALstatusB = $row[2]; +$DIALstatusC = $row[3]; +$DIALstatusD = $row[4]; +$DIALstatusE = $row[5]; +$DIALorder = $row[6]; +$DIALfilter = $row[7]; +$HOPlev = $row[8]; +$DIALmethod = $row[9]; +$maxDIALlev = $row[10]; +$DROPmax = $row[11]; +$targetDIFF = $row[12]; +$ADAintense = $row[13]; +$ADAavailonly = $row[14]; +$TAPERtime = $row[15]; +$CALLtime = $row[16]; +$DIALtimeout = $row[17]; +$DIALstatuses = $row[18]; + $DIALstatuses = (preg_replace("/ -$|^ /","",$DIALstatuses)); + $DIALstatuses = (ereg_replace(' ',', ',$DIALstatuses)); + +$stmt="select count(*) from vicidial_hopper where campaign_id='" . mysql_real_escape_string($group) . "';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$VDhop = $row[0]; + +$stmt="select dialable_leads,calls_today,drops_today,drops_answers_today_pct,differential_onemin,agents_average_onemin,balance_trunk_fill,answers_today,status_category_1,status_category_count_1,status_category_2,status_category_count_2,status_category_3,status_category_count_3,status_category_4,status_category_count_4 from vicidial_campaign_stats where campaign_id='" . mysql_real_escape_string($group) . "';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$DAleads = $row[0]; +$callsTODAY = $row[1]; +$dropsTODAY = $row[2]; +$drpctTODAY = $row[3]; +$diffONEMIN = $row[4]; +$agentsONEMIN = $row[5]; +$balanceFILL = $row[6]; +$answersTODAY = $row[7]; +$VSCcat1 = $row[8]; +$VSCcat1tally = $row[9]; +$VSCcat2 = $row[10]; +$VSCcat2tally = $row[11]; +$VSCcat3 = $row[12]; +$VSCcat3tally = $row[13]; +$VSCcat4 = $row[14]; +$VSCcat4tally = $row[15]; + +if ( ($diffONEMIN != 0) and ($agentsONEMIN > 0) ) + { + $diffpctONEMIN = ( ($diffONEMIN / $agentsONEMIN) * 100); + $diffpctONEMIN = sprintf("%01.2f", $diffpctONEMIN); + } +else {$diffpctONEMIN = '0.00';} + +$stmt="select sum(local_trunk_shortage) from vicidial_campaign_server_stats where campaign_id='" . mysql_real_escape_string($group) . "';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$balanceSHORT = $row[0]; + +echo "
"; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; + +if ($adastats>1) + { + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; + +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; + +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; + +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo "
DIAL NÍVEL:  $DIALlev    TRUNK SHORT/FILL:  $balanceSHORT / $balanceFILL     FILTER:  $DIALfilter   TIME:   $NOW_TIME
  MAX NÍVEL:  $maxDIALlev   DROPPED MAX:  $DROPmax%    TARGET DIFF:  $targetDIFF     INTENSITY:  $ADAintense    
DIAL TIMEOUT:  $DIALtimeout  TAPER TIME:  $TAPERtime  LOCAL TIME:  $CALLtime  AVAIL ONLY:  $ADAavailonly  
DIALABLE LEADS:  $DAleads     CALLS TODAY:  $callsTODAY     AVG AGENTS:  $agentsONEMIN     MÉTODO DE DISC.:  $DIALmethod    
HOPPER NÍVEL:  $HOPlev     DROPPED / RESPOSTAED:  $dropsTODAY / $answersTODAY   DL DIFF:  $diffONEMIN     STATUS:  $DIALstatuses    
LEADS IN HOPPER:  $VDhop     DROPPED PERCENT:  "; +if ($drpctTODAY >= $DROPmax) + {echo "$drpctTODAY%";} +else + {echo "$drpctTODAY%";} +echo "    DIFF:  $diffpctONEMIN%     ORDER:  $DIALorder    
"; +if ( (!eregi('NULL',$VSCcat1)) and (strlen($VSCcat1)>0) ) + {echo "$VSCcat1:   $VSCcat1tally       \n";} +if ( (!eregi('NULL',$VSCcat2)) and (strlen($VSCcat2)>0) ) + {echo "$VSCcat2:   $VSCcat2tally       \n";} +if ( (!eregi('NULL',$VSCcat3)) and (strlen($VSCcat3)>0) ) + {echo "$VSCcat3:   $VSCcat3tally       \n";} +if ( (!eregi('NULL',$VSCcat4)) and (strlen($VSCcat4)>0) ) + {echo "$VSCcat4:   $VSCcat4tally       \n";} +echo "
"; + +### Header finish + + + + + +################################################################################ +### START calculating calls/agents +################################################################################ + +################################################################################ +###### OUTBOUND CALLS +################################################################################ +if ($campaign_allow_inbound > 0) + { + $stmt="select closer_campaigns from vicidial_campaigns where campaign_id='" . mysql_real_escape_string($group) . "';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $closer_campaigns = preg_replace("/^ | -$/","",$row[0]); + $closer_campaigns = preg_replace("/ /","','",$closer_campaigns); + $closer_campaigns = "'$closer_campaigns'"; + + $stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and ( (call_type='IN' and campaign_id IN($closer_campaigns)) or (campaign_id='" . mysql_real_escape_string($group) . "' and call_type='OUT') );"; + } +else + { + if ($group=='XXXX-ALL-ACTIVE-XXXX') {$groupSQL = '';} + else {$groupSQL = " and campaign_id='" . mysql_real_escape_string($group) . "'";} + + $stmt="select status from vicidial_auto_calls where status NOT IN('XFER') $groupSQL;"; + } +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$parked_to_print = mysql_num_rows($rslt); + if ($parked_to_print > 0) + { + $i=0; + $out_total=0; + $out_ring=0; + $out_live=0; + $in_ivr=0; + while ($i < $parked_to_print) + { + $row=mysql_fetch_row($rslt); + + if (eregi("LIVE",$row[0])) + {$out_live++;} + else + { + if (eregi("IVR",$row[0])) + {$in_ivr++;} + if (eregi("CLOSER",$row[0])) + {$nothing=1;} + else + {$out_ring++;} + } + $out_total++; + $i++; + } + + if ($out_live > 0) {$F=''; $FG='';} + if ($out_live > 4) {$F=''; $FG='';} + if ($out_live > 9) {$F=''; $FG='';} + if ($out_live > 14) {$F=''; $FG='';} + + if ($campaign_allow_inbound > 0) + {echo "$NFB$out_total$NFE current active calls      \n";} + else + {echo "$NFB$out_total$NFE calls being placed       \n";} + + echo "$NFB$out_ring$NFE calls ringing         \n"; + echo "$NFB$F  $out_live $FG$NFE calls waiting for agents       \n"; + echo "$NFB  $in_ivr$NFE calls in IVR       \n"; + } + else + { + echo "SEM CHAMADAS EM ESPERA\n"; + } + + +################################################################################### +###### TIME ON SYSTEM +################################################################################### + +$agent_incall=0; +$agent_ready=0; +$agent_paused=0; +$agent_total=0; + +$stmt="select extension,user,conf_exten,status,server_ip,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish),call_server_ip,campaign_id from vicidial_live_agents where campaign_id='" . mysql_real_escape_string($group) . "';"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$talking_to_print = mysql_num_rows($rslt); + if ($talking_to_print > 0) + { + $i=0; + $agentcount=0; + while ($i < $talking_to_print) + { + $row=mysql_fetch_row($rslt); + if (eregi("READY|PAUSED",$row[3])) + { + $row[5]=$row[6]; + } + $Lstatus = $row[3]; + $status = sprintf("%-6s", $row[3]); + if (!eregi("INCALL|QUEUE",$row[3])) + {$call_time_S = ($STARTtime - $row[6]);} + else + {$call_time_S = ($STARTtime - $row[5]);} + + $call_time_M = ($call_time_S / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $call_time_MS = sprintf("%7s", $call_time_MS); + $G = ''; $EG = ''; + if (eregi("PAUSED",$row[3])) + { + if ($call_time_M_int >= 30) + {$i++; continue;} + else + { + $agent_paused++; $agent_total++; + } + } + + if ( (eregi("INCALL",$status)) or (eregi("QUEUE",$status)) ) {$agent_incall++; $agent_total++;} + if ( (eregi("READY",$status)) or (eregi("CLOSER",$status)) ) {$agent_ready++; $agent_total++;} + $agentcount++; + + + $i++; + } + + if ($agent_ready > 0) {$B=''; $BG='';} + if ($agent_ready > 4) {$B=''; $BG='';} + if ($agent_ready > 9) {$B=''; $BG='';} + if ($agent_ready > 14) {$B=''; $BG='';} + + echo "\n
\n"; + + echo "$NFB$agent_total$NFE agents logged in         \n"; + echo "$NFB$agent_incall$NFE agents in calls       \n"; + echo "$NFB$B  $agent_ready $BG$NFE agents waiting       \n"; + echo "$NFB$agent_paused$NFE paused agents       \n"; + + echo "
";
+		echo "";
+	}
+	else
+	{
+	echo " NO AGENTS ON CALLS
\n"; + } + +################################################################################ +### END calculating calls/agents +################################################################################ + + + + + +echo "
"; + +echo "\n\n"; +$k++; +} + +?> + +
+ + diff --git a/LANG_www/vicidial_br/AST_timeonpark.php b/LANG_www/vicidial_br/AST_timeonpark.php new file mode 100644 index 00000000..d32cf6b6 --- /dev/null +++ b/LANG_www/vicidial_br/AST_timeonpark.php @@ -0,0 +1,220 @@ + LICENSE: AGPLv2 +# +# CHANGES +# +# 60620-1042 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# 90508-0644 - Changed to PHP long tags +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];} + elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $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";} + $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 "Nome ou Senha inválidos: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +$timeONEhoursAGO = ($STARTtime - 3600); +$epochHALFhoursAGO = ($STARTtime - 1860); +$timeONEhoursAGO = date("Y-m-d H:i:s",$timeONEhoursAGO); +$timeHALFhoursAGO = date("Y-m-d H:i:s",$epochHALFhoursAGO); + +$reset_counter++; + +if ($reset_counter > 7) + { + $reset_counter=0; + + $stmt="update park_log set status='HUNGUP' where hangup_time is not null;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + + if ($DB) + { + $stmt="delete from park_log where status='TALKING' and grab_time < '$timeONEhoursAGO' and (hangup_time is null or hangup_time='');"; + $rslt=mysql_query($stmt, $link); + echo "$stmt\n"; + + $stmt="delete from park_log where status='PARKED' and parked_time < '$timeHALFhoursAGO' and (hangup_time is null or hangup_time='');"; + $rslt=mysql_query($stmt, $link); + echo "$stmt\n"; + + } + } + +?> + + + + + +\n"; +echo"\n"; +echo "VICIDIAL: Time On Park\n"; +echo "
\n\n";
+
+echo "VICIDIAL: Time On Park         $NOW_TIME    RELATÓRIOS\n\n";
+echo "+------------+-----------------+---------------------+---------+\n";
+echo "| CHANNEL    | GROUP           | START TIME          | MINUTES |\n";
+echo "+------------+-----------------+---------------------+---------+\n";
+
+#$link=mysql_connect("localhost", "cron", "1234");
+# $linkX=mysql_connect("localhost", "cron", "1234");
+#mysql_select_db("asterisk");
+
+$stmt="select extension,user,channel,channel_group,parked_time,UNIX_TIMESTAMP(parked_time) from park_log where status ='PARKED' and server_ip='" . mysql_real_escape_string($server_ip) . "' order by uniqueid;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$parked_to_print = mysql_num_rows($rslt);
+	if ($parked_to_print > 0)
+	{
+	$i=0;
+	while ($i < $parked_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+
+		$channel =			sprintf("%-10s", $row[2]);
+		$number_dialed =	sprintf("%-15s", $row[3]);
+		$start_time =		sprintf("%-19s", $row[4]);
+		$call_time_S = ($STARTtime - $row[5]);
+
+		$call_time_M = ($call_time_S / 60);
+		$call_time_M = round($call_time_M, 2);
+		$call_time_M_int = intval("$call_time_M");
+		$call_time_SEC = ($call_time_M - $call_time_M_int);
+		$call_time_SEC = ($call_time_SEC * 60);
+		$call_time_SEC = round($call_time_SEC, 0);
+		if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+		$call_time_MS = "$call_time_M_int:$call_time_SEC";
+		$call_time_MS =		sprintf("%7s", $call_time_MS);
+		$G = '';		$EG = '';
+		if ($call_time_M_int >= 1) {$G=''; $EG='';}
+		if ($call_time_M_int >= 6) {$G=''; $EG='';}
+
+		echo "| $G$channel$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+		$i++;
+		}
+
+		echo "+------------+-----------------+---------------------+---------+\n";
+		echo "  $i callers waiting on server $server_ip\n\n";
+
+		echo "             - 1 minute or more on hold\n";
+		echo "             - Over 5 minutes on hold\n";
+
+		}
+	else
+	{
+	echo "****************************************************************\n";
+	echo "****************************************************************\n";
+	echo "********************SEM CHAMADAS EM ESPERA*********************\n";
+	echo "****************************************************************\n";
+	echo "****************************************************************\n";
+	}
+
+###################################################################################
+###### TIME ON INBOUND CALLS
+###################################################################################
+echo "\n\n";
+echo "----------------------------------------------------------------------------------------";
+echo "\n\n";
+echo "VICIDIAL: Agentes Time On Inbound Calls                             $NOW_TIME\n\n";
+echo "+------------|--------+------------+-----------------+---------------------+---------+\n";
+echo "| STATION    | USER   | CHANNEL    | GROUP           | START TIME          | MINUTES |\n";
+echo "+------------|--------+------------+-----------------+---------------------+---------+\n";
+
+
+$stmt="select extension,user,channel,channel_group,grab_time,UNIX_TIMESTAMP(grab_time) from park_log where status ='TALKING' and server_ip='" . mysql_real_escape_string($server_ip) . "' order by uniqueid;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$talking_to_print = mysql_num_rows($rslt);
+	if ($talking_to_print > 0)
+	{
+	$i=0;
+	while ($i < $talking_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+
+		$extension =		sprintf("%-10s", $row[0]);
+		$user =				sprintf("%-6s", $row[1]);
+		$channel =			sprintf("%-10s", $row[2]);
+		$number_dialed =	sprintf("%-15s", $row[3]);
+		$start_time =		sprintf("%-19s", $row[4]);
+		$call_time_S = ($STARTtime - $row[5]);
+
+		$call_time_M = ($call_time_S / 60);
+		$call_time_M = round($call_time_M, 2);
+		$call_time_M_int = intval("$call_time_M");
+		$call_time_SEC = ($call_time_M - $call_time_M_int);
+		$call_time_SEC = ($call_time_SEC * 60);
+		$call_time_SEC = round($call_time_SEC, 0);
+		if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+		$call_time_MS = "$call_time_M_int:$call_time_SEC";
+		$call_time_MS =		sprintf("%7s", $call_time_MS);
+		$G = '';		$EG = '';
+		if ($call_time_M_int >= 12) {$G=''; $EG='';}
+		if ($call_time_M_int >= 31) {$G=''; $EG='';}
+
+		echo "| $G$extension$EG | $G$user$EG | $G$channel$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+		$i++;
+		}
+
+		echo "+------------|--------+------------+-----------------+---------------------+---------+\n";
+		echo "  $i agents on calls on server $server_ip\n\n";
+
+		echo "             - 12 minutes or more on call\n";
+		echo "             - Over 30 minutes on call\n";
+
+	}
+	else
+	{
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	echo "*********************************AGENTES SEM CHAMADAS*********************************\n";
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	}
+
+
+?>
+
+ + \ No newline at end of file diff --git a/LANG_www/vicidial_br/admin.php b/LANG_www/vicidial_br/admin.php new file mode 100644 index 00000000..209385a8 --- /dev/null +++ b/LANG_www/vicidial_br/admin.php @@ -0,0 +1,25097 @@ + LICENSE: AGPLv2 +# + +require("dbconnect.php"); + +###################################################################################################### +###################################################################################################### +####### static variable settings for display options +###################################################################################################### +###################################################################################################### + +$page_width='770'; +$section_width='750'; +$header_font_size='3'; +$subheader_font_size='2'; +$subcamp_font_size='2'; +$header_selected_bold=''; +$header_nonselected_bold=''; +$users_color = '#FFFF99'; +$campaigns_color = '#FFCC99'; +$lists_color = '#FFCCCC'; +$ingroups_color = '#CC99FF'; +$remoteagent_color ='#CCFFCC'; +$usergroups_color = '#CCFFFF'; +$scripts_color = '#99FFCC'; +$filters_color = '#CCCCCC'; +$admin_color = '#FF99FF'; +$reports_color = '#99FF33'; + $times_color = '#FF33FF'; + $shifts_color = '#FF33FF'; + $phones_color = '#FF33FF'; + $conference_color = '#FF33FF'; + $server_color = '#FF33FF'; + $templates_color = '#FF33FF'; + $carriers_color = '#FF33FF'; + $settings_color = '#FF33FF'; + $status_color = '#FF33FF'; + $moh_color = '#FF33FF'; + $vm_color = '#FF33FF'; + $tts_color = '#FF33FF'; +$subcamp_color = '#FF9933'; +$users_font = 'BLACK'; +$campaigns_font = 'BLACK'; +$lists_font = 'BLACK'; +$ingroups_font = 'BLACK'; +$remoteagent_font = 'BLACK'; +$usergroups_font = 'BLACK'; +$scripts_font = 'BLACK'; +$filters_font = 'BLACK'; +$admin_font = 'BLACK'; +$reports_font = 'BLACK'; + $times_font = 'BLACK'; + $phones_font = 'BLACK'; + $conference_font = 'BLACK'; + $server_font = 'BLACK'; + $settings_font = 'BLACK'; + $status_font = 'BLACK'; + $moh_font = 'BLACK'; + $vm_font = 'BLACK'; + $tts_font = 'BLACK'; +$subcamp_font = 'BLACK'; + +### comment this section out for colorful section headings +$users_color = '#E6E6E6'; +$campaigns_color = '#E6E6E6'; +$lists_color = '#E6E6E6'; +$ingroups_color = '#E6E6E6'; +$remoteagent_color ='#E6E6E6'; +$usergroups_color = '#E6E6E6'; +$scripts_color = '#E6E6E6'; +$filters_color = '#E6E6E6'; +$admin_color = '#E6E6E6'; +$reports_color = '#E6E6E6'; + $times_color = '#C6C6C6'; + $shifts_color = '#C6C6C6'; + $phones_color = '#C6C6C6'; + $conference_color = '#C6C6C6'; + $server_color = '#C6C6C6'; + $templates_color = '#C6C6C6'; + $carriers_color = '#C6C6C6'; + $settings_color = '#C6C6C6'; + $status_color = '#C6C6C6'; + $moh_color = '#C6C6C6'; + $vm_color = '#C6C6C6'; + $tts_color = '#C6C6C6'; +$subcamp_color = '#C6C6C6'; +### + + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; + +###################################################################################################### +###################################################################################################### +####### Form variable declaration +###################################################################################################### +###################################################################################################### + + +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["active"])) {$active=$_GET["active"];} + elseif (isset($_POST["active"])) {$active=$_POST["active"];} +if (isset($_GET["adaptive_dl_diff_target"])) {$adaptive_dl_diff_target=$_GET["adaptive_dl_diff_target"];} + elseif (isset($_POST["adaptive_dl_diff_target"])) {$adaptive_dl_diff_target=$_POST["adaptive_dl_diff_target"];} +if (isset($_GET["adaptive_dropped_percentage"])) {$adaptive_dropped_percentage=$_GET["adaptive_dropped_percentage"];} + elseif (isset($_POST["adaptive_dropped_percentage"])){$adaptive_dropped_percentage=$_POST["adaptive_dropped_percentage"];} +if (isset($_GET["adaptive_intensity"])) {$adaptive_intensity=$_GET["adaptive_intensity"];} + elseif (isset($_POST["adaptive_intensity"])) {$adaptive_intensity=$_POST["adaptive_intensity"];} +if (isset($_GET["adaptive_latest_server_time"])) {$adaptive_latest_server_time=$_GET["adaptive_latest_server_time"];} + elseif (isset($_POST["adaptive_latest_server_time"])){$adaptive_latest_server_time=$_POST["adaptive_latest_server_time"];} +if (isset($_GET["adaptive_maximum_level"])) {$adaptive_maximum_level=$_GET["adaptive_maximum_level"];} + elseif (isset($_POST["adaptive_maximum_level"])) {$adaptive_maximum_level=$_POST["adaptive_maximum_level"];} +if (isset($_GET["SUB"])) {$SUB=$_GET["SUB"];} + elseif (isset($_POST["SUB"])) {$SUB=$_POST["SUB"];} +if (isset($_GET["ADD"])) {$ADD=$_GET["ADD"];} + elseif (isset($_POST["ADD"])) {$ADD=$_POST["ADD"];} +if (isset($_GET["admin_hangup_enabled"])) {$admin_hangup_enabled=$_GET["admin_hangup_enabled"];} + elseif (isset($_POST["admin_hangup_enabled"])) {$admin_hangup_enabled=$_POST["admin_hangup_enabled"];} +if (isset($_GET["admin_hijack_enabled"])) {$admin_hijack_enabled=$_GET["admin_hijack_enabled"];} + elseif (isset($_POST["admin_hijack_enabled"])) {$admin_hijack_enabled=$_POST["admin_hijack_enabled"];} +if (isset($_GET["admin_monitor_enabled"])) {$admin_monitor_enabled=$_GET["admin_monitor_enabled"];} + elseif (isset($_POST["admin_monitor_enabled"])) {$admin_monitor_enabled=$_POST["admin_monitor_enabled"];} +if (isset($_GET["AFLogging_enabled"])) {$AFLogging_enabled=$_GET["AFLogging_enabled"];} + elseif (isset($_POST["AFLogging_enabled"])) {$AFLogging_enabled=$_POST["AFLogging_enabled"];} +if (isset($_GET["agent_choose_ingroups"])) {$agent_choose_ingroups=$_GET["agent_choose_ingroups"];} + elseif (isset($_POST["agent_choose_ingroups"])) {$agent_choose_ingroups=$_POST["agent_choose_ingroups"];} +if (isset($_GET["agentcall_manual"])) {$agentcall_manual=$_GET["agentcall_manual"];} + elseif (isset($_POST["agentcall_manual"])) {$agentcall_manual=$_POST["agentcall_manual"];} +if (isset($_GET["agentonly_callbacks"])) {$agentonly_callbacks=$_GET["agentonly_callbacks"];} + elseif (isset($_POST["agentonly_callbacks"])) {$agentonly_callbacks=$_POST["agentonly_callbacks"];} +if (isset($_GET["AGI_call_logging_enabled"])) {$AGI_call_logging_enabled=$_GET["AGI_call_logging_enabled"];} + elseif (isset($_POST["AGI_call_logging_enabled"])) {$AGI_call_logging_enabled=$_POST["AGI_call_logging_enabled"];} +if (isset($_GET["agi_output"])) {$agi_output=$_GET["agi_output"];} + elseif (isset($_POST["agi_output"])) {$agi_output=$_POST["agi_output"];} +if (isset($_GET["allcalls_delay"])) {$allcalls_delay=$_GET["allcalls_delay"];} + elseif (isset($_POST["allcalls_delay"])) {$allcalls_delay=$_POST["allcalls_delay"];} +if (isset($_GET["allow_closers"])) {$allow_closers=$_GET["allow_closers"];} + elseif (isset($_POST["allow_closers"])) {$allow_closers=$_POST["allow_closers"];} +if (isset($_GET["alt_number_dialing"])) {$alt_number_dialing=$_GET["alt_number_dialing"];} + elseif (isset($_POST["alt_number_dialing"])) {$alt_number_dialing=$_POST["alt_number_dialing"];} +if (isset($_GET["alter_agent_interface_options"])) {$alter_agent_interface_options=$_GET["alter_agent_interface_options"];} + elseif (isset($_POST["alter_agent_interface_options"])) {$alter_agent_interface_options=$_POST["alter_agent_interface_options"];} +if (isset($_GET["am_message_exten"])) {$am_message_exten=$_GET["am_message_exten"];} + elseif (isset($_POST["am_message_exten"])) {$am_message_exten=$_POST["am_message_exten"];} +if (isset($_GET["amd_send_to_vmx"])) {$amd_send_to_vmx=$_GET["amd_send_to_vmx"];} + elseif (isset($_POST["amd_send_to_vmx"])) {$amd_send_to_vmx=$_POST["amd_send_to_vmx"];} +if (isset($_GET["answer_transfer_agent"])) {$answer_transfer_agent=$_GET["answer_transfer_agent"];} + elseif (isset($_POST["answer_transfer_agent"])) {$answer_transfer_agent=$_POST["answer_transfer_agent"];} +if (isset($_GET["ast_admin_access"])) {$ast_admin_access=$_GET["ast_admin_access"];} + elseif (isset($_POST["ast_admin_access"])) {$ast_admin_access=$_POST["ast_admin_access"];} +if (isset($_GET["ast_delete_phones"])) {$ast_delete_phones=$_GET["ast_delete_phones"];} + elseif (isset($_POST["ast_delete_phones"])) {$ast_delete_phones=$_POST["ast_delete_phones"];} +if (isset($_GET["asterisk_version"])) {$asterisk_version=$_GET["asterisk_version"];} + elseif (isset($_POST["asterisk_version"])) {$asterisk_version=$_POST["asterisk_version"];} +if (isset($_GET["ASTmgrSECRET"])) {$ASTmgrSECRET=$_GET["ASTmgrSECRET"];} + elseif (isset($_POST["ASTmgrSECRET"])) {$ASTmgrSECRET=$_POST["ASTmgrSECRET"];} +if (isset($_GET["ASTmgrUSERNAME"])) {$ASTmgrUSERNAME=$_GET["ASTmgrUSERNAME"];} + elseif (isset($_POST["ASTmgrUSERNAME"])) {$ASTmgrUSERNAME=$_POST["ASTmgrUSERNAME"];} +if (isset($_GET["ASTmgrUSERNAMElisten"])) {$ASTmgrUSERNAMElisten=$_GET["ASTmgrUSERNAMElisten"];} + elseif (isset($_POST["ASTmgrUSERNAMElisten"])) {$ASTmgrUSERNAMElisten=$_POST["ASTmgrUSERNAMElisten"];} +if (isset($_GET["ASTmgrUSERNAMEsend"])) {$ASTmgrUSERNAMEsend=$_GET["ASTmgrUSERNAMEsend"];} + elseif (isset($_POST["ASTmgrUSERNAMEsend"])) {$ASTmgrUSERNAMEsend=$_POST["ASTmgrUSERNAMEsend"];} +if (isset($_GET["ASTmgrUSERNAMEupdate"])) {$ASTmgrUSERNAMEupdate=$_GET["ASTmgrUSERNAMEupdate"];} + elseif (isset($_POST["ASTmgrUSERNAMEupdate"])) {$ASTmgrUSERNAMEupdate=$_POST["ASTmgrUSERNAMEupdate"];} +if (isset($_GET["attempt_delay"])) {$attempt_delay=$_GET["attempt_delay"];} + elseif (isset($_POST["attempt_delay"])) {$attempt_delay=$_POST["attempt_delay"];} +if (isset($_GET["attempt_maximum"])) {$attempt_maximum=$_GET["attempt_maximum"];} + elseif (isset($_POST["attempt_maximum"])) {$attempt_maximum=$_POST["attempt_maximum"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["auto_dial_next_number"])) {$auto_dial_next_number=$_GET["auto_dial_next_number"];} + elseif (isset($_POST["auto_dial_next_number"])) {$auto_dial_next_number=$_POST["auto_dial_next_number"];} +if (isset($_GET["available_only_ratio_tally"])) {$available_only_ratio_tally=$_GET["available_only_ratio_tally"];} + elseif (isset($_POST["available_only_ratio_tally"])){$available_only_ratio_tally=$_POST["available_only_ratio_tally"];} +if (isset($_GET["call_out_number_group"])) {$call_out_number_group=$_GET["call_out_number_group"];} + elseif (isset($_POST["call_out_number_group"])) {$call_out_number_group=$_POST["call_out_number_group"];} +if (isset($_GET["call_parking_enabled"])) {$call_parking_enabled=$_GET["call_parking_enabled"];} + elseif (isset($_POST["call_parking_enabled"])) {$call_parking_enabled=$_POST["call_parking_enabled"];} +if (isset($_GET["call_time_comments"])) {$call_time_comments=$_GET["call_time_comments"];} + elseif (isset($_POST["call_time_comments"])) {$call_time_comments=$_POST["call_time_comments"];} +if (isset($_GET["call_time_id"])) {$call_time_id=$_GET["call_time_id"];} + elseif (isset($_POST["call_time_id"])) {$call_time_id=$_POST["call_time_id"];} +if (isset($_GET["call_time_name"])) {$call_time_name=$_GET["call_time_name"];} + elseif (isset($_POST["call_time_name"])) {$call_time_name=$_POST["call_time_name"];} +if (isset($_GET["CallerID_popup_enabled"])) {$CallerID_popup_enabled=$_GET["CallerID_popup_enabled"];} + elseif (isset($_POST["CallerID_popup_enabled"])) {$CallerID_popup_enabled=$_POST["CallerID_popup_enabled"];} +if (isset($_GET["campaign_cid"])) {$campaign_cid=$_GET["campaign_cid"];} + elseif (isset($_POST["campaign_cid"])) {$campaign_cid=$_POST["campaign_cid"];} +if (isset($_GET["campaign_detail"])) {$campaign_detail=$_GET["campaign_detail"];} + elseif (isset($_POST["campaign_detail"])) {$campaign_detail=$_POST["campaign_detail"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["campaign_name"])) {$campaign_name=$_GET["campaign_name"];} + elseif (isset($_POST["campaign_name"])) {$campaign_name=$_POST["campaign_name"];} +if (isset($_GET["campaign_rec_exten"])) {$campaign_rec_exten=$_GET["campaign_rec_exten"];} + elseif (isset($_POST["campaign_rec_exten"])) {$campaign_rec_exten=$_POST["campaign_rec_exten"];} +if (isset($_GET["campaign_rec_filename"])) {$campaign_rec_filename=$_GET["campaign_rec_filename"];} + elseif (isset($_POST["campaign_rec_filename"])) {$campaign_rec_filename=$_POST["campaign_rec_filename"];} +if (isset($_GET["ingroup_rec_filename"])) {$ingroup_rec_filename=$_GET["ingroup_rec_filename"];} + elseif (isset($_POST["ingroup_rec_filename"])) {$ingroup_rec_filename=$_POST["ingroup_rec_filename"];} +if (isset($_GET["campaign_recording"])) {$campaign_recording=$_GET["campaign_recording"];} + elseif (isset($_POST["campaign_recording"])) {$campaign_recording=$_POST["campaign_recording"];} +if (isset($_GET["campaign_vdad_exten"])) {$campaign_vdad_exten=$_GET["campaign_vdad_exten"];} + elseif (isset($_POST["campaign_vdad_exten"])) {$campaign_vdad_exten=$_POST["campaign_vdad_exten"];} +if (isset($_GET["change_agent_campaign"])) {$change_agent_campaign=$_GET["change_agent_campaign"];} + elseif (isset($_POST["change_agent_campaign"])) {$change_agent_campaign=$_POST["change_agent_campaign"];} +if (isset($_GET["client_browser"])) {$client_browser=$_GET["client_browser"];} + elseif (isset($_POST["client_browser"])) {$client_browser=$_POST["client_browser"];} +if (isset($_GET["closer_default_blended"])) {$closer_default_blended=$_GET["closer_default_blended"];} + elseif (isset($_POST["closer_default_blended"])) {$closer_default_blended=$_POST["closer_default_blended"];} +if (isset($_GET["company"])) {$company=$_GET["company"];} + elseif (isset($_POST["company"])) {$company=$_POST["company"];} +if (isset($_GET["computer_ip"])) {$computer_ip=$_GET["computer_ip"];} + elseif (isset($_POST["computer_ip"])) {$computer_ip=$_POST["computer_ip"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["conf_on_extension"])) {$conf_on_extension=$_GET["conf_on_extension"];} + elseif (isset($_POST["conf_on_extension"])) {$conf_on_extension=$_POST["conf_on_extension"];} +if (isset($_GET["conferencing_enabled"])) {$conferencing_enabled=$_GET["conferencing_enabled"];} + elseif (isset($_POST["conferencing_enabled"])) {$conferencing_enabled=$_POST["conferencing_enabled"];} +if (isset($_GET["CoNfIrM"])) {$CoNfIrM=$_GET["CoNfIrM"];} + elseif (isset($_POST["CoNfIrM"])) {$CoNfIrM=$_POST["CoNfIrM"];} +if (isset($_GET["ct_default_start"])) {$ct_default_start=$_GET["ct_default_start"];} + elseif (isset($_POST["ct_default_start"])) {$ct_default_start=$_POST["ct_default_start"];} +if (isset($_GET["ct_default_stop"])) {$ct_default_stop=$_GET["ct_default_stop"];} + elseif (isset($_POST["ct_default_stop"])) {$ct_default_stop=$_POST["ct_default_stop"];} +if (isset($_GET["ct_friday_start"])) {$ct_friday_start=$_GET["ct_friday_start"];} + elseif (isset($_POST["ct_friday_start"])) {$ct_friday_start=$_POST["ct_friday_start"];} +if (isset($_GET["ct_friday_stop"])) {$ct_friday_stop=$_GET["ct_friday_stop"];} + elseif (isset($_POST["ct_friday_stop"])) {$ct_friday_stop=$_POST["ct_friday_stop"];} +if (isset($_GET["ct_monday_start"])) {$ct_monday_start=$_GET["ct_monday_start"];} + elseif (isset($_POST["ct_monday_start"])) {$ct_monday_start=$_POST["ct_monday_start"];} +if (isset($_GET["ct_monday_stop"])) {$ct_monday_stop=$_GET["ct_monday_stop"];} + elseif (isset($_POST["ct_monday_stop"])) {$ct_monday_stop=$_POST["ct_monday_stop"];} +if (isset($_GET["ct_saturday_start"])) {$ct_saturday_start=$_GET["ct_saturday_start"];} + elseif (isset($_POST["ct_saturday_start"])) {$ct_saturday_start=$_POST["ct_saturday_start"];} +if (isset($_GET["ct_saturday_stop"])) {$ct_saturday_stop=$_GET["ct_saturday_stop"];} + elseif (isset($_POST["ct_saturday_stop"])) {$ct_saturday_stop=$_POST["ct_saturday_stop"];} +if (isset($_GET["ct_sunday_start"])) {$ct_sunday_start=$_GET["ct_sunday_start"];} + elseif (isset($_POST["ct_sunday_start"])) {$ct_sunday_start=$_POST["ct_sunday_start"];} +if (isset($_GET["ct_sunday_stop"])) {$ct_sunday_stop=$_GET["ct_sunday_stop"];} + elseif (isset($_POST["ct_sunday_stop"])) {$ct_sunday_stop=$_POST["ct_sunday_stop"];} +if (isset($_GET["ct_thursday_start"])) {$ct_thursday_start=$_GET["ct_thursday_start"];} + elseif (isset($_POST["ct_thursday_start"])) {$ct_thursday_start=$_POST["ct_thursday_start"];} +if (isset($_GET["ct_thursday_stop"])) {$ct_thursday_stop=$_GET["ct_thursday_stop"];} + elseif (isset($_POST["ct_thursday_stop"])) {$ct_thursday_stop=$_POST["ct_thursday_stop"];} +if (isset($_GET["ct_tuesday_start"])) {$ct_tuesday_start=$_GET["ct_tuesday_start"];} + elseif (isset($_POST["ct_tuesday_start"])) {$ct_tuesday_start=$_POST["ct_tuesday_start"];} +if (isset($_GET["ct_tuesday_stop"])) {$ct_tuesday_stop=$_GET["ct_tuesday_stop"];} + elseif (isset($_POST["ct_tuesday_stop"])) {$ct_tuesday_stop=$_POST["ct_tuesday_stop"];} +if (isset($_GET["ct_wednesday_start"])) {$ct_wednesday_start=$_GET["ct_wednesday_start"];} + elseif (isset($_POST["ct_wednesday_start"])) {$ct_wednesday_start=$_POST["ct_wednesday_start"];} +if (isset($_GET["ct_wednesday_stop"])) {$ct_wednesday_stop=$_GET["ct_wednesday_stop"];} + elseif (isset($_POST["ct_wednesday_stop"])) {$ct_wednesday_stop=$_POST["ct_wednesday_stop"];} +if (isset($_GET["DBX_database"])) {$DBX_database=$_GET["DBX_database"];} + elseif (isset($_POST["DBX_database"])) {$DBX_database=$_POST["DBX_database"];} +if (isset($_GET["DBX_pass"])) {$DBX_pass=$_GET["DBX_pass"];} + elseif (isset($_POST["DBX_pass"])) {$DBX_pass=$_POST["DBX_pass"];} +if (isset($_GET["DBX_port"])) {$DBX_port=$_GET["DBX_port"];} + elseif (isset($_POST["DBX_port"])) {$DBX_port=$_POST["DBX_port"];} +if (isset($_GET["DBX_server"])) {$DBX_server=$_GET["DBX_server"];} + elseif (isset($_POST["DBX_server"])) {$DBX_server=$_POST["DBX_server"];} +if (isset($_GET["DBX_user"])) {$DBX_user=$_GET["DBX_user"];} + elseif (isset($_POST["DBX_user"])) {$DBX_user=$_POST["DBX_user"];} +if (isset($_GET["DBY_database"])) {$DBY_database=$_GET["DBY_database"];} + elseif (isset($_POST["DBY_database"])) {$DBY_database=$_POST["DBY_database"];} +if (isset($_GET["DBY_pass"])) {$DBY_pass=$_GET["DBY_pass"];} + elseif (isset($_POST["DBY_pass"])) {$DBY_pass=$_POST["DBY_pass"];} +if (isset($_GET["DBY_port"])) {$DBY_port=$_GET["DBY_port"];} + elseif (isset($_POST["DBY_port"])) {$DBY_port=$_POST["DBY_port"];} +if (isset($_GET["DBY_server"])) {$DBY_server=$_GET["DBY_server"];} + elseif (isset($_POST["DBY_server"])) {$DBY_server=$_POST["DBY_server"];} +if (isset($_GET["DBY_user"])) {$DBY_user=$_GET["DBY_user"];} + elseif (isset($_POST["DBY_user"])) {$DBY_user=$_POST["DBY_user"];} +if (isset($_GET["delete_call_times"])) {$delete_call_times=$_GET["delete_call_times"];} + elseif (isset($_POST["delete_call_times"])) {$delete_call_times=$_POST["delete_call_times"];} +if (isset($_GET["delete_campaigns"])) {$delete_campaigns=$_GET["delete_campaigns"];} + elseif (isset($_POST["delete_campaigns"])) {$delete_campaigns=$_POST["delete_campaigns"];} +if (isset($_GET["delete_filters"])) {$delete_filters=$_GET["delete_filters"];} + elseif (isset($_POST["delete_filters"])) {$delete_filters=$_POST["delete_filters"];} +if (isset($_GET["delete_ingroups"])) {$delete_ingroups=$_GET["delete_ingroups"];} + elseif (isset($_POST["delete_ingroups"])) {$delete_ingroups=$_POST["delete_ingroups"];} +if (isset($_GET["delete_lists"])) {$delete_lists=$_GET["delete_lists"];} + elseif (isset($_POST["delete_lists"])) {$delete_lists=$_POST["delete_lists"];} +if (isset($_GET["delete_remote_agents"])) {$delete_remote_agents=$_GET["delete_remote_agents"];} + elseif (isset($_POST["delete_remote_agents"])) {$delete_remote_agents=$_POST["delete_remote_agents"];} +if (isset($_GET["delete_scripts"])) {$delete_scripts=$_GET["delete_scripts"];} + elseif (isset($_POST["delete_scripts"])) {$delete_scripts=$_POST["delete_scripts"];} +if (isset($_GET["delete_user_groups"])) {$delete_user_groups=$_GET["delete_user_groups"];} + elseif (isset($_POST["delete_user_groups"])) {$delete_user_groups=$_POST["delete_user_groups"];} +if (isset($_GET["delete_users"])) {$delete_users=$_GET["delete_users"];} + elseif (isset($_POST["delete_users"])) {$delete_users=$_POST["delete_users"];} +if (isset($_GET["dial_method"])) {$dial_method=$_GET["dial_method"];} + elseif (isset($_POST["dial_method"])) {$dial_method=$_POST["dial_method"];} +if (isset($_GET["dial_prefix"])) {$dial_prefix=$_GET["dial_prefix"];} + elseif (isset($_POST["dial_prefix"])) {$dial_prefix=$_POST["dial_prefix"];} +if (isset($_GET["dial_status_a"])) {$dial_status_a=$_GET["dial_status_a"];} + elseif (isset($_POST["dial_status_a"])) {$dial_status_a=$_POST["dial_status_a"];} +if (isset($_GET["dial_status_b"])) {$dial_status_b=$_GET["dial_status_b"];} + elseif (isset($_POST["dial_status_b"])) {$dial_status_b=$_POST["dial_status_b"];} +if (isset($_GET["dial_status_c"])) {$dial_status_c=$_GET["dial_status_c"];} + elseif (isset($_POST["dial_status_c"])) {$dial_status_c=$_POST["dial_status_c"];} +if (isset($_GET["dial_status_d"])) {$dial_status_d=$_GET["dial_status_d"];} + elseif (isset($_POST["dial_status_d"])) {$dial_status_d=$_POST["dial_status_d"];} +if (isset($_GET["dial_status_e"])) {$dial_status_e=$_GET["dial_status_e"];} + elseif (isset($_POST["dial_status_e"])) {$dial_status_e=$_POST["dial_status_e"];} +if (isset($_GET["dial_timeout"])) {$dial_timeout=$_GET["dial_timeout"];} + elseif (isset($_POST["dial_timeout"])) {$dial_timeout=$_POST["dial_timeout"];} +if (isset($_GET["dialplan_number"])) {$dialplan_number=$_GET["dialplan_number"];} + elseif (isset($_POST["dialplan_number"])) {$dialplan_number=$_POST["dialplan_number"];} +if (isset($_GET["drop_call_seconds"])) {$drop_call_seconds=$_GET["drop_call_seconds"];} + elseif (isset($_POST["drop_call_seconds"])) {$drop_call_seconds=$_POST["drop_call_seconds"];} +if (isset($_GET["drop_exten"])) {$drop_exten=$_GET["drop_exten"];} + elseif (isset($_POST["drop_exten"])) {$drop_exten=$_POST["drop_exten"];} +if (isset($_GET["drop_action"])) {$drop_action=$_GET["drop_action"];} + elseif (isset($_POST["drop_action"])) {$drop_action=$_POST["drop_action"];} +if (isset($_GET["dtmf_send_extension"])) {$dtmf_send_extension=$_GET["dtmf_send_extension"];} + elseif (isset($_POST["dtmf_send_extension"])) {$dtmf_send_extension=$_POST["dtmf_send_extension"];} +if (isset($_GET["enable_fast_refresh"])) {$enable_fast_refresh=$_GET["enable_fast_refresh"];} + elseif (isset($_POST["enable_fast_refresh"])) {$enable_fast_refresh=$_POST["enable_fast_refresh"];} +if (isset($_GET["enable_persistant_mysql"])) {$enable_persistant_mysql=$_GET["enable_persistant_mysql"];} + elseif (isset($_POST["enable_persistant_mysql"])) {$enable_persistant_mysql=$_POST["enable_persistant_mysql"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["fast_refresh_rate"])) {$fast_refresh_rate=$_GET["fast_refresh_rate"];} + elseif (isset($_POST["fast_refresh_rate"])) {$fast_refresh_rate=$_POST["fast_refresh_rate"];} +if (isset($_GET["force_logout"])) {$force_logout=$_GET["force_logout"];} + elseif (isset($_POST["force_logout"])) {$force_logout=$_POST["force_logout"];} +if (isset($_GET["fronter_display"])) {$fronter_display=$_GET["fronter_display"];} + elseif (isset($_POST["fronter_display"])) {$fronter_display=$_POST["fronter_display"];} +if (isset($_GET["full_name"])) {$full_name=$_GET["full_name"];} + elseif (isset($_POST["full_name"])) {$full_name=$_POST["full_name"];} +if (isset($_GET["fullname"])) {$fullname=$_GET["fullname"];} + elseif (isset($_POST["fullname"])) {$fullname=$_POST["fullname"];} +if (isset($_GET["get_call_launch"])) {$get_call_launch=$_GET["get_call_launch"];} + elseif (isset($_POST["get_call_launch"])) {$get_call_launch=$_POST["get_call_launch"];} +if (isset($_GET["group_color"])) {$group_color=$_GET["group_color"];} + elseif (isset($_POST["group_color"])) {$group_color=$_POST["group_color"];} +if (isset($_GET["group_id"])) {$group_id=$_GET["group_id"];} + elseif (isset($_POST["group_id"])) {$group_id=$_POST["group_id"];} +if (isset($_GET["group_name"])) {$group_name=$_GET["group_name"];} + elseif (isset($_POST["group_name"])) {$group_name=$_POST["group_name"];} +if (isset($_GET["groups"])) {$groups=$_GET["groups"];} + elseif (isset($_POST["groups"])) {$groups=$_POST["groups"];} +if (isset($_GET["XFERgroups"])) {$XFERgroups=$_GET["XFERgroups"];} + elseif (isset($_POST["XFERgroups"])) {$XFERgroups=$_POST["XFERgroups"];} +if (isset($_GET["HKstatus"])) {$HKstatus=$_GET["HKstatus"];} + elseif (isset($_POST["HKstatus"])) {$HKstatus=$_POST["HKstatus"];} +if (isset($_GET["hopper_level"])) {$hopper_level=$_GET["hopper_level"];} + elseif (isset($_POST["hopper_level"])) {$hopper_level=$_POST["hopper_level"];} +if (isset($_GET["hotkey"])) {$hotkey=$_GET["hotkey"];} + elseif (isset($_POST["hotkey"])) {$hotkey=$_POST["hotkey"];} +if (isset($_GET["hotkeys_active"])) {$hotkeys_active=$_GET["hotkeys_active"];} + elseif (isset($_POST["hotkeys_active"])) {$hotkeys_active=$_POST["hotkeys_active"];} +if (isset($_GET["install_directory"])) {$install_directory=$_GET["install_directory"];} + elseif (isset($_POST["install_directory"])) {$install_directory=$_POST["install_directory"];} +if (isset($_GET["lead_filter_comments"])) {$lead_filter_comments=$_GET["lead_filter_comments"];} + elseif (isset($_POST["lead_filter_comments"])) {$lead_filter_comments=$_POST["lead_filter_comments"];} +if (isset($_GET["lead_filter_id"])) {$lead_filter_id=$_GET["lead_filter_id"];} + elseif (isset($_POST["lead_filter_id"])) {$lead_filter_id=$_POST["lead_filter_id"];} +if (isset($_GET["lead_filter_name"])) {$lead_filter_name=$_GET["lead_filter_name"];} + elseif (isset($_POST["lead_filter_name"])) {$lead_filter_name=$_POST["lead_filter_name"];} +if (isset($_GET["lead_filter_sql"])) {$lead_filter_sql=$_GET["lead_filter_sql"];} + elseif (isset($_POST["lead_filter_sql"])) {$lead_filter_sql=$_POST["lead_filter_sql"];} +if (isset($_GET["lead_order"])) {$lead_order=$_GET["lead_order"];} + elseif (isset($_POST["lead_order"])) {$lead_order=$_POST["lead_order"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["list_name"])) {$list_name=$_GET["list_name"];} + elseif (isset($_POST["list_name"])) {$list_name=$_POST["list_name"];} +if (isset($_GET["load_leads"])) {$load_leads=$_GET["load_leads"];} + elseif (isset($_POST["load_leads"])) {$load_leads=$_POST["load_leads"];} +if (isset($_GET["local_call_time"])) {$local_call_time=$_GET["local_call_time"];} + elseif (isset($_POST["local_call_time"])) {$local_call_time=$_POST["local_call_time"];} +if (isset($_GET["local_gmt"])) {$local_gmt=$_GET["local_gmt"];} + elseif (isset($_POST["local_gmt"])) {$local_gmt=$_POST["local_gmt"];} +if (isset($_GET["local_web_callerID_URL"])) {$local_web_callerID_URL=$_GET["local_web_callerID_URL"];} + elseif (isset($_POST["local_web_callerID_URL"])) {$local_web_callerID_URL=$_POST["local_web_callerID_URL"];} +if (isset($_GET["login"])) {$login=$_GET["login"];} + elseif (isset($_POST["login"])) {$login=$_POST["login"];} +if (isset($_GET["login_campaign"])) {$login_campaign=$_GET["login_campaign"];} + elseif (isset($_POST["login_campaign"])) {$login_campaign=$_POST["login_campaign"];} +if (isset($_GET["login_pass"])) {$login_pass=$_GET["login_pass"];} + elseif (isset($_POST["login_pass"])) {$login_pass=$_POST["login_pass"];} +if (isset($_GET["login_user"])) {$login_user=$_GET["login_user"];} + elseif (isset($_POST["login_user"])) {$login_user=$_POST["login_user"];} +if (isset($_GET["max_vicidial_trunks"])) {$max_vicidial_trunks=$_GET["max_vicidial_trunks"];} + elseif (isset($_POST["max_vicidial_trunks"])) {$max_vicidial_trunks=$_POST["max_vicidial_trunks"];} +if (isset($_GET["modify_call_times"])) {$modify_call_times=$_GET["modify_call_times"];} + elseif (isset($_POST["modify_call_times"])) {$modify_call_times=$_POST["modify_call_times"];} +if (isset($_GET["modify_leads"])) {$modify_leads=$_GET["modify_leads"];} + elseif (isset($_POST["modify_leads"])) {$modify_leads=$_POST["modify_leads"];} +if (isset($_GET["monitor_prefix"])) {$monitor_prefix=$_GET["monitor_prefix"];} + elseif (isset($_POST["monitor_prefix"])) {$monitor_prefix=$_POST["monitor_prefix"];} +if (isset($_GET["next_agent_call"])) {$next_agent_call=$_GET["next_agent_call"];} + elseif (isset($_POST["next_agent_call"])) {$next_agent_call=$_POST["next_agent_call"];} +if (isset($_GET["number_of_lines"])) {$number_of_lines=$_GET["number_of_lines"];} + elseif (isset($_POST["number_of_lines"])) {$number_of_lines=$_POST["number_of_lines"];} +if (isset($_GET["old_campaign_id"])) {$old_campaign_id=$_GET["old_campaign_id"];} + elseif (isset($_POST["old_campaign_id"])) {$old_campaign_id=$_POST["old_campaign_id"];} +if (isset($_GET["old_conf_exten"])) {$old_conf_exten=$_GET["old_conf_exten"];} + elseif (isset($_POST["old_conf_exten"])) {$old_conf_exten=$_POST["old_conf_exten"];} +if (isset($_GET["old_extension"])) {$old_extension=$_GET["old_extension"];} + elseif (isset($_POST["old_extension"])) {$old_extension=$_POST["old_extension"];} +if (isset($_GET["old_server_id"])) {$old_server_id=$_GET["old_server_id"];} + elseif (isset($_POST["old_server_id"])) {$old_server_id=$_POST["old_server_id"];} +if (isset($_GET["old_server_ip"])) {$old_server_ip=$_GET["old_server_ip"];} + elseif (isset($_POST["old_server_ip"])) {$old_server_ip=$_POST["old_server_ip"];} +if (isset($_GET["OLDuser_group"])) {$OLDuser_group=$_GET["OLDuser_group"];} + elseif (isset($_POST["OLDuser_group"])) {$OLDuser_group=$_POST["OLDuser_group"];} +if (isset($_GET["omit_phone_code"])) {$omit_phone_code=$_GET["omit_phone_code"];} + elseif (isset($_POST["omit_phone_code"])) {$omit_phone_code=$_POST["omit_phone_code"];} +if (isset($_GET["outbound_cid"])) {$outbound_cid=$_GET["outbound_cid"];} + elseif (isset($_POST["outbound_cid"])) {$outbound_cid=$_POST["outbound_cid"];} +if (isset($_GET["park_ext"])) {$park_ext=$_GET["park_ext"];} + elseif (isset($_POST["park_ext"])) {$park_ext=$_POST["park_ext"];} +if (isset($_GET["park_file_name"])) {$park_file_name=$_GET["park_file_name"];} + elseif (isset($_POST["park_file_name"])) {$park_file_name=$_POST["park_file_name"];} +if (isset($_GET["park_on_extension"])) {$park_on_extension=$_GET["park_on_extension"];} + elseif (isset($_POST["park_on_extension"])) {$park_on_extension=$_POST["park_on_extension"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["phone_ip"])) {$phone_ip=$_GET["phone_ip"];} + elseif (isset($_POST["phone_ip"])) {$phone_ip=$_POST["phone_ip"];} +if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];} + elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];} + elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];} +if (isset($_GET["phone_type"])) {$phone_type=$_GET["phone_type"];} + elseif (isset($_POST["phone_type"])) {$phone_type=$_POST["phone_type"];} +if (isset($_GET["picture"])) {$picture=$_GET["picture"];} + elseif (isset($_POST["picture"])) {$picture=$_POST["picture"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} +if (isset($_GET["QUEUE_ACTION_enabled"])) {$QUEUE_ACTION_enabled=$_GET["QUEUE_ACTION_enabled"];} + elseif (isset($_POST["QUEUE_ACTION_enabled"])) {$QUEUE_ACTION_enabled=$_POST["QUEUE_ACTION_enabled"];} +if (isset($_GET["recording_exten"])) {$recording_exten=$_GET["recording_exten"];} + elseif (isset($_POST["recording_exten"])) {$recording_exten=$_POST["recording_exten"];} +if (isset($_GET["remote_agent_id"])) {$remote_agent_id=$_GET["remote_agent_id"];} + elseif (isset($_POST["remote_agent_id"])) {$remote_agent_id=$_POST["remote_agent_id"];} +if (isset($_GET["reset_hopper"])) {$reset_hopper=$_GET["reset_hopper"];} + elseif (isset($_POST["reset_hopper"])) {$reset_hopper=$_POST["reset_hopper"];} +if (isset($_GET["reset_list"])) {$reset_list=$_GET["reset_list"];} + elseif (isset($_POST["reset_list"])) {$reset_list=$_POST["reset_list"];} +if (isset($_GET["safe_harbor_exten"])) {$safe_harbor_exten=$_GET["safe_harbor_exten"];} + elseif (isset($_POST["safe_harbor_exten"])) {$safe_harbor_exten=$_POST["safe_harbor_exten"];} +if (isset($_GET["drop_action"])) {$drop_action=$_GET["drop_action"];} + elseif (isset($_POST["drop_action"])) {$drop_action=$_POST["drop_action"];} +if (isset($_GET["scheduled_callbacks"])) {$scheduled_callbacks=$_GET["scheduled_callbacks"];} + elseif (isset($_POST["scheduled_callbacks"])) {$scheduled_callbacks=$_POST["scheduled_callbacks"];} +if (isset($_GET["script_comments"])) {$script_comments=$_GET["script_comments"];} + elseif (isset($_POST["script_comments"])) {$script_comments=$_POST["script_comments"];} +if (isset($_GET["script_id"])) {$script_id=$_GET["script_id"];} + elseif (isset($_POST["script_id"])) {$script_id=$_POST["script_id"];} +if (isset($_GET["script_name"])) {$script_name=$_GET["script_name"];} + elseif (isset($_POST["script_name"])) {$script_name=$_POST["script_name"];} +if (isset($_GET["script_text"])) {$script_text=$_GET["script_text"];} + elseif (isset($_POST["script_text"])) {$script_text=$_POST["script_text"];} +if (isset($_GET["selectable"])) {$selectable=$_GET["selectable"];} + elseif (isset($_POST["selectable"])) {$selectable=$_POST["selectable"];} +if (isset($_GET["server_description"])) {$server_description=$_GET["server_description"];} + elseif (isset($_POST["server_description"])) {$server_description=$_POST["server_description"];} +if (isset($_GET["server_id"])) {$server_id=$_GET["server_id"];} + elseif (isset($_POST["server_id"])) {$server_id=$_POST["server_id"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["state_call_time_state"])) {$state_call_time_state=$_GET["state_call_time_state"];} + elseif (isset($_POST["state_call_time_state"])) {$state_call_time_state=$_POST["state_call_time_state"];} +if (isset($_GET["state_rule"])) {$state_rule=$_GET["state_rule"];} + elseif (isset($_POST["state_rule"])) {$state_rule=$_POST["state_rule"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["status_id"])) {$status_id=$_GET["status_id"];} + elseif (isset($_POST["status_id"])) {$status_id=$_POST["status_id"];} +if (isset($_GET["status_name"])) {$status_name=$_GET["status_name"];} + elseif (isset($_POST["status_name"])) {$status_name=$_POST["status_name"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} +if (isset($_GET["sys_perf_log"])) {$sys_perf_log=$_GET["sys_perf_log"];} + elseif (isset($_POST["sys_perf_log"])) {$sys_perf_log=$_POST["sys_perf_log"];} +if (isset($_GET["telnet_host"])) {$telnet_host=$_GET["telnet_host"];} + elseif (isset($_POST["telnet_host"])) {$telnet_host=$_POST["telnet_host"];} +if (isset($_GET["telnet_port"])) {$telnet_port=$_GET["telnet_port"];} + elseif (isset($_POST["telnet_port"])) {$telnet_port=$_POST["telnet_port"];} +if (isset($_GET["updater_check_enabled"])) {$updater_check_enabled=$_GET["updater_check_enabled"];} + elseif (isset($_POST["updater_check_enabled"])) {$updater_check_enabled=$_POST["updater_check_enabled"];} +if (isset($_GET["use_internal_dnc"])) {$use_internal_dnc=$_GET["use_internal_dnc"];} + elseif (isset($_POST["use_internal_dnc"])) {$use_internal_dnc=$_POST["use_internal_dnc"];} +if (isset($_GET["use_campaign_dnc"])) {$use_campaign_dnc=$_GET["use_campaign_dnc"];} + elseif (isset($_POST["use_campaign_dnc"])) {$use_campaign_dnc=$_POST["use_campaign_dnc"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["user_group"])) {$user_group=$_GET["user_group"];} + elseif (isset($_POST["user_group"])) {$user_group=$_POST["user_group"];} +if (isset($_GET["user_level"])) {$user_level=$_GET["user_level"];} + elseif (isset($_POST["user_level"])) {$user_level=$_POST["user_level"];} +if (isset($_GET["user_start"])) {$user_start=$_GET["user_start"];} + elseif (isset($_POST["user_start"])) {$user_start=$_POST["user_start"];} +if (isset($_GET["user_switching_enabled"])) {$user_switching_enabled=$_GET["user_switching_enabled"];} + elseif (isset($_POST["user_switching_enabled"])) {$user_switching_enabled=$_POST["user_switching_enabled"];} +if (isset($_GET["vd_server_logs"])) {$vd_server_logs=$_GET["vd_server_logs"];} + elseif (isset($_POST["vd_server_logs"])) {$vd_server_logs=$_POST["vd_server_logs"];} +if (isset($_GET["VDstop_rec_after_each_call"])) {$VDstop_rec_after_each_call=$_GET["VDstop_rec_after_each_call"];} + elseif (isset($_POST["VDstop_rec_after_each_call"])) {$VDstop_rec_after_each_call=$_POST["VDstop_rec_after_each_call"];} +if (isset($_GET["VICIDIAL_park_on_extension"])) {$VICIDIAL_park_on_extension=$_GET["VICIDIAL_park_on_extension"];} + elseif (isset($_POST["VICIDIAL_park_on_extension"])) {$VICIDIAL_park_on_extension=$_POST["VICIDIAL_park_on_extension"];} +if (isset($_GET["VICIDIAL_park_on_filename"])) {$VICIDIAL_park_on_filename=$_GET["VICIDIAL_park_on_filename"];} + elseif (isset($_POST["VICIDIAL_park_on_filename"])) {$VICIDIAL_park_on_filename=$_POST["VICIDIAL_park_on_filename"];} +if (isset($_GET["vicidial_recording"])) {$vicidial_recording=$_GET["vicidial_recording"];} + elseif (isset($_POST["vicidial_recording"])) {$vicidial_recording=$_POST["vicidial_recording"];} +if (isset($_GET["vicidial_transfers"])) {$vicidial_transfers=$_GET["vicidial_transfers"];} + elseif (isset($_POST["vicidial_transfers"])) {$vicidial_transfers=$_POST["vicidial_transfers"];} +if (isset($_GET["VICIDIAL_web_URL"])) {$VICIDIAL_web_URL=$_GET["VICIDIAL_web_URL"];} + elseif (isset($_POST["VICIDIAL_web_URL"])) {$VICIDIAL_web_URL=$_POST["VICIDIAL_web_URL"];} +if (isset($_GET["voicemail_button_enabled"])) {$voicemail_button_enabled=$_GET["voicemail_button_enabled"];} + elseif (isset($_POST["voicemail_button_enabled"])) {$voicemail_button_enabled=$_POST["voicemail_button_enabled"];} +if (isset($_GET["voicemail_dump_exten"])) {$voicemail_dump_exten=$_GET["voicemail_dump_exten"];} + elseif (isset($_POST["voicemail_dump_exten"])) {$voicemail_dump_exten=$_POST["voicemail_dump_exten"];} +if (isset($_GET["voicemail_ext"])) {$voicemail_ext=$_GET["voicemail_ext"];} + elseif (isset($_POST["voicemail_ext"])) {$voicemail_ext=$_POST["voicemail_ext"];} +if (isset($_GET["voicemail_exten"])) {$voicemail_exten=$_GET["voicemail_exten"];} + elseif (isset($_POST["voicemail_exten"])) {$voicemail_exten=$_POST["voicemail_exten"];} +if (isset($_GET["voicemail_id"])) {$voicemail_id=$_GET["voicemail_id"];} + elseif (isset($_POST["voicemail_id"])) {$voicemail_id=$_POST["voicemail_id"];} +if (isset($_GET["web_form_address"])) {$web_form_address=$_GET["web_form_address"];} + elseif (isset($_POST["web_form_address"])) {$web_form_address=$_POST["web_form_address"];} +if (isset($_GET["wrapup_message"])) {$wrapup_message=$_GET["wrapup_message"];} + elseif (isset($_POST["wrapup_message"])) {$wrapup_message=$_POST["wrapup_message"];} +if (isset($_GET["wrapup_seconds"])) {$wrapup_seconds=$_GET["wrapup_seconds"];} + elseif (isset($_POST["wrapup_seconds"])) {$wrapup_seconds=$_POST["wrapup_seconds"];} +if (isset($_GET["xferconf_a_dtmf"])) {$xferconf_a_dtmf=$_GET["xferconf_a_dtmf"];} + elseif (isset($_POST["xferconf_a_dtmf"])) {$xferconf_a_dtmf=$_POST["xferconf_a_dtmf"];} +if (isset($_GET["xferconf_a_number"])) {$xferconf_a_number=$_GET["xferconf_a_number"];} + elseif (isset($_POST["xferconf_a_number"])) {$xferconf_a_number=$_POST["xferconf_a_number"];} +if (isset($_GET["xferconf_b_dtmf"])) {$xferconf_b_dtmf=$_GET["xferconf_b_dtmf"];} + elseif (isset($_POST["xferconf_b_dtmf"])) {$xferconf_b_dtmf=$_POST["xferconf_b_dtmf"];} +if (isset($_GET["xferconf_b_number"])) {$xferconf_b_number=$_GET["xferconf_b_number"];} + elseif (isset($_POST["xferconf_b_number"])) {$xferconf_b_number=$_POST["xferconf_b_number"];} +if (isset($_GET["vicidial_balance_active"])) {$vicidial_balance_active=$_GET["vicidial_balance_active"];} + elseif (isset($_POST["vicidial_balance_active"])) {$vicidial_balance_active=$_POST["vicidial_balance_active"];} +if (isset($_GET["balance_trunks_offlimits"])) {$balance_trunks_offlimits=$_GET["balance_trunks_offlimits"];} + elseif (isset($_POST["balance_trunks_offlimits"])) {$balance_trunks_offlimits=$_POST["balance_trunks_offlimits"];} +if (isset($_GET["dedicated_trunks"])) {$dedicated_trunks=$_GET["dedicated_trunks"];} + elseif (isset($_POST["dedicated_trunks"])) {$dedicated_trunks=$_POST["dedicated_trunks"];} +if (isset($_GET["trunk_restriction"])) {$trunk_restriction=$_GET["trunk_restriction"];} + elseif (isset($_POST["trunk_restriction"])) {$trunk_restriction=$_POST["trunk_restriction"];} +if (isset($_GET["campaigns"])) {$campaigns=$_GET["campaigns"];} + elseif (isset($_POST["campaigns"])) {$campaigns=$_POST["campaigns"];} +if (isset($_GET["dial_level_override"])) {$dial_level_override=$_GET["dial_level_override"];} + elseif (isset($_POST["dial_level_override"])) {$dial_level_override=$_POST["dial_level_override"];} +if (isset($_GET["concurrent_transfers"])) {$concurrent_transfers=$_GET["concurrent_transfers"];} + elseif (isset($_POST["concurrent_transfers"])) {$concurrent_transfers=$_POST["concurrent_transfers"];} +if (isset($_GET["auto_alt_dial"])) {$auto_alt_dial=$_GET["auto_alt_dial"];} + elseif (isset($_POST["auto_alt_dial"])) {$auto_alt_dial=$_POST["auto_alt_dial"];} +if (isset($_GET["modify_users"])) {$modify_users=$_GET["modify_users"];} + elseif (isset($_POST["modify_users"])) {$modify_users=$_POST["modify_users"];} +if (isset($_GET["modify_campaigns"])) {$modify_campaigns=$_GET["modify_campaigns"];} + elseif (isset($_POST["modify_campaigns"])) {$modify_campaigns=$_POST["modify_campaigns"];} +if (isset($_GET["modify_lists"])) {$modify_lists=$_GET["modify_lists"];} + elseif (isset($_POST["modify_lists"])) {$modify_lists=$_POST["modify_lists"];} +if (isset($_GET["modify_scripts"])) {$modify_scripts=$_GET["modify_scripts"];} + elseif (isset($_POST["modify_scripts"])) {$modify_scripts=$_POST["modify_scripts"];} +if (isset($_GET["modify_filters"])) {$modify_filters=$_GET["modify_filters"];} + elseif (isset($_POST["modify_filters"])) {$modify_filters=$_POST["modify_filters"];} +if (isset($_GET["modify_ingroups"])) {$modify_ingroups=$_GET["modify_ingroups"];} + elseif (isset($_POST["modify_ingroups"])) {$modify_ingroups=$_POST["modify_ingroups"];} +if (isset($_GET["modify_usergroups"])) {$modify_usergroups=$_GET["modify_usergroups"];} + elseif (isset($_POST["modify_usergroups"])) {$modify_usergroups=$_POST["modify_usergroups"];} +if (isset($_GET["modify_remoteagents"])) {$modify_remoteagents=$_GET["modify_remoteagents"];} + elseif (isset($_POST["modify_remoteagents"])) {$modify_remoteagents=$_POST["modify_remoteagents"];} +if (isset($_GET["modify_servers"])) {$modify_servers=$_GET["modify_servers"];} + elseif (isset($_POST["modify_servers"])) {$modify_servers=$_POST["modify_servers"];} +if (isset($_GET["view_reports"])) {$view_reports=$_GET["view_reports"];} + elseif (isset($_POST["view_reports"])) {$view_reports=$_POST["view_reports"];} +if (isset($_GET["agent_pause_codes_active"])) {$agent_pause_codes_active=$_GET["agent_pause_codes_active"];} + elseif (isset($_POST["agent_pause_codes_active"])) {$agent_pause_codes_active=$_POST["agent_pause_codes_active"];} +if (isset($_GET["pause_code"])) {$pause_code=$_GET["pause_code"];} + elseif (isset($_POST["pause_code"])) {$pause_code=$_POST["pause_code"];} +if (isset($_GET["pause_code_name"])) {$pause_code_name=$_GET["pause_code_name"];} + elseif (isset($_POST["pause_code_name"])) {$pause_code_name=$_POST["pause_code_name"];} +if (isset($_GET["billable"])) {$billable=$_GET["billable"];} + elseif (isset($_POST["billable"])) {$billable=$_POST["billable"];} +if (isset($_GET["campaign_description"])) {$campaign_description=$_GET["campaign_description"];} + elseif (isset($_POST["campaign_description"])) {$campaign_description=$_POST["campaign_description"];} +if (isset($_GET["campaign_stats_refresh"])) {$campaign_stats_refresh=$_GET["campaign_stats_refresh"];} + elseif (isset($_POST["campaign_stats_refresh"])){$campaign_stats_refresh=$_POST["campaign_stats_refresh"];} +if (isset($_GET["list_description"])) {$list_description=$_GET["list_description"];} + elseif (isset($_POST["list_description"])) {$list_description=$_POST["list_description"];} +if (isset($_GET["vicidial_recording_override"])) {$vicidial_recording_override=$_GET["vicidial_recording_override"];} + elseif (isset($_POST["vicidial_recording_override"])) {$vicidial_recording_override=$_POST["vicidial_recording_override"];} +if (isset($_GET["use_non_latin"])) {$use_non_latin=$_GET["use_non_latin"];} + elseif (isset($_POST["use_non_latin"])) {$use_non_latin=$_POST["use_non_latin"];} +if (isset($_GET["webroot_writable"])) {$webroot_writable=$_GET["webroot_writable"];} + elseif (isset($_POST["webroot_writable"])) {$webroot_writable=$_POST["webroot_writable"];} +if (isset($_GET["enable_queuemetrics_logging"])) {$enable_queuemetrics_logging=$_GET["enable_queuemetrics_logging"];} + elseif (isset($_POST["enable_queuemetrics_logging"])) {$enable_queuemetrics_logging=$_POST["enable_queuemetrics_logging"];} +if (isset($_GET["queuemetrics_server_ip"])) {$queuemetrics_server_ip=$_GET["queuemetrics_server_ip"];} + elseif (isset($_POST["queuemetrics_server_ip"])) {$queuemetrics_server_ip=$_POST["queuemetrics_server_ip"];} +if (isset($_GET["queuemetrics_dbname"])) {$queuemetrics_dbname=$_GET["queuemetrics_dbname"];} + elseif (isset($_POST["queuemetrics_dbname"])) {$queuemetrics_dbname=$_POST["queuemetrics_dbname"];} +if (isset($_GET["queuemetrics_login"])) {$queuemetrics_login=$_GET["queuemetrics_login"];} + elseif (isset($_POST["queuemetrics_login"])) {$queuemetrics_login=$_POST["queuemetrics_login"];} +if (isset($_GET["queuemetrics_pass"])) {$queuemetrics_pass=$_GET["queuemetrics_pass"];} + elseif (isset($_POST["queuemetrics_pass"])) {$queuemetrics_pass=$_POST["queuemetrics_pass"];} +if (isset($_GET["queuemetrics_url"])) {$queuemetrics_url=$_GET["queuemetrics_url"];} + elseif (isset($_POST["queuemetrics_url"])) {$queuemetrics_url=$_POST["queuemetrics_url"];} +if (isset($_GET["queuemetrics_log_id"])) {$queuemetrics_log_id=$_GET["queuemetrics_log_id"];} + elseif (isset($_POST["queuemetrics_log_id"])) {$queuemetrics_log_id=$_POST["queuemetrics_log_id"];} +if (isset($_GET["dial_status"])) {$dial_status=$_GET["dial_status"];} + elseif (isset($_POST["dial_status"])) {$dial_status=$_POST["dial_status"];} +if (isset($_GET["queuemetrics_eq_prepend"])) {$queuemetrics_eq_prepend=$_GET["queuemetrics_eq_prepend"];} + elseif (isset($_POST["queuemetrics_eq_prepend"])) {$queuemetrics_eq_prepend=$_POST["queuemetrics_eq_prepend"];} +if (isset($_GET["vicidial_agent_disable"])) {$vicidial_agent_disable=$_GET["vicidial_agent_disable"];} + elseif (isset($_POST["vicidial_agent_disable"])) {$vicidial_agent_disable=$_POST["vicidial_agent_disable"];} +if (isset($_GET["disable_alter_custdata"])) {$disable_alter_custdata=$_GET["disable_alter_custdata"];} + elseif (isset($_POST["disable_alter_custdata"])) {$disable_alter_custdata=$_POST["disable_alter_custdata"];} +if (isset($_GET["alter_custdata_override"])) {$alter_custdata_override=$_GET["alter_custdata_override"];} + elseif (isset($_POST["alter_custdata_override"])) {$alter_custdata_override=$_POST["alter_custdata_override"];} +if (isset($_GET["no_hopper_leads_logins"])) {$no_hopper_leads_logins=$_GET["no_hopper_leads_logins"];} + elseif (isset($_POST["no_hopper_leads_logins"])) {$no_hopper_leads_logins=$_POST["no_hopper_leads_logins"];} +if (isset($_GET["enable_sipsak_messages"])) {$enable_sipsak_messages=$_GET["enable_sipsak_messages"];} + elseif (isset($_POST["enable_sipsak_messages"])) {$enable_sipsak_messages=$_POST["enable_sipsak_messages"];} +if (isset($_GET["allow_sipsak_messages"])) {$allow_sipsak_messages=$_GET["allow_sipsak_messages"];} + elseif (isset($_POST["allow_sipsak_messages"])) {$allow_sipsak_messages=$_POST["allow_sipsak_messages"];} +if (isset($_GET["admin_home_url"])) {$admin_home_url=$_GET["admin_home_url"];} + elseif (isset($_POST["admin_home_url"])) {$admin_home_url=$_POST["admin_home_url"];} +if (isset($_GET["list_order_mix"])) {$list_order_mix=$_GET["list_order_mix"];} + elseif (isset($_POST["list_order_mix"])) {$list_order_mix=$_POST["list_order_mix"];} +if (isset($_GET["vcl_id"])) {$vcl_id=$_GET["vcl_id"];} + elseif (isset($_POST["vcl_id"])) {$vcl_id=$_POST["vcl_id"];} +if (isset($_GET["vcl_name"])) {$vcl_name=$_GET["vcl_name"];} + elseif (isset($_POST["vcl_name"])) {$vcl_name=$_POST["vcl_name"];} +if (isset($_GET["list_mix_container"])) {$list_mix_container=$_GET["list_mix_container"];} + elseif (isset($_POST["list_mix_container"])) {$list_mix_container=$_POST["list_mix_container"];} +if (isset($_GET["mix_method"])) {$mix_method=$_GET["mix_method"];} + elseif (isset($_POST["mix_method"])) {$mix_method=$_POST["mix_method"];} +if (isset($_GET["human_answered"])) {$human_answered=$_GET["human_answered"];} + elseif (isset($_POST["human_answered"])) {$human_answered=$_POST["human_answered"];} +if (isset($_GET["category"])) {$category=$_GET["category"];} + elseif (isset($_POST["category"])) {$category=$_POST["category"];} +if (isset($_GET["vsc_id"])) {$vsc_id=$_GET["vsc_id"];} + elseif (isset($_POST["vsc_id"])) {$vsc_id=$_POST["vsc_id"];} +if (isset($_GET["vsc_name"])) {$vsc_name=$_GET["vsc_name"];} + elseif (isset($_POST["vsc_name"])) {$vsc_name=$_POST["vsc_name"];} +if (isset($_GET["vsc_description"])) {$vsc_description=$_GET["vsc_description"];} + elseif (isset($_POST["vsc_description"])) {$vsc_description=$_POST["vsc_description"];} +if (isset($_GET["tovdad_display"])) {$tovdad_display=$_GET["tovdad_display"];} + elseif (isset($_POST["tovdad_display"])) {$tovdad_display=$_POST["tovdad_display"];} +if (isset($_GET["mix_container_item"])) {$mix_container_item=$_GET["mix_container_item"];} + elseif (isset($_POST["mix_container_item"])) {$mix_container_item=$_POST["mix_container_item"];} +if (isset($_GET["enable_agc_xfer_log"])) {$enable_agc_xfer_log=$_GET["enable_agc_xfer_log"];} + elseif (isset($_POST["enable_agc_xfer_log"])) {$enable_agc_xfer_log=$_POST["enable_agc_xfer_log"];} +if (isset($_GET["after_hours_action"])) {$after_hours_action=$_GET["after_hours_action"];} + elseif (isset($_POST["after_hours_action"])) {$after_hours_action=$_POST["after_hours_action"];} +if (isset($_GET["after_hours_message_filename"])) {$after_hours_message_filename=$_GET["after_hours_message_filename"];} + elseif (isset($_POST["after_hours_message_filename"])) {$after_hours_message_filename=$_POST["after_hours_message_filename"];} +if (isset($_GET["after_hours_exten"])) {$after_hours_exten=$_GET["after_hours_exten"];} + elseif (isset($_POST["after_hours_exten"])) {$after_hours_exten=$_POST["after_hours_exten"];} +if (isset($_GET["after_hours_voicemail"])) {$after_hours_voicemail=$_GET["after_hours_voicemail"];} + elseif (isset($_POST["after_hours_voicemail"])) {$after_hours_voicemail=$_POST["after_hours_voicemail"];} +if (isset($_GET["welcome_message_filename"])) {$welcome_message_filename=$_GET["welcome_message_filename"];} + elseif (isset($_POST["welcome_message_filename"])) {$welcome_message_filename=$_POST["welcome_message_filename"];} +if (isset($_GET["moh_context"])) {$moh_context=$_GET["moh_context"];} + elseif (isset($_POST["moh_context"])) {$moh_context=$_POST["moh_context"];} +if (isset($_GET["onhold_prompt_filename"])) {$onhold_prompt_filename=$_GET["onhold_prompt_filename"];} + elseif (isset($_POST["onhold_prompt_filename"])) {$onhold_prompt_filename=$_POST["onhold_prompt_filename"];} +if (isset($_GET["prompt_interval"])) {$prompt_interval=$_GET["prompt_interval"];} + elseif (isset($_POST["prompt_interval"])) {$prompt_interval=$_POST["prompt_interval"];} +if (isset($_GET["agent_alert_exten"])) {$agent_alert_exten=$_GET["agent_alert_exten"];} + elseif (isset($_POST["agent_alert_exten"])) {$agent_alert_exten=$_POST["agent_alert_exten"];} +if (isset($_GET["agent_alert_delay"])) {$agent_alert_delay=$_GET["agent_alert_delay"];} + elseif (isset($_POST["agent_alert_delay"])) {$agent_alert_delay=$_POST["agent_alert_delay"];} +if (isset($_GET["group_rank"])) {$group_rank=$_GET["group_rank"];} + elseif (isset($_POST["group_rank"])) {$group_rank=$_POST["group_rank"];} +if (isset($_GET["campaign_allow_inbound"])) {$campaign_allow_inbound=$_GET["campaign_allow_inbound"];} + elseif (isset($_POST["campaign_allow_inbound"])) {$campaign_allow_inbound=$_POST["campaign_allow_inbound"];} +if (isset($_GET["manual_dial_list_id"])) {$manual_dial_list_id=$_GET["manual_dial_list_id"];} + elseif (isset($_POST["manual_dial_list_id"])) {$manual_dial_list_id=$_POST["manual_dial_list_id"];} +if (isset($_GET["campaign_rank"])) {$campaign_rank=$_GET["campaign_rank"];} + elseif (isset($_POST["campaign_rank"])) {$campaign_rank=$_POST["campaign_rank"];} +if (isset($_GET["source_campaign_id"])) {$source_campaign_id=$_GET["source_campaign_id"];} + elseif (isset($_POST["source_campaign_id"])) {$source_campaign_id=$_POST["source_campaign_id"];} +if (isset($_GET["source_user_id"])) {$source_user_id=$_GET["source_user_id"];} + elseif (isset($_POST["source_user_id"])) {$source_user_id=$_POST["source_user_id"];} +if (isset($_GET["source_group_id"])) {$source_group_id=$_GET["source_group_id"];} + elseif (isset($_POST["source_group_id"])) {$source_group_id=$_POST["source_group_id"];} +if (isset($_GET["default_xfer_group"])) {$default_xfer_group=$_GET["default_xfer_group"];} + elseif (isset($_POST["default_xfer_group"])) {$default_xfer_group=$_POST["default_xfer_group"];} +if (isset($_GET["qc_enabled"])) {$qc_enabled=$_GET["qc_enabled"];} + elseif (isset($_POST["qc_enabled"])) {$qc_enabled=$_POST["qc_enabled"];} +if (isset($_GET["qc_user_level"])) {$qc_user_level=$_GET["qc_user_level"];} + elseif (isset($_POST["qc_user_level"])) {$qc_user_level=$_POST["qc_user_level"];} +if (isset($_GET["qc_pass"])) {$qc_pass=$_GET["qc_pass"];} + elseif (isset($_POST["qc_pass"])) {$qc_pass=$_POST["qc_pass"];} +if (isset($_GET["qc_finish"])) {$qc_finish=$_GET["qc_finish"];} + elseif (isset($_POST["qc_finish"])) {$qc_finish=$_POST["qc_finish"];} +if (isset($_GET["qc_commit"])) {$qc_commit=$_GET["qc_commit"];} + elseif (isset($_POST["qc_commit"])) {$qc_commit=$_POST["qc_commit"];} +if (isset($_GET["qc_campaigns"])) {$qc_campaigns=$_GET["qc_campaigns"];} + elseif (isset($_POST["qc_campaigns"])) {$qc_campaigns=$_POST["qc_campaigns"];} +if (isset($_GET["qc_groups"])) {$qc_groups=$_GET["qc_groups"];} + elseif (isset($_POST["qc_groups"])) {$qc_groups=$_POST["qc_groups"];} +if (isset($_GET["queue_priority"])) {$queue_priority=$_GET["queue_priority"];} + elseif (isset($_POST["queue_priority"])) {$queue_priority=$_POST["queue_priority"];} +if (isset($_GET["drop_inbound_group"])) {$drop_inbound_group=$_GET["drop_inbound_group"];} + elseif (isset($_POST["drop_inbound_group"])) {$drop_inbound_group=$_POST["drop_inbound_group"];} +if (isset($_GET["qc_statuses"])) {$qc_statuses=$_GET["qc_statuses"];} + elseif (isset($_POST["qc_statuses"])) {$qc_statuses=$_POST["qc_statuses"];} +if (isset($_GET["qc_lists"])) {$qc_lists=$_GET["qc_lists"];} + elseif (isset($_POST["qc_lists"])) {$qc_lists=$_POST["qc_lists"];} +if (isset($_GET["qc_get_record_launch"])) {$qc_get_record_launch=$_GET["qc_get_record_launch"];} + elseif (isset($_POST["qc_get_record_launch"])) {$qc_get_record_launch=$_POST["qc_get_record_launch"];} +if (isset($_GET["qc_show_recording"])) {$qc_show_recording=$_GET["qc_show_recording"];} + elseif (isset($_POST["qc_show_recording"])) {$qc_show_recording=$_POST["qc_show_recording"];} +if (isset($_GET["qc_shift_id"])) {$qc_shift_id=$_GET["qc_shift_id"];} + elseif (isset($_POST["qc_shift_id"])) {$qc_shift_id=$_POST["qc_shift_id"];} +if (isset($_GET["qc_web_form_address"])) {$qc_web_form_address=$_GET["qc_web_form_address"];} + elseif (isset($_POST["qc_web_form_address"])) {$qc_web_form_address=$_POST["qc_web_form_address"];} +if (isset($_GET["qc_script"])) {$qc_script=$_GET["qc_script"];} + elseif (isset($_POST["qc_script"])) {$qc_script=$_POST["qc_script"];} +if (isset($_GET["ingroup_recording_override"])) {$ingroup_recording_override=$_GET["ingroup_recording_override"];} + elseif (isset($_POST["ingroup_recording_override"])) {$ingroup_recording_override=$_POST["ingroup_recording_override"];} +if (isset($_GET["code"])) {$code=$_GET["code"];} + elseif (isset($_POST["code"])) {$code=$_POST["code"];} +if (isset($_GET["code_name"])) {$code_name=$_GET["code_name"];} + elseif (isset($_POST["code_name"])) {$code_name=$_POST["code_name"];} +if (isset($_GET["afterhours_xfer_group"])) {$afterhours_xfer_group=$_GET["afterhours_xfer_group"];} + elseif (isset($_POST["afterhours_xfer_group"])) {$afterhours_xfer_group=$_POST["afterhours_xfer_group"];} +if (isset($_GET["alias_id"])) {$alias_id=$_GET["alias_id"];} + elseif (isset($_POST["alias_id"])) {$alias_id=$_POST["alias_id"];} +if (isset($_GET["alias_name"])) {$alias_name=$_GET["alias_name"];} + elseif (isset($_POST["alias_name"])) {$alias_name=$_POST["alias_name"];} +if (isset($_GET["logins_list"])) {$logins_list=$_GET["logins_list"];} + elseif (isset($_POST["logins_list"])) {$logins_list=$_POST["logins_list"];} +if (isset($_GET["shift_id"])) {$shift_id=$_GET["shift_id"];} + elseif (isset($_POST["shift_id"])) {$shift_id=$_POST["shift_id"];} +if (isset($_GET["shift_name"])) {$shift_name=$_GET["shift_name"];} + elseif (isset($_POST["shift_name"])) {$shift_name=$_POST["shift_name"];} +if (isset($_GET["shift_start_time"])) {$shift_start_time=$_GET["shift_start_time"];} + elseif (isset($_POST["shift_start_time"])) {$shift_start_time=$_POST["shift_start_time"];} +if (isset($_GET["shift_length"])) {$shift_length=$_GET["shift_length"];} + elseif (isset($_POST["shift_length"])) {$shift_length=$_POST["shift_length"];} +if (isset($_GET["shift_weekdays"])) {$shift_weekdays=$_GET["shift_weekdays"];} + elseif (isset($_POST["shift_weekdays"])) {$shift_weekdays=$_POST["shift_weekdays"];} +if (isset($_GET["group_shifts"])) {$group_shifts=$_GET["group_shifts"];} + elseif (isset($_POST["group_shifts"])) {$group_shifts=$_POST["group_shifts"];} +if (isset($_GET["timeclock_end_of_day"])) {$timeclock_end_of_day=$_GET["timeclock_end_of_day"];} + elseif (isset($_POST["timeclock_end_of_day"])) {$timeclock_end_of_day=$_POST["timeclock_end_of_day"];} +if (isset($_GET["survey_first_audio_file"])) {$survey_first_audio_file=$_GET["survey_first_audio_file"];} + elseif (isset($_POST["survey_first_audio_file"])) {$survey_first_audio_file=$_POST["survey_first_audio_file"];} +if (isset($_GET["survey_dtmf_digits"])) {$survey_dtmf_digits=$_GET["survey_dtmf_digits"];} + elseif (isset($_POST["survey_dtmf_digits"])) {$survey_dtmf_digits=$_POST["survey_dtmf_digits"];} +if (isset($_GET["survey_ni_digit"])) {$survey_ni_digit=$_GET["survey_ni_digit"];} + elseif (isset($_POST["survey_ni_digit"])) {$survey_ni_digit=$_POST["survey_ni_digit"];} +if (isset($_GET["survey_opt_in_audio_file"])) {$survey_opt_in_audio_file=$_GET["survey_opt_in_audio_file"];} + elseif (isset($_POST["survey_opt_in_audio_file"])) {$survey_opt_in_audio_file=$_POST["survey_opt_in_audio_file"];} +if (isset($_GET["survey_ni_audio_file"])) {$survey_ni_audio_file=$_GET["survey_ni_audio_file"];} + elseif (isset($_POST["survey_ni_audio_file"])) {$survey_ni_audio_file=$_POST["survey_ni_audio_file"];} +if (isset($_GET["survey_method"])) {$survey_method=$_GET["survey_method"];} + elseif (isset($_POST["survey_method"])) {$survey_method=$_POST["survey_method"];} +if (isset($_GET["survey_no_response_action"])) {$survey_no_response_action=$_GET["survey_no_response_action"];} + elseif (isset($_POST["survey_no_response_action"])) {$survey_no_response_action=$_POST["survey_no_response_action"];} +if (isset($_GET["survey_ni_status"])) {$survey_ni_status=$_GET["survey_ni_status"];} + elseif (isset($_POST["survey_ni_status"])) {$survey_ni_status=$_POST["survey_ni_status"];} +if (isset($_GET["survey_response_digit_map"])) {$survey_response_digit_map=$_GET["survey_response_digit_map"];} + elseif (isset($_POST["survey_response_digit_map"])) {$survey_response_digit_map=$_POST["survey_response_digit_map"];} +if (isset($_GET["survey_xfer_exten"])) {$survey_xfer_exten=$_GET["survey_xfer_exten"];} + elseif (isset($_POST["survey_xfer_exten"])) {$survey_xfer_exten=$_POST["survey_xfer_exten"];} +if (isset($_GET["survey_camp_record_dir"])) {$survey_camp_record_dir=$_GET["survey_camp_record_dir"];} + elseif (isset($_POST["survey_camp_record_dir"])) {$survey_camp_record_dir=$_POST["survey_camp_record_dir"];} +if (isset($_GET["add_timeclock_log"])) {$add_timeclock_log=$_GET["add_timeclock_log"];} + elseif (isset($_POST["add_timeclock_log"])) {$add_timeclock_log=$_POST["add_timeclock_log"];} +if (isset($_GET["modify_timeclock_log"])) {$modify_timeclock_log=$_GET["modify_timeclock_log"];} + elseif (isset($_POST["modify_timeclock_log"])) {$modify_timeclock_log=$_POST["modify_timeclock_log"];} +if (isset($_GET["delete_timeclock_log"])) {$delete_timeclock_log=$_GET["delete_timeclock_log"];} + elseif (isset($_POST["delete_timeclock_log"])) {$delete_timeclock_log=$_POST["delete_timeclock_log"];} +if (isset($_GET["phone_numbers"])) {$phone_numbers=$_GET["phone_numbers"];} + elseif (isset($_POST["phone_numbers"])) {$phone_numbers=$_POST["phone_numbers"];} +if (isset($_GET["vdc_header_date_format"])) {$vdc_header_date_format=$_GET["vdc_header_date_format"];} + elseif (isset($_POST["vdc_header_date_format"])) {$vdc_header_date_format=$_POST["vdc_header_date_format"];} +if (isset($_GET["vdc_customer_date_format"])) {$vdc_customer_date_format=$_GET["vdc_customer_date_format"];} + elseif (isset($_POST["vdc_customer_date_format"])) {$vdc_customer_date_format=$_POST["vdc_customer_date_format"];} +if (isset($_GET["vdc_header_phone_format"])) {$vdc_header_phone_format=$_GET["vdc_header_phone_format"];} + elseif (isset($_POST["vdc_header_phone_format"])) {$vdc_header_phone_format=$_POST["vdc_header_phone_format"];} +if (isset($_GET["disable_alter_custphone"])) {$disable_alter_custphone=$_GET["disable_alter_custphone"];} + elseif (isset($_POST["disable_alter_custphone"])) {$disable_alter_custphone=$_POST["disable_alter_custphone"];} +if (isset($_GET["alter_custphone_override"])) {$alter_custphone_override=$_GET["alter_custphone_override"];} + elseif (isset($_POST["alter_custphone_override"])) {$alter_custphone_override=$_POST["alter_custphone_override"];} +if (isset($_GET["vdc_agent_api_access"])) {$vdc_agent_api_access=$_GET["vdc_agent_api_access"];} + elseif (isset($_POST["vdc_agent_api_access"])) {$vdc_agent_api_access=$_POST["vdc_agent_api_access"];} +if (isset($_GET["vdc_agent_api_active"])) {$vdc_agent_api_active=$_GET["vdc_agent_api_active"];} + elseif (isset($_POST["vdc_agent_api_active"])) {$vdc_agent_api_active=$_POST["vdc_agent_api_active"];} +if (isset($_GET["display_queue_count"])) {$display_queue_count=$_GET["display_queue_count"];} + elseif (isset($_POST["display_queue_count"])) {$display_queue_count=$_POST["display_queue_count"];} +if (isset($_GET["sale_category"])) {$sale_category=$_GET["sale_category"];} + elseif (isset($_POST["sale_category"])) {$sale_category=$_POST["sale_category"];} +if (isset($_GET["dead_lead_category"])) {$dead_lead_category=$_GET["dead_lead_category"];} + elseif (isset($_POST["dead_lead_category"])) {$dead_lead_category=$_POST["dead_lead_category"];} +if (isset($_GET["manual_dial_filter"])) {$manual_dial_filter=$_GET["manual_dial_filter"];} + elseif (isset($_POST["manual_dial_filter"])) {$manual_dial_filter=$_POST["manual_dial_filter"];} +if (isset($_GET["agent_clipboard_copy"])) {$agent_clipboard_copy=$_GET["agent_clipboard_copy"];} + elseif (isset($_POST["agent_clipboard_copy"])) {$agent_clipboard_copy=$_POST["agent_clipboard_copy"];} +if (isset($_GET["agent_extended_alt_dial"])) {$agent_extended_alt_dial=$_GET["agent_extended_alt_dial"];} + elseif (isset($_POST["agent_extended_alt_dial"])) {$agent_extended_alt_dial=$_POST["agent_extended_alt_dial"];} +if (isset($_GET["play_place_in_line"])) {$play_place_in_line=$_GET["play_place_in_line"];} + elseif (isset($_POST["play_place_in_line"])) {$play_place_in_line=$_POST["play_place_in_line"];} +if (isset($_GET["play_estimate_hold_time"])) {$play_estimate_hold_time=$_GET["play_estimate_hold_time"];} + elseif (isset($_POST["play_estimate_hold_time"])) {$play_estimate_hold_time=$_POST["play_estimate_hold_time"];} +if (isset($_GET["hold_time_option"])) {$hold_time_option=$_GET["hold_time_option"];} + elseif (isset($_POST["hold_time_option"])) {$hold_time_option=$_POST["hold_time_option"];} +if (isset($_GET["hold_time_option_seconds"])) {$hold_time_option_seconds=$_GET["hold_time_option_seconds"];} + elseif (isset($_POST["hold_time_option_seconds"])) {$hold_time_option_seconds=$_POST["hold_time_option_seconds"];} +if (isset($_GET["hold_time_option_exten"])) {$hold_time_option_exten=$_GET["hold_time_option_exten"];} + elseif (isset($_POST["hold_time_option_exten"])) {$hold_time_option_exten=$_POST["hold_time_option_exten"];} +if (isset($_GET["hold_time_option_voicemail"])) {$hold_time_option_voicemail=$_GET["hold_time_option_voicemail"];} + elseif (isset($_POST["hold_time_option_voicemail"])) {$hold_time_option_voicemail=$_POST["hold_time_option_voicemail"];} +if (isset($_GET["hold_time_option_xfer_group"])) {$hold_time_option_xfer_group=$_GET["hold_time_option_xfer_group"];} + elseif (isset($_POST["hold_time_option_xfer_group"])) {$hold_time_option_xfer_group=$_POST["hold_time_option_xfer_group"];} +if (isset($_GET["hold_time_option_callback_filename"])) {$hold_time_option_callback_filename=$_GET["hold_time_option_callback_filename"];} + elseif (isset($_POST["hold_time_option_callback_filename"])) {$hold_time_option_callback_filename=$_POST["hold_time_option_callback_filename"];} +if (isset($_GET["hold_time_option_callback_list_id"])) {$hold_time_option_callback_list_id=$_GET["hold_time_option_callback_list_id"];} + elseif (isset($_POST["hold_time_option_callback_list_id"])) {$hold_time_option_callback_list_id=$_POST["hold_time_option_callback_list_id"];} +if (isset($_GET["hold_recall_xfer_group"])) {$hold_recall_xfer_group=$_GET["hold_recall_xfer_group"];} + elseif (isset($_POST["hold_recall_xfer_group"])) {$hold_recall_xfer_group=$_POST["hold_recall_xfer_group"];} +if (isset($_GET["no_delay_call_route"])) {$no_delay_call_route=$_GET["no_delay_call_route"];} + elseif (isset($_POST["no_delay_call_route"])) {$no_delay_call_route=$_POST["no_delay_call_route"];} +if (isset($_GET["play_welcome_message"])) {$play_welcome_message=$_GET["play_welcome_message"];} + elseif (isset($_POST["play_welcome_message"])) {$play_welcome_message=$_POST["play_welcome_message"];} +if (isset($_GET["did_id"])) {$did_id=$_GET["did_id"];} + elseif (isset($_POST["did_id"])) {$did_id=$_POST["did_id"];} +if (isset($_GET["source_did"])) {$source_did=$_GET["source_did"];} + elseif (isset($_POST["source_did"])) {$source_did=$_POST["source_did"];} +if (isset($_GET["did_pattern"])) {$did_pattern=$_GET["did_pattern"];} + elseif (isset($_POST["did_pattern"])) {$did_pattern=$_POST["did_pattern"];} +if (isset($_GET["did_description"])) {$did_description=$_GET["did_description"];} + elseif (isset($_POST["did_description"])) {$did_description=$_POST["did_description"];} +if (isset($_GET["did_active"])) {$did_active=$_GET["did_active"];} + elseif (isset($_POST["did_active"])) {$did_active=$_POST["did_active"];} +if (isset($_GET["did_route"])) {$did_route=$_GET["did_route"];} + elseif (isset($_POST["did_route"])) {$did_route=$_POST["did_route"];} +if (isset($_GET["exten_context"])) {$exten_context=$_GET["exten_context"];} + elseif (isset($_POST["exten_context"])) {$exten_context=$_POST["exten_context"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["user_unavailable_action"])) {$user_unavailable_action=$_GET["user_unavailable_action"];} + elseif (isset($_POST["user_unavailable_action"])) {$user_unavailable_action=$_POST["user_unavailable_action"];} +if (isset($_GET["user_route_settings_ingroup"])) {$user_route_settings_ingroup=$_GET["user_route_settings_ingroup"];} + elseif (isset($_POST["user_route_settings_ingroup"])) {$user_route_settings_ingroup=$_POST["user_route_settings_ingroup"];} +if (isset($_GET["call_handle_method"])) {$call_handle_method=$_GET["call_handle_method"];} + elseif (isset($_POST["call_handle_method"])) {$call_handle_method=$_POST["call_handle_method"];} +if (isset($_GET["agent_search_method"])) {$agent_search_method=$_GET["agent_search_method"];} + elseif (isset($_POST["agent_search_method"])) {$agent_search_method=$_POST["agent_search_method"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["modify_inbound_dids"])) {$modify_inbound_dids=$_GET["modify_inbound_dids"];} + elseif (isset($_POST["modify_inbound_dids"])) {$modify_inbound_dids=$_POST["modify_inbound_dids"];} +if (isset($_GET["delete_inbound_dids"])) {$delete_inbound_dids=$_GET["delete_inbound_dids"];} + elseif (isset($_POST["delete_inbound_dids"])) {$delete_inbound_dids=$_POST["delete_inbound_dids"];} +if (isset($_GET["three_way_call_cid"])) {$three_way_call_cid=$_GET["three_way_call_cid"];} + elseif (isset($_POST["three_way_call_cid"])) {$three_way_call_cid=$_POST["three_way_call_cid"];} +if (isset($_GET["three_way_dial_prefix"])) {$three_way_dial_prefix=$_GET["three_way_dial_prefix"];} + elseif (isset($_POST["three_way_dial_prefix"])) {$three_way_dial_prefix=$_POST["three_way_dial_prefix"];} +if (isset($_GET["forced_timeclock_login"])) {$forced_timeclock_login=$_GET["forced_timeclock_login"];} + elseif (isset($_POST["forced_timeclock_login"])) {$forced_timeclock_login=$_POST["forced_timeclock_login"];} +if (isset($_GET["answer_sec_pct_rt_stat_one"])) {$answer_sec_pct_rt_stat_one=$_GET["answer_sec_pct_rt_stat_one"];} + elseif (isset($_POST["answer_sec_pct_rt_stat_one"])) {$answer_sec_pct_rt_stat_one=$_POST["answer_sec_pct_rt_stat_one"];} +if (isset($_GET["answer_sec_pct_rt_stat_two"])) {$answer_sec_pct_rt_stat_two=$_GET["answer_sec_pct_rt_stat_two"];} + elseif (isset($_POST["answer_sec_pct_rt_stat_two"])) {$answer_sec_pct_rt_stat_two=$_POST["answer_sec_pct_rt_stat_two"];} +if (isset($_GET["list_active_change"])) {$list_active_change=$_GET["list_active_change"];} + elseif (isset($_POST["list_active_change"])) {$list_active_change=$_POST["list_active_change"];} +if (isset($_GET["web_form_target"])) {$web_form_target=$_GET["web_form_target"];} + elseif (isset($_POST["web_form_target"])) {$web_form_target=$_POST["web_form_target"];} +if (isset($_GET["alt_server_ip"])) {$alt_server_ip=$_GET["alt_server_ip"];} + elseif (isset($_POST["alt_server_ip"])) {$alt_server_ip=$_POST["alt_server_ip"];} +if (isset($_GET["recording_web_link"])) {$recording_web_link=$_GET["recording_web_link"];} + elseif (isset($_POST["recording_web_link"])) {$recording_web_link=$_POST["recording_web_link"];} +if (isset($_GET["enable_vtiger_integration"])) {$enable_vtiger_integration=$_GET["enable_vtiger_integration"];} + elseif (isset($_POST["enable_vtiger_integration"])) {$enable_vtiger_integration=$_POST["enable_vtiger_integration"];} +if (isset($_GET["vtiger_server_ip"])) {$vtiger_server_ip=$_GET["vtiger_server_ip"];} + elseif (isset($_POST["vtiger_server_ip"])) {$vtiger_server_ip=$_POST["vtiger_server_ip"];} +if (isset($_GET["vtiger_dbname"])) {$vtiger_dbname=$_GET["vtiger_dbname"];} + elseif (isset($_POST["vtiger_dbname"])) {$vtiger_dbname=$_POST["vtiger_dbname"];} +if (isset($_GET["vtiger_login"])) {$vtiger_login=$_GET["vtiger_login"];} + elseif (isset($_POST["vtiger_login"])) {$vtiger_login=$_POST["vtiger_login"];} +if (isset($_GET["vtiger_pass"])) {$vtiger_pass=$_GET["vtiger_pass"];} + elseif (isset($_POST["vtiger_pass"])) {$vtiger_pass=$_POST["vtiger_pass"];} +if (isset($_GET["vtiger_url"])) {$vtiger_url=$_GET["vtiger_url"];} + elseif (isset($_POST["vtiger_url"])) {$vtiger_url=$_POST["vtiger_url"];} +if (isset($_GET["vtiger_search_category"])) {$vtiger_search_category=$_GET["vtiger_search_category"];} + elseif (isset($_POST["vtiger_search_category"])) {$vtiger_search_category=$_POST["vtiger_search_category"];} +if (isset($_GET["vtiger_create_call_record"])) {$vtiger_create_call_record=$_GET["vtiger_create_call_record"];} + elseif (isset($_POST["vtiger_create_call_record"])) {$vtiger_create_call_record=$_POST["vtiger_create_call_record"];} +if (isset($_GET["vtiger_create_lead_record"])) {$vtiger_create_lead_record=$_GET["vtiger_create_lead_record"];} + elseif (isset($_POST["vtiger_create_lead_record"])) {$vtiger_create_lead_record=$_POST["vtiger_create_lead_record"];} +if (isset($_GET["vtiger_screen_login"])) {$vtiger_screen_login=$_GET["vtiger_screen_login"];} + elseif (isset($_POST["vtiger_screen_login"])) {$vtiger_screen_login=$_POST["vtiger_screen_login"];} +if (isset($_GET["qc_features_active"])) {$qc_features_active=$_GET["qc_features_active"];} + elseif (isset($_POST["qc_features_active"])) {$qc_features_active=$_POST["qc_features_active"];} +if (isset($_GET["outbound_autodial_active"])) {$outbound_autodial_active=$_GET["outbound_autodial_active"];} + elseif (isset($_POST["outbound_autodial_active"])) {$outbound_autodial_active=$_POST["outbound_autodial_active"];} +if (isset($_GET["cpd_amd_action"])) {$cpd_amd_action=$_GET["cpd_amd_action"];} + elseif (isset($_POST["cpd_amd_action"])) {$cpd_amd_action=$_POST["cpd_amd_action"];} +if (isset($_GET["download_lists"])) {$download_lists=$_GET["download_lists"];} + elseif (isset($_POST["download_lists"])) {$download_lists=$_POST["download_lists"];} +if (isset($_GET["active_asterisk_server"])) {$active_asterisk_server=$_GET["active_asterisk_server"];} + elseif (isset($_POST["active_asterisk_server"])) {$active_asterisk_server=$_POST["active_asterisk_server"];} +if (isset($_GET["generate_vicidial_conf"])) {$generate_vicidial_conf=$_GET["generate_vicidial_conf"];} + elseif (isset($_POST["generate_vicidial_conf"])) {$generate_vicidial_conf=$_POST["generate_vicidial_conf"];} +if (isset($_GET["rebuild_conf_files"])) {$rebuild_conf_files=$_GET["rebuild_conf_files"];} + elseif (isset($_POST["rebuild_conf_files"])) {$rebuild_conf_files=$_POST["rebuild_conf_files"];} +if (isset($_GET["template_id"])) {$template_id=$_GET["template_id"];} + elseif (isset($_POST["template_id"])) {$template_id=$_POST["template_id"];} +if (isset($_GET["conf_override"])) {$conf_override=$_GET["conf_override"];} + elseif (isset($_POST["conf_override"])) {$conf_override=$_POST["conf_override"];} +if (isset($_GET["template_name"])) {$template_name=$_GET["template_name"];} + elseif (isset($_POST["template_name"])) {$template_name=$_POST["template_name"];} +if (isset($_GET["template_contents"])) {$template_contents=$_GET["template_contents"];} + elseif (isset($_POST["template_contents"])) {$template_contents=$_POST["template_contents"];} +if (isset($_GET["carrier_id"])) {$carrier_id=$_GET["carrier_id"];} + elseif (isset($_POST["carrier_id"])) {$carrier_id=$_POST["carrier_id"];} +if (isset($_GET["carrier_name"])) {$carrier_name=$_GET["carrier_name"];} + elseif (isset($_POST["carrier_name"])) {$carrier_name=$_POST["carrier_name"];} +if (isset($_GET["registration_string"])) {$registration_string=$_GET["registration_string"];} + elseif (isset($_POST["registration_string"])) {$registration_string=$_POST["registration_string"];} +if (isset($_GET["account_entry"])) {$account_entry=$_GET["account_entry"];} + elseif (isset($_POST["account_entry"])) {$account_entry=$_POST["account_entry"];} +if (isset($_GET["globals_string"])) {$globals_string=$_GET["globals_string"];} + elseif (isset($_POST["globals_string"])) {$globals_string=$_POST["globals_string"];} +if (isset($_GET["dialplan_entry"])) {$dialplan_entry=$_GET["dialplan_entry"];} + elseif (isset($_POST["dialplan_entry"])) {$dialplan_entry=$_POST["dialplan_entry"];} +if (isset($_GET["group_alias_id"])) {$group_alias_id=$_GET["group_alias_id"];} + elseif (isset($_POST["group_alias_id"])) {$group_alias_id=$_POST["group_alias_id"];} +if (isset($_GET["group_alias_name"])) {$group_alias_name=$_GET["group_alias_name"];} + elseif (isset($_POST["group_alias_name"])) {$group_alias_name=$_POST["group_alias_name"];} +if (isset($_GET["caller_id_number"])) {$caller_id_number=$_GET["caller_id_number"];} + elseif (isset($_POST["caller_id_number"])) {$caller_id_number=$_POST["caller_id_number"];} +if (isset($_GET["caller_id_name"])) {$caller_id_name=$_GET["caller_id_name"];} + elseif (isset($_POST["caller_id_name"])) {$caller_id_name=$_POST["caller_id_name"];} +if (isset($_GET["agent_allow_group_alias"])) {$agent_allow_group_alias=$_GET["agent_allow_group_alias"];} + elseif (isset($_POST["agent_allow_group_alias"])) {$agent_allow_group_alias=$_POST["agent_allow_group_alias"];} +if (isset($_GET["default_group_alias"])) {$default_group_alias=$_GET["default_group_alias"];} + elseif (isset($_POST["default_group_alias"])) {$default_group_alias=$_POST["default_group_alias"];} +if (isset($_GET["outbound_calls_per_second"])) {$outbound_calls_per_second=$_GET["outbound_calls_per_second"];} + elseif (isset($_POST["outbound_calls_per_second"])) {$outbound_calls_per_second=$_POST["outbound_calls_per_second"];} +if (isset($_GET["shift_enforcement"])) {$shift_enforcement=$_GET["shift_enforcement"];} + elseif (isset($_POST["shift_enforcement"])) {$shift_enforcement=$_POST["shift_enforcement"];} +if (isset($_GET["agent_shift_enforcement_override"])) {$agent_shift_enforcement_override=$_GET["agent_shift_enforcement_override"];} + elseif (isset($_POST["agent_shift_enforcement_override"])) {$agent_shift_enforcement_override=$_POST["agent_shift_enforcement_override"];} +if (isset($_GET["manager_shift_enforcement_override"])) {$manager_shift_enforcement_override=$_GET["manager_shift_enforcement_override"];} + elseif (isset($_POST["manager_shift_enforcement_override"])) {$manager_shift_enforcement_override=$_POST["manager_shift_enforcement_override"];} +if (isset($_GET["export_reports"])) {$export_reports=$_GET["export_reports"];} + elseif (isset($_POST["export_reports"])) {$export_reports=$_POST["export_reports"];} +if (isset($_GET["delete_from_dnc"])) {$delete_from_dnc=$_GET["delete_from_dnc"];} + elseif (isset($_POST["delete_from_dnc"])) {$delete_from_dnc=$_POST["delete_from_dnc"];} +if (isset($_GET["vtiger_search_dead"])) {$vtiger_search_dead=$_GET["vtiger_search_dead"];} + elseif (isset($_POST["vtiger_search_dead"])) {$vtiger_search_dead=$_POST["vtiger_search_dead"];} +if (isset($_GET["vtiger_status_call"])) {$vtiger_status_call=$_GET["vtiger_status_call"];} + elseif (isset($_POST["vtiger_status_call"])) {$vtiger_status_call=$_POST["vtiger_status_call"];} +if (isset($_GET["sale"])) {$sale=$_GET["sale"];} + elseif (isset($_POST["sale"])) {$sale=$_POST["sale"];} +if (isset($_GET["dnc"])) {$dnc=$_GET["dnc"];} + elseif (isset($_POST["dnc"])) {$dnc=$_POST["dnc"];} +if (isset($_GET["customer_contact"])) {$customer_contact=$_GET["customer_contact"];} + elseif (isset($_POST["customer_contact"])) {$customer_contact=$_POST["customer_contact"];} +if (isset($_GET["not_interested"])) {$not_interested=$_GET["not_interested"];} + elseif (isset($_POST["not_interested"])) {$not_interested=$_POST["not_interested"];} +if (isset($_GET["unworkable"])) {$unworkable=$_GET["unworkable"];} + elseif (isset($_POST["unworkable"])) {$unworkable=$_POST["unworkable"];} +if (isset($_GET["user_code"])) {$user_code=$_GET["user_code"];} + elseif (isset($_POST["user_code"])) {$user_code=$_POST["user_code"];} +if (isset($_GET["territory"])) {$territory=$_GET["territory"];} + elseif (isset($_POST["territory"])) {$territory=$_POST["territory"];} +if (isset($_GET["survey_third_digit"])) {$survey_third_digit=$_GET["survey_third_digit"];} + elseif (isset($_POST["survey_third_digit"])) {$survey_third_digit=$_POST["survey_third_digit"];} +if (isset($_GET["survey_fourth_digit"])) {$survey_fourth_digit=$_GET["survey_fourth_digit"];} + elseif (isset($_POST["survey_fourth_digit"])) {$survey_fourth_digit=$_POST["survey_fourth_digit"];} +if (isset($_GET["survey_third_audio_file"])) {$survey_third_audio_file=$_GET["survey_third_audio_file"];} + elseif (isset($_POST["survey_third_audio_file"])) {$survey_third_audio_file=$_POST["survey_third_audio_file"];} +if (isset($_GET["survey_fourth_audio_file"])) {$survey_fourth_audio_file=$_GET["survey_fourth_audio_file"];} + elseif (isset($_POST["survey_fourth_audio_file"])) {$survey_fourth_audio_file=$_POST["survey_fourth_audio_file"];} +if (isset($_GET["survey_third_status"])) {$survey_third_status=$_GET["survey_third_status"];} + elseif (isset($_POST["survey_third_status"])) {$survey_third_status=$_POST["survey_third_status"];} +if (isset($_GET["survey_fourth_status"])) {$survey_fourth_status=$_GET["survey_fourth_status"];} + elseif (isset($_POST["survey_fourth_status"])) {$survey_fourth_status=$_POST["survey_fourth_status"];} +if (isset($_GET["survey_third_exten"])) {$survey_third_exten=$_GET["survey_third_exten"];} + elseif (isset($_POST["survey_third_exten"])) {$survey_third_exten=$_POST["survey_third_exten"];} +if (isset($_GET["survey_fourth_exten"])) {$survey_fourth_exten=$_GET["survey_fourth_exten"];} + elseif (isset($_POST["survey_fourth_exten"])) {$survey_fourth_exten=$_POST["survey_fourth_exten"];} +if (isset($_GET["menu_id"])) {$menu_id=$_GET["menu_id"];} + elseif (isset($_POST["menu_id"])) {$menu_id=$_POST["menu_id"];} +if (isset($_GET["menu_name"])) {$menu_name=$_GET["menu_name"];} + elseif (isset($_POST["menu_name"])) {$menu_name=$_POST["menu_name"];} +if (isset($_GET["menu_prompt"])) {$menu_prompt=$_GET["menu_prompt"];} + elseif (isset($_POST["menu_prompt"])) {$menu_prompt=$_POST["menu_prompt"];} +if (isset($_GET["menu_timeout"])) {$menu_timeout=$_GET["menu_timeout"];} + elseif (isset($_POST["menu_timeout"])) {$menu_timeout=$_POST["menu_timeout"];} +if (isset($_GET["menu_timeout_prompt"])) {$menu_timeout_prompt=$_GET["menu_timeout_prompt"];} + elseif (isset($_POST["menu_timeout_prompt"])) {$menu_timeout_prompt=$_POST["menu_timeout_prompt"];} +if (isset($_GET["menu_invalid_prompt"])) {$menu_invalid_prompt=$_GET["menu_invalid_prompt"];} + elseif (isset($_POST["menu_invalid_prompt"])) {$menu_invalid_prompt=$_POST["menu_invalid_prompt"];} +if (isset($_GET["menu_repeat"])) {$menu_repeat=$_GET["menu_repeat"];} + elseif (isset($_POST["menu_repeat"])) {$menu_repeat=$_POST["menu_repeat"];} +if (isset($_GET["menu_time_check"])) {$menu_time_check=$_GET["menu_time_check"];} + elseif (isset($_POST["menu_time_check"])) {$menu_time_check=$_POST["menu_time_check"];} +if (isset($_GET["track_in_vdac"])) {$track_in_vdac=$_GET["track_in_vdac"];} + elseif (isset($_POST["track_in_vdac"])) {$track_in_vdac=$_POST["track_in_vdac"];} +if (isset($_GET["source_menu"])) {$source_menu=$_GET["source_menu"];} + elseif (isset($_POST["source_menu"])) {$source_menu=$_POST["source_menu"];} +if (isset($_GET["agentonly_callback_campaign_lock"])) {$agentonly_callback_campaign_lock=$_GET["agentonly_callback_campaign_lock"];} + elseif (isset($_POST["agentonly_callback_campaign_lock"])) {$agentonly_callback_campaign_lock=$_POST["agentonly_callback_campaign_lock"];} +if (isset($_GET["sounds_central_control_active"])) {$sounds_central_control_active=$_GET["sounds_central_control_active"];} + elseif (isset($_POST["sounds_central_control_active"])) {$sounds_central_control_active=$_POST["sounds_central_control_active"];} +if (isset($_GET["sounds_web_server"])) {$sounds_web_server=$_GET["sounds_web_server"];} + elseif (isset($_POST["sounds_web_server"])) {$sounds_web_server=$_POST["sounds_web_server"];} +if (isset($_GET["sounds_web_directory"])) {$sounds_web_directory=$_GET["sounds_web_directory"];} + elseif (isset($_POST["sounds_web_directory"])) {$sounds_web_directory=$_POST["sounds_web_directory"];} +if (isset($_GET["sounds_update"])) {$sounds_update=$_GET["sounds_update"];} + elseif (isset($_POST["sounds_update"])) {$sounds_update=$_POST["sounds_update"];} +if (isset($_GET["active_voicemail_server"])) {$active_voicemail_server=$_GET["active_voicemail_server"];} + elseif (isset($_POST["active_voicemail_server"])) {$active_voicemail_server=$_POST["active_voicemail_server"];} +if (isset($_GET["auto_dial_limit"])) {$auto_dial_limit=$_GET["auto_dial_limit"];} + elseif (isset($_POST["auto_dial_limit"])) {$auto_dial_limit=$_POST["auto_dial_limit"];} +if (isset($_GET["user_territories_active"])) {$user_territories_active=$_GET["user_territories_active"];} + elseif (isset($_POST["user_territories_active"])) {$user_territories_active=$_POST["user_territories_active"];} +if (isset($_GET["vicidial_recording_limit"])) {$vicidial_recording_limit=$_GET["vicidial_recording_limit"];} + elseif (isset($_POST["vicidial_recording_limit"])) {$vicidial_recording_limit=$_POST["vicidial_recording_limit"];} +if (isset($_GET["phone_context"])) {$phone_context=$_GET["phone_context"];} + elseif (isset($_POST["phone_context"])) {$phone_context=$_POST["phone_context"];} +if (isset($_GET["carrier_logging_active"])) {$carrier_logging_active=$_GET["carrier_logging_active"];} + elseif (isset($_POST["carrier_logging_active"])) {$carrier_logging_active=$_POST["carrier_logging_active"];} +if (isset($_GET["drop_lockout_time"])) {$drop_lockout_time=$_GET["drop_lockout_time"];} + elseif (isset($_POST["drop_lockout_time"])) {$drop_lockout_time=$_POST["drop_lockout_time"];} +if (isset($_GET["allow_custom_dialplan"])) {$allow_custom_dialplan=$_GET["allow_custom_dialplan"];} + elseif (isset($_POST["allow_custom_dialplan"])) {$allow_custom_dialplan=$_POST["allow_custom_dialplan"];} +if (isset($_GET["custom_dialplan_entry"])) {$custom_dialplan_entry=$_GET["custom_dialplan_entry"];} + elseif (isset($_POST["custom_dialplan_entry"])) {$custom_dialplan_entry=$_POST["custom_dialplan_entry"];} +if (isset($_GET["phone_ring_timeout"])) {$phone_ring_timeout=$_GET["phone_ring_timeout"];} + elseif (isset($_POST["phone_ring_timeout"])) {$phone_ring_timeout=$_POST["phone_ring_timeout"];} +if (isset($_GET["conf_secret"])) {$conf_secret=$_GET["conf_secret"];} + elseif (isset($_POST["conf_secret"])) {$conf_secret=$_POST["conf_secret"];} +if (isset($_GET["tracking_group"])) {$tracking_group=$_GET["tracking_group"];} + elseif (isset($_POST["tracking_group"])) {$tracking_group=$_POST["tracking_group"];} +if (isset($_GET["no_agent_no_queue"])) {$no_agent_no_queue=$_GET["no_agent_no_queue"];} + elseif (isset($_POST["no_agent_no_queue"])) {$no_agent_no_queue=$_POST["no_agent_no_queue"];} +if (isset($_GET["no_agent_action"])) {$no_agent_action=$_GET["no_agent_action"];} + elseif (isset($_POST["no_agent_action"])) {$no_agent_action=$_POST["no_agent_action"];} +if (isset($_GET["no_agent_action_value"])) {$no_agent_action_value=$_GET["no_agent_action_value"];} + elseif (isset($_POST["no_agent_action_value"])) {$no_agent_action_value=$_POST["no_agent_action_value"];} +if (isset($_GET["quick_transfer_button"])) {$quick_transfer_button=$_GET["quick_transfer_button"];} + elseif (isset($_POST["quick_transfer_button"])) {$quick_transfer_button=$_POST["quick_transfer_button"];} +if (isset($_GET["prepopulate_transfer_preset"])) {$prepopulate_transfer_preset=$_GET["prepopulate_transfer_preset"];} + elseif (isset($_POST["prepopulate_transfer_preset"])) {$prepopulate_transfer_preset=$_POST["prepopulate_transfer_preset"];} +if (isset($_GET["enable_tts_integration"])) {$enable_tts_integration=$_GET["enable_tts_integration"];} + elseif (isset($_POST["enable_tts_integration"])) {$enable_tts_integration=$_POST["enable_tts_integration"];} +if (isset($_GET["tts_id"])) {$tts_id=$_GET["tts_id"];} + elseif (isset($_POST["tts_id"])) {$tts_id=$_POST["tts_id"];} +if (isset($_GET["tts_name"])) {$tts_name=$_GET["tts_name"];} + elseif (isset($_POST["tts_name"])) {$tts_name=$_POST["tts_name"];} +if (isset($_GET["tts_text"])) {$tts_text=$_GET["tts_text"];} + elseif (isset($_POST["tts_text"])) {$tts_text=$_POST["tts_text"];} +if (isset($_GET["drop_rate_group"])) {$drop_rate_group=$_GET["drop_rate_group"];} + elseif (isset($_POST["drop_rate_group"])) {$drop_rate_group=$_POST["drop_rate_group"];} +if (isset($_GET["agent_status_viewable_groups"])) {$agent_status_viewable_groups=$_GET["agent_status_viewable_groups"];} + elseif (isset($_POST["agent_status_viewable_groups"])) {$agent_status_viewable_groups=$_POST["agent_status_viewable_groups"];} +if (isset($_GET["agent_status_view_time"])) {$agent_status_view_time=$_GET["agent_status_view_time"];} + elseif (isset($_POST["agent_status_view_time"])) {$agent_status_view_time=$_POST["agent_status_view_time"];} +if (isset($_GET["view_calls_in_queue"])) {$view_calls_in_queue=$_GET["view_calls_in_queue"];} + elseif (isset($_POST["view_calls_in_queue"])) {$view_calls_in_queue=$_POST["view_calls_in_queue"];} +if (isset($_GET["view_calls_in_queue_launch"])) {$view_calls_in_queue_launch=$_GET["view_calls_in_queue_launch"];} + elseif (isset($_POST["view_calls_in_queue_launch"])) {$view_calls_in_queue_launch=$_POST["view_calls_in_queue_launch"];} +if (isset($_GET["grab_calls_in_queue"])) {$grab_calls_in_queue=$_GET["grab_calls_in_queue"];} + elseif (isset($_POST["grab_calls_in_queue"])) {$grab_calls_in_queue=$_POST["grab_calls_in_queue"];} +if (isset($_GET["call_requeue_button"])) {$call_requeue_button=$_GET["call_requeue_button"];} + elseif (isset($_POST["call_requeue_button"])) {$call_requeue_button=$_POST["call_requeue_button"];} +if (isset($_GET["pause_after_each_call"])) {$pause_after_each_call=$_GET["pause_after_each_call"];} + elseif (isset($_POST["pause_after_each_call"])) {$pause_after_each_call=$_POST["pause_after_each_call"];} +if (isset($_GET["no_hopper_dialing"])) {$no_hopper_dialing=$_GET["no_hopper_dialing"];} + elseif (isset($_POST["no_hopper_dialing"])) {$no_hopper_dialing=$_POST["no_hopper_dialing"];} +if (isset($_GET["agent_dial_owner_only"])) {$agent_dial_owner_only=$_GET["agent_dial_owner_only"];} + elseif (isset($_POST["agent_dial_owner_only"])) {$agent_dial_owner_only=$_POST["agent_dial_owner_only"];} +if (isset($_GET["reset_time"])) {$reset_time=$_GET["reset_time"];} + elseif (isset($_POST["reset_time"])) {$reset_time=$_POST["reset_time"];} +if (isset($_GET["allow_alerts"])) {$allow_alerts=$_GET["allow_alerts"];} + elseif (isset($_POST["allow_alerts"])) {$allow_alerts=$_POST["allow_alerts"];} +if (isset($_GET["agent_display_dialable_leads"])) {$agent_display_dialable_leads=$_GET["agent_display_dialable_leads"];} + elseif (isset($_POST["agent_display_dialable_leads"])) {$agent_display_dialable_leads=$_POST["agent_display_dialable_leads"];} +if (isset($_GET["vicidial_balance_rank"])) {$vicidial_balance_rank=$_GET["vicidial_balance_rank"];} + elseif (isset($_POST["vicidial_balance_rank"])) {$vicidial_balance_rank=$_POST["vicidial_balance_rank"];} +if (isset($_GET["agent_script_override"])) {$agent_script_override=$_GET["agent_script_override"];} + elseif (isset($_POST["agent_script_override"])) {$agent_script_override=$_POST["agent_script_override"];} +if (isset($_GET["moh_id"])) {$moh_id=$_GET["moh_id"];} + elseif (isset($_POST["moh_id"])) {$moh_id=$_POST["moh_id"];} +if (isset($_GET["moh_name"])) {$moh_name=$_GET["moh_name"];} + elseif (isset($_POST["moh_name"])) {$moh_name=$_POST["moh_name"];} +if (isset($_GET["random"])) {$random=$_GET["random"];} + elseif (isset($_POST["random"])) {$random=$_POST["random"];} +if (isset($_GET["filename"])) {$filename=$_GET["filename"];} + elseif (isset($_POST["filename"])) {$filename=$_POST["filename"];} +if (isset($_GET["rank"])) {$rank=$_GET["rank"];} + elseif (isset($_POST["rank"])) {$rank=$_POST["rank"];} +if (isset($_GET["rebuild_music_on_hold"])) {$rebuild_music_on_hold=$_GET["rebuild_music_on_hold"];} + elseif (isset($_POST["rebuild_music_on_hold"])) {$rebuild_music_on_hold=$_POST["rebuild_music_on_hold"];} +if (isset($_GET["active_agent_login_server"])) {$active_agent_login_server=$_GET["active_agent_login_server"];} + elseif (isset($_POST["active_agent_login_server"])) {$active_agent_login_server=$_POST["active_agent_login_server"];} +if (isset($_GET["enable_second_webform"])) {$enable_second_webform=$_GET["enable_second_webform"];} + elseif (isset($_POST["enable_second_webform"])) {$enable_second_webform=$_POST["enable_second_webform"];} +if (isset($_GET["web_form_address_two"])) {$web_form_address_two=$_GET["web_form_address_two"];} + elseif (isset($_POST["web_form_address_two"])) {$web_form_address_two=$_POST["web_form_address_two"];} +if (isset($_GET["waitforsilence_options"])) {$waitforsilence_options=$_GET["waitforsilence_options"];} + elseif (isset($_POST["waitforsilence_options"])) {$waitforsilence_options=$_POST["waitforsilence_options"];} +if (isset($_GET["campaign_cid_override"])) {$campaign_cid_override=$_GET["campaign_cid_override"];} + elseif (isset($_POST["campaign_cid_override"])) {$campaign_cid_override=$_POST["campaign_cid_override"];} +if (isset($_GET["am_message_exten_override"])) {$am_message_exten_override=$_GET["am_message_exten_override"];} + elseif (isset($_POST["am_message_exten_override"])) {$am_message_exten_override=$_POST["am_message_exten_override"];} +if (isset($_GET["drop_inbound_group_override"])) {$drop_inbound_group_override=$_GET["drop_inbound_group_override"];} + elseif (isset($_POST["drop_inbound_group_override"])) {$drop_inbound_group_override=$_POST["drop_inbound_group_override"];} +if (isset($_GET["agent_select_territories"])) {$agent_select_territories=$_GET["agent_select_territories"];} + elseif (isset($_POST["agent_select_territories"])) {$agent_select_territories=$_POST["agent_select_territories"];} +if (isset($_GET["agent_choose_territories"])) {$agent_choose_territories=$_GET["agent_choose_territories"];} + elseif (isset($_POST["agent_choose_territories"])) {$agent_choose_territories=$_POST["agent_choose_territories"];} +if (isset($_GET["carrier_description"])) {$carrier_description=$_GET["carrier_description"];} + elseif (isset($_POST["carrier_description"])) {$carrier_description=$_POST["carrier_description"];} +if (isset($_GET["delete_vm_after_email"])) {$delete_vm_after_email=$_GET["delete_vm_after_email"];} + elseif (isset($_POST["delete_vm_after_email"])) {$delete_vm_after_email=$_POST["delete_vm_after_email"];} +if (isset($_GET["custom_one"])) {$custom_one=$_GET["custom_one"];} + elseif (isset($_POST["custom_one"])) {$custom_one=$_POST["custom_one"];} +if (isset($_GET["custom_two"])) {$custom_two=$_GET["custom_two"];} + elseif (isset($_POST["custom_two"])) {$custom_two=$_POST["custom_two"];} +if (isset($_GET["custom_three"])) {$custom_three=$_GET["custom_three"];} + elseif (isset($_POST["custom_three"])) {$custom_three=$_POST["custom_three"];} +if (isset($_GET["custom_four"])) {$custom_four=$_GET["custom_four"];} + elseif (isset($_POST["custom_four"])) {$custom_four=$_POST["custom_four"];} +if (isset($_GET["custom_five"])) {$custom_five=$_GET["custom_five"];} + elseif (isset($_POST["custom_five"])) {$custom_five=$_POST["custom_five"];} +if (isset($_GET["crm_popup_login"])) {$crm_popup_login=$_GET["crm_popup_login"];} + elseif (isset($_POST["crm_popup_login"])) {$crm_popup_login=$_POST["crm_popup_login"];} +if (isset($_GET["crm_login_address"])) {$crm_login_address=$_GET["crm_login_address"];} + elseif (isset($_POST["crm_login_address"])) {$crm_login_address=$_POST["crm_login_address"];} +if (isset($_GET["timer_action"])) {$timer_action=$_GET["timer_action"];} + elseif (isset($_POST["timer_action"])) {$timer_action=$_POST["timer_action"];} +if (isset($_GET["timer_action_message"])) {$timer_action_message=$_GET["timer_action_message"];} + elseif (isset($_POST["timer_action_message"])) {$timer_action_message=$_POST["timer_action_message"];} +if (isset($_GET["timer_action_seconds"])) {$timer_action_seconds=$_GET["timer_action_seconds"];} + elseif (isset($_POST["timer_action_seconds"])) {$timer_action_seconds=$_POST["timer_action_seconds"];} +if (isset($_GET["start_call_url"])) {$start_call_url=$_GET["start_call_url"];} + elseif (isset($_POST["start_call_url"])) {$start_call_url=$_POST["start_call_url"];} +if (isset($_GET["dispo_call_url"])) {$dispo_call_url=$_GET["dispo_call_url"];} + elseif (isset($_POST["dispo_call_url"])) {$dispo_call_url=$_POST["dispo_call_url"];} +if (isset($_GET["xferconf_c_number"])) {$xferconf_c_number=$_GET["xferconf_c_number"];} + elseif (isset($_POST["xferconf_c_number"])) {$xferconf_c_number=$_POST["xferconf_c_number"];} +if (isset($_GET["xferconf_d_number"])) {$xferconf_d_number=$_GET["xferconf_d_number"];} + elseif (isset($_POST["xferconf_d_number"])) {$xferconf_d_number=$_POST["xferconf_d_number"];} +if (isset($_GET["xferconf_e_number"])) {$xferconf_e_number=$_GET["xferconf_e_number"];} + elseif (isset($_POST["xferconf_e_number"])) {$xferconf_e_number=$_POST["xferconf_e_number"];} + + if (isset($script_id)) {$script_id= strtoupper($script_id);} + if (isset($lead_filter_id)) {$lead_filter_id = strtoupper($lead_filter_id);} + +if (strlen($dial_status) > 0) + { + $ADD='28'; + $status = $dial_status; + } + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin,enable_queuemetrics_logging,enable_vtiger_integration,qc_features_active,outbound_autodial_active,sounds_central_control_active,enable_second_webform,user_territories_active FROM system_settings;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$qm_conf_ct = mysql_num_rows($rslt); +if ($qm_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $non_latin = $row[0]; + $SSenable_queuemetrics_logging = $row[1]; + $SSenable_vtiger_integration = $row[2]; + $SSqc_features_active = $row[3]; + $SSoutbound_autodial_active = $row[4]; + $SSsounds_central_control_active = $row[5]; + $SSenable_second_webform = $row[6]; + $SSuser_territories_active = $row[7]; + } +##### END SETTINGS LOOKUP ##### +########################################### + +###################################################################################################### +###################################################################################################### +####### Form variable filtering for security and data integrity +###################################################################################################### +###################################################################################################### + +if ($non_latin < 1) + { + ### DIGITS ONLY ### + $adaptive_latest_server_time = ereg_replace("[^0-9]","",$adaptive_latest_server_time); + $admin_hangup_enabled = ereg_replace("[^0-9]","",$admin_hangup_enabled); + $admin_hijack_enabled = ereg_replace("[^0-9]","",$admin_hijack_enabled); + $admin_monitor_enabled = ereg_replace("[^0-9]","",$admin_monitor_enabled); + $AFLogging_enabled = ereg_replace("[^0-9]","",$AFLogging_enabled); + $agent_choose_ingroups = ereg_replace("[^0-9]","",$agent_choose_ingroups); + $agentcall_manual = ereg_replace("[^0-9]","",$agentcall_manual); + $agentonly_callbacks = ereg_replace("[^0-9]","",$agentonly_callbacks); + $AGI_call_logging_enabled = ereg_replace("[^0-9]","",$AGI_call_logging_enabled); + $allcalls_delay = ereg_replace("[^0-9]","",$allcalls_delay); + $alter_agent_interface_options = ereg_replace("[^0-9]","",$alter_agent_interface_options); + $answer_transfer_agent = ereg_replace("[^0-9]","",$answer_transfer_agent); + $ast_admin_access = ereg_replace("[^0-9]","",$ast_admin_access); + $ast_delete_phones = ereg_replace("[^0-9]","",$ast_delete_phones); + $attempt_delay = ereg_replace("[^0-9]","",$attempt_delay); + $attempt_maximum = ereg_replace("[^0-9]","",$attempt_maximum); + $auto_dial_next_number = ereg_replace("[^0-9]","",$auto_dial_next_number); + $balance_trunks_offlimits = ereg_replace("[^0-9]","",$balance_trunks_offlimits); + $call_parking_enabled = ereg_replace("[^0-9]","",$call_parking_enabled); + $CallerID_popup_enabled = ereg_replace("[^0-9]","",$CallerID_popup_enabled); + $campaign_detail = ereg_replace("[^0-9]","",$campaign_detail); + $campaign_rec_exten = ereg_replace("[^0-9]","",$campaign_rec_exten); + $campaign_vdad_exten = ereg_replace("[^0-9]","",$campaign_vdad_exten); + $change_agent_campaign = ereg_replace("[^0-9]","",$change_agent_campaign); + $closer_default_blended = ereg_replace("[^0-9]","",$closer_default_blended); + $conf_exten = ereg_replace("[^0-9]","",$conf_exten); + $conf_on_extension = ereg_replace("[^0-9]","",$conf_on_extension); + $conferencing_enabled = ereg_replace("[^0-9]","",$conferencing_enabled); + $ct_default_start = ereg_replace("[^0-9]","",$ct_default_start); + $ct_default_stop = ereg_replace("[^0-9]","",$ct_default_stop); + $ct_friday_start = ereg_replace("[^0-9]","",$ct_friday_start); + $ct_friday_stop = ereg_replace("[^0-9]","",$ct_friday_stop); + $ct_monday_start = ereg_replace("[^0-9]","",$ct_monday_start); + $ct_monday_stop = ereg_replace("[^0-9]","",$ct_monday_stop); + $ct_saturday_start = ereg_replace("[^0-9]","",$ct_saturday_start); + $ct_saturday_stop = ereg_replace("[^0-9]","",$ct_saturday_stop); + $ct_sunday_start = ereg_replace("[^0-9]","",$ct_sunday_start); + $ct_sunday_stop = ereg_replace("[^0-9]","",$ct_sunday_stop); + $ct_thursday_start = ereg_replace("[^0-9]","",$ct_thursday_start); + $ct_thursday_stop = ereg_replace("[^0-9]","",$ct_thursday_stop); + $ct_tuesday_start = ereg_replace("[^0-9]","",$ct_tuesday_start); + $ct_tuesday_stop = ereg_replace("[^0-9]","",$ct_tuesday_stop); + $ct_wednesday_start = ereg_replace("[^0-9]","",$ct_wednesday_start); + $ct_wednesday_stop = ereg_replace("[^0-9]","",$ct_wednesday_stop); + $DBX_port = ereg_replace("[^0-9]","",$DBX_port); + $DBY_port = ereg_replace("[^0-9]","",$DBY_port); + $dedicated_trunks = ereg_replace("[^0-9]","",$dedicated_trunks); + $delete_call_times = ereg_replace("[^0-9]","",$delete_call_times); + $delete_campaigns = ereg_replace("[^0-9]","",$delete_campaigns); + $delete_filters = ereg_replace("[^0-9]","",$delete_filters); + $delete_ingroups = ereg_replace("[^0-9]","",$delete_ingroups); + $delete_lists = ereg_replace("[^0-9]","",$delete_lists); + $delete_remote_agents = ereg_replace("[^0-9]","",$delete_remote_agents); + $delete_scripts = ereg_replace("[^0-9]","",$delete_scripts); + $delete_user_groups = ereg_replace("[^0-9]","",$delete_user_groups); + $delete_users = ereg_replace("[^0-9]","",$delete_users); + $dial_timeout = ereg_replace("[^0-9]","",$dial_timeout); + $dialplan_number = ereg_replace("[^0-9]","",$dialplan_number); + $enable_fast_refresh = ereg_replace("[^0-9]","",$enable_fast_refresh); + $enable_persistant_mysql = ereg_replace("[^0-9]","",$enable_persistant_mysql); + $fast_refresh_rate = ereg_replace("[^0-9]","",$fast_refresh_rate); + $hopper_level = ereg_replace("[^0-9]","",$hopper_level); + $hotkey = ereg_replace("[^0-9]","",$hotkey); + $hotkeys_active = ereg_replace("[^0-9]","",$hotkeys_active); + $list_id = ereg_replace("[^0-9]","",$list_id); + $load_leads = ereg_replace("[^0-9]","",$load_leads); + $max_vicidial_trunks = ereg_replace("[^0-9]","",$max_vicidial_trunks); + $modify_call_times = ereg_replace("[^0-9]","",$modify_call_times); + $modify_users = ereg_replace("[^0-9]","",$modify_users); + $modify_campaigns = ereg_replace("[^0-9]","",$modify_campaigns); + $modify_lists = ereg_replace("[^0-9]","",$modify_lists); + $modify_scripts = ereg_replace("[^0-9]","",$modify_scripts); + $modify_filters = ereg_replace("[^0-9]","",$modify_filters); + $modify_ingroups = ereg_replace("[^0-9]","",$modify_ingroups); + $modify_usergroups = ereg_replace("[^0-9]","",$modify_usergroups); + $modify_remoteagents = ereg_replace("[^0-9]","",$modify_remoteagents); + $modify_servers = ereg_replace("[^0-9]","",$modify_servers); + $view_reports = ereg_replace("[^0-9]","",$view_reports); + $modify_leads = ereg_replace("[^0-9]","",$modify_leads); + $monitor_prefix = ereg_replace("[^0-9]","",$monitor_prefix); + $number_of_lines = ereg_replace("[^0-9]","",$number_of_lines); + $old_conf_exten = ereg_replace("[^0-9]","",$old_conf_exten); + $outbound_cid = ereg_replace("[^0-9]","",$outbound_cid); + $park_ext = ereg_replace("[^0-9]","",$park_ext); + $park_on_extension = ereg_replace("[^0-9]","",$park_on_extension); + $phone_number = ereg_replace("[^0-9]","",$phone_number); + $QUEUE_ACTION_enabled = ereg_replace("[^0-9]","",$QUEUE_ACTION_enabled); + $recording_exten = ereg_replace("[^0-9]","",$recording_exten); + $remote_agent_id = ereg_replace("[^0-9]","",$remote_agent_id); + $telnet_port = ereg_replace("[^0-9]","",$telnet_port); + $updater_check_enabled = ereg_replace("[^0-9]","",$updater_check_enabled); + $user_level = ereg_replace("[^0-9]","",$user_level); + $user_start = ereg_replace("[^0-9]","",$user_start); + $user_switching_enabled = ereg_replace("[^0-9]","",$user_switching_enabled); + $VDstop_rec_after_each_call = ereg_replace("[^0-9]","",$VDstop_rec_after_each_call); + $VICIDIAL_park_on_extension = ereg_replace("[^0-9]","",$VICIDIAL_park_on_extension); + $vicidial_recording = ereg_replace("[^0-9]","",$vicidial_recording); + $vicidial_transfers = ereg_replace("[^0-9]","",$vicidial_transfers); + $voicemail_button_enabled = ereg_replace("[^0-9]","",$voicemail_button_enabled); + $voicemail_dump_exten = ereg_replace("[^0-9]","",$voicemail_dump_exten); + $voicemail_ext = ereg_replace("[^0-9]","",$voicemail_ext); + $voicemail_exten = ereg_replace("[^0-9]","",$voicemail_exten); + $wrapup_seconds = ereg_replace("[^0-9]","",$wrapup_seconds); + $use_non_latin = ereg_replace("[^0-9]","",$use_non_latin); + $webroot_writable = ereg_replace("[^0-9]","",$webroot_writable); + $enable_queuemetrics_logging = ereg_replace("[^0-9]","",$enable_queuemetrics_logging); + $enable_sipsak_messages = ereg_replace("[^0-9]","",$enable_sipsak_messages); + $allow_sipsak_messages = ereg_replace("[^0-9]","",$allow_sipsak_messages); + $mix_container_item = ereg_replace("[^0-9]","",$mix_container_item); + $prompt_interval = ereg_replace("[^0-9]","",$prompt_interval); + $agent_alert_delay = ereg_replace("[^0-9]","",$agent_alert_delay); + $manual_dial_list_id = ereg_replace("[^0-9]","",$manual_dial_list_id); + $qc_user_level = ereg_replace("[^0-9]","",$qc_user_level); + $qc_pass = ereg_replace("[^0-9]","",$qc_pass); + $qc_finish = ereg_replace("[^0-9]","",$qc_finish); + $qc_commit = ereg_replace("[^0-9]","",$qc_commit); + $shift_start_time = ereg_replace("[^0-9]","",$shift_start_time); + $timeclock_end_of_day = ereg_replace("[^0-9]","",$timeclock_end_of_day); + $survey_xfer_exten = ereg_replace("[^0-9]","",$survey_xfer_exten); + $add_timeclock_log = ereg_replace("[^0-9]","",$add_timeclock_log); + $modify_timeclock_log = ereg_replace("[^0-9]","",$modify_timeclock_log); + $delete_timeclock_log = ereg_replace("[^0-9]","",$delete_timeclock_log); + $vdc_agent_api_access = ereg_replace("[^0-9]","",$vdc_agent_api_access); + $vdc_agent_api_active = ereg_replace("[^0-9]","",$vdc_agent_api_active); + $hold_time_option_seconds = ereg_replace("[^0-9]","",$hold_time_option_seconds); + $hold_time_option_callback_list_id = ereg_replace("[^0-9]","",$hold_time_option_callback_list_id); + $did_id = ereg_replace("[^0-9]","",$did_id); + $source_did = ereg_replace("[^0-9]","",$source_did); + $modify_inbound_dids = ereg_replace("[^0-9]","",$modify_inbound_dids); + $delete_inbound_dids = ereg_replace("[^0-9]","",$delete_inbound_dids); + $answer_sec_pct_rt_stat_one = ereg_replace("[^0-9]","",$answer_sec_pct_rt_stat_one); + $answer_sec_pct_rt_stat_two = ereg_replace("[^0-9]","",$answer_sec_pct_rt_stat_two); + $enable_vtiger_integration = ereg_replace("[^0-9]","",$enable_vtiger_integration); + $qc_features_active = ereg_replace("[^0-9]","",$qc_features_active); + $outbound_autodial_active = ereg_replace("[^0-9]","",$outbound_autodial_active); + $download_lists = ereg_replace("[^0-9]","",$download_lists); + $caller_id_number = ereg_replace("[^0-9]","",$caller_id_number); + $outbound_calls_per_second = ereg_replace("[^0-9]","",$outbound_calls_per_second); + $manager_shift_enforcement_override = ereg_replace("[^0-9]","",$manager_shift_enforcement_override); + $export_reports = ereg_replace("[^0-9]","",$export_reports); + $delete_from_dnc = ereg_replace("[^0-9]","",$delete_from_dnc); + $menu_timeout = ereg_replace("[^0-9]","",$menu_timeout); + $menu_time_check = ereg_replace("[^0-9]","",$menu_time_check); + $track_in_vdac = ereg_replace("[^0-9]","",$track_in_vdac); + $menu_repeat = ereg_replace("[^0-9]","",$menu_repeat); + $agentonly_callback_campaign_lock = ereg_replace("[^0-9]","",$agentonly_callback_campaign_lock); + $sounds_central_control_active = ereg_replace("[^0-9]","",$sounds_central_control_active); + $user_territories_active = ereg_replace("[^0-9]","",$user_territories_active); + $vicidial_recording_limit = ereg_replace("[^0-9]","",$vicidial_recording_limit); + $allow_custom_dialplan = ereg_replace("[^0-9]","",$allow_custom_dialplan); + $phone_ring_timeout = ereg_replace("[^0-9]","",$phone_ring_timeout); + $enable_tts_integration = ereg_replace("[^0-9]","",$enable_tts_integration); + $allow_alerts = ereg_replace("[^0-9]","",$allow_alerts); + $vicidial_balance_rank = ereg_replace("[^0-9]","",$vicidial_balance_rank); + $rank = ereg_replace("[^0-9]","",$rank); + $enable_second_webform = ereg_replace("[^0-9]","",$enable_second_webform); + $campaign_cid_override = ereg_replace("[^0-9]","",$campaign_cid_override); + $agent_choose_territories = ereg_replace("[^0-9]","",$agent_choose_territories); + $timer_action_seconds = ereg_replace("[^0-9]","",$timer_action_seconds); + + $drop_call_seconds = ereg_replace("[^-0-9]","",$drop_call_seconds); + + ### DIGITS and COLONS + $shift_length = ereg_replace("[^\:0-9]","",$shift_length); + + ### DIGITS and HASHES and STARS + $survey_dtmf_digits = ereg_replace("[^\#\*0-9]","",$survey_dtmf_digits); + $survey_ni_digit = ereg_replace("[^\#\*0-9]","",$survey_ni_digit); + + ### DIGITS and DASHES + $group_rank = ereg_replace("[^-0-9]","",$group_rank); + $campaign_rank = ereg_replace("[^-0-9]","",$campaign_rank); + $queue_priority = ereg_replace("[^-0-9]","",$queue_priority); + + ### DIGITS and NEWLINES + $phone_numbers = ereg_replace("[^X\n0-9]","",$phone_numbers); + + ### Y or N ONLY ### + $allow_closers = ereg_replace("[^NY]","",$allow_closers); + $reset_hopper = ereg_replace("[^NY]","",$reset_hopper); + $amd_send_to_vmx = ereg_replace("[^NY]","",$amd_send_to_vmx); + $alt_number_dialing = ereg_replace("[^NY]","",$alt_number_dialing); + $selectable = ereg_replace("[^NY]","",$selectable); + $reset_list = ereg_replace("[^NY]","",$reset_list); + $fronter_display = ereg_replace("[^NY]","",$fronter_display); + $omit_phone_code = ereg_replace("[^NY]","",$omit_phone_code); + $available_only_ratio_tally = ereg_replace("[^NY]","",$available_only_ratio_tally); + $sys_perf_log = ereg_replace("[^NY]","",$sys_perf_log); + $vicidial_balance_active = ereg_replace("[^NY]","",$vicidial_balance_active); + $vd_server_logs = ereg_replace("[^NY]","",$vd_server_logs); + $campaign_stats_refresh = ereg_replace("[^NY]","",$campaign_stats_refresh); + $disable_alter_custdata = ereg_replace("[^NY]","",$disable_alter_custdata); + $no_hopper_leads_logins = ereg_replace("[^NY]","",$no_hopper_leads_logins); + $human_answered = ereg_replace("[^NY]","",$human_answered); + $tovdad_display = ereg_replace("[^NY]","",$tovdad_display); + $campaign_allow_inbound = ereg_replace("[^NY]","",$campaign_allow_inbound); + $display_queue_count = ereg_replace("[^NY]","",$display_queue_count); + $qc_show_recording = ereg_replace("[^NY]","",$qc_show_recording); + $sale_category = ereg_replace("[^NY]","",$sale_category); + $dead_lead_category = ereg_replace("[^NY]","",$dead_lead_category); + $agent_extended_alt_dial = ereg_replace("[^NY]","",$agent_extended_alt_dial); + $play_place_in_line = ereg_replace("[^NY]","",$play_place_in_line); + $play_estimate_hold_time = ereg_replace("[^NY]","",$play_estimate_hold_time); + $no_delay_call_route = ereg_replace("[^NY]","",$no_delay_call_route); + $did_active = ereg_replace("[^NY]","",$did_active); + $active_asterisk_server = ereg_replace("[^NY]","",$active_asterisk_server); + $generate_vicidial_conf = ereg_replace("[^NY]","",$generate_vicidial_conf); + $rebuild_conf_files = ereg_replace("[^NY]","",$rebuild_conf_files); + $agent_allow_group_alias = ereg_replace("[^NY]","",$agent_allow_group_alias); + $vtiger_status_call = ereg_replace("[^NY]","",$vtiger_status_call); + $sale = ereg_replace("[^NY]","",$sale); + $dnc = ereg_replace("[^NY]","",$dnc); + $customer_contact = ereg_replace("[^NY]","",$customer_contact); + $not_interested = ereg_replace("[^NY]","",$not_interested); + $unworkable = ereg_replace("[^NY]","",$unworkable); + $sounds_update = ereg_replace("[^NY]","",$sounds_update); + $carrier_logging_active = ereg_replace("[^NY]","",$carrier_logging_active); + $agent_status_view_time = ereg_replace("[^NY]","",$agent_status_view_time); + $no_hopper_dialing = ereg_replace("[^NY]","",$no_hopper_dialing); + $agent_display_dialable_leads = ereg_replace("[^NY]","",$agent_display_dialable_leads); + $random = ereg_replace("[^NY]","",$random); + $rebuild_music_on_hold = ereg_replace("[^NY]","",$rebuild_music_on_hold); + $active_agent_login_server = ereg_replace("[^NY]","",$active_agent_login_server); + $agent_select_territories = ereg_replace("[^NY]","",$agent_select_territories); + $delete_vm_after_email = ereg_replace("[^NY]","",$delete_vm_after_email); + $crm_popup_login = ereg_replace("[^NY]","",$crm_popup_login); + + $qc_enabled = ereg_replace("[^0-9NY]","",$qc_enabled); + $active = ereg_replace("[^0-9NY]","",$active); + + + ### ALPHA-NUMERIC ONLY ### + $script_id = ereg_replace("[^0-9a-zA-Z]","",$script_id); + $agent_script_override = ereg_replace("[^0-9a-zA-Z]","",$agent_script_override); + $campaign_script = ereg_replace("[^0-9a-zA-Z]","",$campaign_script); + $submit = ereg_replace("[^0-9a-zA-Z]","",$submit); + $campaign_cid = ereg_replace("[^0-9a-zA-Z]","",$campaign_cid); + $get_call_launch = ereg_replace("[^0-9a-zA-Z]","",$get_call_launch); + $campaign_recording = ereg_replace("[^0-9a-zA-Z]","",$campaign_recording); + $ADD = ereg_replace("[^0-9a-zA-Z]","",$ADD); + $dial_prefix = ereg_replace("[^0-9a-zA-Z]","",$dial_prefix); + $state_call_time_state = ereg_replace("[^0-9a-zA-Z]","",$state_call_time_state); + $scheduled_callbacks = ereg_replace("[^0-9a-zA-Z]","",$scheduled_callbacks); + $concurrent_transfers = ereg_replace("[^0-9a-zA-Z]","",$concurrent_transfers); + $billable = ereg_replace("[^0-9a-zA-Z]","",$billable); + $pause_code = ereg_replace("[^0-9a-zA-Z]","",$pause_code); + $vicidial_recording_override = ereg_replace("[^0-9a-zA-Z]","",$vicidial_recording_override); + $ingroup_recording_override = ereg_replace("[^0-9a-zA-Z]","",$ingroup_recording_override); + $queuemetrics_log_id = ereg_replace("[^0-9a-zA-Z]","",$queuemetrics_log_id); + $after_hours_exten = ereg_replace("[^0-9a-zA-Z]","",$after_hours_exten); + $after_hours_voicemail = ereg_replace("[^0-9a-zA-Z]","",$after_hours_voicemail); + $qc_script = ereg_replace("[^0-9a-zA-Z]","",$qc_script); + $code = ereg_replace("[^0-9a-zA-Z]","",$code); + $survey_no_response_action = ereg_replace("[^0-9a-zA-Z]","",$survey_no_response_action); + $survey_ni_status = ereg_replace("[^0-9a-zA-Z]","",$survey_ni_status); + $qc_get_record_launch = ereg_replace("[^0-9a-zA-Z]","",$qc_get_record_launch); + $agent_pause_codes_active = ereg_replace("[^0-9a-zA-Z]","",$agent_pause_codes_active); + $three_way_dial_prefix = ereg_replace("[^0-9a-zA-Z]","",$three_way_dial_prefix); + $shift_enforcement = ereg_replace("[^0-9a-zA-Z]","",$shift_enforcement); + $agent_shift_enforcement_override = ereg_replace("[^0-9a-zA-Z]","",$agent_shift_enforcement_override); + $survey_third_status = ereg_replace("[^0-9a-zA-Z]","",$survey_third_status); + $survey_fourth_status = ereg_replace("[^0-9a-zA-Z]","",$survey_fourth_status); + $sounds_web_directory = ereg_replace("[^0-9a-zA-Z]","",$sounds_web_directory); + $disable_alter_custphone = ereg_replace("[^0-9a-zA-Z]","",$disable_alter_custphone); + $view_calls_in_queue = ereg_replace("[^0-9a-zA-Z]","",$view_calls_in_queue); + $view_calls_in_queue_launch = ereg_replace("[^0-9a-zA-Z]","",$view_calls_in_queue_launch); + $grab_calls_in_queue = ereg_replace("[^0-9a-zA-Z]","",$grab_calls_in_queue); + $call_requeue_button = ereg_replace("[^0-9a-zA-Z]","",$call_requeue_button); + $pause_after_each_call = ereg_replace("[^0-9a-zA-Z]","",$pause_after_each_call); + $use_internal_dnc = ereg_replace("[^0-9a-zA-Z]","",$use_internal_dnc); + $use_campaign_dnc = ereg_replace("[^0-9a-zA-Z]","",$use_campaign_dnc); + $voicemail_id = ereg_replace("[^0-9a-zA-Z]","",$voicemail_id); + $status_id = ereg_replace("[^0-9a-zA-Z]","",$status_id); + + ### DIGITS and Dots + $server_ip = ereg_replace("[^\.0-9]","",$server_ip); + $auto_dial_level = ereg_replace("[^\.0-9]","",$auto_dial_level); + $adaptive_maximum_level = ereg_replace("[^\.0-9]","",$adaptive_maximum_level); + $phone_ip = ereg_replace("[^\.0-9]","",$phone_ip); + $old_server_ip = ereg_replace("[^\.0-9]","",$old_server_ip); + $computer_ip = ereg_replace("[^\.0-9]","",$computer_ip); + $queuemetrics_server_ip = ereg_replace("[^\.0-9]","",$queuemetrics_server_ip); + $vtiger_server_ip = ereg_replace("[^\.0-9]","",$vtiger_server_ip); + $active_voicemail_server = ereg_replace("[^\.0-9]","",$active_voicemail_server); + $auto_dial_limit = ereg_replace("[^\.0-9]","",$auto_dial_limit); + $adaptive_dropped_percentage = ereg_replace("[^\.0-9]","",$adaptive_dropped_percentage); + $drop_lockout_time = ereg_replace("[^\.0-9]","",$drop_lockout_time); + + ### ALPHA-NUMERIC and spaces and hash and star and comma + $xferconf_a_dtmf = ereg_replace("[^ \,\*\#0-9a-zA-Z]","",$xferconf_a_dtmf); + $xferconf_b_dtmf = ereg_replace("[^ \,\*\#0-9a-zA-Z]","",$xferconf_b_dtmf); + $xferconf_c_dtmf = ereg_replace("[^ \,\*\#0-9a-zA-Z]","",$xferconf_c_dtmf); + $xferconf_d_dtmf = ereg_replace("[^ \,\*\#0-9a-zA-Z]","",$xferconf_d_dtmf); + $xferconf_e_dtmf = ereg_replace("[^ \,\*\#0-9a-zA-Z]","",$xferconf_e_dtmf); + $survey_third_digit = ereg_replace("[^ \,\*\#0-9a-zA-Z]","",$survey_third_digit); + $survey_fourth_digit = ereg_replace("[^ \,\*\#0-9a-zA-Z]","",$survey_fourth_digit); + $survey_third_exten = ereg_replace("[^ \,\*\#0-9a-zA-Z]","",$survey_third_exten); + $survey_fourth_exten = ereg_replace("[^ \,\*\#0-9a-zA-Z]","",$survey_fourth_exten); + + ### ALPHACAPS-NUMERIC + $xferconf_a_number = ereg_replace("[^0-9A-Z]","",$xferconf_a_number); + $xferconf_b_number = ereg_replace("[^0-9A-Z]","",$xferconf_b_number); + + ### ALPHA-NUMERIC and underscore and dash + $agi_output = ereg_replace("[^-_0-9a-zA-Z]","",$agi_output); + $ASTmgrSECRET = ereg_replace("[^-_0-9a-zA-Z]","",$ASTmgrSECRET); + $ASTmgrUSERNAME = ereg_replace("[^-_0-9a-zA-Z]","",$ASTmgrUSERNAME); + $ASTmgrUSERNAMElisten = ereg_replace("[^-_0-9a-zA-Z]","",$ASTmgrUSERNAMElisten); + $ASTmgrUSERNAMEsend = ereg_replace("[^-_0-9a-zA-Z]","",$ASTmgrUSERNAMEsend); + $ASTmgrUSERNAMEupdate = ereg_replace("[^-_0-9a-zA-Z]","",$ASTmgrUSERNAMEupdate); + $call_time_id = ereg_replace("[^-_0-9a-zA-Z]","",$call_time_id); + $campaign_id = ereg_replace("[^-_0-9a-zA-Z]","",$campaign_id); + $CoNfIrM = ereg_replace("[^-_0-9a-zA-Z]","",$CoNfIrM); + $DBX_database = ereg_replace("[^-_0-9a-zA-Z]","",$DBX_database); + $DBX_pass = ereg_replace("[^-_0-9a-zA-Z]","",$DBX_pass); + $DBX_user = ereg_replace("[^-_0-9a-zA-Z]","",$DBX_user); + $DBY_database = ereg_replace("[^-_0-9a-zA-Z]","",$DBY_database); + $DBY_pass = ereg_replace("[^-_0-9a-zA-Z]","",$DBY_pass); + $DBY_user = ereg_replace("[^-_0-9a-zA-Z]","",$DBY_user); + $dial_method = ereg_replace("[^-_0-9a-zA-Z]","",$dial_method); + $dial_status_a = ereg_replace("[^-_0-9a-zA-Z]","",$dial_status_a); + $dial_status_b = ereg_replace("[^-_0-9a-zA-Z]","",$dial_status_b); + $dial_status_c = ereg_replace("[^-_0-9a-zA-Z]","",$dial_status_c); + $dial_status_d = ereg_replace("[^-_0-9a-zA-Z]","",$dial_status_d); + $dial_status_e = ereg_replace("[^-_0-9a-zA-Z]","",$dial_status_e); + $ext_context = ereg_replace("[^-_0-9a-zA-Z]","",$ext_context); + $group_id = ereg_replace("[^-_0-9a-zA-Z]","",$group_id); + $lead_filter_id = ereg_replace("[^-_0-9a-zA-Z]","",$lead_filter_id); + $local_call_time = ereg_replace("[^-_0-9a-zA-Z]","",$local_call_time); + $login = ereg_replace("[^-_0-9a-zA-Z]","",$login); + $login_campaign = ereg_replace("[^-_0-9a-zA-Z]","",$login_campaign); + $login_pass = ereg_replace("[^-_0-9a-zA-Z]","",$login_pass); + $login_user = ereg_replace("[^-_0-9a-zA-Z]","",$login_user); + $next_agent_call = ereg_replace("[^-_0-9a-zA-Z]","",$next_agent_call); + $old_campaign_id = ereg_replace("[^-_0-9a-zA-Z]","",$old_campaign_id); + $old_server_id = ereg_replace("[^-_0-9a-zA-Z]","",$old_server_id); + $OLDuser_group = ereg_replace("[^-_0-9a-zA-Z]","",$OLDuser_group); + $park_file_name = ereg_replace("[^-_0-9a-zA-Z]","",$park_file_name); + $pass = ereg_replace("[^-_0-9a-zA-Z]","",$pass); + $phone_login = ereg_replace("[^-_0-9a-zA-Z]","",$phone_login); + $phone_pass = ereg_replace("[^-_0-9a-zA-Z]","",$phone_pass); + $PHP_AUTH_PW = ereg_replace("[^-_0-9a-zA-Z]","",$PHP_AUTH_PW); + $PHP_AUTH_USER = ereg_replace("[^-_0-9a-zA-Z]","",$PHP_AUTH_USER); + $protocol = ereg_replace("[^-_0-9a-zA-Z]","",$protocol); + $server_id = ereg_replace("[^-_0-9a-zA-Z]","",$server_id); + $stage = ereg_replace("[^-_0-9a-zA-Z]","",$stage); + $state_rule = ereg_replace("[^-_0-9a-zA-Z]","",$state_rule); + $trunk_restriction = ereg_replace("[^-_0-9a-zA-Z]","",$trunk_restriction); + $user = ereg_replace("[^-_0-9a-zA-Z]","",$user); + $user_group = ereg_replace("[^-_0-9a-zA-Z]","",$user_group); + $VICIDIAL_park_on_filename = ereg_replace("[^-_0-9a-zA-Z]","",$VICIDIAL_park_on_filename); + $auto_alt_dial = ereg_replace("[^-_0-9a-zA-Z]","",$auto_alt_dial); + $dial_status = ereg_replace("[^-_0-9a-zA-Z]","",$dial_status); + $queuemetrics_eq_prepend = ereg_replace("[^-_0-9a-zA-Z]","",$queuemetrics_eq_prepend); + $vicidial_agent_disable = ereg_replace("[^-_0-9a-zA-Z]","",$vicidial_agent_disable); + $alter_custdata_override = ereg_replace("[^-_0-9a-zA-Z]","",$alter_custdata_override); + $list_order_mix = ereg_replace("[^-_0-9a-zA-Z]","",$list_order_mix); + $vcl_id = ereg_replace("[^-_0-9a-zA-Z]","",$vcl_id); + $mix_method = ereg_replace("[^-_0-9a-zA-Z]","",$mix_method); + $category = ereg_replace("[^-_0-9a-zA-Z]","",$category); + $vsc_id = ereg_replace("[^-_0-9a-zA-Z]","",$vsc_id); + $moh_context = ereg_replace("[^-_0-9a-zA-Z]","",$moh_context); + $source_campaign_id = ereg_replace("[^-_0-9a-zA-Z]","",$source_campaign_id); + $source_user_id = ereg_replace("[^-_0-9a-zA-Z]","",$source_user_id); + $source_group_id = ereg_replace("[^-_0-9a-zA-Z]","",$source_group_id); + $default_xfer_group = ereg_replace("[^-_0-9a-zA-Z]","",$default_xfer_group); + $drop_exten = ereg_replace("[^-_0-9a-zA-Z]","",$drop_exten); + $safe_harbor_exten = ereg_replace("[^-_0-9a-zA-Z]","",$safe_harbor_exten); + $drop_action = ereg_replace("[^-_0-9a-zA-Z]","",$drop_action); + $drop_inbound_group = ereg_replace("[^-_0-9a-zA-Z]","",$drop_inbound_group); + $afterhours_xfer_group = ereg_replace("[^-_0-9a-zA-Z]","",$afterhours_xfer_group); + $after_hours_action = ereg_replace("[^-_0-9a-zA-Z]","",$after_hours_action); + $alias_id = ereg_replace("[^-_0-9a-zA-Z]","",$alias_id); + $shift_id = ereg_replace("[^-_0-9a-zA-Z]","",$shift_id); + $qc_shift_id = ereg_replace("[^-_0-9a-zA-Z]","",$qc_shift_id); + $survey_first_audio_file = ereg_replace("[^-_0-9a-zA-Z]","",$survey_first_audio_file); + $survey_opt_in_audio_file = ereg_replace("[^-_0-9a-zA-Z]","",$survey_opt_in_audio_file); + $survey_ni_audio_file = ereg_replace("[^-_0-9a-zA-Z]","",$survey_ni_audio_file); + $survey_method = ereg_replace("[^-_0-9a-zA-Z]","",$survey_method); + $alter_custphone_override = ereg_replace("[^-_0-9a-zA-Z]","",$alter_custphone_override); + $manual_dial_filter = ereg_replace("[^-_0-9a-zA-Z]","",$manual_dial_filter); + $agent_clipboard_copy = ereg_replace("[^-_0-9a-zA-Z]","",$agent_clipboard_copy); + $hold_time_option = ereg_replace("[^-_0-9a-zA-Z]","",$hold_time_option); + $hold_time_option_xfer_group = ereg_replace("[^-_0-9a-zA-Z]","",$hold_time_option_xfer_group); + $hold_recall_xfer_group = ereg_replace("[^-_0-9a-zA-Z]","",$hold_recall_xfer_group); + $play_welcome_message = ereg_replace("[^-_0-9a-zA-Z]","",$play_welcome_message); + $did_route = ereg_replace("[^-_0-9a-zA-Z]","",$did_route); + $user_unavailable_action = ereg_replace("[^-_0-9a-zA-Z]","",$user_unavailable_action); + $user_route_settings_ingroup = ereg_replace("[^-_0-9a-zA-Z]","",$user_route_settings_ingroup); + $call_handle_method = ereg_replace("[^-_0-9a-zA-Z]","",$call_handle_method); + $agent_search_method = ereg_replace("[^-_0-9a-zA-Z]","",$agent_search_method); + $hold_time_option_voicemail = ereg_replace("[^-_0-9a-zA-Z]","",$hold_time_option_voicemail); + $exten_context = ereg_replace("[^-_0-9a-zA-Z]","",$exten_context); + $three_way_call_cid = ereg_replace("[^-_0-9a-zA-Z]","",$three_way_call_cid); + $web_form_target = ereg_replace("[^-_0-9a-zA-Z]","",$web_form_target); + $recording_web_link = ereg_replace("[^-_0-9a-zA-Z]","",$recording_web_link); + $vtiger_search_category = ereg_replace("[^-_0-9a-zA-Z]","",$vtiger_search_category); + $vtiger_create_call_record = ereg_replace("[^-_0-9a-zA-Z]","",$vtiger_create_call_record); + $vtiger_create_lead_record = ereg_replace("[^-_0-9a-zA-Z]","",$vtiger_create_lead_record); + $vtiger_screen_login = ereg_replace("[^-_0-9a-zA-Z]","",$vtiger_screen_login); + $cpd_amd_action = ereg_replace("[^-_0-9a-zA-Z]","",$cpd_amd_action); + $template_id = ereg_replace("[^-_0-9a-zA-Z]","",$template_id); + $carrier_id = ereg_replace("[^-_0-9a-zA-Z]","",$carrier_id); + $group_alias_id = ereg_replace("[^-_0-9a-zA-Z]","",$group_alias_id); + $default_group_alias = ereg_replace("[^-_0-9a-zA-Z]","",$default_group_alias); + $vtiger_search_dead = ereg_replace("[^-_0-9a-zA-Z]","",$vtiger_search_dead); + $survey_third_audio_file = ereg_replace("[^-_0-9a-zA-Z]","",$survey_third_audio_file); + $survey_fourth_audio_file = ereg_replace("[^-_0-9a-zA-Z]","",$survey_fourth_audio_file); + $menu_id = ereg_replace("[^-_0-9a-zA-Z]","",$menu_id); + $source_menu = ereg_replace("[^-_0-9a-zA-Z]","",$source_menu); + $call_time_id = ereg_replace("[^-_0-9a-zA-Z]","",$call_time_id); + $phone_context = ereg_replace("[^-_0-9a-zA-Z]","",$phone_context); + $conf_secret = ereg_replace("[^-_0-9a-zA-Z]","",$conf_secret); + $tracking_group = ereg_replace("[^-_0-9a-zA-Z]","",$tracking_group); + $no_agent_no_queue = ereg_replace("[^-_0-9a-zA-Z]","",$no_agent_no_queue); + $no_agent_action = ereg_replace("[^-_0-9a-zA-Z]","",$no_agent_action); + $quick_transfer_button = ereg_replace("[^-_0-9a-zA-Z]","",$quick_transfer_button); + $prepopulate_transfer_preset = ereg_replace("[^-_0-9a-zA-Z]","",$prepopulate_transfer_preset); + $tts_id = ereg_replace("[^-_0-9a-zA-Z]","",$tts_id); + $drop_rate_group = ereg_replace("[^-_0-9a-zA-Z]","",$drop_rate_group); + $agent_dial_owner_only = ereg_replace("[^-_0-9a-zA-Z]","",$agent_dial_owner_only); + $reset_time = ereg_replace("[^-_0-9a-zA-Z]","",$reset_time); + $moh_id = ereg_replace("[^-_0-9a-zA-Z]","",$moh_id); + $drop_inbound_group_override = ereg_replace("[^-_0-9a-zA-Z]","",$drop_inbound_group_override); + $timer_action = ereg_replace("[^-_0-9a-zA-Z]","",$timer_action); + + ### ALPHA-NUMERIC and underscore and dash and slash and dot + $menu_prompt = ereg_replace("[^-\/\|\._0-9a-zA-Z]","",$menu_prompt); + $menu_timeout_prompt = ereg_replace("[^-\/\|\._0-9a-zA-Z]","",$menu_timeout_prompt); + $menu_invalid_prompt = ereg_replace("[^-\/\|\._0-9a-zA-Z]","",$menu_invalid_prompt); + $after_hours_message_filename = ereg_replace("[^-\/\|\._0-9a-zA-Z]","",$after_hours_message_filename); + $welcome_message_filename = ereg_replace("[^-\/\|\._0-9a-zA-Z]","",$welcome_message_filename); + $onhold_prompt_filename = ereg_replace("[^-\/\|\._0-9a-zA-Z]","",$onhold_prompt_filename); + $hold_time_option_callback_filename = ereg_replace("[^-\/\|\._0-9a-zA-Z]","",$hold_time_option_callback_filename); + $agent_alert_exten = ereg_replace("[^-\|\/\._0-9a-zA-Z]","",$agent_alert_exten); + $filename = ereg_replace("[^-\/\._0-9a-zA-Z]","",$filename); + $am_message_exten = ereg_replace("[^-\|\/\._0-9a-zA-Z]","",$am_message_exten); + $am_message_exten_override = ereg_replace("[^-\|\/\._0-9a-zA-Z]","",$am_message_exten_override); + + ### ALPHA-NUMERIC and underscore and dash and comma + $logins_list = ereg_replace("[^-\,\_0-9a-zA-Z]","",$logins_list); + $forced_timeclock_login = ereg_replace("[^-\,\_0-9a-zA-Z]","",$forced_timeclock_login); + + ### ALPHA-NUMERIC and dots + $sounds_web_server = ereg_replace("[^\.0-9a-zA-Z]","",$sounds_web_server); + ### ALPHA-NUMERIC and spaces + $lead_order = ereg_replace("[^ 0-9a-zA-Z]","",$lead_order); + ### ALPHA-NUMERIC and hash + $group_color = ereg_replace("[^\#0-9a-zA-Z]","",$group_color); + ### ALPHA-NUMERIC and hash and star and dot and underscore + $hold_time_option_exten = ereg_replace("[^\*\#\.\_0-9a-zA-Z]","",$hold_time_option_exten); + $did_pattern = ereg_replace("[^\*\#\.\_0-9a-zA-Z]","",$did_pattern); + $voicemail_ext = ereg_replace("[^\*\#\.\_0-9a-zA-Z]","",$voicemail_ext); + $phone = ereg_replace("[^\*\#\.\_0-9a-zA-Z]","",$phone); + $phone_code = ereg_replace("[^\*\#\.\_0-9a-zA-Z]","",$phone_code); + + ### ALPHA-NUMERIC and spaces dots, commas, dashes, underscores + $adaptive_dl_diff_target = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$adaptive_dl_diff_target); + $adaptive_intensity = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$adaptive_intensity); + $asterisk_version = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$asterisk_version); + $call_time_comments = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$call_time_comments); + $call_time_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$call_time_name); + $campaign_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$campaign_name); + $campaign_rec_filename = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$campaign_rec_filename); + $ingroup_rec_filename = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$ingroup_rec_filename); + $company = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$company); + $full_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$full_name); + $fullname = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$fullname); + $group_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$group_name); + $HKstatus = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$HKstatus); + $lead_filter_comments = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$lead_filter_comments); + $lead_filter_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$lead_filter_name); + $list_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$list_name); + $local_gmt = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$local_gmt); + $phone_type = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$phone_type); + $picture = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$picture); + $script_comments = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$script_comments); + $script_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$script_name); + $server_description = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$server_description); + $status = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$status); + $status_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$status_name); + $wrapup_message = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$wrapup_message); + $pause_code_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$pause_code_name); + $campaign_description = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$campaign_description); + $list_description = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$list_description); + $vcl_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$vcl_name); + $vsc_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$vsc_name); + $vsc_description = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$vsc_description); + $code_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$code_name); + $alias_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$alias_name); + $shift_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$shift_name); + $did_description = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$did_description); + $alt_server_ip = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$alt_server_ip); + $template_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$template_name); + $carrier_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$carrier_name); + $group_alias_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$group_alias_name); + $caller_id_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$caller_id_name); + $user_code = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$user_code); + $territory = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$territory); + $tts_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$tts_name); + $moh_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$moh_name); + $timer_action_message = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$timer_action_message); + + ### ALPHA-NUMERIC and underscore and dash and slash and at and dot + $call_out_number_group = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$call_out_number_group); + $client_browser = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$client_browser); + $DBX_server = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$DBX_server); + $DBY_server = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$DBY_server); + $dtmf_send_extension = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$dtmf_send_extension); + $extension = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$extension); + $install_directory = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$install_directory); + $old_extension = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$old_extension); + $telnet_host = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$telnet_host); + $queuemetrics_dbname = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$queuemetrics_dbname); + $queuemetrics_login = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$queuemetrics_login); + $queuemetrics_pass = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$queuemetrics_pass); + $email = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$email); + $vtiger_dbname = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$vtiger_dbname); + $vtiger_login = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$vtiger_login); + $vtiger_pass = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$vtiger_pass); + $custom_one = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$custom_one); + $custom_two = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$custom_two); + $custom_three = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$custom_three); + $custom_four = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$custom_four); + $custom_five = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$custom_five); + + ### NUMERIC and comma and pipe + $waitforsilence_options = ereg_replace("[^\|\,0-9]","",$waitforsilence_options); + + ### value cleaning + $no_agent_action_value = ereg_replace("[^-\/\|\_\#\*\,\.\_0-9a-zA-Z]","",$no_agent_action_value); + + ### ALPHA-NUMERIC and underscore and dash and slash and at and space and colon + $vdc_header_date_format = ereg_replace("[^- \:\/\_0-9a-zA-Z]","",$vdc_header_date_format); + $vdc_customer_date_format = ereg_replace("[^- \:\/\_0-9a-zA-Z]","",$vdc_customer_date_format); + $menu_name = ereg_replace("[^- \:\/\_0-9a-zA-Z]","",$menu_name); + + ### ALPHA-NUMERIC and underscore and dash and at and space and parantheses + $vdc_header_phone_format = ereg_replace("[^- \(\)\_0-9a-zA-Z]","",$vdc_header_phone_format); + + ### remove semi-colons ### + $lead_filter_sql = ereg_replace(";","",$lead_filter_sql); + $list_mix_container = ereg_replace(";","",$list_mix_container); + $survey_response_digit_map = ereg_replace(";","",$survey_response_digit_map); + $survey_camp_record_dir = ereg_replace(";","",$survey_camp_record_dir); + $conf_override = ereg_replace(";","",$conf_override); + $template_contents = ereg_replace(";","",$template_contents); + $registration_string = ereg_replace(";","",$registration_string); + $account_entry = ereg_replace(";","",$account_entry); + $account_entry = ereg_replace("\r","",$account_entry); + $globals_string = ereg_replace(";","",$globals_string); + $dialplan_entry = ereg_replace(";","",$dialplan_entry); + $dialplan_entry = ereg_replace("\r","",$dialplan_entry); + $custom_dialplan_entry = ereg_replace("\\\\","",$custom_dialplan_entry); + $custom_dialplan_entry = ereg_replace(";","",$custom_dialplan_entry); + $custom_dialplan_entry = ereg_replace("\r","",$custom_dialplan_entry); + $tts_text = ereg_replace("\\\\","",$tts_text); + $tts_text = ereg_replace(";","",$tts_text); + $tts_text = ereg_replace("\r","",$tts_text); + $tts_text = ereg_replace("\"","",$tts_text); + $carrier_description = ereg_replace("\\\\","",$carrier_description); + $carrier_description = ereg_replace(";","",$carrier_description); + $carrier_description = ereg_replace("\r","",$carrier_description); + $carrier_description = ereg_replace("\"","",$carrier_description); + + + ### VARIABLES TO BE mysql_real_escape_string ### + # $web_form_address + # $queuemetrics_url + # $admin_home_url + # $qc_web_form_address + # $vtiger_url + # $web_form_address_two + # $crm_login_address + # $start_call_url + # $dispo_call_url + + ### VARIABLES not filtered at all ### + # $script_text + + } # end of non_latin +else + { + $PHP_AUTH_PW = ereg_replace("'|\"|\\\\|;","",$PHP_AUTH_PW); + $PHP_AUTH_USER = ereg_replace("'|\"|\\\\|;","",$PHP_AUTH_USER); + } + + + +##### END VARIABLE FILTERING FOR SECURITY ##### + + +# ViciDial database administration +# admin.php +# +# CHANGELOG: +# 50315-1110 - Added Custom Campaign Statuses +# 50317-1438 - Added Fronter Display var to inbound groups +# 50322-1355 - Added custom callerID per campaign +# 50517-1356 - Added user_groups sections and user_group to vicidial_users +# 50517-1440 - Added ability to logout (must click OK with empty user/pass) +# 50602-1622 - Added lead loader pages to load new files into vicidial_list +# 50620-1351 - Added custom vdad transfer AGI extension per campaign +# 50810-1414 - modified in groups to kick out spaces and dashes +# 50908-2136 - Added Custom Campaign HotKeys +# 50914-0950 - Fixed user search by user_group +# 50926-1358 - Modified to allow for language translation +# 50926-1615 - Added WeBRooTWritablE write controls +# 51020-1008 - Added editable web address and park ext - NEW dial campaigns +# 51020-1056 - Added fields and help for campaign recording control +# 51123-1335 - Altered code to function in php globals=off +# 51208-1038 - Added user_level changes, function controls and default user phones +# 51208-1556 - Added deletion of users/lists/campaigns/in groups/remote agents +# 51213-1706 - Added add/delete/modify vicidial scripts +# 51214-1737 - Added preview of vicidial script in popup window +# 51219-1225 - Added campaign and ingroups script selector and get_call_launch field +# 51222-1055 - Added am_message_exten to campaigns to allow for AM Message button +# 51222-1125 - Fixed new vicidial_campaigns default values not being assigned bug +# 51222-1156 - Added LOG OUT ALL AGENTS ON THIS CAMPAIGN button to campaign screen +# 60204-0659 - Fixed hopper reset bug +# 60207-1413 - Added AMD send to voicemail extension and xfer-conf dtmf presets +# 60213-1100 - Added several vicidial_users permissions fields +# 60215-1319 - Added On-hold CallBacks display and links +# 60227-1226 - Fixed vicidial_inbound_groups insert bug +# 60413-1308 - Fixed list display to have 1 row/status: count and time zone tables +# - Added status name in selected dial statuses in campaign screen +# 60417-1416 - Added vicidial_lead_filters sections +# - Changed the header links to color-coded sectional with sublinks below +# - Added filter name and script name to campaign and in-group modify sections +# - Added callback and alt dial options to campaigns section +# - Added callback, alt dial and other options to users section +# 60419-1628 - Alter Callbacks display to include status and LIVE listings, reordered +# 60421-1441 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60425-2355 - Added agent options to vicidial_users, reformatted user page +# 60502-1627 - Added drop_call_seconds and safe_harbor_ fields to campaign screen +# 60503-1228 - Added drop_call_seconds and drop_ fields to inbound groups screen +# 60505-1117 - Added initial framework for new local_call_times tables and definitions +# 60506-1033 - More revisions to the local_call_time section +# 60508-1354 - Finished call_times and state_call_times sections +# - Added modify/delete options for call_times +# 60509-1311 - Functionalize campaign dialable leads calculation +# - Change state_call_times selection from call_times to only allow one per state +# - Added dialable leads count popup to campaign screen if auto-calc is disabled +# - Added test dialable leads count popup to filter screen +# 60510-1050 - Added Wrapup seconds and Wrapup message to campaigns screen +# 60608-1401 - Added allowable inbound_groups checkboxes to CLOSER campaign detail screen +# 60609-1051 - Added add-to-dnc in LISTS section +# 60613-1415 - Added lead recycling options to campaign detail screen +# 60619-1523 - Added variable filtering to eliminate SQL injection attack threat +# 60622-1216 - Fixed HotKey addition form issues and variable filtering +# 60623-1159 - Fixed Scheduled Callbacks over-filtering bug and filter_sql bug +# 60808-1147 - Changed filtering for and added instructions for consutative transfers +# 60816-1552 - Added allcalls_delay start delay for recordings in vicidial.php +# 60817-2226 - Fixed bug that would not allow lead recycling of non-selectable statuses +# 60821-1543 - Added option to Omit Phone Code while dialing in vicidial +# 60821-1625 - Added ALLFORCE recording option for campaign_recording +# 60823-1154 - Added fields for adaptive dialing +# 60824-1326 - Added adaptive_latest_target_gmt for ADAPT_TAPERED dial method +# 60825-1205 - Added adaptive_intensity for ADAPT_ dial methods +# 60828-1019 - Changed adaptive_latest_target_gmt to adaptive_latest_server_time +# 60828-1115 - Added adaptive_dl_diff_target and changed intensity dropdown +# 60927-1246 - Added astguiclient/admin.php functions under SERVERS tab +# 61002-1402 - Added fields for vicidial balance trunk controls +# 61003-1123 - Added functions for vicidial_server_trunks records +# 61109-1022 - Added Emergency VDAC Jam Clear function to Campaign Detail screen +# 61110-1502 - Add ability to select NONE in dial statuses, new list_id must not be < 100 +# 61122-1228 - Added user group campaign restrictions +# 61122-1535 - Changed script_text to unfiltered and added more variables to SCRIPTS +# 61129-1028 - Added headers to Users and Phones with clickable order-by titles +# 70108-1405 - Added ADAPT OVERRIDE to allow for forced dial_level changes in ADAPT dial methods +# - Screen width definable at top of script, merged server_stats into this script +# 70109-1638 - Added ALTPH2 and ADDR3 hotkey options for alt number dialing with HotKeys +# 70109-1716 - Added concurrent_transfers option to vicidial_campaigns +# 70115-1152 - Aded (CLOSER|BLEND|INBND|_C$|_B$|_I$) options for CLOSER-type campaigns +# 70115-1532 - Added auto_alt_dial field to campaign screen for auto-dialing of alt numbers +# 70116-1200 - Added auto_alt_dial_status functionality to campaign screen +# 70117-1235 - Added header formatting variables at top of script +# - Moved Call Times and Phones/Server functions to Admin section +# 70118-1706 - Added new user group displays and links +# 70123-1519 - Added user permission settings for all sections +# 70124-1346 - Fixed spelling errors and formatting consistency +# 70202-1120 - Added agent_pause_codes section to campaigns +# 70205-1204 - Added memo, last dialed, timestamp and stats-refresh fields to vicidial_campaigns/lists +# 70206-1323 - Added user setting for vicidial_recording_override +# 70212-1412 - Added system settings section +# 70214-1226 - Added QueueMetrics Log ID field to system settings section +# 70219-1102 - Changed campaign dial statuses to be one string allowing for high limit +# 70223-0957 - Added queuemetrics_eq_prepend for custom ENTERQUEUE prepending of a field +# 70302-1111 - Fixed small bug in dialable leads calculation +# 70314-1133 - Added insert selection on script forms +# 70319-1423 - Added Alter Customer Data and agent disable display functions +# 70319-1625 - Added option to allow agents to login to outbound campaigns with no leads in the hopper +# 70322-1455 - Added sipsak messages parameters +# 70402-1157 - Added HOME link and entry to system_settings table, added QM link on reports section +# 70516-1628 - Started reformatting campaigns to use submenus to break up options +# 70529-1653 - Added help for list mix +# 70530-1354 - Added human_answered field to statuses, added system status modification +# 70530-1714 - Added lists for all campaign subsections +# 70531-1631 - Development on List mix admin interface +# 70601-1629 - More development on List mix admin interface, formatting, and added some javascript +# 70602-1300 - More development on List mix admin interface, more javascript +# 70608-1459 - Added option to set LIVE Callbacks to INACTIVE after one month +# 70612-1451 - Added Callback INACTIVE link for after one week, sort by user/group/entrydate +# 70614-0231 - Added Status Categories, ability to Modify Statuses, moved system statuses to sub-section +# 70623-1008 - List Mix section now allows modification of list mix entries +# 70629-1721 - List Mix section adding and removing of list entries active +# 70706-1636 - List Mix section cleanup and more error-checking +# 70908-0941 - Added agc logile enable system_settings +# 71020-1934 - Added inbound groups options: on-hold music, messages, call_times +# 71022-1343 - Added inbound group ranks for users +# 71029-1710 - Added option for campaign to be inbound and/or blended with no restrictions on the campaign_id name +# - Added 5th NEW and 6th NEW to the dial order options +# 71030-2010 - Added Manual Dial List ID field to campaigns table +# 71103-2207 - Added inbound_group_rank and fewest_calls to the inbound groups call order options +# 71113-1521 - Added campaign_rank to agent options +# - Added ability to Copy a campaign's setting to a new campaign +# 71113-2225 - Added ability to copy user and in-group settings to new users and in-groups +# 71116-0942 - Added campaign_rank and fewest_calls as methods for agent call routing +# 71122-1135 - Added default transfer group for campaigns and inbound groups +# 71125-1751 - Added allowable transfer groups to campaign detail screen +# 80107-1204 - Started framework for new QC section +# 80112-0242 - Added more options for lead order +# 80211-1901 - Added DB Schema Version to system settings display +# 80224-1334 - Added Queue Priority to in-groups and campaigns +# 80302-0232 - added drop_action and transfer to in-group for both in-groups and outbound +# 80310-1504 - added QC settings section to campaign screen +# 80317-2037 - Added Recording override settings to in-groups +# 80414-1505 - More work on QC, added vicidial_qc_codes +# 80424-0442 - Added non_latin system_settings lookup at top to override dbconnect setting +# 80505-0333 - Added phones_alias sections to allow for load-balanced-phone-logins +# 80512-1529 - Added auto-generate of User ID feature +# 80515-1345 - Added Shifts sub-section to Admin section +# 80528-0001 - Added campaign survey sub-section +# 80528-1102 - Added user timeclock edit options +# 80608-1304 - Changed add-to-DNC to allow for multiple entries per submission +# 80625-0032 - Added time/phone display format options to system settings +# 80703-0124 - Added alter cust phone and api settings +# 80715-1130 - Added Recycle leads limit count +# 80719-1351 - Changed QC settings in campaigns and In-Groups +# 80809-2305 - Added Sale and Dead Lead categories to status categories page +# 80815-1036 - Added manual dial filter to capaigns +# 80823-2124 - Added copy to clipboard campaign option +# 80829-2359 - Added EXTENDED auto_alt_dial options +# 80831-0406 - Added agent screen extended alt-dial option to campaigns +# 80909-0553 - Added campaign-specific DNC list option and add +# 81002-1101 - Added more in-group options and new DID section and user options +# 81007-0936 - Added three_way_call_cid option to campaigns +# 81012-1725 - Added INBOUND_MAN dial method allowing for manual list dialing with inbound calls +# 81030-0348 - Added campaign pause code force option +# 81030-2228 - Fixed DIDs creation issue +# 81103-1408 - Added 3way call dial prefix option +# 81107-1551 - Added Stats Percent of Calls Answered Within X seconds fields to in-groups +# 81118-0933 - Changed lists listing with links and more options +# 81119-0715 - Added ability to bulk enable/disable lists from modify campaign screen +# 81209-1538 - Added web_form_target to campaign screen +# 81210-1430 - Added http server IP and recording link options to servers +# 81222-0500 - Reformatted all listings to same format changed to field selects instead of * +# 81228-2300 - Added fields for vtiger integration and active vicidial_user display +# 90101-1216 - Added options for user synchronization with vtiger +# 90112-0335 - Added vtiger_create_lead_record and vtiger_create_lead_record options +# 90115-0502 - Activated AGENT DID routing option +# 90126-2256 - Added vtiger_screen_login campaign option and user agent alert option +# 90201-1503 - Added option to disable the viewing of inactive QC features +# 90202-0112 - Added option to disable outbound autodialing(or list dialing) +# 90202-0444 - Added cpd_amd_action option for processing of AMD messages +# 90209-1339 - Added download_lists option to allow downloading of lists +# 90210-1042 - Added options for auto-generation of asterisk conf files +# 90301-2026 - Added Vtiger group synchronization +# 90302-2046 - Changed Section heading to be on the left side of the screen +# 90303-0631 - Added web vars to agent campaign and in-group settings +# 90303-2047 - Added group aliases and default group aliases +# 90306-1214 - Added shift enforcement and server/system calls per second options +# 90308-0956 - Added server statistics +# 90309-0059 - Changed logging to admin_server_log +# 90310-2203 - Added export_reports option for call activity report data exports +# 90315-1010 - Changed revision for new trunk 2.2.0 +# 90320-0424 - Fixed several small bugs conf records group alias and permissions +# 90322-0122 - Added ability to delete from the DNC lists +# 90322-1105 - Added new status settings and vtiger options +# 90409-2133 - Fixed special characters in SCRIPTS +# 90413-0755 - Fixed filter and script slashes issues +# 90417-0211 - Fixed filter and script slashes issues +# 90422-0613 - Added user_code, territory and email to vicidial_users +# 90429-0542 - Added 3rd&4th options to SURVEY campaigns +# 90430-0154 - Added RANDOM and LAST CALL TIME options to lead order for campaigns +# 90504-0901 - Added Call Menu feature, changed script to use long PHP tags +# 90511-0910 - Added agentonly_callback_campaign_lock to system_settings +# 90512-0440 - Added sounds settings to system_settings table +# 90514-0607 - Added select prompts from list in call menu and in-group screens +# 90521-0029 - Added user territories enable option +# 90522-0506 - Security fix for logins when using non-latin setting +# 90524-2307 - Changed Reports screen layout +# 90528-2055 - Added ViciDial recording limit field in servers and phone_context to phones +# 90530-1206 - Changed List Mix to allow for 40 mixes +# 90531-1802 - Added auto-generated options for users, campaigns, in-groups, etc..., added option to HIDE custphone +# 90531-2339 - Added Dynamic options for Call Menu +# 90605-0248 - Added carrier_logging_active servers option +# 90607-1716 - Changed drop percent limit to allow for 0.1 steps under 3% +# 90608-0944 - Added Drop Lockout Time feature to Campaign Detail Modification screen +# 90612-0909 - Added audio prompt selection feature to survey screen +# 90614-0827 - Added In-Group routing to Call Menu screen, Added pull-down Call Menu option to DID screen +# 90617-0733 - Added phone ring timeout and call menu custom dialplan entries +# 90621-0821 - Added phone Conf File Secret field to use a separate password from the user interface for a phone +# 90621-1220 - Added Call Menu logging tracking_group +# 90627-0547 - Added no-agent-no-queue options +# 90627-2333 - Added default transfer button and prepopulate preset options +# 90628-0924 - Added Text To Speech(TTS) fields +# 90628-2213 - Added Multi-campaign drop rate groups +# 90705-0926 - Added User Group agent view options +# 90710-1528 - Added Agent view and grab queue calls and every call pause options +# 90717-0646 - Added dialed_label and dialed_number to script variables +# 90721-1350 - Added RANK and OWNER as list order options and list screen display tables +# 90722-1235 - Added list reset time and campaign no hopper dialing, agent dial owner only options +# 90726-0153 - Added allow_alerts for users to disable agent browser alerts +# 90729-0555 - Added agent_display_dialable_leads and vicidial_balance_rank options +# 90808-0300 - Added longest_wait_time option for agent call routing +# 90827-1552 - Added agent_script_override option for lists +# 90830-2217 - Added Music On Hold section +# 90904-1536 - Added moh chooser option, timezone list ordering +# 90908-1207 - Added cross-listing linking for DIDs, CallMenus and In-groups +# 90916-1105 - Added second web form to ingroups and campaigns and added audio choose for answering machine message and waitforsilence_options +# 90917-1108 - Added Extra Voicemail boxes config in Admin section +# 90919-2251 - Removed all SELECT STAR instances in the code, code cleanup to conform to standard +# 90924-1645 - Added list_id overrides for cid, am_message and drop in-group +# 90930-2107 - Added agent territory selection options for ViciDial agents +# 91026-1050 - Added AREACODE DNC option for campaigns +# 91031-1232 - Added carrier_description field, campaigns links from in-group screen, server links on reports page, agent ranks listing active only +# 91121-0334 - Limited list called count display to 100+ +# 91125-0628 - Added conf_secret for servers +# 91204-1652 - Added recording_filename and recording_id as script variables +# 91205-2231 - Added delete_vm_after_email voicemail option to phones and extra voicemail sections +# 91210-2038 - Added better logging of Campaign emergency logout +# 91211-1359 - Added custom user fields and campaign CRM login fields +# 91219-0719 - Changed some field backgrounds in the Campaign Modification screens +# 91223-1031 - Added VIDPROMPT options for in-group routing in DIDs +# 91228-1837 - Added timer action settings to in-groups and campaigns +# 100103-0727 - Added Start/Dispo call url, 3/4/5 conf number presets, Lists conf-number overrides +# 100104-1454 - Fixed in-group/campaign copy duplication issue +# 100116-0718 - Added presets to script select list +# 100319-1708 - Changed user/pass for users to 20 characters in length, highlighted conf file secret in phones +# 100413-2328 - several small fixes, logging, removal of old SIP/IAX monitor/barge links +# +# make sure you have added a user to the vicidial_users MySQL table with at least user_level 8 to access this page the first time + +$admin_version = '2.2.0-236'; +$build = '100413-2328'; + +$STARTtime = date("U"); +$SQLdate = date("Y-m-d H:i:s"); +$REPORTdate = date("Y-m-d"); +$MT[0]=''; +$US='_'; +$active_lists=0; +$inactive_lists=0; + +$month_old = mktime(0, 0, 0, date("m")-1, date("d"), date("Y")); +$past_month_date = date("Y-m-d H:i:s",$month_old); +$week_old = mktime(0, 0, 0, date("m"), date("d")-7, date("Y")); +$past_week_date = date("Y-m-d H:i:s",$week_old); + +$dtmf[0]='0'; $dtmf_key[0]='0'; +$dtmf[1]='1'; $dtmf_key[1]='1'; +$dtmf[2]='2'; $dtmf_key[2]='2'; +$dtmf[3]='3'; $dtmf_key[3]='3'; +$dtmf[4]='4'; $dtmf_key[4]='4'; +$dtmf[5]='5'; $dtmf_key[5]='5'; +$dtmf[6]='6'; $dtmf_key[6]='6'; +$dtmf[7]='7'; $dtmf_key[7]='7'; +$dtmf[8]='8'; $dtmf_key[8]='8'; +$dtmf[9]='9'; $dtmf_key[9]='9'; +$dtmf[10]='HASH'; $dtmf_key[10]='#'; +$dtmf[11]='STAR'; $dtmf_key[11]='*'; +$dtmf[12]='A'; $dtmf_key[12]='A'; +$dtmf[13]='B'; $dtmf_key[13]='B'; +$dtmf[14]='C'; $dtmf_key[14]='C'; +$dtmf[15]='D'; $dtmf_key[15]='D'; +$dtmf[16]='TIMECHECK'; $dtmf_key[16]='TIMECHECK'; +$dtmf[17]='TIMEOUT'; $dtmf_key[17]='TIMEOUT'; +$dtmf[18]='INVALID'; $dtmf_key[18]='INVALID'; + +if ($force_logout) + { + if( (strlen($PHP_AUTH_USER)>0) or (strlen($PHP_AUTH_PW)>0) ) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + } + echo "Voce efetuou logout. Obrigado\n"; + exit; + } + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin,auto_dial_limit,user_territories_active,allow_custom_dialplan FROM system_settings;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$qm_conf_ct = mysql_num_rows($rslt); +if ($qm_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $non_latin = $row[0]; + $SSauto_dial_limit = $row[1]; + $SSuser_territories_active = $row[2]; + $SSallow_custom_dialplan = $row[3]; + } +##### END SETTINGS LOOKUP ##### +########################################### + +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7 and active='Y';"; +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 ($WeBRooTWritablE > 0) + {$fp = fopen ("./project_auth_entries.txt", "a");} + +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + +if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or ($auth<1)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Nome ou Senha inválidos: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } +else + { + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT user_id,user,pass,full_name,user_level,user_group,phone_login,phone_pass,delete_users,delete_user_groups,delete_lists,delete_campaigns,delete_ingroups,delete_remote_agents,load_leads,campaign_detail,ast_admin_access,ast_delete_phones,delete_scripts,modify_leads,hotkeys_active,change_agent_campaign,agent_choose_ingroups,closer_campaigns,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,delete_filters,alter_agent_interface_options,closer_default_blended,delete_call_times,modify_call_times,modify_users,modify_campaigns,modify_lists,modify_scripts,modify_filters,modify_ingroups,modify_usergroups,modify_remoteagents,modify_servers,view_reports,vicidial_recording_override,alter_custdata_override,qc_enabled,qc_user_level,qc_pass,qc_finish,qc_commit,add_timeclock_log,modify_timeclock_log,delete_timeclock_log,alter_custphone_override,vdc_agent_api_access,modify_inbound_dids,delete_inbound_dids,active,alert_enabled,download_lists,agent_shift_enforcement_override,manager_shift_enforcement_override,shift_override_flag,export_reports,delete_from_dnc,email,user_code,territory,allow_alerts from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfull_name =$row[3]; + $LOGuser_level =$row[4]; + $LOGuser_group =$row[5]; + $LOGdelete_users =$row[8]; + $LOGdelete_user_groups =$row[9]; + $LOGdelete_lists =$row[10]; + $LOGdelete_campaigns =$row[11]; + $LOGdelete_ingroups =$row[12]; + $LOGdelete_remote_agents =$row[13]; + $LOGload_leads =$row[14]; + $LOGcampaign_detail =$row[15]; + $LOGast_admin_access =$row[16]; + $LOGast_delete_phones =$row[17]; + $LOGdelete_scripts =$row[18]; + $LOGdelete_filters =$row[29]; + $LOGalter_agent_interface =$row[30]; + $LOGdelete_call_times =$row[32]; + $LOGmodify_call_times =$row[33]; + $LOGmodify_users =$row[34]; + $LOGmodify_campaigns =$row[35]; + $LOGmodify_lists =$row[36]; + $LOGmodify_scripts =$row[37]; + $LOGmodify_filters =$row[38]; + $LOGmodify_ingroups =$row[39]; + $LOGmodify_usergroups =$row[40]; + $LOGmodify_remoteagents =$row[41]; + $LOGmodify_servers =$row[42]; + $LOGview_reports =$row[43]; + $LOGmodify_dids =$row[56]; + $LOGdelete_dids =$row[57]; + $LOGmanager_shift_enforcement_override=$row[61]; + $LOGexport_reports =$row[64]; + $LOGdelete_from_dnc =$row[65]; + + $stmt="SELECT allowed_campaigns from vicidial_user_groups where user_group='$LOGuser_group';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGallowed_campaigns = $row[0]; + + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|XXXX|$ip|$browser|$LOGfull_name|\n"); + fclose($fp); + } + } + else + { + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + } + +###################################################################################################### +###################################################################################################### +####### Header settings +###################################################################################################### +###################################################################################################### + + +header ("Content-type: text/html; charset=utf-8"); +echo "\n"; +echo "\n"; +echo "\n"; +echo "ADMINISTRATION: "; + +if (!isset($ADD)) {$ADD=0;} + +if ($ADD=="1") {$hh='users'; echo "Incluir Usuário";} +if ($ADD=="1A") {$hh='users'; echo "Copiar Usuário";} +if ($ADD==11) {$hh='campaigns'; $sh='basic'; echo "Incluir Campanha";} +if ($ADD==12) {$hh='campaigns'; $sh='basic'; echo "Copiar Campanha";} +if ($ADD==111) {$hh='lists'; echo "Incluir Lista";} +if ($ADD==121) {$hh='lists'; echo "Novo Bloqueio";} +if ($ADD==1111) {$hh='ingroups'; echo "Incluir Grupo de Entrada";} +if ($ADD==1211) {$hh='ingroups'; echo "Copiar Grupo de Entrada";} +if ($ADD==1311) {$hh='ingroups'; echo "IncluirDID";} +if ($ADD==1411) {$hh='ingroups'; echo "CopiarDID";} +if ($ADD==1511) {$hh='ingroups'; echo "Incluir Menu de Chamada";} +if ($ADD==1611) {$hh='ingroups'; echo "Copiar Menu de Chamada";} +if ($ADD==11111) {$hh='remoteagent'; echo "Incluir Usuário Remoto";} +if ($ADD==111111) {$hh='usergroups'; echo "Incluir Grupo de Usuários";} +if ($ADD==1111111) {$hh='scripts'; echo "Incluir Script";} +if ($ADD==11111111) {$hh='filters'; echo "Incluir Novo Filtro";} +if ($ADD==111111111) {$hh='admin'; $sh='times'; echo "Novo Horário de Cham.";} +if ($ADD==131111111) {$hh='admin'; $sh='shifts'; echo "Incluir Turno";} +if ($ADD==1111111111) {$hh='admin'; $sh='times'; echo "Novo Horário de Cham. por Estado";} +if ($ADD==11111111111) {$hh='admin'; $sh='phones'; echo "NOVO RAMAL";} +if ($ADD==12111111111) {$hh='admin'; $sh='phones'; echo "INCLUIR ALIAS DE RAMAL";} +if ($ADD==13111111111) {$hh='admin'; $sh='phones'; echo "INCLUIR ALIAS DE GRUPO";} +if ($ADD==111111111111) {$hh='admin'; $sh='server'; echo "NOVO SERVIDOR";} +if ($ADD==131111111111) {$hh='admin'; $sh='templates'; echo "INCLUIR TEMPLATE CONF";} +if ($ADD==141111111111) {$hh='admin'; $sh='carriers'; echo "Incluir Operadora";} +if ($ADD==151111111111) {$hh='admin'; $sh='tts'; echo "ADD NEW TTS ENTRADA";} +if ($ADD==161111111111) {$hh='admin'; $sh='moh'; echo "ADD NEW MUSIC EN ESPERA DE ENTRADA";} +if ($ADD==171111111111) {$hh='admin'; $sh='vm'; echo "ADD NEW contestador";} +if ($ADD==1111111111111) {$hh='admin'; $sh='conference'; echo "NOVA CONFERÊNCIA";} +if ($ADD==11111111111111) {$hh='admin'; $sh='conference'; echo "ADD NEW VICIDIAL CONFERENCE";} +if ($ADD=='2') {$hh='users'; echo "Novo usuário";} +if ($ADD=='2A') {$hh='users'; echo "Inclusão de Usuário Copiado";} +if ($ADD==20) {$hh='campaigns'; $sh='basic'; echo "Inclusão de Campanha Copiada";} +if ($ADD==21) {$hh='campaigns'; $sh='basic'; echo "Nova Campanha";} +if ($ADD==22) {$hh='campaigns'; $sh='status'; echo "Novo Status de Campanha";} +if ($ADD==23) {$hh='campaigns'; $sh='hotkey'; echo "New Campanha HotKey Addition";} +if ($ADD==25) {$hh='campaigns'; $sh='recycle'; echo "Nova Reciclagem de registros";} +if ($ADD==26) {$hh='campaigns'; $sh='autoalt'; echo "Novo Status de Disc. Alt.";} +if ($ADD==27) {$hh='campaigns'; $sh='pause'; echo "Novo Código de Pausa";} +if ($ADD==28) {$hh='campaigns'; $sh='dialstat'; echo "Status de Discagem Adicionado";} +if ($ADD==29) {$hh='campaigns'; $sh='listmix'; echo "Mesclagem de Listas Incluído";} +if ($ADD==211) {$hh='lists'; echo "Nova Lista";} +if ($ADD==2111) {$hh='ingroups'; echo "Novo Grupo de Entrada";} +if ($ADD==2011) {$hh='ingroups'; echo "Inclusão de Grupo de Entrada Copiada";} +if ($ADD==2311) {$hh='ingroups'; echo "Incluir DDR";} +if ($ADD==2411) {$hh='ingroups'; echo "Inclusão de DDR por cópia";} +if ($ADD==2511) {$hh='ingroups'; echo "Novo Menu de Chamada";} +if ($ADD==2611) {$hh='ingroups'; echo "Novo Menu de Chamada";} +if ($ADD==21111) {$hh='remoteagent'; echo "Novo Agente Remoto";} +if ($ADD==211111) {$hh='usergroups'; echo "Novo Grupo de Usuários";} +if ($ADD==2111111) {$hh='scripts'; echo "Novo Script";} +if ($ADD==21111111) {$hh='filters'; echo "Novo Filtro";} +if ($ADD==211111111) {$hh='admin'; $sh='times'; echo "Nova Inclusão de Horário de Cham.";} +if ($ADD==231111111) {$hh='admin'; $sh='shifts'; echo "Inclusão de Turno";} +if ($ADD==2111111111) {$hh='admin'; $sh='times'; echo "Nova Inclusão de Hor. de Cham. por Estado";} +if ($ADD==21111111111) {$hh='admin'; $sh='phones'; echo "INCLUINDO RAMAL";} +if ($ADD==22111111111) {$hh='admin'; $sh='phones'; echo "INCLUINDO ALIAS DE RAMAL";} +if ($ADD==23111111111) {$hh='admin'; $sh='phones'; echo "INCLUINDO ALIAS DE GRUPO";} +if ($ADD==211111111111) {$hh='admin'; $sh='server'; echo "ADICIONANDO SERVIDOR";} +if ($ADD==221111111111) {$hh='admin'; $sh='server'; echo "ADICIONANDO TRUNK DO SERVIDOR VICIDIAL";} +if ($ADD==231111111111) {$hh='admin'; $sh='templates'; echo "INCLUINDO TEMPLATE CONF";} +if ($ADD==241111111111) {$hh='admin'; $sh='carriers'; echo "INCLUIR OPERADORA";} +if ($ADD==251111111111) {$hh='admin'; $sh='tts'; echo "AGREGAR NUEVO TTS ENTRADA";} +if ($ADD==261111111111) {$hh='admin'; $sh='moh'; echo "ADDING NEW MUSIC EN ESPERA DE ENTRADA";} +if ($ADD==271111111111) {$hh='admin'; $sh='vm'; echo "AGREGAR NUEVO contestador";} +if ($ADD==2111111111111) {$hh='admin'; $sh='conference'; echo "ADICIONANDO CONFERÊNCIA";} +if ($ADD==21111111111111) {$hh='admin'; $sh='conference'; echo "ADDING NEW VICIDIAL CONFERENCE";} +if ($ADD==221111111111111) {$hh='admin'; $sh='status'; echo "INCLUINDO STATUS DE SISTEMA DO VICIDIAL";} +if ($ADD==231111111111111) {$hh='admin'; $sh='status'; echo "INCLUIR CATEGORIA DE STATUS";} +if ($ADD==241111111111111) {$hh='admin'; $sh='status'; echo "INCLUINDO CÓDIGO DE STATUS DE CQ";} +if ($ADD==3) {$hh='users'; echo "Alterar Usuário";} +if ($ADD==30) {$hh='campaigns'; echo "Campanha não permitida";} +if ($ADD==31) + { + $hh='campaigns'; $sh='detail'; echo "Alterar Campanha - Detalhes - $campaign_id"; + if ($SUB==22) {echo " - Status";} + if ($SUB==23) {echo " - Atalhos";} + if ($SUB==25) {echo " -Reciclagem de RegistrosEntries";} + if ($SUB==26) {echo " - Discar Num. Alt. Status";} + if ($SUB==27) {echo " - Agent Códigos de Pausa";} + if ($SUB==28) {echo " - QC";} + if ($SUB==29) {echo " - Mesclagem de Listaes";} + if ($SUB=='20A') {echo " - Pesquisa";} + } +if ($ADD==34) + { + $hh='campaigns'; $sh='basic'; echo "Alterar Campanha - Visão Básica - $campaign_id"; + if ($SUB==22) {echo " - Status";} + if ($SUB==23) {echo " - Atalhos";} + if ($SUB==25) {echo " -Reciclagem de RegistrosEntries";} + if ($SUB==26) {echo " - Discar Num. Alt. Status";} + if ($SUB==27) {echo " - Agent Códigos de Pausa";} + if ($SUB==28) {echo " - QC";} + if ($SUB==29) {echo " - Mesclagem de Listaes";} + if ($SUB=='20A') {echo " - Pesquisa";} + } +if ($ADD==32) {$hh='campaigns'; $sh='status'; echo "Status da Campanha";} +if ($ADD==33) {$hh='campaigns'; $sh='hotkey'; echo "Atalhos da Campanha";} +if ($ADD==35) {$hh='campaigns'; $sh='recycle'; echo "Reciclagem de Registros da Campanha";} +if ($ADD==36) {$hh='campaigns'; $sh='autoalt'; echo "Status de Disc. Alt. da Campanha";} +if ($ADD==37) {$hh='campaigns'; $sh='pause'; echo "Códigos de Pausa de Agente da Campanha";} +if ($ADD==38) {$hh='campaigns'; $sh='dialstat'; echo "Status de Discagem da Campanha";} +if ($ADD==39) {$hh='campaigns'; $sh='listmix'; echo "Mesclagem de Listas";} +if ($ADD==311) {$hh='lists'; echo "Alterar Lista";} +if ($ADD==3111) {$hh='ingroups'; echo "Alterar Groupo de Entrada";} +if ($ADD==3311) {$hh='ingroups'; echo "AlterarDID";} +if ($ADD==3511) {$hh='ingroups'; echo "Alterar Menu de Chamada";} +if ($ADD==31111) {$hh='remoteagent'; echo "Alterar Agentes Remotos";} +if ($ADD==311111) {$hh='usergroups'; echo "Alterar Grupos de Usuários";} +if ($ADD==3111111) {$hh='scripts'; echo "Alterar Script";} +if ($ADD==31111111) {$hh='filters'; echo "Alterar Filtro";} +if ($ADD==311111111) {$hh='admin'; $sh='times'; echo "Alterar um Hor. de Cham.";} +if ($ADD==321111111) {$hh='admin'; $sh='times'; echo "Alterar as configurações de horário de chamada por estado";} +if ($ADD==331111111) {$hh='admin'; $sh='shifts'; echo "Alterar Turno";} +if ($ADD==3111111111) {$hh='admin'; $sh='times'; echo "Alterar um horário de chamada por estado";} +if ($ADD==31111111111) {$hh='admin'; $sh='phones'; echo "ALTERAR RAMAL";} +if ($ADD==32111111111) {$hh='admin'; $sh='phones'; echo "ALTERAR ALIAS DE RAMAL";} +if ($ADD==33111111111) {$hh='admin'; $sh='phones'; echo "ALTERAR ALIAS DE GRUPO";} +if ($ADD==311111111111) {$hh='admin'; $sh='server'; echo "ALTERAR SERVIDOR";} +if ($ADD==331111111111) {$hh='admin'; $sh='templates'; echo "ALTERAR TEMPLATE CONF";} +if ($ADD==341111111111) {$hh='admin'; $sh='carriers'; echo "ALTERAR OPERADORA";} +if ($ADD==351111111111) {$hh='admin'; $sh='tts'; echo "MODIFICAR TTS ENTRADA";} +if ($ADD==361111111111) {$hh='admin'; $sh='moh'; echo "MODIFICAR MÚSICA EN ESPERA DE ENTRADA";} +if ($ADD==371111111111) {$hh='admin'; $sh='vm'; echo "MODIFICAR contestador";} +if ($ADD==3111111111111) {$hh='admin'; $sh='conference'; echo "ALTERAR CONFERÊNCIA";} +if ($ADD==31111111111111) {$hh='admin'; $sh='conference'; echo "MODIFY VICIDIAL CONFERENCE";} +if ($ADD==311111111111111) {$hh='admin'; $sh='settings'; echo "ALTERAR CONFIG. DE SISTEMA DO VICIDIAL";} +if ($ADD==321111111111111) {$hh='admin'; $sh='status'; echo "ALTERAR STATUS DE SISTEMA DO VICIDIAL";} +if ($ADD==331111111111111) {$hh='admin'; $sh='status'; echo "ALTERAR CATEGORIA DE STATUS";} +if ($ADD==341111111111111) {$hh='admin'; $sh='status'; echo "ALTERAR CÓDIGO DE STATUS DE CQ";} +if ($ADD=="4A") {$hh='users'; echo "Alterar Usuário - Admin";} +if ($ADD=="4B") {$hh='users'; echo "Alterar Usuário - Admin";} +if ($ADD==4) {$hh='users'; echo "Alterar Usuário";} +if ($ADD==41) {$hh='campaigns'; $sh='detail'; echo "Alterar Campanha";} +if ($ADD==42) {$hh='campaigns'; $sh='status'; echo "Alterar Campanha Status";} +if ($ADD==43) {$hh='campaigns'; $sh='hotkey'; echo "Alterar Campanha HotKey";} +if ($ADD==44) {$hh='campaigns'; $sh='basic'; echo "Alterar Campanha - Visão Básica";} +if ($ADD==45) {$hh='campaigns'; $sh='recycle'; echo "Alterar Reciclagem de registros";} +if ($ADD==47) {$hh='campaigns'; $sh='pause'; echo "Alterar Código de Pausa";} +if ($ADD==48) {$hh='campaigns'; $sh='qc'; echo "Alterar Configurações de CQ";} +if ($ADD==49) {$hh='campaigns'; $sh='listmix'; echo "Alterar Mesclagem de Listas";} +if ($ADD=='40A') {$hh='campaigns'; $sh='survey'; echo "Alterar Campanha de Pesquisa";} +if ($ADD==411) {$hh='lists'; echo "Alterar Lista";} +if ($ADD==4111) {$hh='ingroups'; echo "Alterar Groupo de Entrada";} +if ($ADD==4311) {$hh='ingroups'; echo "AlterarDID";} +if ($ADD==4511) {$hh='ingroups'; echo "Alterar Menu de Chamada";} +if ($ADD==41111) {$hh='remoteagent'; echo "Alterar Agentes Remotos";} +if ($ADD==411111) {$hh='usergroups'; echo "Alterar Grupos de Usuários";} +if ($ADD==4111111) {$hh='scripts'; echo "Alterar Script";} +if ($ADD==41111111) {$hh='filters'; echo "Alterar Filtro";} +if ($ADD==411111111) {$hh='admin'; $sh='times'; echo "Alterar um Hor. de Cham.";} +if ($ADD==431111111) {$hh='admin'; $sh='shifts'; echo "Alterar Turno";} +if ($ADD==4111111111) {$hh='admin'; $sh='times'; echo "Alterar um horário de chamada por estado";} +if ($ADD==41111111111) {$hh='admin'; $sh='phones'; echo "ALTERAR RAMAL";} +if ($ADD==42111111111) {$hh='admin'; $sh='phones'; echo "ALTERAR ALIAS DE RAMAL";} +if ($ADD==43111111111) {$hh='admin'; $sh='phones'; echo "ALTERAR ALIAS DE GRUPO";} +if ($ADD==411111111111) {$hh='admin'; $sh='server'; echo "ALTERAR SERVIDOR";} +if ($ADD==421111111111) {$hh='admin'; $sh='server'; echo "ALTERAR TRUNK DO SERVIDOR VICIDIAL";} +if ($ADD==431111111111) {$hh='admin'; $sh='templates'; echo "ALTERAR TEMPLATE CONF";} +if ($ADD==441111111111) {$hh='admin'; $sh='carriers'; echo "ALTERAR OPERADORA";} +if ($ADD==451111111111) {$hh='admin'; $sh='tts'; echo "MODIFICAR TTS ENTRADA";} +if ($ADD==461111111111) {$hh='admin'; $sh='moh'; echo "MODIFICAR MÚSICA EN ESPERA DE ENTRADA";} +if ($ADD==471111111111) {$hh='admin'; $sh='vm'; echo "MODIFICAR contestador";} +if ($ADD==4111111111111) {$hh='admin'; $sh='conference'; echo "ALTERAR CONFERÊNCIA";} +if ($ADD==41111111111111) {$hh='admin'; $sh='conference'; echo "MODIFY VICIDIAL CONFERENCE";} +if ($ADD==411111111111111) {$hh='admin'; $sh='settings'; echo "ALTERAR CONFIG. DE SISTEMA DO VICIDIAL";} +if ($ADD==421111111111111) {$hh='admin'; $sh='status'; echo "ALTERAR STATUS DE SISTEMA DO VICIDIAL";} +if ($ADD==431111111111111) {$hh='admin'; $sh='status'; echo "ALTERAR CATEGORIA DE STATUS";} +if ($ADD==441111111111111) {$hh='admin'; $sh='status'; echo "ALTERAR CÓDIGO DE STATUS DE CQ";} +if ($ADD==5) {$hh='users'; echo "RemoverUsuário";} +if ($ADD==51) {$hh='campaigns'; $sh='detail'; echo "RemoverCampanha";} +if ($ADD==52) {$hh='campaigns'; $sh='detail'; echo "Efetuar Saída dos Agentes";} +if ($ADD==53) {$hh='campaigns'; $sh='detail'; echo "Limpador de emergência para VDAC";} +if ($ADD==511) {$hh='lists'; echo "RemoverList";} +if ($ADD==5111) {$hh='ingroups'; echo "RemoverIn-Group";} +if ($ADD==5311) {$hh='ingroups'; echo "RemoverDID";} +if ($ADD==5511) {$hh='ingroups'; echo "Remover Menu de Chamada";} +if ($ADD==51111) {$hh='remoteagent'; echo "Apagar Usuários Remotos";} +if ($ADD==511111) {$hh='usergroups'; echo "Apagar Usuários Group";} +if ($ADD==5111111) {$hh='scripts'; echo "Apagar Scripts";} +if ($ADD==51111111) {$hh='filters'; echo "Apagar Filtro";} +if ($ADD==511111111) {$hh='admin'; $sh='times'; echo "RemoverCall Time";} +if ($ADD==531111111) {$hh='admin'; $sh='shifts'; echo "Remover Turno";} +if ($ADD==5111111111) {$hh='admin'; $sh='times'; echo "Apagar Hor. de Cham. por Estado";} +if ($ADD==51111111111) {$hh='admin'; $sh='phones'; echo "DELETE PHONE";} +if ($ADD==52111111111) {$hh='admin'; $sh='phones'; echo "REMOVER ALIAS DE RAMAL";} +if ($ADD==53111111111) {$hh='admin'; $sh='phones'; echo "REMOVER ALIAS DE GRUPO";} +if ($ADD==511111111111) {$hh='admin'; $sh='server'; echo "DELETE SERVER";} +if ($ADD==531111111111) {$hh='admin'; $sh='templates'; echo "REMOVER TEMPLATE CONF";} +if ($ADD==541111111111) {$hh='admin'; $sh='carriers'; echo "REMOVER OPERADORA";} +if ($ADD==551111111111) {$hh='admin'; $sh='tts'; echo "DELETE TTS ENTRADA";} +if ($ADD==561111111111) {$hh='admin'; $sh='moh'; echo "DELETE MÚSICA EN ESPERA DE ENTRADA";} +if ($ADD==571111111111) {$hh='admin'; $sh='vm'; echo "DELETE contestador";} +if ($ADD==5111111111111) {$hh='admin'; $sh='conference'; echo "DELETE CONFERENCE";} +if ($ADD==51111111111111) {$hh='admin'; $sh='conference'; echo "DELETE VICIDIAL CONFERENCE";} +if ($ADD==6) {$hh='users'; echo "RemoverUsuário";} +if ($ADD==61) {$hh='campaigns'; $sh='detail'; echo "RemoverCampanha";} +if ($ADD==62) {$hh='campaigns'; $sh='detail'; echo "Efetuar Saída dos Agentes";} +if ($ADD==63) {$hh='campaigns'; $sh='detail'; echo "Limpador de emergência para VDAC";} +if ($ADD==65) {$hh='campaigns'; $sh='recycle'; echo "Remover Reciclagem de Registros";} +if ($ADD==66) {$hh='campaigns'; $sh='autoalt'; echo "Remover Status de Disc. Alt.";} +if ($ADD==67) {$hh='campaigns'; $sh='pause'; echo "Apagar Código de Pausa";} +if ($ADD==68) {$hh='campaigns'; $sh='dialstat'; echo "Status de Discagem Removido";} +if ($ADD==69) {$hh='campaigns'; $sh='listmix'; echo "Listas de Campanha Removida";} +if ($ADD==611) {$hh='lists'; echo "RemoverList";} +if ($ADD==6111) {$hh='ingroups'; echo "RemoverIn-Group";} +if ($ADD==6311) {$hh='ingroups'; echo "RemoverDID";} +if ($ADD==6511) {$hh='ingroups'; echo "Remover Menu de Chamada";} +if ($ADD==61111) {$hh='remoteagent'; echo "Apagar Usuários Remotos";} +if ($ADD==611111) {$hh='usergroups'; echo "Apagar Usuários Group";} +if ($ADD==6111111) {$hh='scripts'; echo "Apagar Scripts";} +if ($ADD==61111111) {$hh='filters'; echo "Apagar Filtro";} +if ($ADD==611111111) {$hh='admin'; $sh='times'; echo "RemoverCall Time";} +if ($ADD==631111111) {$hh='admin'; $sh='shifts'; echo "Remover Turno";} +if ($ADD==6111111111) {$hh='admin'; $sh='times'; echo "Apagar Hor. de Cham. por Estado";} +if ($ADD==61111111111) {$hh='admin'; $sh='phones'; echo "DELETE PHONE";} +if ($ADD==62111111111) {$hh='admin'; $sh='phones'; echo "REMOVER ALIAS DE RAMAL";} +if ($ADD==63111111111) {$hh='admin'; $sh='phones'; echo "REMOVER ALIAS DE GRUPO";} +if ($ADD==611111111111) {$hh='admin'; $sh='server'; echo "DELETE SERVER";} +if ($ADD==621111111111) {$hh='admin'; $sh='server'; echo "REMOVER TRUNK DO SERVIDOR VICIDIAL";} +if ($ADD==631111111111) {$hh='admin'; $sh='templates'; echo "REMOVER TEMPLATE CONF";} +if ($ADD==641111111111) {$hh='admin'; $sh='carriers'; echo "REMOVER OPERADORA";} +if ($ADD==651111111111) {$hh='admin'; $sh='tts'; echo "DELETE TTS ENTRADA";} +if ($ADD==661111111111) {$hh='admin'; $sh='moh'; echo "DELETE MÚSICA EN ESPERA DE ENTRADA";} +if ($ADD==671111111111) {$hh='admin'; $sh='vm'; echo "DELETE contestador";} +if ($ADD==6111111111111) {$hh='admin'; $sh='conference'; echo "DELETE CONFERENCE";} +if ($ADD==61111111111111) {$hh='admin'; $sh='conference'; echo "DELETE VICIDIAL CONFERENCE";} +if ($ADD==73) {$hh='campaigns'; echo "Total de Registros Discáveis";} +if ($ADD==7111111) {$hh='scripts'; echo "Pré-Visualizar Script";} +if ($ADD==700000000000000) {$hh='reports'; echo "VICIDIAL LOG DE ALT. ADMIN";} +if ($ADD==710000000000000) {$hh='reports'; echo "VICIDIAL LOG DE ALT. DO USUÁRIO ADMIN";} +if ($ADD==720000000000000) {$hh='reports'; echo "VICIDIAL LOG DE ALT. DA SEÇÃO ADMIN";} +if ($ADD==730000000000000) {$hh='reports'; echo "VICIDIAL LOG DE ALT. DE DETALHES ADMIN";} +if ($ADD==0) {$hh='users'; echo "Lista de Usuários";} +if ($ADD==8) {$hh='users'; echo "Chamadas Agendadas deste Agente";} +if ($ADD==81) {$hh='campaigns'; $sh='list'; echo "Chamadas Agendadas nesta Campanha";} +if ($ADD==811) {$hh='lists'; echo "Chamadas Agendadas nesta Lista";} +if ($ADD==8111) {$hh='usergroups'; echo "Agendamentos do Grupo de Usuários";} +if ($ADD==10) {$hh='campaigns'; $sh='list'; echo "Campanhas";} +if ($ADD==100) {$hh='lists'; echo "Listas";} +if ($ADD==1000) {$hh='ingroups'; echo "Groupos de Entrada";} +if ($ADD==1300) {$hh='ingroups'; echo "DIDs";} +if ($ADD==1500) {$hh='ingroups'; echo "Menus de Chamada";} +if ($ADD==10000) {$hh='remoteagent'; echo "Agentes Remotos";} +if ($ADD==100000) {$hh='usergroups'; echo "Grupos de Usuário";} +if ($ADD==1000000) {$hh='scripts'; echo "Scripts";} +if ($ADD==10000000) {$hh='filters'; echo "Filtros";} +if ($ADD==100000000) {$hh='admin'; $sh='times'; echo "Horários de Cham.";} +if ($ADD==130000000) {$hh='admin'; $sh='shifts'; echo "Turnos";} +if ($ADD==1000000000) {$hh='admin'; $sh='times'; echo "Horários de Chamada por Estado";} +if ($ADD==10000000000) {$hh='admin'; $sh='phones'; echo "LISTA DE RAMAIS";} +if ($ADD==12000000000) {$hh='admin'; $sh='phones'; echo "LISTA DE ALIAS DE RAMAL";} +if ($ADD==13000000000) {$hh='admin'; $sh='phones'; echo "LISTA DE ALIAS DE GRUPOS";} +if ($ADD==100000000000) {$hh='admin'; $sh='server'; echo "LISTA DE SERVIDORES";} +if ($ADD==130000000000) {$hh='admin'; $sh='templates'; echo "LISTA DE TEMPLATES CONF";} +if ($ADD==140000000000) {$hh='admin'; $sh='carriers'; echo "LISTA DE OPERADORAS";} +if ($ADD==150000000000) {$hh='admin'; $sh='tts'; echo "TTS LISTA INSCRITOS";} +if ($ADD==160000000000) {$hh='admin'; $sh='moh'; echo "MÚSICA EN ESPERA LISTA DE ENTRADA";} +if ($ADD==170000000000) {$hh='admin'; $sh='vm'; echo "LISTA DE CORREO DE VOZ CAJAS";} +if ($ADD==1000000000000) {$hh='admin'; $sh='conference'; echo "LISTA DE CONFERÊNCIAS";} +if ($ADD==10000000000000) {$hh='admin'; $sh='conference'; echo "VICIDIAL LISTA DE CONFERÊNCIAS";} +if ($ADD==550) {$hh='users'; echo "Formulário de Pesquisa";} +if ($ADD==551) {$hh='users'; echo "PESQUISAR RAMAIS";} +if ($ADD==660) {$hh='users'; echo "RESULTADOS DA PESQUISA";} +if ($ADD==661) {$hh='users'; echo "RESULTADO DA PESQUISA DE RAMAIS";} +if ($ADD==99999) {$hh='users'; echo "AJUDA";} +if ($ADD==999999) {$hh='reports'; echo "RELATÓRIOS";} + +if ( ($ADD>9) && ($ADD < 99998) ) + { + ##### get scripts listing for dynamic pulldown + $stmt="SELECT script_id,script_name from vicidial_scripts order by script_id"; + $rslt=mysql_query($stmt, $link); + $scripts_to_print = mysql_num_rows($rslt); + $scripts_list="<option value=\"\">NONE</option>\n"; + + $o=0; + while ($scripts_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $scripts_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $scriptname_list["$rowx[0]"] = "$rowx[1]"; + $o++; + } + + ##### get filters listing for dynamic pulldown + $stmt="SELECT lead_filter_id,lead_filter_name,lead_filter_sql from vicidial_lead_filters order by lead_filter_id"; + $rslt=mysql_query($stmt, $link); + $filters_to_print = mysql_num_rows($rslt); + $filters_list="<option value=\"\">NONE</option>\n"; + + $o=0; + while ($filters_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $filters_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $filtername_list["$rowx[0]"] = "$rowx[1]"; + $filtersql_list["$rowx[0]"] = "$rowx[2]"; + $o++; + } + + ##### get call_times listing for dynamic pulldown + $stmt="SELECT call_time_id,call_time_name from vicidial_call_times order by call_time_id"; + $rslt=mysql_query($stmt, $link); + $times_to_print = mysql_num_rows($rslt); + + $o=0; + while ($times_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $call_times_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $call_timename_list["$rowx[0]"] = "$rowx[1]"; + $o++; + } + } + +if ( ( (strlen($ADD)>4) && ($ADD < 99998) ) or ($ADD==3) or (($ADD>20) and ($ADD<70)) or ($ADD=="4A") or ($ADD=="4B") or (strlen($ADD)==12) ) + { + ##### get server listing for dynamic pulldown + $stmt="SELECT server_ip,server_description from servers order by server_ip"; + $rslt=mysql_query($stmt, $link); + $servers_to_print = mysql_num_rows($rslt); + $servers_list=''; + + $o=0; + while ($servers_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $servers_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $o++; + } + + ##### BEGIN get campaigns listing for rankings ##### + + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $campaigns_to_print = mysql_num_rows($rslt); + $campaigns_list=''; + $campaigns_value=''; + $RANKcampaigns_list="<tr><td>CAMPANHA</td><td>     RANK</td><td>     CALLS</td><td ALIGN=CENTER>WEB VARS</td></tr>\n"; + + $o=0; + while ($campaigns_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $campaigns_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $campaign_id_values[$o] = $rowx[0]; + $campaign_name_values[$o] = $rowx[1]; + $o++; + } + + $o=0; + while ($campaigns_to_print > $o) + { + $group_web_vars=''; + $campaign_web=''; + $stmt="SELECT campaign_rank,calls_today,group_web_vars from vicidial_campaign_agents where user='$user' and campaign_id='$campaign_id_values[$o]'"; + $rslt=mysql_query($stmt, $link); + $ranks_to_print = mysql_num_rows($rslt); + if ($ranks_to_print > 0) + { + $row=mysql_fetch_row($rslt); + $SELECT_campaign_rank = $row[0]; + $calls_today = $row[1]; + $group_web_vars = $row[2]; + } + else + {$calls_today=0; $SELECT_campaign_rank=0; $group_web_vars='';} + if ( ($ADD=="4A") or ($ADD=="4B") ) + { + $stmt_grp_values=''; + if (isset($_GET["RANK_$campaign_id_values[$o]"])) {$campaign_rank=$_GET["RANK_$campaign_id_values[$o]"];} + elseif (isset($_POST["RANK_$campaign_id_values[$o]"])) {$campaign_rank=$_POST["RANK_$campaign_id_values[$o]"];} + if (isset($_GET["WEB_$campaign_id_values[$o]"])) {$campaign_web=$_GET["WEB_$campaign_id_values[$o]"];} + elseif (isset($_POST["WEB_$campaign_id_values[$o]"])) {$campaign_web=$_POST["WEB_$campaign_id_values[$o]"];} + if ($non_latin < 1) + { + $campaign_rank = ereg_replace("[^-\_0-9]","",$campaign_rank); + $campaign_web = preg_replace("/;|\"|\'/","",$campaign_web); + } + + if ($ranks_to_print > 0) + { + $stmt="UPDATE vicidial_campaign_agents set campaign_rank='$campaign_rank', campaign_weight='$campaign_rank', group_web_vars='$campaign_web' where campaign_id='$campaign_id_values[$o]' and user='$user';"; + $rslt=mysql_query($stmt, $link); + $stmt_grp_values .= "$stmt|"; + } + else + { + $stmt="INSERT INTO vicidial_campaign_agents set campaign_rank='$campaign_rank', campaign_weight='$campaign_rank', campaign_id='$campaign_id_values[$o]', user='$user', group_web_vars='$campaign_web';"; + $rslt=mysql_query($stmt, $link); + $stmt_grp_values .= "$stmt|"; + } + + $stmt="UPDATE vicidial_live_agents set campaign_weight='$campaign_rank' where campaign_id='$campaign_id_values[$o]' and user='$user';"; + $rslt=mysql_query($stmt, $link); + $stmt_grp_values .= "$stmt|"; + } + else {$campaign_rank = $SELECT_campaign_rank;} + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + # disable non user-group allowable campaign ranks + $stmt="SELECT user_group from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $Ruser_group = $row[0]; + + $stmt="SELECT allowed_campaigns from vicidial_user_groups where user_group='$Ruser_group';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $allowed_campaigns = $row[0]; + $allowed_campaigns = preg_replace("/ -$/","",$allowed_campaigns); + $UGcampaigns = explode(" ", $allowed_campaigns); + + $p=0; $RANK_camp_active=0; $CR_disabled = ''; + if (eregi('-ALL-CAMPANHAS-',$allowed_campaigns)) + {$RANK_camp_active++;} + else + { + $UGcampaign_ct = count($UGcampaigns); + while ($p < $UGcampaign_ct) + { + if ($campaign_id_values[$o] == $UGcampaigns[$p]) + {$RANK_camp_active++;} + $p++; + } + } + if ($RANK_camp_active < 1) {$CR_disabled = 'DISABLED';} + + $RANKcampaigns_list .= "<tr $bgcolor><td>"; + $campaigns_list .= "<a href=\"$PHP_SELF?ADD=31&campaign_id=$campaign_id_values[$o]\">$campaign_id_values[$o]</a> - $campaign_name_values[$o] <BR>\n"; + $RANKcampaigns_list .= "<a href=\"$PHP_SELF?ADD=31&campaign_id=$campaign_id_values[$o]\">$campaign_id_values[$o]</a> - $campaign_name_values[$o] </td>"; + $RANKcampaigns_list .= "<td>     <select size=1 name=RANK_$campaign_id_values[$o] $CR_disabled>\n"; + $h="9"; + while ($h>=-9) + { + $RANKcampaigns_list .= "<option value=\"$h\""; + if ($h==$campaign_rank) + {$RANKcampaigns_list .= " SELECTED";} + $RANKcampaigns_list .= ">$h</option>"; + $h--; + } + if ( (strlen($campaign_web) < 1) and (strlen($group_web_vars) > 0) ) + {$campaign_web=$group_web_vars;} + $RANKcampaigns_list .= "</select></td>\n"; + $RANKcampaigns_list .= "<td align=right>     $calls_today</td>\n"; + $RANKcampaigns_list .= "<td>     <input type=text size=25 maxlength=255 name=WEB_$campaign_id_values[$o] value=\"$campaign_web\"></td></tr>\n"; + $o++; + } + ##### END get campaigns listing for rankings ##### + + + ##### BEGIN get inbound groups listing for checkboxes ##### + $xfer_groupsSQL=''; + if ( (($ADD>20) and ($ADD<70)) and ($ADD!=41) or ( ($ADD==41) and (eregi('list_activation', $stage))) ) + { + $stmt="SELECT closer_campaigns,xfer_groups from vicidial_campaigns where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $closer_campaigns = $row[0]; + $closer_campaigns = preg_replace("/ -$/","",$closer_campaigns); + $groups = explode(" ", $closer_campaigns); + $xfer_groups = $row[1]; + $xfer_groups = preg_replace("/ -$/","",$xfer_groups); + $XFERgroups = explode(" ", $xfer_groups); + $xfer_groupsSQL = preg_replace("/^ | -$/","",$xfer_groups); + $xfer_groupsSQL = preg_replace("/ /","','",$xfer_groupsSQL); + $xfer_groupsSQL = "WHERE group_id IN('$xfer_groupsSQL')"; + } + if ($ADD==41) + { + $p=0; + $XFERgroup_ct = count($XFERgroups); + while ($p < $XFERgroup_ct) + { + $xfer_groups .= " $XFERgroups[$p]"; + $p++; + } + $xfer_groupsSQL = preg_replace("/^ | -$/","",$xfer_groups); + $xfer_groupsSQL = preg_replace("/ /","','",$xfer_groupsSQL); + $xfer_groupsSQL = "WHERE group_id IN('$xfer_groupsSQL')"; + } + + if ( (($ADD==31111) or ($ADD==31111)) and (count($groups)<1) ) + { + $stmt="SELECT closer_campaigns from vicidial_remote_agents where remote_agent_id='$remote_agent_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $closer_campaigns = $row[0]; + $closer_campaigns = preg_replace("/ -$/","",$closer_campaigns); + $groups = explode(" ", $closer_campaigns); + } + + if ($ADD==3) + { + $stmt="SELECT closer_campaigns from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $closer_campaigns = $row[0]; + $closer_campaigns = preg_replace("/ -$/","",$closer_campaigns); + $groups = explode(" ", $closer_campaigns); + } + + $stmt="SELECT group_id,group_name from vicidial_inbound_groups order by group_id"; +# $stmt="SELECT group_id,group_name from vicidial_inbound_groups where group_id NOT IN('AGENTDIRECT') order by group_id"; + $rslt=mysql_query($stmt, $link); + $groups_to_print = mysql_num_rows($rslt); + $groups_list=''; + $groups_value=''; + $XFERgroups_list=''; + $RANKgroups_list="<tr><td>ENTRANTE GROUP</td><td>     RANK</td><td>     CALLS</td><td ALIGN=CENTER>WEB VARS</td></tr>\n"; + + $o=0; + while ($groups_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $group_id_values[$o] = $rowx[0]; + $group_name_values[$o] = $rowx[1]; + $o++; + } + + $o=0; + while ($groups_to_print > $o) + { + $group_web_vars=''; + $group_web=''; + $stmt="SELECT group_rank,calls_today,group_web_vars from vicidial_inbound_group_agents where user='$user' and group_id='$group_id_values[$o]'"; + $rslt=mysql_query($stmt, $link); + $ranks_to_print = mysql_num_rows($rslt); + if ($ranks_to_print > 0) + { + $row=mysql_fetch_row($rslt); + $SELECT_group_rank = $row[0]; + $calls_today = $row[1]; + $group_web_vars = $row[2]; + } + else + {$calls_today=0; $SELECT_group_rank=0;} + if ( ($ADD=="4A") or ($ADD=="4B") ) + { + if (isset($_GET["RANK_$group_id_values[$o]"])) {$group_rank=$_GET["RANK_$group_id_values[$o]"];} + elseif (isset($_POST["RANK_$group_id_values[$o]"])) {$group_rank=$_POST["RANK_$group_id_values[$o]"];} + if (isset($_GET["WEB_$group_id_values[$o]"])) {$group_web=$_GET["WEB_$group_id_values[$o]"];} + elseif (isset($_POST["WEB_$group_id_values[$o]"])) {$group_web=$_POST["WEB_$group_id_values[$o]"];} + + if ($non_latin < 1) + { + $group_rank = ereg_replace("[^-\_0-9]","",$group_rank); + $group_web = preg_replace("/;|\"|\'/","",$group_web); + } + + if ($ranks_to_print > 0) + { + $stmt="UPDATE vicidial_inbound_group_agents set group_rank='$group_rank', group_weight='$group_rank', group_web_vars='$group_web' where group_id='$group_id_values[$o]' and user='$user';"; + $rslt=mysql_query($stmt, $link); + $stmt_grp_values .= "$stmt|"; + } + else + { + $stmt="INSERT INTO vicidial_inbound_group_agents set group_rank='$group_rank', group_weight='$group_rank', group_id='$group_id_values[$o]', user='$user', group_web_vars='$group_web';"; + $rslt=mysql_query($stmt, $link); + $stmt_grp_values .= "$stmt|"; + } + + $stmt="UPDATE vicidial_live_inbound_agents set group_weight='$group_rank' where group_id='$group_id_values[$o]' and user='$user';"; + $rslt=mysql_query($stmt, $link); + $stmt_grp_values .= "$stmt|"; + } + else {$group_rank = $SELECT_group_rank;} + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $groups_list .= "<input type=\"checkbox\" name=\"groups[]\" value=\"$group_id_values[$o]\""; + $XFERgroups_list .= "<input type=\"checkbox\" name=\"XFERgroups[]\" value=\"$group_id_values[$o]\""; + $RANKgroups_list .= "<tr $bgcolor><td><input type=\"checkbox\" name=\"groups[]\" value=\"$group_id_values[$o]\""; + $p=0; + $group_ct = count($groups); + while ($p < $group_ct) + { + if ($group_id_values[$o] == $groups[$p]) + { + $groups_list .= " CHECKED"; + $RANKgroups_list .= " CHECKED"; + $groups_value .= " $group_id_values[$o]"; + } + $p++; + } + $p=0; + $XFERgroup_ct = count($XFERgroups); + while ($p < $XFERgroup_ct) + { + if ($group_id_values[$o] == $XFERgroups[$p]) + { + $XFERgroups_list .= " CHECKED"; + $XFERgroups_value .= " $group_id_values[$o]"; + } + $p++; + } + $stmt="SELECT queue_priority from vicidial_inbound_groups where group_id='$group_id_values[$o]';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $VIG_priority = $row[0]; + + $groups_list .= "> <a href=\"$PHP_SELF?ADD=3111&group_id=$group_id_values[$o]\">$group_id_values[$o]</a> - $group_name_values[$o] - $VIG_priority <BR>\n"; + $XFERgroups_list .= "> <a href=\"$PHP_SELF?ADD=3111&group_id=$group_id_values[$o]\">$group_id_values[$o]</a> - $group_name_values[$o] <BR>\n"; + $RANKgroups_list .= "> <a href=\"$PHP_SELF?ADD=3111&group_id=$group_id_values[$o]\">$group_id_values[$o]</a> - $group_name_values[$o] </td>"; + $RANKgroups_list .= "<td>     <select size=1 name=RANK_$group_id_values[$o]>\n"; + $h="9"; + while ($h>=-9) + { + $RANKgroups_list .= "<option value=\"$h\""; + if ($h==$group_rank) + {$RANKgroups_list .= " SELECTED";} + $RANKgroups_list .= ">$h</option>"; + $h--; + } + if ( (strlen($group_web) < 1) and (strlen($group_web_vars) > 0) ) + {$group_web=$group_web_vars;} + $RANKgroups_list .= "</select></td>\n"; + $RANKgroups_list .= "<td align=right>     $calls_today</td>\n"; + $RANKgroups_list .= "<td>     <input type=text size=25 maxlength=255 name=WEB_$group_id_values[$o] value=\"$group_web\"></td></tr>\n"; + $o++; + } + if (strlen($groups_value)>2) {$groups_value .= " -";} + if (strlen($XFERgroups_value)>2) {$XFERgroups_value .= " -";} + } + ##### END get inbound groups listing for checkboxes ##### + + +##### BEGIN get campaigns listing for checkboxes ##### +if ( ($ADD==211111) or ($ADD==311111) or ($ADD==411111) or ($ADD==511111) or ($ADD==611111) ) + { + if ( ($ADD==211111) or ($ADD==311111) or ($ADD==511111) or ($ADD==611111) ) + { + $stmt="SELECT allowed_campaigns,qc_allowed_campaigns,qc_allowed_inbound_groups from vicidial_user_groups where user_group='$user_group';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $allowed_campaigns = $row[0]; + $qc_allowed_campaigns = $row[1]; + $qc_allowed_inbound_groups = $row[2]; + $allowed_campaigns = preg_replace("/ -$/","",$allowed_campaigns); + $campaigns = explode(" ", $allowed_campaigns); + $qc_allowed_campaigns = preg_replace("/ -$/","",$qc_allowed_campaigns); + $qc_campaigns = explode(" ", $qc_allowed_campaigns); + $qc_allowed_inbound_groups = preg_replace("/ -$/","",$qc_allowed_inbound_groups); + $qc_groups = explode(" ", $qc_allowed_inbound_groups); + } + + $campaigns_value=''; + $campaigns_list='<B><input type="checkbox" name="campaigns[]" value="-ALL-CAMPANHAS-"'; + $qc_campaigns_value=''; + $qc_campaigns_list='<B><input type="checkbox" name="qc_campaigns[]" value="-ALL-CAMPANHAS-"'; + $qc_groups_value=''; + $qc_groups_list='<B><input type="checkbox" name="qc_groups[]" value="-ALL-GROUPS-"'; + $p=0; + while ($p<2000) + { + if (eregi('ALL-CAMPANHAS',$campaigns[$p])) + { + $campaigns_list.=" CHECKED"; + $campaigns_value .= " -ALL-CAMPANHAS-"; + } + if (eregi('ALL-CAMPANHAS',$qc_campaigns[$p])) + { + $qc_campaigns_list.=" CHECKED"; + $qc_campaigns_value .= " -ALL-CAMPANHAS-"; + } + if (eregi('ALL-GROUPS',$qc_groups[$p])) + { + $qc_groups_list.=" CHECKED"; + $qc_groups_value .= " -ALL-GROUPS-"; + } + $p++; + } + $campaigns_list.="> ALL-CAMPANHAS - USUÁRIOS PODEM VER QUALQUER CAMPANHA</B><BR>\n"; + $qc_campaigns_list.="> ALL-CAMPANHAS - USUÁRIOS PODEM FAZER CQ EM QUALQUER CAMPANHA</B><BR>\n"; + $qc_groups_list.="> ALL-GROUPS - USUÁRIOS PODEM FAZER CQ EM QUALQUER GRUPO DE ENTRADA</B><BR>\n"; + + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $campaigns_to_print = mysql_num_rows($rslt); + + $o=0; + while ($campaigns_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $campaign_id_value = $rowx[0]; + $campaign_name_value = $rowx[1]; + $campaigns_list .= "<input type=\"checkbox\" name=\"campaigns[]\" value=\"$campaign_id_value\""; + $qc_campaigns_list .= "<input type=\"checkbox\" name=\"qc_campaigns[]\" value=\"$campaign_id_value\""; + $p=0; + while ($p<1000) + { + if ( ($campaign_id_value == $campaigns[$p]) and (strlen($campaign_id_value) > 1) ) + { + # echo "<!-- X $p|$campaign_id_value|$campaigns[$p]| -->"; + $campaigns_list .= " CHECKED"; + $campaigns_value .= " $campaign_id_value"; + } + if ($campaign_id_value == $qc_campaigns[$p]) + { + $qc_campaigns_list .= " CHECKED"; + $qc_campaigns_value .= " $campaign_id_value"; + } + # echo "<!-- O $p|$campaign_id_value|$campaigns[$p]| -->"; + $p++; + } + $campaigns_list .= "> $campaign_id_value - $campaign_name_value<BR>\n"; + $qc_campaigns_list .= "> $campaign_id_value - $campaign_name_value<BR>\n"; + $o++; + } + + $stmt="SELECT group_id,group_name from vicidial_inbound_groups where group_id NOT IN('AGENTDIRECT') order by group_id"; + $rslt=mysql_query($stmt, $link); + $groups_to_print = mysql_num_rows($rslt); + + $o=0; + while ($groups_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $group_id_value = $rowx[0]; + $group_name_value = $rowx[1]; + $qc_groups_list .= "<input type=\"checkbox\" name=\"qc_groups[]\" value=\"$group_id_value\""; + $p=0; + while ($p<2000) + { + if ( ($group_id_value == $qc_groups[$p]) and (strlen($group_id_value) > 1) ) + { + $qc_groups_list .= " CHECKED"; + $qc_groups_value .= " $group_id_value"; + } + $p++; + } + $qc_groups_list .= "> $group_id_value - $group_name_value<BR>\n"; + $o++; + } + + if (strlen($campaigns_value)>2) {$campaigns_value .= " -";} + if (strlen($qc_campaigns_value)>2) {$qc_campaigns_value .= " -";} + if (strlen($qc_groups_value)>2) {$qc_groups_value .= " -";} + } + ##### END get campaigns listing for checkboxes ##### + + +if ( (strlen($ADD)==11) or (strlen($ADD)>12) or ( ($ADD > 1299) and ($ADD < 9999) ) ) + { + ##### get server listing for dynamic pulldown + $stmt="SELECT server_ip,server_description from servers order by server_ip"; + $rsltx=mysql_query($stmt, $link); + $servers_to_print = mysql_num_rows($rsltx); + $servers_list=''; + + $o=0; + while ($servers_to_print > $o) + { + $rowx=mysql_fetch_row($rsltx); + $servers_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $o++; + } + } + + + +$NWB = "   <a href=\"javascript:openNewWindow('$PHP_SELF?ADD=99999"; +$NWE = "')\"><IMG SRC=\"help.gif\" WIDTH=20 HEIGHT=20 Border=0 ALT=\"AJUDA\" ALIGN=TOP></A>"; + + +###################################################################################################### +###################################################################################################### +####### 9 series, HELP screen +###################################################################################################### +###################################################################################################### + + +###################### +# ADD=99999 display the HELP SCREENS +###################### + +if ($ADD==99999) + { + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "
ADMINISTRATION: AJUDA


\n"; + + ?> + VICIDIAL_USUÁRIOS TABELA

+ +
+ ID de Usuário - Este campo é onde deve ser colocado o ID de usuário do VICIDIAL, pode ter até 8 caracteres de comprimento, Deve ter pelo menos 2 caracteres de comprimento. + +
+
+
+ Senha - Este campo é onde deve ser configurada a senha do usuário do VICIDIAL. Deve ter pelo menos 2 caracteres de comprimento. + +
+
+
+ Nome completo - Neste campo é configurado o Nome completo do usuário do VICIDIAL. Deve ter no mínimo 2 caracteres de comprimento. + +
+
+
+ Nível de usuário - Neste menu deve ser selecionado o nível do usuário do VICIDIAL. Deve ser pelo menos 1 para acessar o VICIDIAL, deve ser maior que 2 para acessar como finalizador, deve ser nível 8 ou maior para acessar a tela de admin. + +
+
+
+ Grupo de usuário - Este menu é onde você seleciona o grupo de usuários do VICIDIAL ao qual esse usuário pertence. Isto ainda não faz restrições, é usado somente para subdividir usuários e permitir futuras funcionalidades baseadas nele. + +
+
+
+ Login do Ramal - Aqui é onde você pode configurar um valor padrão para o login do ramal, usado quando o usuário loga no vicidial.php. Este valor será colocado no campo de login do ramal automaticamente quando o usuário loga na campanha no vicidial pela tela do vicidial.php. + +
+
+
+ Senha do Ramal- Aqui é onde fica configurada a senha padrão para o ramal quando o usuário loga no vicidial.php. Este valor será colocado automaticamente no campo da senha, quando o usuário faz logon na campanha pela tela vicidial.php. + +
+
+
+ Ativo - Este campo define se o usuário está ativo no sistema e pode usar os recursos do VICIDIAL. O padrão é Y + +
+
+
+ Email, Código do Usuário e Território - Estes são campos opcionais. + +
+
+
+ Atalhos Ativos - Esta opção quando configurada, permite ao usuário usar atalhos de teclado para classificação da chamada vicidial.php. + +
+
+
+ Agente Escolhe Grupos de Entrada - Esta opção com valor 1, permite ao usuário escolher os grupos de entrada que quer receber chamadas quando fazem sogon em uma campanha CLOSER ou ENTRANTE. Caso contrário, o Gerente vai precisar configurar isto na tela de detalhes do cadastro de usuários no site admin. + +
+
+
+ Agente Elija territorios - Esta opción si se establece en 1 permite al usuario elegir los territorios que van a recibir llamadas de los usuarios cuando ingresan a un manual o campaña ENTRANTE_MAN. De lo contrario el usuario será configurado para utilizar todos los territorios que se establecen a pertenecer a los territorios de usuario administrativos sección. + +
+
+
+ Scheduled Callbacks - Esta opción permite que un agente a disposición de una llamada como CALLBK y elegir la fecha y hora en que el plomo se vuelva a activar. + +
+
+
+ Chamada Agendada por Agente - Permite que um agente configure uma chamada agendada com fidelização, assim ela retorna somente para ele. Isso também permite ao agente ver a sua lista de agendamentos e os chamar qualquer hora que desejem. + +
+
+
+ Agente com Chamada Manual- Permite que um agente manualmente adicione um novo registro ao sistema e comande a discagem. Isso também permite que seja comandado a discagem de qualquer número na tela do vicidial e a coloque na sua sessão. Use esta opção com cautela. + +
+
+
+ Gravação do Vicidial - Esta opção previne um agente de fazer qualquer gravação após ter entrado no vicidial. Esta opção deve estar ligada para que o vicidial grave as chamadas da campanha . + +
+
+
+ Transferências Vicidial - Esta opção pode previnir que um agente abra a sessão de transferência/conferência do vicidial. Se estiver desabilitada, o agente não poderá transferir ou incluir um terceiro na chamada. + + 0) + { + ?> +
+
+
+ Padrão Mesclado para Finalizador - Esta opção simplesmente marca ou nao o checkbox de Mesclado(blended) no login da campanha Finalizador (closer). + + +
+
+
+ Sobrepor Config. de Gravação do VICIDIAL - Esta opção irá sobrepor qualquer configuração de gravação que esteja na campanha. DISABLED não irá sobrepor a configuração da campanha. NEVER irá desabilitar a gravação no client. ONDEMAND é o padrão e permite ao agente iniciar e parar a gravação conforme necessário. ALLCALLS irá iniciar a gravação no client quando uma chamada é enviada ao agente. ALLFORCE irá iniciar a gravação no client quando uma chamada é enviada para o agente, sem dar a opção de parar a gravação, Para ALLCALLS e ALLFORCE existe uma opção para atrasar a gravação e evitar gravações curtas demais e evitar carga no sistema. + +
+
+
+ Sobrepor Controle de Turno do Agente - Esta configuração irá sobrepor qualquer configuração feita no grupo do agente para controle de turno. DISABLED irá usár a configuração do grupo. OFF não irá forçar turnos. START irá somente forçar o horário de login do turno mas não terá efeito sobre horário acima do final do turno se o usuário ainda estiver logado. ALL irá forçar o inicio do turno e irá fazer logout do agente caso passe do final do horário do turno. O padrão é DISABLED. + +
+
+
+ Alerta Ativo - Este campo mostra se o agente tem alertas pelo browser habilitados para quando chamadas entram na sessão do usuário. O padrão é 0 para Não. + +
+
+
+ Permitir Alertas - Este campo le da la capacidad para permitir navegador agente de alertas para ser habilitado por el agente para cuando las llamadas entran en su período de sesiones vicidial.php. Por defecto es 0 para el NO. + +
+
+
+ Rankings da Campanha - Nessa sessão você define o ranking que cada agente terá em cada campanha. Esses rankings podem ser usados para permitir roteamento preferencial de chamadas quando o campo Próximo Agente está como campaign_rank. Também nesta seção estão as variáveis WEB para caba campanha. Elas permitem cada agente ter variáveis diferentes que podem ser adicionadas a URL do WEB FORM ou do SCRIPT, simplestemnte colocando --A--web_vars--B-- da mesma forma que faria com qualquer outro campo + +
+
+
+ Grupos de entrada - Aqui é selecionado o grupo de entrada do qual você quer receber chamadas se você selecionou uma campanha CLOSER(finalização). Você também poderá configurar o ranking, ou nível de conhecimento, nessa sessão para cada grupo de entrada, assim como será capaz de ver o número de chamadas recebidas por cada grupo de entrada por agente específico. Também nessa sessão está a possibilidade de atribuir um ranking do agente para cada Grupo de Entrada. Esses rankings podem ser usados para roteamento preferencial quando essa opção está selecionada na tela de Grupos de Entrada. Também nesta seção estão as variáveis WEB para caba campanha. Elas permitem cada agente ter variáveis diferentes que podem ser adicionadas a URL do WEB FORM ou do SCRIPT, simplestemnte colocando --A--web_vars--B-- da mesma forma que faria com qualquer outro campo + +
+
+
+ Sobrepor Permissão de Alteração-<\/B> Esta opção irá sobrepor qualquer opção na campanha para alterar dados do cliente. NOT_ACTIVE irá usar qualquer configuração presente na campanha. ALLOW_ALTER irá sempre permitir alteração no registro do cliente, não importando a configuração da campanha. O padrão é NOT_ACTIVE. + +
+
+
+ Sobrepor Permissão de Alter. de Telefone- Esta opção irá sobrepor qualquer configuração na campanha sobre alterar o telefone do cliente. NOT_ACTIVE irá usar a configuração presente na campanha. ALLOW_ALTER irá sempre permitir que o agente altere o telefone do cliente, não importando a configuração da campanha. O padrão é NOT_ACTIVE. + +
+
+
+ Los campos de usuario personalizada - Estos cinco campos se puede utilizar para diversos fines, y que se puede rellenar en el formulario web y direcciones de secuencias de comandos como user_custom_one y así sucesivamente. + +
+
+
+ Alterar Opções da Interface do Agente - Esta opção quando configurada como 1 permite ao usuário administrativo modificar a interface do agente no admin.php. + +
+
+
+ Apagar Usuários - Esta opção quando habilitada permite que o usuário apaga outros usuários de igual ou menor nível do sistema. + +
+
+
+ Apagar Grupos de Usuários - Esta opção, quando habilitada, permite que este usuário apague grupos de usuário do sistema. + +
+
+
+ Apagar Listas - Esta opção, quando habilitada, permite ao usuário apagar listas do vicidial. + +
+
+
+ Apagar Campanhas - Esta opção, quando habilitada, permite ao usuário apagar campanhas do vicidial. + +
+
+
+ Apagar Grupos de Entrada- Esta opção, quando habilitada, permite ao usuário apagar Grupos de entrada do sistema. + +
+
+
+ Apagar Agentes Remotos - Esta opção quando comfigurada como 1, permite ao usuário apagar agentes remotos do sistema. + + 0) + { + ?> +
+
+
+ Carregar Registros - Esta opção, quando configurada como 1, permite ao usuário carregar novos registros de clientes na tabela vicidial_list atravéz do carregador de arquivos no client web. + + +
+
+
+ Detalhes da Campanha- Esta opção, quando configurada como 1, permite ao usuário ver e modificar os detalhes da campanha . + +
+
+
+ Acesso AGC Admin- Esta opção, quando configurada como 1, permite o usuário efetuar logon nas páginas de admin do astGUIclient. + +
+
+
+ Apagar Fones no AGC- Esta opção, quando configurada como 1, permite ao usuário apagar registros de fone nas paginas de admin do astGUIclient. + +
+
+
+ Apagar Scripts - Esta opção, quando configurada como 1, permite o usuário apagar scripts de campanha na tela de configuração do script. + +
+
+
+ Modificar Registros - Esta opção quando configurada permite ao usuário modificar registros na página de pesquisa do site admin. + +
+
+
+ Trocar Campanha do Agente - Esta opção quando configurada, permite ao usuário trocar a campanha em que um agente está logado no sistema sem que haja necessidade de sair do sistema. + + 0) + { + ?> +
+
+
+ Apagar Filtros - Esta opção permite que o usuário possa apagar filtros de registro no sistema vicidial. + + +
+
+
+ Remover Horários de Chamada - Esta opção permite ao usuário apagar registros de horários de chamada e chamadas por estado do sistema. + +
+
+
+ Alterar Horários de Chamada - Esta opção permite ao usuário visualizar e alterar os registros de horários e estados de ligação. O usuário não precisa desta opção habilitada se for somente alterar as opções de horário na tela de configuração de campanha. + +
+
+
+ Alterar Sessões - Estas opções permitem ao usuário visualizar e alterar registros de cada sessão. Se configurado como 0, o usuário será capaz de ver a lista de sessões, mas não poderá ver os detalhes nem alterar os registros da sessão. + +
+
+
+ Visualizar Relatórios - Esta opção permite ao usuário visualizar os relatórios VICIDIAL. + + 0) + { + ?> +
+
+
+ CQ Habilitado - Esta opção permite ao usuário logar na tela de agente de Controle de Qualidade. + +
+
+
+ Nível de usuário CQ - Esta configuração define qual é o nível do usuário do Controle de Qualidade. Isso irá ditar o nível de funcionalidade desse agente na seção de CQ:
+ 1 - Não Modificar Nada
+ 2 - Não Modificar Nada Exceto Status
+ 3 - Modificar Todos Campos
+ 4 - Verificar primeiro nível de CQ
+ 5 - Vizualizar Estatísticas de CQ
+ 6 - Capacidade de Alterar Registros Finalizados
+ 7 - Nível Gerente
+ +
+
+
+ Registro Passou no CQ - Esta opção permite ao agente especificar que um registro passou no primeiro nível de Controle de Qualidade após revisar o registro. + +
+
+
+ Finalizado no CQ - Esta opção permite ao agente especificar que um registro finalizou o segundo nível de Controle de Qualidade após revisar o registro. + +
+
+
+ Confirmado no CQ - Esta opção permite ao agente especificar que um registro foi Confirmado no Controle de Qualidade. E não poderá ser alterado por ninguém. + + +
+
+
+ Incluir Registro de Ponto - Esta opção permite ao usuário adicionar registros de log ao Relógio de Ponto. + +
+
+
+ Alterar Registro de Log do Ponto - Esta opção permite ao usuário alterar os registros do log do Relógio de ponto. + +
+
+
+ Remover Registro de Log do Ponto - Esta opção permite ao usuário remover registros do log do relógio de ponto. + +
+
+
+ Agente para Acesso ao API - Esta opção permite esta conta ser usada com comandos de API. + +
+
+
+ Sobrepor Controle de Turno do Gerente - Esta configuração quando 1 irá permitir ao gerente entrar com suas credenciais na tela do agente para sobrepor o controle do turno caso o agente esteja tentando logar fora do horário determinado para seu turno. O padrão é 0. + +
+
+
+ Download Listas - Esta configuração quando 1 permite aoa gerente clicar no download da lista na parte inferior da tela de alteração de listas para exportar o conteúdo da lista para um arquivo em formato de texto. O padrão é 0. + +
+
+
+ Exportar Relatórios - Esta configuração quando configurada como 1 irá permitir ao gerente acessar o ítem de exportação de relatórios na tela de relatórios. O padrão é 0 +:
call_date, phone_number, status, user, full_name, campaign_id/in-group, vendor_lead_code, source_id, list_id, gmt_offset_now, phone_code, phone_number, title, first_name, middle_initial, last_name, address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email, security_phrase, comments, length_in_sec, user_group, alt_dial/queue_seconds, rank, owner + +
+
+
+ Remover da Lista de Bloqueio - Esta configuração quando 1 permite que o gerente remova números de telefone da lista de bloqueio no sistema VICIDIAL . + + + + + + +



+ + VICIDIAL_CAMPANHAS TABELA

+
+
+ ID da Campanha - Este é o nome curto para a campanha, não é editável após cadastrado, não pode conter espaços e deve ter entre 2 e 8 caracteres de comprimentoh. + +
+
+
+ Nome da Campanha- Esta é a descrição da campanha, deve ter entre 6 e 40 caracteres de comprimento. + +
+
+
+ Descrição da Campanha - Este é um campo de texto para a campanha, é opicional e pode ter no máximo 255 caracteres de comprimento. + +
+
+
+ Data de Alteração da Campanha - Esta é a última vez que a configuração desta campanha foi alterada. + +
+
+
+ Data do Último Login na Campanha - É a data da última vez que um agente logou nesta campanha. + +
+
+
+ Última fecha de convocatoria de la Campaña - Esta es la última vez que una llamada fue manejado por un agente registrado en esta campaña. + +
+
+
+ Atualizar Estat. da Campanha - Este checkbox irá permitir que você force uma atualizaão das estatísticas, mesmo se a campanha não estiver ativa. + +
+
+
+ Ativo - Aqui é onde você configura a campanha coma Ativa ou Inativa. Se Inativa, ninguem pode entrar nela. + +
+
+
+ Exten do Estacionamento - Aqui é onde você pode customizar a musica em espera para o VICIDIAL. Tenha certeza que a extensão existe no extensions.conf e que aponta para o nome de arquivo abaixo. + +
+
+
+ Nome do arquivo de Estacionamento - Aqui é onde você pode customizar a musica em espera para o VICIDIAL. Tenha certeza que o nome do arquivo tem 10 ou menos caracteres de comprimento e que o arquivo está na pasta /var/lib/asterisk/sounds . + +
+
+
+ Formulário Web - Aqui é onde você configura a página web customizada que é aberta quando o usuário clica no botão WEB FORM. Para personalizar a string de pesquisa do formulário web, simplesmente inicie o formulário web com VAR e então a URL que você quer usar, substituindo as variáveis com os nomes de variável que você quer usar --A--phone_number--B-- da mesma forma que na seção SCRIPTS. + +
+
+
+ Target do Form. Web- Esta configuração é onde você coloca o frame da página que o formulário web irá ser aberto quando o usuário clica no botão WEB FORM. O padrão é _blank. + +
+
+
+ Permitir Finalizadores - Aqui é onde você pode configurar se os usuários dessa campanha poderão ter a opção de enviar a chamada para um finalizador. + +
+
+
+ Grupo de Transf. Padrão - Este campo é o Grupo de Entrada padrão que será automaticamente selecionado quando um agente seleciona transferência-conferência na tela do agente. + +
+
+
+ Grupos de Transferência Permitidos - Nessa lista você pode selecionar grupos para os quais os agentes nessa campanha podem transferir chamadas. Permitir Finalizadores (closers) deve estar habilitado para que esta opção seja mostrada. + + 0) + { + ?> +
+
+
+ Permitir Entrantes e Blended - Aqui é onde se configura se o usuário desta campanha irá ter a opção de receber chamadas entrantes nesta campanha. Se você quiser mesclar entrantes e saintes, deve estar configurado como Y. Se você quer apenas fazer chamadas saintes nesta campnaha, configure como N. O padrão é N. + +
+
+
+ Status da Discagem - Aqui é onde você configura os status que você deseja discar nas listas ativas para a campanha abaixo. Para adicionar outro status de discagem, selecione-o na lista e clique ADD. Para remover um dos status, clique no link REMOVE ao lado do status que você quer remover. + +
+
+
+ Ordem da Lista - Este menu é onde você seleciona como os registros nos status selecionados acima serão colocados no hopper: +
  - DOWN: selecione o primeiro registro carregado na tabela vicidial_list +
  - UP: selecione o último registro carregado na tabela vicidial_list +
  - UP PHONE: seleciona o número de telefone mais alto e desce até o fim +
  - DOWN PHONE: seleciona o telefone mais baixo e sube até o topo +
  - UP LAST NAME: inicia com sobrenomes iniciando em Z e desce até o fim +
  - DOWN LAST NAME: inicia com sobrenomes iniciando em A e sobe até o inicio +
  - UP COUNT: inicia com registros mais chamados e vai até o fim +
  - DOWN COUNT: inicia com registros menos chamados e vai até o começo +
  - DOWN COUNT 2nd NEW: inicia com registros menos chamados e vai até o começo inserindo registros NOVOS intercalados - Não deve ter selecionado NOVOS nos status de discagem +
  - DOWN COUNT 3nd NEW: inicia com registros menos chamados e vai até o começo inserindo um registro NOVO a cada três registros - Não deve ter NOVOS selecionado nos status de discagem +
  - DOWN COUNT 4th NEW: inicia com registros menos chamados e vai até o começo inserindo um registro novo a cada quatro registros - Não deve ter NOVOS selecionado nos status de discagem +
  - RANDOM: Aleatoriamente pega um registro entre os status e listas definidas +
  - HORA DA ÚLTIMA CHAMADA PARA CIMA: Ordena os registros pela chamada mais recente +
  - HORA DA ÚLTIMA CHAMADA PARA BAIXO: Ordena os registros pela chamada mais antiga +
  - UP RANK: Comienza con la más alta categoría y se abre camino hacia abajo +
  - DOWN RANK: Comienza con el rango más bajo y se abre camino hasta +
  - UP OWNER: Comienza con los propietarios de inicio con Z y obras de su camino hacia abajo +
  - DOWN OWNER: Comienza con los propietarios empiezan con la letra y se abre camino hasta +
  - UP TIMEZONE: Comienza con las zonas horarias del Este y del Oeste de obras +
  - DOWN TIMEZONE: Comienza con las zonas horarias occidental y oriental de obras + +
+
+
+ Nível de Hopper - Aqui é onde fica configurado quantos registros o VDhopper mantém na tabela vicidial_hopper para esta campanha. Se estiver rodando VDhopper a cada minuto, tenha a garantia que é acima do número de registros discados por minuto. + +
+
+
+ Filtro de Registros - Este é um método de filtrar os registros usando um fragmento de uma query SQL. Use este recurso com cuidado, é fácil parar de discar acidentalmente com uma pequena alteração no comando SQL. O padrão é NONE. + +
+
+
+ Tiempo de caída de bloqueo - Este es un número de horas que DROP abandonar pide se le impida que se está marcando, para establecer inhabilitar a 0. Esta opción es muy útil en países como el Reino Unido, donde existen normas que impiden la tentativa de llamar a los clientes dentro de las 72 horas de abandono, o DROP. Por defecto es 0. + +
+
+
+ Força Limpeza do Hopper - Isto permite que você limpe o conteúdo do hopper a partir do comando enviar da página. O hopper deve ser preenchido assim que o script do VDhopper for executado. + +
+
+
+ Método de discagem - Esta é a definição de como a discagem deve ser feita. Se MANUAL então o níver de discagem automática ficará travado em 0 a não ser que o método seja alterado. Se RATIO então a discagem será feita baseada na quantidade de agentes livres. ADAPT_HARD_LIMIT irá discar preditivamente até o nível de chamadas derrubadas e não discará agressivamente após o nível ter sido alcançado até que abaixe novamente. ADAPT_TAPERED permite se passar do nível de derrubadas na primeira metade do turno, conforme definido no horário de campanha, e fica menos agressivo conforme o turno avança. ADAPT_AVERAGE tenta manter uma média no percentual de derrubadas não impondo limites e não sendo tão agressivo como os outros dois métodos. Você não pode mudar o nível de discagem automática se você usar alguns dos métodos ADAPT. Somente o Discador pode mudar o nível no modo preditivo. ENTRANTE_MAN permite ao agente fazer chamadas manuais a partir de uma campanha enquanto está disponível para receber chamadas entrantes, entre as chamadas manuais. + +
+
+
+ Nível de Discagem Automática - Aqui deve ser configurado quantas linhas o VICIDIAL deve usar por agente ativo. Zero(0) significa que o discador automático está desligado e os agentes devem clicar para discar cada número. Caso contrário o VICIDIAL irá manter discando na quantidade de linhas igual ao número de agentes livres multiplicado pelo valor deste campo. O checkbox SOBREPOR APAPT permite que você force um nível de discagem mesmo que o método seja um dos ADAPT. Isto é útil quando existe uma mudança grande na qualidade dos registros e você quer mudar manualmente o nível. + +
+
+
+ Somente Lista Autom. - Este campo quando configurado como Y não considera a quantidade de chamadas entrantes nem em fila de espera para calcular a quantidade de chamadas para discagem automática. O padrão é N. + +
+
+
+ Percentual Limite de Derrubadas (drop) - Este campo é onde você configura o limite em percentual das chamadas derrubadas quando usamos um dos métodos preditivos(ADAPT), não válido para métodos MANUAL ou RATIO. + +
+
+
+ Nível Máximo de Adapt - Este campo é onde você configura o limite máximo da quantidade de linhas a usar por usuário quando usando um método preditivo (ADAPT), não válido para MANUAL ou RATIO. Este número pode ser maior que o nível de discagem automática se o seu hardware permitir. O valor deve ser um número positivo maior que 1 e pode ter casas decimáis. O padrão é 3.0. + +
+
+
+ Horário Final do Servidor - Este campo só é usado pelo método ADAPT_TAPERED. Você deve entrar com a hora e o minuto em que vai parar de fazer chamadas para esta campanha, 2100 significa que você vai parar de discar esta campanha as 21 horas. Isto permite ao algoritmo do método Tapered decidir quanto agressivo deve ser e quanto tempo tem até o horário de parar. + +
+
+
+ Modificador de Intensidade - Este campo é usado para ajustar a intensidade preditiva para cima ou para baixo. Quanto mais alto(positivo) o valor selecionado, mais o discador vai aumentar o ritmo de chamadas quando aumentar a velocidade e mais lento será para o discador diminuir a velocidade. Quanto mais negativo for o número que você selecionou, mais devagar o discador irá aumentar o ritmo quando precisar, e mais rápido diminuirá a velocidade quando precisar diminuir o ritmo. O padrão é 0. Este campo não é usado pelos métodos MANUAL ou RATIO. . + +
+
+
+ Alvo da Diferença de Nível - Este campo é usado para definir se você quer alcançar um número específico de agentes esperando chamadas ou chamadas esperando agentes. Por exemplo: se você gostaria de sempre ter em média um agente livre para receber chamadas imediatamente, você configura como -1, se você gostaria que sempre houvesse uma chamada esperando por agente, você configura como 1. O padrão é 0. Este campo não é usado pelos métodos MANUAL e RATIO. + +
+
+
+ Transferências Simultâneas - Esta configuração é usada para definir o número de chamadas que podem ser enviadas para agentes ao mesmo tempo. É recomendado que esta configuração seja deixada em AUTO. Este campo não é usado pelo método MANUAL de discagem. + +
+
+
+ Prioridade da Fila - Valor utilizado para definir a ordem na qual as chamadas dessa campanha de saída devem ser respondidas em relação as chamadas entrantes desta campanha em modo blended. + +
+
+
+ Varias campañas Drop Rate Grupo - Esta característica le permite establecer una campaña como miembro de una campaña de la velocidad de descenso del Grupo, o un grupo de campañas cuyas llamadas contestadas y llamadas Humanos Drop para todas las campañas en el grupo se combinarán en un porcentaje de caída compartida, o tasa de abandono. Esto le permite ejecutar varias campañas a la vez y más fácil de controlar su tasa de caída. Esto es particularmente útil en el Reino Unido, donde las regulaciones lo permiten esta disminución método del tipo de cálculo con la campaña de la agrupación por la misma empresa, incluso si hay varias campañas que la empresa está ejecutando en el mismo día. Para habilitar esta para una campaña, sólo tienes que seleccionar un grupo de la lista. Hay 10 grupos definidos en el sistema por defecto, puede ponerse en contacto con el administrador del sistema para añadir más. Desactivado por defecto. + +
+
+
+ Auto Discar Alternativo - Esta configuração é usada para automaticamente discar números alternativos enquanto os métodos RATIO e ADAPT são usados e não há contato no telefone principal para um registro com status NA, B, DC e N. Esta configuração não é usada pelo método MANUAL de discagem. EXTENDIDOS são números alternativos que são carregados no sistema fora da tela padrão de informações sobre registros. Usando EXTENDED você pode ter centenas de números de telefone para um único registro de cliente. + +
+
+
+ Tempo excedido de discagem - Se configurado, as chamadas que normalmente seriam desligadas após o tempo definido no extensions.conf serão desligadas no tempo configurado aqui, caso este valor seja menor do que o do extensions.conf. Isso permite que rapidamente sejam alterados os timeouts por campanha e que a configuração seja igual para todos os servidores. Se você está recebendo muitas chamadas de secretária eletrônica ou correio de voz, pode tentar mudar esse valor para valores entre 21 e 26 e verifique se melhora. + +
+
+
+ Extensão VDAD da Campanha - Este campo permite personalizar a extensão de transferência do VDAD. Isso permite que você use métodos de controle da chamada dependendo da sua campanha + - 8364 - mesma que 8368 + - 8365 - Irá enviar a chamada somente para o servidor no qual o agente está logado + - 8366 - Utilizado somente para campanhas de pressione-1 e pesquisa + - 8367 - Irá tentar enviar a chamada para um agente no servidor local, então irá procurar em outros servidores + - 8368 - DEFAULT Will send the call to the next available agent no matter what server they are on + - 8369 - Usado para detecção de secretária eletrônica, após a detecção segue o mesmo caminho da 8368 + - 8373 - Usado para detecção de secretária eletrônica, após a detecção segue o mesmo caminho da 8366 + +
+
+
+ Mensagem na Secretária Eletrônica - Este campo es para entrar en el sistema para jugar cuando el agente recibe un contestador automático y hace clic en el botón Responder a máquina contestadora en el marco de conferencias de transferencia. Debe establecer que esto sea un archivo de audio en la tienda de audio o un sistema TTS TTS si está habilitada en su sistema de. + +
+
+
+ Opciones WaitForSilence - Si Wait For silencio es deseada en las llamadas que se detectan como Contestadoras entonces este campo tiene esas opciones. Hay dos opciones separadas por una coma, la primera opción es el tiempo para detectar silencio en milisegundos y la segunda opción es para cuántas veces se detecta que antes de reproducir el mensaje. Por defecto está vacío para discapacitados. Un valor estándar para este sería esperar 2 segundos de silencio en dos ocasiones: 2000,2 + +
+
+
+ AMD envia para exten correio de voz- Este menu permite definir se uma mensagem deve ser deixada na secretária eletrônica quando é detectada. A chamada irá imediatamente ser direcionada para a extensão se o AMD estiver ativo e determinar que é uma secretária eletrônica. + +
+
+
+ Ação CPD AMD - Se você estiver usando o software de Detecção Sangoma ParaXip Call Progress então você deve habilitar esta configuração para DISPO que irá finalizar a chamada como AA e desligar se a chamada estiver sendo processada e ainda não foi enviada para um agente ou MESSAGE que irá enviar a chamada para o campo definido como Mensagem de Secretária Eletrônica para esta Campanha. O padrão é DISABLED. + +
+
+
+ Discagem para Número Alt. - Permite que um agente manualmente disque para o telefone alternativo ou campo address3 após o número principal tenha sido discado. + +
+
+
+ Segundos para derrubar chamada - Número de segundos entre o atendimento pelo cliente até a chamada ser considerada um DROP (derrubada), só se aplica a chamadas saintes. + +
+
+
+ Ação de Drop - Este menu permite que você escolha o que acontece com uma chamada quando esta ficou esperando mais que o tempo configurado no campo Tempo Limite de Drop. HANGUP irá simplesmente desligar a chamada, MESSAGE irá enviar a chamada para Extensão de Drop que você definiu abaixo, VOICEMAIL irá enviar a chamada para a caixa de voicemail que você definiu abaixo e IN_GROUP irá enviar a chamada para o grupo de entrada que você define abaixo + +
+
+
+ Exten do Porto Seguro - Esta é a extensão do plano de discagem designada para o porto seguro, deve tocar o arquivo de mensagem localizado no seu servidor. + +
+
+
+ Correio de Voz - Se configurado, as chamadas que normalmente seriam derrubadas por falta de agente, serão transferidas para esse Correio de Voz, irão ouvir uma mensagem e poderão gravar um recado. + +
+
+
+ Grupo de Transferência de Drop - Caso a Ação de Drop esteja configurada como IN_GROUP, a chamada será enviada para esse Grupo de Entrada após o tempo limite. + +
+
+
+ Permitir Logar sem Registro no Hopper - Quando Y, permite agentes logarem na campanha mesmo que não existam registros carregados no hopper para esta campanha. Esta funcionalidade não é necessária em campanha de Finalização(CLOSER). O padrão é N. + +
+
+
+ N marcado Hopper - Si esta opción está activada, la tolva no se ejecutará para esta campaña. Esta opción sólo está disponible cuando el método de línea se establece en Manual o ENTRANTE_MAN. Se recomienda que no habilite esta opción si usted tiene una base de datos de plomo muy grande, más de 100.000 clientes potenciales. Con n marcado Hopper, las características siguientes no funcionan: reciclaje de plomo, auto-alt-marcación, la mezcla lista, lista de pedido con X NEW. Si desea utilizar único dueño de marcado no debe tener marcado Hopper habilitado. Por defecto es n para discapacitados. + +
+
+
+ Único propietario de marcado - Si esta opción está activada, el agente sólo recibirá las pistas que están dentro de los parámetros de la propiedad. Si esto se establece a usuario entonces el agente debe ser definida por el usuario en la base de datos como el propietario de este lugar. Si esto se establece en territorio que entonces el dueño de la iniciativa debe coincidir con el territorio que figuran en la pantalla de modificación del usuario de este agente. Si esto se establece a USER_GROUP entonces el dueño de la iniciativa debe coincidir con el grupo de usuarios que el agente es un miembro de. Para que esta característica funcione el método de línea se debe establecer en Manual o ENTRANTE_MAN marcado Hopper y no debe estar activado. El valor predeterminado es NINGUNO para discapacitados. + + 0) + { + ?> +
+
+
+ Agente Seleccione territorios - Si esta opción está activada y el agente pertenece a al menos un territorio, el agente tendrá la opción de selección de territorios a los cables de línea. El agente podrá ver una lista de los territorios disponibles a inicio de sesión y tendrán la capacidad de volver a la lista territorio cuando se detuvo a cambiar sus territorios. Para esta función a la labor del único dueño de marcado opción debe configurarse con el territorio y territorios de usuario debe estar habilitado en la configuración del sistema. + + +
+
+
+ Ordem de Mesclagem - Sobrepõe a ordem nos campos Ordem de Registros e Status de Discagem. . + +
+
+
+ ID da Mescl. de Lista - ID da mesclagem de listas. Deve ter entre 2 e 20 caracteres de comprimento sem espaços ou pontos. + +
+
+
+ Nome da Mescl. de Lista - nombre descriptivo de la mezcla dela lista. Debe ser a partir de 2-50 caracteres en longitud. + +
+
+
+ Detalhes da Mescl. de Lista - Composição da Mesclagem de listas. Contém o ID, ordem, percentuais, e status que montam essa Mesclagem. Os percentuais devem sempre somar 100, e as listas devem estar ativas e configuradas na campanha em que a mesclagem vai ser configurada. + +
+
+
+ Método de Mesclagem - O método de Mesclagem de todos os ítens da lista. EVEN_MIX mistura os registros de cada parte intercalados com as outras partes, por exemplo: 1,2,3,1,2,3,1,2,3. IN_ORDER irá colocar os registros na ordem que estão listados na tela de detalhes 1,1,1,2,2,2,3,3,3. RANDOM irá colocar em ordem randômica: 1,3,2,1,1,3,2,1,3. O padrão é IN_ORDER. + +
+
+
+ Discagem Extendida na tela do Agente - Este recurso permite ao agente acessar a lista extendida de telefones alternativos para o registro, além dos campos Alt Phone e Address3, que podem ser usados no vicidial para números de telefone além do telefone principal do cliente. Os números extendidos podem ser discados automaticamente usando-se o recurso Auto-Alt-Dial nas config. da campanha, mas habilitar isso na tela do Agente irá permitir ao agente ligar para estes números a partir da tela e também alterar essas informações. + +
+
+
+ Primeiro Audio da Pesquisa - Este é o nome do arquivo de audio que é tocado assim que o cliente atende o telefone em uma campanha de pesquisa. + +
+
+
+ Digitos DTMF da Pesquisa - Este campo é onde você define os digitos que um cliente pode digitar como opção para campanha de pesquisa. Digitos válidos são 0123456789*#. Todas as opções, com exceção de Not Interested, Terceiro e Quarto dígito, irão mover a chamada para o método de Pesquisa(Pesquisa). + +
+
+
+ Digito de Não Interessado - Este campo é onde você define qual digito o cliente aperta para dizer que não está interessado. + +
+
+
+ Status de Não Interessado - Este campo é onde você seleciona o status a ser usado para Não Interessado. Se o DNC for usado e a campanha estiver configurada para Bloquear DNC então o número do telefone irá automaticamente para a lista de Não Ligar do VICIDIAL.e possivelmente a lista específica de bloqueio. + +
+
+
+ Arquivo de Aceito - Este é o arquivo de audio que é tocado quando o cliente aceita participar da pesquisa, não respondeu "não interessado" e não respondeu, se a opção de ação sem resposta for OPTOUT. Após esse arquivo de audio ser tocado, a ação do método de pesquisa é realizada + +
+
+
+ Arquivo de Não Interessado - Este é o nome do arquivo de audio que é tocado quando o cliente desistiu da pesquisa, não aceitou a pesquisa ou não respondeu, caso a ação para sem resposta seja OPTIN. Após este arquivo de audio ser tocado, a chamada será desligada. + +
+
+
+ Método de Pesquisa - Esta opção define o que acontece com uma chamada após o cliente ter aceitado a pesquisa. AGENT_XFER irá enviar a chamada para o próximo agente disponível. VOICEMAIL irá enviar a chamada para o voicemail especificado no campo Correio de Voz. EXTENSION irá enviar o cliente para uma extensão definida no campo Extensão de Transf. HANGUP irá desligar o cliente. CAMPREC_60_WAV irá enviar o cliente para que grave uma resposta, esta gravação ficará na pasta com o nome da campanha, dentro do diretório de gravações da Campanha de Pesquisa + +
+
+
+ Ação p/ Sem Resposta - Aqui é definido o que acontece se não há resposta para a pergunta da pesquisa. OPTIN só irá enviar a chamada para o método de pesquisa se o cliente apertar algum digito DTMF. OPTOUT irá enviar o cliente para o método mesmo que ele não pressione um dígito. + +
+
+
+ Mapa de Digitos de Resposta - Aqui você pode definir uma descrição para representar cada dígito que o cliente pode selecionar + +
+
+
+ Extensão de Transfer. - Se o método de pesquisa selecionado for EXTENSION o cliente será transferido para esta extensão do plano de discagem. + +
+
+
+ Diretório de Gravação - Se o método de pesquisa selecionado for CAMPREC_60_WAV então o cliente poderá gravar uma mensagem que será colocada no diretório com o nome da campanha, dentro deste diretório + +
+
+
+ Terceiro Dígito - Isto permite que exista um terceiro caminho se o terceiro dígito conforme definido por este campo for pressionado pelo cliente. + +
+
+
+ Quarto Dígito - Isto permite que exista um quarto caminho se o quarto digito conforme digitado neste campo for digitado pelo cliente. + +
+
+
+ Terceiro Arquivo de Audio - Este é o terceiro arquivo de audio a ser tocado assim que seja selecionado pelo cliente a terceira opção. + +
+
+
+ Terceiro Status - Este é o terceiro status usado para a chamada assim que o cliente escolhe a terceira opção. + +
+
+
+ Terceira Extensão - Esta é a terceira extensão usada pela chamada assim que é selecionada pelo cliente a terceira opção. O padrão é 8300 que imediatamente desliga a chamada após a mensagem de audio é reproduzida. + +
+
+
+ Agente de pantalla Dialable Leads - Esta opción se mostrará si está habilitado el número de derivaciones dialable disponibles en la campaña en la pantalla del agente. Este segundo número se actualiza en el sistema una vez por minuto y se actualiza en la pantalla del agente por cada par de. + + + +
+
+
+ Próximo Agente - Isto determina qual agente recebe a próxima chamada disponível: +
  - random: ordena por um número randômico de atualizações na tabela vicidial_live_agents +
  - oldest_call_start: ordena pela última vez que um agente recebeu uma chamada. Resulta nos agentes recebendo uma média igual de chamadas. +
  - oldest_call_finish: ordena pela última vez que um agente finalizou uma chamada. Também conhecido como agente que está mais tempo esperando cliente, recebe a primeira chamada. +
  - overall_user_level: ordena pelo nível do usuário do agente conforme definido na tabela vicidial_users, um valor mais alto irá receber mais chamadas. +
  - campaign_rank: ordena pelo ranking dado para o agente na campanha. Mais alto para Mais baixo. +
  - fewest_calls: ordena pelo número de chamadas recebidas por um agente para o grupo de entrada específico. Menor qtd de chamadas primeiro. +
  - longest_wait_time: pedidos por la cantidad de tiempo que el agente ha estado activamente la espera de una llamada de. + +
+
+
+ Horário de chamada local - Aqui é onde se configura o horário que se deseja discar, conforme determinação do horário no local para o qual está se discando. Isto é controlado por código de área e é ajustado para o horário de verão caso esteja em vigor. A recomendação para os EUA é de empresa para empresa, das 9:00 as 17:00 e da empresa para consumidor, das 9:00 as 21:00. + +
+
+
+ Prefixo de Discagem - Este campo permite que facilmente configuremos o caminho de discagem sem precisar alteração de configurações de servidor e sem precisar recarregar o Asterisk. O padrão é 9 baseado em 91NXXNXXXXXX no plano de discagem - extensions.conf. + +
+
+
+ Omitir o Código do Telefone - Este campo permite que você deixe o campo código do telefone de fora quando discando pelo VICIDIAL. Por exemplo se você estiver discando dentro do Reino Unido você teria 44 como seu código do telefone nos registros, mas você só quer discar 10 digitos no seu plano de discagem para fazer a chamada, ao invés de 44 mais 10 digitos. Padrão é N. + +
+
+
+ CallerID da Campanha- Este campo permite que seja enviado um número customizado de CallerID nas chamadas saintes. Este número irá ser mostrado no Identificador da pessoa que você está chamando. O padrão é UNKNOWN. Se você está usando T1 ou E1 para discar esta opção está disponível apenas se estiver usando PRIs - ISDN T1 ou E1 - que tenham o recurso de customizar o callerID habilitados, isso nao irá funcionar em circuitos RBS (Robbed-bit Service). Isto também funciona na maioria dos provedores SIP ou IAX que permitem customizar callerID. O callerID customizado se aplica apenas a chamadas feitas por campanhas VICIDIAL diretamente, qualquer chamadas de terceiros ou transferências nao receberá o callerID customizado. ATENÇÃO: algumas vezes colocando-se UNKNOWN ou PRIVATE neste campo pode causar que seja enviado o callerID da sua operadora. Você pode testar isso colocando 00000000000 no campo callerid se você nao quer enviar seu CallerID . + +
+
+
+ Extensão de Gravação - Este campo permite que se use uma extensão de gravação customizada com o VICIDIAL. Isto permite que sejas usadas extensões diferentes dependendo de quanto tempo máximo você quer permitir uma gravação e que tipo de codec você quer usar. A extensão padrão é 8309 a qual, se você seguiu os exemplos do SCRATCH_INSTALL irá gravar as chamadas no formato WAV até uma hora. Outra opção incluida nos exemplos é 8310 que irá gravar no formato GSM até uma hora. + +
+
+
+ Gravação da Campanha - Este menu permite que você escolha o nível de gravação permitido para esta campanha. NEVER irá desabilitar a gravação no client. ONDEMAND é o padrão e permite ao agente iniciar e parar a gravação conforme necessário. ALLCALLS irá iniciar a gravação assim que uma chamada for enviada para o client. ALLFORCE irá iniciar gravação no client assim que uma chamada for enviada ao agente e não dando opção ao agente de parar a gravação. Para ALLCALLS e ALLFORCE existe uma opção para usar o atraso de gravação para evitar gravações curtas e reduzir carga no servidor. + +
+
+
+ Nome do Arquivo de Gravação - Este campo permite que seja customizado o nome do arquivo de gravação quando a configuração de gravação da campanha esteja em ONDEMAND ou ALLCALLS. As variáveis permitidas sao CAMPANHA CUSTPHONE FULLDATE TINYDATE EPOCH AGENT. O padrão é FULLDATE_AGENTE e se parece assim: 20051020-103108-6666. Outro exemplo é CAMPANHA_TINYDATE_CUSTPHONE que se parece assim: TESTCAMP_51020103108_312551212. 50 char max. + +
+
+
+ Atraso de Gravação - Somente para gravações ALLCALLS e ALLFORCE. Esta configuração irá atrasar a gravação da chamada o tempo em segundos especificado no campo. O padrão é 0. + +
+
+
+ Script da Campanha - Este menu permite que seja escolhido um script que irá aparecer na tela do agente para essa campanha. Selecione NONE para não mostrar scripts para esta campanha. + +
+
+
+ Abrir com Chamada - Este menu permite que seja escolhido se você deseja abrir automaticamente a pagina web em uma janela separada, abrir a aba SCRIPT ou nao fazer nada quando uma chamada é enviada ao agente para esta campanha. + +
+
+
+ Xfer-Conf DTMF - Estos cuatro campos permiten que usted tenga dos conjuntos de transferencia de la Conferencia y presets DTMF. Cuando se carga la llamada o de la campaña, la secuencia de comandos vicidial.php mostrará dos botones en el marco de la transferencia de conferencias y rellenará de forma automática el número a marcar y el enviar los campos DTMF cuando se presiona. Si desea permitir Consultivo transferencias, un Fronter a una mayor, que el agente utiliza la casilla de consulta, que no funciona por falta de terceros Vicidial llamadas de consulta. Para aquellos que sólo tienen el agente, haga clic en el dial con el botón del cliente. Entonces, el agente puede dejar-3way-CALL y pasar a la siguiente llamada. Si desea permitir la transferencia ciega de los clientes a una secuencia de comandos AGI Vicidial para el registro o un IVR, a continuación, AXFER lugar en el número a marcar el terreno. También puede especificar una extensión personalizada después de la AXFER, por ejemplo, si usted quiere hacer una llamada a un IVR especiales que se han fijado a la extensión 83900 pondrías AXFER83900 en el número a marcar el terreno. + +
+
+
+ Rápida transferencia Button - Esta opción agrega un botón de la transferencia rápida a la pantalla por debajo de la agente de transferencia de botón Conf. que permitirá la transferencia de un solo clic ciego de llamadas a los seleccionados en Grupo o un número. IN_GROUP enviará pide al Grupo de Xfer predeterminado para esta campaña, o en grupo-si hay una llamada entrante. Las opciones predeterminadas enviará las llamadas a los preset seleccionado. Por defecto es n para discapacitados. + +
+
+
+ Transferencia de rellenar previamente Preset - Esta opción le proporcione el número telefónico al campo en el marco de la Conferencia de transferencia de la pantalla si el agente definido. Por defecto es n para discapacitados. + +
+
+
+ Temporizador de Acción de - Esta característica le permite activar acciones después de una cierta cantidad de tiempo. D1 y D2 opciones de marcación lanzará un llamamiento a la transferencia de presets Conferencia Número y enviarlos a la sesión del agente, éste se utiliza generalmente para aplicaciones sencillas de validación IVR AGI o simplemente para jugar un mensaje pregrabado. WebForm se abrirá la dirección de formulario web. MESSAGE_ONLY simplemente mostrará el mensaje de que está en el campo de abajo. Ninguna de ellas podrá deshabilitar esta característica y es el predeterminado. + +
+
+
+ Temporizador de mensaje de acción - Este es el mensaje que aparece en la pantalla del agente en el momento de la acción del temporizador se dispara. + +
+
+
+ Temporizador Segundos Acción - Esta es la cantidad de tiempo después de la llamada se conecta a los clientes que se desencadena la acción del temporizador. El valor predeterminado es -1, que también está inactivo. + +
+
+
+ Chamadas Agendadas - Permite um agente classificar uma chamada como CALLBK e escolher uma data e hora na qual deseja que o registro seja discado. + +
+
+
+ Segundos de Pós Atendimento - Quantidade de segundos para forçar o agente esperar antes de permitir que ele receba ou faça outra chamada. O timer inicia assim que o agente desliga a chamada com o cliente, ou em caso de chamada a número alternativo, quando termina o trabalho com um registro. Valor padrão é 0 segundos. Se o timer acabar antes que o agente tenha finalizado a chamada, o agente não receberá novo registro até que finalize o atual. + +
+
+
+ Mensagem de Pós Atendimento - É uma mensagem específica da campanha a ser mostrada na tela de pós atendimento se o tempo de pós atendimento for configurado. + +
+
+
+ Usar Lista de Bloqueio Interna - Define se esta campanha deve filtrar registros levando em conta a lista de bloqueio interna. Se estiver configurada como Y, o hopper irá procurar cada número na lista de bloqueio antes de carregar. Se o número estiver na lista de bloqueio, o registro de chamada será alterado para o status DNCL assim não será chamado. Padrão é N. La opción codigoDeArea es como la opción-y, excepto que se utiliza para filtrar también un código de área en toda América del Norte desde que se está marcando, en este caso mediante la entrada en la lista 201XXXXXXX DNC podría bloquear todas las llamadas a los 201 codigoDeArea si está habilitada. + +
+
+
+ Usar Lista de Bloqueio - Este recurso define se a campanha deve filtrar registros usando a lista de Bloqueio que é específica para esta campanha. Se configurado como Y, o hopper irá procurar cada número na lista específica de Bloqueio antes de colocar o número na lista do hopper. Se estiver em uma lista específica de Bloqueio, então ele irá alterar o status do registro para DNCC para que este registro não seja discado. O padrão é N La opción codigoDeArea es como la opción-y, excepto que se utiliza para filtrar también un código de área en toda América del Norte desde que se está marcando, en este caso mediante la entrada en la lista 201XXXXXXX DNC podría bloquear todas las llamadas a los 201 codigoDeArea si está habilitada. + +
+
+
+ Grupos De entrada Permitidos - For CLOSER campaigns only. Here is where you select the inbound groups you want agents in this CLOSER campaign to be able to take calls from. It is important for BLENDED inbound-outbound campaigns only to select the inbound groups that are used for agents in this campaign. The calls coming into the inbound groups selected here will be counted as active calls for a blended campaign even if all agents in the campaign are not logged in to receive calls from all of those selected inbound groups. + +
+
+
+ Códigos de Pausa do Agente Ativos - Permite aos agentes selecionar códigos de pausa quando eles clicam o botão pausa no vicidial.php. Códigos de pausa são definidos por campanha no final da página de detalhes da campanha e são guardados na tabela vicidial_agent_log. O padrão é N. FORCE irá forçar o agente escolher um código de pausa se eles clicar no botão pausa. + +
+
+
+ Desabilitar Alteração nos Dados do Cliente - Quando configurada como Y, não permite ao usuário alterar registros de cliente quando o Agente finaliza a chamada. O padrão é N. + +
+
+
+ Desab. Alterar Telefone do Cliente - Se configurado como Y, não altera o telefone do cliente quando um agente finaliza a chamada. O padrão é Y. Utilice la opción Ocultar para eliminar completamente el número de teléfono del cliente de la pantalla del agente de. + +
+
+
+ Mostrar Contagem da Fila ao Agente - Quando configurada como Y, quando um cliente está esperando um agente, será demonstrado na tela do agente a quantidade de clientes em espera. O padrão é Y. + +
+
+
+ ID da Lista Manual - O list_id padrão para ser usado quando um agente faz uma chamada manual e novos registros são criados na vicidial_list. O padrão é 999. O campo pode receber somente digitos. + +
+
+
+ Filtro de Discagem Manual - Permite que você filtre as chamadas que os agentes fazem no modo manual de discagem para esta campanha por uma combinação dos seguintes: DNC - para tirar, CAMPANHALISTAS - o número deve estar nas lístas para a campanha, NONE - sem filtros na discagem manual ou lista de discagem rápida . + +
+
+
+ Cópia p/ Área de Transf. do Agente - ESTE RECURSO SÓ FUNCIONA NO INTERNET EXPLORER. Este recurso permite que você escolha um campo que será copiado para a área de transferência do agente quando uma chamada é enviada ao agente. Um uso comum para este recurso é permitir fácil uso do comando "colar" para números do cliente ou números de telefone em aplicativos cliente no computador do agente. + +
+
+
+ CallerID de Chamada a 3 - Isso define o que é enviado como número do CallerID em chamadas a 3 realizadas pelo agente. CAMPANHA usa o CallerID customizado da campanha, CUSTOMER usa o número do cliente que está ativo na tela do agente e AGENT_PHONE usa o callerID do ramal que o agente está logado. AGENT_CHOOSE permite que o agente escolha qual CallerID usar em chamadas a 3 a partir de uma lista de opções + +
+
+
+ Prefixo para Chamadas a 3 - Isso define o que será usado como prefixo de discagem nas chamadas a 3, o padrão é vazio, então o prefixo da campanha é usado, uma alternativa para se ouvir tocar é 88. + + 0) + { + ?> +
+
+
+ CQ Ativado - Configurando este campo como Y permite que os recursos de Controle de Qualidade do agente funcionem. O padrão é N. + +
+
+
+ Status de CQ - Esta área é onde você escolhe quais status de registro devem passar pelo Controle de Qualidade. Selecione o status que você quer que o CQ revise. + +
+
+
+ Turno de CQ- Este é o controle de tempo usado para trazer registros de uma campanha para o CQ. Os dias da semana são ignorados para esta função. + +
+
+
+ Entrada do Registro de CQ - Isso permite uma das seguintes ações a ser ativada na entrada de um registro de CQ para um agente. + +
+
+
+ Mostrar Gravação do CQ - Permite que uma gravação que está ligada com o registro do CQ seja mostrada na tela do agente de CQ. + +
+
+
+ Endereço WebForm de CQ - Este é o endereço do websitem que o agente de CQ pode entrar quando clicar no botão WEBFORM na tela de CQ. + +
+
+
+ Script CQ - Este é o Script que pode ser usado pelos agentes de CQ na aba SCRIPT na tela de CQ. + + +
+
+
+ Categoria de Pesquisa Vtiger- Se a integração do Vtiger estiver habilitada no sistema então esta configuração irá definir onde a página vtiger_search.php irá pesquisar o número do telefone que foi digitado. Existem 4 opções que podem ser usadas nesse campo: LEAD- Esta opção irá pesquisar apenas nos registros do Vtiger, ACCOUNT- Esta opção irá pesquisar nas contas do Vtiger e todos os contatos e sub-contatos para o número do telefone, VENDOR- Esta opção irá apenas pesquisar nos vendedores do Vtiger, ACCTID- Esta opção funciona somente para contas e irá pegar o campo vendor_lead_code no vicidial e tentará procurar no ID da conta do Vtiger. Se nao tiver sucesso irá tentar outros métodos listados que você selecionou. Múltiplas opções podem ser usadas para pesquisa, mas em bases de dados grandes não é recomendado. O padrão é LEAD. UNIFIED_CONTACT-Esta opción se utiliza la versión beta 5.1.0 Vtiger función para buscar por número de teléfono y acceder a la página de búsqueda en Vtiger. + +
+
+
+ Pesquisar contas Mortas no Vtiger - Se a integração com o Vtiger estiver habilitada nas confifurações do sistema então esta configuração define se contas apagadas serão pesquisadas quando o agente clica em WEB FORM para procurar no sistema Vtiger. DISABLED- registros apagados não serão pesquisados, ASK- registros apagados serão pesquisados e a página de pesquisa do vtiger irá perguntar ao agente se ele quer ativar a conta no Vtiger, RESURRECT- irá automaticamente ativar a conta e levar o agente para a tela da conta sem atrasos após clicar em WEB FORM. O padrão é DISABLED. + +
+
+
+ Vtiger Cria Registro de Chamada - Se a integração com Vtiger estiver habilitada, esta configuração define se um registro de atividade do Vtiger é gravado quando o agente entra na página de pesquisa do vtiger (vtiger_search). O padrão é Y. A opção DISPO irá criar um registro de chamada para a conta Vtiger sem que o agente precise ir para a página da conta no Vtiger através do botão WEB FORM. + +
+
+
+ Criar Registro de Tel. no Vtiger- Se a integração com o Vtiger estiver habilitada no sistema e a Categoria de Pesquisa no Vtiger incluir LEAD, esta configuração define se um novo registro da chamada do Vtiger é criado quando o agente entra na página de pesquisa do vtiger e o registro não é encontrado para que se tenha um número de telefone. O padrão é Y. + +
+
+
+ Tela de Login do Vtiger - Se a integração do Vtiger estiver habilitada então esta configuração irá definir se o usuário será logado automaticamente na interface do Vtiger quando entra no VICIDIAL. O padrão é Y. A opção NEW_WINDOW irá abrir uma nova janela ao efetuar login na tela do agente do VICIDIAL. + +
+
+
+ Status da Chamada no Vtiger - Se a integração com o Vtiger estiver habilitada nas configurações do sistema então esta configuração irá definir se o status da conta no Vtiger irá ser atualizada com o status da chamada no VICIDIAL depois que ela foi finalizada. O padrão é N. + +
+
+
+ CRM Popup Login - Si se establece en Y, la Dirección de Popup CRM se utiliza para abrir una nueva ventana de inicio de sesión agente a esta campaña. Por defecto es n. + +
+
+
+ CRM Dirección Popup - La dirección en Internet de una página de acceso de CRM, puede tener las variables de población como la dirección de formulario web, con el VAR en el frente y con la opción - A - user_custom_one - B - para definir variables. + +
+
+
+ Iniciar llamada URL - Esta web dirección URL no es visto por el agente, sino que es llamado cada vez que una llamada se envía a un agente si se poblaron. Utiliza las mismas variables que los campos de formulario web y scripts. Esta URL no puede ser una ruta relativa. La URL de inicio no funciona para las llamadas de marcación manual. Por defecto está en blanco. + +
+
+
+ Dispo Call URL - Esta web dirección URL no es visto por el agente, sino que es llamado cada vez que una llamada es dispositioned por un agente, si se poblaron. Utiliza las mismas variables que los campos de formulario web y scripts. dispo y talk_time son las variables que puede utilizar para recuperar el agente definido por la disposición de la llamada y el tiempo de conversación real en segundos de la llamada. Esta URL no puede ser una ruta relativa. Por defecto está en blanco. + +
+
+
+ Alias de Grupo Permitidas - Se você quer permitir seus agentes a usarem alias de grupo então você deve configurar como Y. Alias de grupo são explicados melhor na seção Admin, eles permitem que os agentes usem CallerIDs diferentes para chamadas manuais que realizam. O padrão é N. + +
+
+
+ Alias de Grupo Padrão - Se você permitiu Alias de Grupo então este é o alias de grupo que será selecionado como padrão quando o agente escolhe usar um alias de grupo em uma chamada manual. O padrão é NONE ou vazio. + +
+
+
+ Agente Pide Ver en cola - Si se pone a nada, pero NINGUNO, los agentes podrán consultar los detalles de las llamadas que están esperando en la cola en la pantalla de su agente. Si se establece en un valor de número, las llamadas que aparecerá será limitada al número seleccionado. El valor predeterminado es NINGUNO. + +
+
+
+ Ver las llamadas en cola de lanzamiento - Este ajuste, si en AUTO tendrá las convocatorias en el marco de la cola aparecen en inicio de sesión por el agente en la pantalla del agente. El valor predeterminado es MANUAL. + +
+
+
+ Agente Pide Agarre en cola - Esta opción si se define Y permitirá que el agente para seleccionar la llamada que desea tomar de las llamadas en la pantalla de la cola haciendo clic en él durante la pausa. Los agentes sólo podrán coger las llamadas entrantes o las llamadas transferidas, las llamadas no de salida. Por defecto es n. + +
+
+
+ Agente de Call Re-Cola Button - Esta opción si se define Y agregará un botón Re-cliente de la cola a la pantalla del agente, permite a las agencias para enviar la llamada en una cola de AGENTDIRECT que está reservado para el único agente. Por defecto es n. + +
+
+
+ Agente de pausa después de cada llamada - Esta opción si se define como Y hará una pausa en el agente después de cada llamada automáticamente. Por defecto es n. + + + + + +



+ + VICIDIAL_LISTAS TABELA

+
+
+ ID da Lista - Este é o nome numérico da lista, não é editável após a confirmação do cadastro, deve conter somente numeros e deve ter entre 2 e 8 caracteres de comprimento. Must be a number greater than 100. + +
+
+
+ Nome da Lista - Esta é a descrição da lista, deve ter entre 2 e 20 caracteres de comprimento. + +
+
+
+ Descrição da List - É um campo texto para descrião da lista, é opicional. + +
+
+
+ Data de Alteração da Lista - Esta é a última vez que as configurações da lista foram modificadas. + +
+
+
+ Data da Última Chamada da Lista - É a data em que o último registro da lista foi discado. + +
+
+
+ Campanha - Este é a campanha que esta lista pertence. Uma lista só pode ser discada por uma campanha de cada vez. + +
+
+
+ Ativo - Indica se a lista é para ser discada ou não. + +
+
+
+ Zerar Status de chamada dos registros desta lista - Zera todos os registros desta lista colocando N para \"not called since last reset"\ e significa que qualquer registro pode ser discado agora se for do status conforme configurado na tela da campanha. + +
+
+
+ Perdí Times - Este campo le permite poner veces, separados por un guión, que esta lista se restablece automáticamente por el sistema. Los tiempos deben estar en formato de 24 horas sin puntuacion, por ejemplo 0800-1700 se restablecer la lista de las 8 AM y las 5 PM todos los días. Por defecto está vacío. + +
+
+
+ Agente de secuencias de comandos Reemplazar - Si se establece este campo, esta será la secuencia de comandos que el agente ve en su pantalla en lugar de la secuencia de comandos de campaña cuando la ventaja es de esta lista. Por defecto no se establece. + +
+
+
+ Campaña CID Override - Si se establece este campo, que reemplazarán la campaña CallerID que se establece para las llamadas que se colocan a la cabeza en esta lista. Por defecto no se establece. + +
+
+
+ Contestador automático de mensajes Override - Si se establece este campo, esto anulará el mensaje de contestador automático situado en la campaña para los clientes en esta lista. Por defecto no se establece. +
+
+
+ Drop de entrada Grupo de Override - Si se establece este campo, en este grupo se utilizará para las llamadas salientes dentro de esta lista que la caída de la campaña de salida en lugar de la caída en grupo situado en la pantalla de detalle de la campaña. Por defecto no se establece. + +
+
+
+ Xfer-Conf Número Override - Estos cinco campos permiten reemplazar la transferencia de presets Conferencia número cuando la iniciativa es de esta lista. Por defecto está en blanco. + + +
+
+
+ Lista de Bloqueio do VICIDIAL - Esta lista de bloqueio contém cada registro que foi enviado para um status de Não Ligar no sistema. Através da página: LISTAS - INCLUIR BLOQUEIO você pode manualmente adicionar números para esta lista para que não sejam ligados por campanhas que usam a lista de bloqueio interna. Existe também a opção de incluir registros em listas de bloqueio específicas de campanhas. Si usted tiene la opción de DNC activas de codigoDeArea a continuación, usted también puede usar el código de entradas de la zona este 201XXXXXXX como comodín para bloquear todas las llamadas a los 201 codigoDeArea cuando está activado. + + + +



+ + VICIDIAL_ENTRANTE_GROUPS TABELA

+
+
+ ID do Grupo - Nome curto do grupo de entrada, não é editável após confirmação, não deve conter qualquer espaços e deve ter entre 2 e 20 caracteres de comprimento. + +
+
+
+ Nome do Grupo - Descrição do grupo, deve ter entre 2 e 30 caracteres de comprimento. Não pode incluir os caracteres - + ou espaço . + +
+
+
+ Cor do Grupo - Cor mostrada no aplicativo client do VICIDIAL quando uma chamada entra para este grupo. Deve ser entre 2 e 7 caracteres de comprimento. Se for uma definição de cor em hexadecimal, você deve lembrar de colocar o # no começo ou o VICIDIAL não vai funcionar corretamente. + +
+
+
+ Ativo - Indica se o grupo será mostrado na caixa de seleção quando o agente do VICIDIAL efetua logon . + +
+
+
+ Formulário Web - Endereço customizado para o qual o botão WEB FORM no VICIDIAL leva quando clicado, nas chamadas que entram para este grupo. + +
+
+
+ Próximo Agente - Isto determina qual agente recebe a próxima chamada disponível: +
  - random: ordena por um número randômico de atualizações na tabela vicidial_live_agents +
  - oldest_call_start: ordena pela última vez que um agente recebeu uma chamada. Resulta nos agentes recebendo uma média igual de chamadas. +
  - oldest_call_finish: ordena pela última vez que um agente finalizou uma chamada. Também conhecido como agente que está mais tempo esperando cliente, recebe a primeira chamada. +
  - overall_user_level: ordena pelo nível do usuário do agente conforme definido na tabela vicidial_users, um valor mais alto irá receber mais chamadas. +
  - inbound_group_rank: ordena pelo ranking dado para um agente para um grupo de entrada. Do mais alto para o mais baixo. +
  - fewest_calls: ordena pelo número de chamadas recebidas por um agente para o grupo de entrada específico. Menor qtd de chamadas primeiro. +
  - campaign_rank: ordena pelo ranking dado para o agente na campanha. Mais alto para Mais baixo. +
  - fewest_calls_campaign: orders by the number of calls received by an agent for the campaign. Least calls first. +
  - longest_wait_time: pedidos por la cantidad de tiempo que el agente ha estado activamente la espera de una llamada de. +
+ +
+
+
+ Queue Priority - This setting is used to define the order in which the calls from this inbound group should be answered in relation to calls from other inbound groups. + +
+
+ Exibição do Primário - Este campo determina se uma chamada entrante para o agente VICIDIAL deve ter o nome do agente primário, se existir, exibido no campo status da tela quando uma chamada é transferida para o agente. + +
+
+
+ Script da Campanha - Este menu permite que seja escolhido um script que irá aparecer na tela do agente para essa campanha. Selecione NONE para não mostrar scripts para esta campanha. + +
+
+
+ Abrir com Chamada - Este menu permite que seja escolhido se você deseja abrir automaticamente a pagina web em uma janela separada, abrir a aba SCRIPT ou nao fazer nada quando uma chamada é enviada ao agente para esta campanha. + +
+
+
+ Xfer-Conf DTMF - Estos cuatro campos permiten que usted tenga dos conjuntos de transferencia de la Conferencia y presets DTMF. Cuando se carga la llamada o de la campaña, la secuencia de comandos vicidial.php mostrará dos botones en el marco de la transferencia de conferencias y rellenará de forma automática el número a marcar y el enviar los campos DTMF cuando se presiona. Si desea permitir Consultivo transferencias, un Fronter a una mayor, que el agente utiliza la casilla de consulta, que no funciona por falta de terceros Vicidial llamadas de consulta. Para aquellos que sólo tienen el agente, haga clic en el dial con el botón del cliente. Entonces, el agente puede dejar-3way-CALL y pasar a la siguiente llamada. Si desea permitir la transferencia ciega de los clientes a una secuencia de comandos AGI Vicidial para el registro o un IVR, a continuación, AXFER lugar en el número a marcar el terreno. También puede especificar una extensión personalizada después de la AXFER, por ejemplo, si usted quiere hacer una llamada a un IVR especiales que se han fijado a la extensión 83900 pondrías AXFER83900 en el número a marcar el terreno. + +
+
+
+ Temporizador de Acción de - Esta característica le permite activar acciones después de una cierta cantidad de tiempo. D1 y D2 opciones de marcación lanzará un llamamiento a la transferencia de presets Conferencia Número y enviarlos a la sesión del agente, éste se utiliza generalmente para aplicaciones sencillas de validación IVR AGI o simplemente para jugar un mensaje pregrabado. WebForm se abrirá la dirección de formulario web. MESSAGE_ONLY simplemente mostrará el mensaje de que está en el campo de abajo. Ninguna de ellas podrá deshabilitar esta característica y es el predeterminado. Esta configuración anula la configuración de la campaña. + +
+
+
+ Temporizador de mensaje de acción - Este es el mensaje que aparece en la pantalla del agente en el momento de la acción del temporizador se dispara. + +
+
+
+ Temporizador Segundos Acción - Esta es la cantidad de tiempo después de la llamada se conecta a los clientes que se desencadena la acción del temporizador. El valor predeterminado es -1, que también está inactivo. + +
+
+
+ Tempo Limite de Drop- O número em segundos que uma chamada deve ficar na fila de espera até ser considerada um DROP. + +
+
+
+ Ação de Drop - Este menu permite que você escolha o que acontece com uma chamada quando esta ficou esperando mais que o tempo configurado no campo Tempo Limite de Drop. HANGUP irá simplesmente desligar a chamada, MESSAGE irá enviar a chamada para Extensão de Drop que você definiu abaixo, VOICEMAIL irá enviar a chamada para a caixa de voicemail que você definiu abaixo e IN_GROUP irá enviar a chamada para o grupo de entrada que você define abaixo. + +
+
+
+ Extensão de Drop - Se a Ação de Drop estiver configurada como MESSAGE, este é o número do plano de discagem a ser discado para transferir a chamada após o tempo limite de drop. + +
+
+
+ Correio de Voz - If Drop Action is set to VOICEMAIL, the call DROP would instead be directed to this voicemail box to hear and leave a message. + +
+
+
+ Grupo de Transferência de Drop - Caso a Ação de Drop esteja configurada como IN_GROUP, a chamada será enviada para esse Grupo de Entrada após o tempo limite. + +
+
+
+ Horário de Chamada É a configuração do horário de chamada para ser usado neste grupo de entrada. Lembre-se que o horário é baseado no horário do servidor. Padrão é 24Horas. + +
+
+
+ Ação Fora do Expediente - A ação a ser realizada se o horário for fora do definido no horário de chamada para este grupo de entrada. HANGUP irá imediatamente desligar a chamada, MESSAGE irá tocar o arquivo no campo Arquivo de Mensagem Fora de Expediente, EXTENSION irá enviar a chamada para o extensão do campo Extensão Fora do Expediente no plano de discagem e VOICEMAIL irá enviar a chamada para a caixa de voicemail listada no campo de Correio de Voz Fora do Expediente, IN_GROUP irá enviar a chamada para o grupo de entrada selecionado na lista Grupo de Entrada Fora do Expediente. Padrão é MESSAGE. + +
+
+
+ Arquivo Fora do Expediente - O arquivo de audio localizado no servidor, que deve ser tocado quando a ação estiver configurada como MESSAGE. Padrão é vm-goodbye + +
+
+
+ Extensão Fora do Expediente - Extensão a ser enviada a chamada que entrar se o campo Ação estiver como EXTENSION. O padrão é 8300. + +
+
+
+ Correio de Voz Fora do Expediente- A caixa de VoiceMail a ser enviada a chamada, quando o campo Ação for VOICEMAIL. + +
+
+
+ Grupo de Transferência Fora do Expediente- Se a Ação de Fora do Expediente estiver configurada para IN_GROUP, a chamada irá ser enviada para esse grupo de entrada se ela entrar neste grupo de entrada fora do horário configurado no Horário de Chamadas para este grupo de entrada. + +
+
+
+ N de colas n Agentes - Si este campo está establecido en Y o NO_PAUSED entonces no se pide se pondrá en la cola de este grupo en si no hay agentes conectado y las llamadas se vaya a la agente n Ninguna acción de la cola. La opción NO_PAUSED no se envían también las personas que llaman a la cola si sólo hay una pausa en los agentes en el grupo. Por defecto es n. + +
+
+
+ No No Acción cola de agente - Si está activada ninguna cola Ningún Agente, entonces este campo se define en la llamada pasará si no hay agentes en la A-Group. Por defecto es el mensaje, este reproduce los archivos de sonido en el campo el valor de acción y luego cuelga el. + +
+
+
+ No hay ninguna cola Acción Agente Valor - Este es el valor de la acción anterior. El valor predeterminado es nbdy-avail-to-take-call|vm-goodbye. + +
+
+
+ Arquivo de Mensagem Boasvindas - Arquivo de audio localizado no servidor a ser tocado quando uma chamada entra. Se estiver configurado como ---NONE--- então nenhuma mensagem irá ser tocada. O padrão é ---NONE---. Este campo como con los otros campos de audio en In-grupos, con la excepción del nombre de archivo de alerta de agente, puede tener múltiples archivos de audio reproducido si se pone un tubo de lista separada de los archivos de audio en el campo. + +
+
+
+ Tocar Mensagem de Boas Vindas - Esta configuração seleciona quando tocar mensagens de boas vindas, ALWAYS irá tocar toda vez, NEVER nunca irá tocar, IF_WAIT_ONLY irá somente tocar a mensagem se a chamada não for diretamente para o agente, e YES_UNLESS_NODELAY irá sempre tocar a mensagem a não ser que a configuração de Sem Atraso estiver habilitada. O padrão é ALWAYS. + +
+
+
+ Contexto da Música de Espera- O contexto de Música de Espera a ser usado quando o cliente é colocado em espera. O padrão é default. + +
+
+
+ Arquivo de Mensagem de Espera - Arquivo de audio localizado no servidor a ser tocado em um intervalo regular quando o cliente está em espera. O padrão é generic_hold. Este arquivo de audio deve ter até 9 segundos + +
+
+
+ Intervalo de Anúncio - O tempo em segundos para esperar até tocar a mensagem de Espera. O padrão é 60. Para desabilitar a Mensagem em Espera, configuro o intervalo como 0. + +
+
+
+ Tocar Posição na Fila - Isto define se o cliente irá ouvir seu lugar na fila de atendimento quando entram na fila e também periodicamente. O padrão é N. + +
+
+
+ Tocar Tempo Estimado - Isto define se o cliente irá ouvir o tempo estimado de espera antes de ser transferido para um agente. O padrão é N. Se o cliente está em espera e ouve o tempo estimado de atendimento, o tempo mínimo que será tocado é de 15 segundos. + +
+
+
+ Opção de Tempo de Espera - Permite que você especifique uma rota para a chamada caso o tempo de espera esteja superior a quantidade de segundos configurada abaixo. O padrão é NONE. + +
+
+
+ Tempo de Opção de Espera - Se a opção de tempo de espera estiver configurado para um valor diferente de NONE, este número em segundos de tempo estimado de atendimento irá acionar esta opção de espera. O padrão é 360 segundos. + +
+
+
+ Extensão de Opção de Tempo - Se a Opção de Tempo de Espera estiver como EXTENSION, esta extensão do plano de discagem será usada para enviar a chamada quando o tempo de espera superar a configuração de tempo de espera. + +
+
+
+ VoiceMail da Opção de Espera - Se a Opção de Espera estiver como VOICEMAIL, esta é a caixa de voicemail que a chamada será direcionada, caso o tempo de espera exceda o tempo configurado na opção de tempo. + +
+
+
+ Gr. de Entr. da Opção de Espera - Se a Opção de Espera for IN_GROUP, este grupo de entrada será usado para transferir a chamada que entrar e o tempo de espera estimado for maior que o tempo da opção.. + +
+
+
+ Arquivo de Agendamento da Espera - Se a configuração de Opção de Tempo de Espera estiver como CALLERID_CALLBACK, esse arquivo será tocado e então a chamada será considerada com status de novo para a lista abaixo se o tempo estimado de espera exceder o tempo configurado. + +
+
+
+ ID da Lista de Agendamento de Espera - Se a Opção de Tempo de Espera estiver como CALLERID_CALLBACK, esta é a ID da lista na qual a chamada é adicionada como novo registro caso o tempo de chamada exceda o tempo definido na configuração . + +
+
+
+ Agente de Alerta Nombre de archivo - El archivo de audio a jugar a un agente de anunciar que una llamada está llegando a su agente. Para no utilizar esta función establezca este valor por defecto es a X. Ding. + +
+
+
+ Atraso de Alerta ao Agente - O tempo em milisegundos para esperar antes de enviar a chamada para o agente após tocar na extensão do agente. O padrão é 1000. + +
+
+
+ Grupo de Transf. Padrão - Este campo é o Grupo de Entrada padrão que será automaticamente selecionado quando um agente seleciona transferência-conferência na tela do agente. + +
+
+
+ Sobreposição de Gravação de Entrada - Este campo permite a sobreposição da configuração da gravação na campanha. Esta configuração pode ser sobreposta pela configuração de sobreposição de gravação do usuário. DISABLED não irá sobrepor a configuração da campanha. NEVER irá desabilitar a gravação no client. ONDEMAND é o padrão e permite ao agente iniciar e finalizar a gravação conforme necessário. ALLCALLS irá iniciar a gravação no client quando uma chamada é enviada ao agente. ALLFORCE irá iniciar gravação no client sempre que uma ligação é enviada ao agente sem dar opção ao agente de parar a gravação. + +
+
+
+ Nome do Arquivo de Gravação de Entrada- Este campo irá sobrepor o perfil de nome de arquivo de gravação da campanha, a não ser que esteja configurado como NONE. As variáveis permitidas são: CAMPANHA CUSTPHONE FULLDATE TINYDATE EPOCH AGENT. O padrão é FULLDATE_AGENTE e irá ficar assim: 20051020-103108_6666. Outro exemplo é CAMPANHA_TINYDATE_CUSTPHONE que irá ficar assim: TESTCAMP_51020103108_3125551212. 50 caracteres no máximo. Padrão é NONE. + + 0) + { + ?> +
+
+
+ CQ Ativado - Configurando este campo como Y permite que os recursos de Controle de Qualidade do agente funcionem. O padrão é N. + +
+
+
+ Status de CQ - Esta área é onde você escolhe quais status de registro devem passar pelo Controle de Qualidade. Selecione o status que você quer que o CQ revise. + +
+
+
+ Turno de CQ - Este é o turno usado pelo CQ para trazer registros de CQ para um grupo de entrada. Os dias da semana são ignorados para estas funções. + +
+
+
+ Entrada do Registro de CQ - Isso permite uma das seguintes ações a ser ativada na entrada de um registro de CQ para um agente. + +
+
+
+ Mostrar Gravação do CQ - Permite que uma gravação que está ligada com o registro do CQ seja mostrada na tela do agente de CQ. + +
+
+
+ Endereço WebForm de CQ - Este é o endereço do websitem que o agente de CQ pode entrar quando clicar no botão WEBFORM na tela de CQ. + +
+
+
+ Script CQ - Este é o Script que pode ser usado pelos agentes de CQ na aba SCRIPT na tela de CQ. + + +
+
+
+ Grupo de Rechamada de Espera- Se um cliente liga de volta para este grupo de entrada mais de uma vez e esta config. estiver como NONE, então a chamada é automaticamente desviada para o Grupo de Entrada selecionado neste campo. O padrão é NONE. + +
+
+
+ Rotear Sem Atraso - Configurando como Y irá remover qualquer tempo de espera ou anuncios de audio e irá tentar enviar a chamada direto para o agente. Não sobrepõe mensagem de boas vindas e anuncios da fila de espera. O padrão é N. + +
+
+
+ Percentual Estatístico de Chamadas Atendidas em X seg - Este campo permite você configurar o número de segundos que a tela de estatísticas em tempo real demorará para calcular o percentual de chamadas atendidas que foram atendidas antes de X segundos em espera. + +
+
+
+ Iniciar llamada URL - This web URL address is not seen by the agent, but it is called every time a call is sent to an agent if it is populated. Uses the same variables as the web form fields and scripts. Default is blank. + +
+
+
+ Dispo Call URL - This web URL address is not seen by the agent, but it is called every time a call is dispositioned by an agent if it is populated. Uses the same variables as the web form fields and scripts. dispo and talk_time are the variables you can use to retrieve the agent-defined disposition for the call and the actual talk time in seconds of the call. Default is blank. + +
+
+
+ Alias de Grupo Padrão - Se você permitium Alias de Grupo para a campanha que o agente está logado, então este é o alias de grupo que é selecionado como padrão em uma chamada vindo deste grupo de entrada quando o agente escolhe um alias de grupo para uma chamada manual. O padrão é NONE ou vazio. + + + + + +



+ + VICIDIAL_ENTRANTE_DIDS TABELA

+
+
+
+ Extensão DDR- Este é o número, extensão ou DDR que irá acionar esta entrada e que você irá rotear no sistema usando este recurso. Existe um DDR padrão reservado que você pode usar que é a palavra -default- sem os traços, que irá permitir que você envie uma chamada que não pertenca a nenhum padrão existente para o DDR padrão. + +
+
+
+ Descrição do DDR - Esta é a descrição do roteamento ao DDR. + +
+
+
+ DDR Ativo - Este é o campo que você configura se o DDR está ativo ou não. O padrão é Y. + +
+
+
+ Rota DDR - Este é o tipo de rota que seu DDR irá usar. EXTEN irá enviar as chamadas para a extensão abaixo, VOICEMAIL irá enviar as chamadas para uma caixa de voicemail digitada abaixo, AGENTE irá enviar as chamadas para um agente do VICIDIAL se ele estiver logado no sistema, PHONE irá enviar a chamada para um ramal configurado abaixo, IN_GROUP irá enviar as chamadas diretamente para um grupo de entrada especificado abaixo. O padrão é EXTEN. MENU irá enviar a chamada para o menu determinado. + +
+
+
+ Extensão - Se EXTEN for selecionado como rota, então este é a extensão do plano de discagem que as chamadas serão enviadas. O padrão é 999811112, sem-serviço. + +
+
+
+ Contexto da Extensão - Se EXTEN estiver selecionado como Rota do DDR, então este é o contexto do plano de discagem para o qual as chamadas serão enviadas. O padrão é default. + +
+
+
+ Caixa de VoiceMail - Se VOICEMAIL estiver selecionado como rota de DDR, então esta é a caixa de voicemail que a chamada deve ser enviada. O padrão é vazio. + +
+
+
+ Extensão do Ramal - Se PHONE estiver selecionado na rota DDR, então esta é a extensão do ramal que as chamadas serão enviadas. + +
+
+
+ IP do Servidor do Ramal - Se PHONE estiver selecionado como rota DDR, então este é o IP do servidor do ramal que as chamadas devem ser enviadas. + +
+
+
+ Menu - Se CALLMENU estiver selecionado como Rota de DDR, então este é o Menu para o qual a chamada será transferida. + +
+
+
+ Usuário do Agente - Se AGENTE estiver selecionado como rota DDR, então este é o agente do vicidial que as chamadas devem ser enviadas. + +
+
+
+ Ação p/ Usuário não Dispon. - Se AGENTE estiver selecionado como rota de DDR, e o usuário não estiver logado ou disponível, então esta é a rota que as chamadas serão direcionadas. + +
+
+
+ Config. de Grupo de Entr. do Agente - Se AGENTE estiver selecionado como roda DDR, então este é o grupo de entrada que irá ser usado para configurações de fila na qual o cliente ficará esperando para ser direcionado ao agente. O padrão é AGENTDIRECT. + +
+
+
+ ID do Grupo de Entr. - Se IN_GROUP estiver selecionado como rota de DDR, então este é o grupo de entrada a ser enviadas as chamadas. + +
+
+
+ In-Group Call Handle Method - IN_GROUP Si se selecciona como la Ruta de DID, entonces este es el llamado método de control utilizado para estas llamadas. Cid agregar un registro de conducir nuevo con cada llamada mediante la CallerID como el número de teléfono, CIDLOOKUP intentará buscar el número de teléfono por el CallerID en todo el sistema, CIDLOOKUPRL intentará buscar el número de teléfono por el CallerID en una sola lista especificada , CIDLOOKUPRC intentará buscar el número de teléfono por el CallerID en todas las listas que pertenecen a la campaña especificada, más cerca se especifica para Vicidial Closer llamadas, ANI añadirá un nuevo registro de conducir con cada llamada mediante la ANI como el número de teléfono, ANILOOKUP intentará buscar el número de teléfono de la ANI en todo el sistema, ANILOOKUPRL intentará buscar el número de teléfono de la ANI en una sola lista especificada, XDIGITID pedirá la llamada de un código de dos dígitos X antes de la llamada se pondrá en la cola, VIDPROMPT pedirá la persona que llama por su número de identificación y creará un registro de conducir nuevo con el CallerID como el número de teléfono y el ID como el identificador de proveedor, VIDPROMPTLOOKUP intentará buscar el ID en todo el sistema, VIDPROMPTLOOKUPRL intentará búsqueda del proveedor de identificación de la identificación en una sola lista se especifica, VIDPROMPTLOOKUPRC tratará de buscar el proveedor de identificación de la identificación en todas las listas que pertenecen a la campaña especificado. El valor predeterminado es CID. + +
+
+
+ Método de Busca do Grupo de Entrada - Se IN_GROUP estiver selecionado na rota de DDR, então este é o método de pesquisa do agente a ser usado pelo grupo de entrada, LO é Balanceamento de Carga com Transbordo e irá tentar enviar a chamada para um agente no servidor local antes de tentar enviar para outro servidor, LB é balanceamento de carga e tentará enviar a chamada para o próximo agente não importando o servidor que estiver logado, SO é Somente Servidor e tentará enviar a chamada somente para agentes no mesmo servidor da chamada. O padrão é LB. + +
+
+
+ ID da Lista do Grupo de Entrada- Se IN_GROUP estiver selecionado como rota de DDR, então este é o ID da lista que os registros devem ser pesquisados e onde o novo registro será incluído se necessário. + +
+
+
+ ID da Camp. do Grp. de Entrada- Se IN_GROUP estiver selecionado como rota de DDR, então este é o ID da campanha que os registros devem ser procurados quando o método de pesquisa for CIDLOOKUPRC. + +
+
+
+ Código do Tel. de Entrada - Se IN_GROUP estiver selecionado como rota de DDR, então este é o código de telefone usado para um novo registro. + + + + +



+ + VICIDIAL_CALL MENU TABELA

+
+
+ ID do Menu - Este é o ID para este passo do menu de chamadas. Ele irá aparecer como o contexto que é usado no plano de discagem para este menu de chamadas. + +
+
+
+ Nome do Menu - Este campo é o nome descritivo do menu de chamadas. + +
+
+
+ Audio do Menu - Este campo contém o nome do arquivo para o audio que será tocado no inicio do menu. Puede introducir propmts múltiples en este campo y los demás ámbitos del sistema mediante la separación de ellos con un carácter de canalización. + +
+
+
+ Tempo max do menu - Este campo é onde você configura o tempo máximo em segundos que um menu irá aguardar o cliente digitar uma opção em DTMF. Establecer este campo a cero 0 significa que no habrá tiempo de espera después de que el sistema se juega. + +
+
+
+ Audio de tempo excedido do menu - Este campo contém o arquivo de audio a ser tocado caso o tempo máximo de espera tenha sido alcançado. O padrão é NONE para nao tocar audio. + +
+
+
+ Audio de Opção Inválida do menu - Este campo contém o nome do arquivo de audio que será tocado quando o cliente selecionar uma opção inválida. O padrão é NONE que não toca audio quando a opção é inválida. + +
+
+
+ Repetir Menu - Este campo é onde você define o número de vezes que o menu irá tocar depois da primeira vez, se nenhuma opção for escolhida pelo cliente. O padrão é 1 para repetir o menu uma vez. + +
+
+
+ Verif. Horário de Menu - Este campo é onde você seleciona se as chamadas á URA devem ser restritas a horários específicos cadastrados no Cadastro de Horários de Chamada. Se o Horário de chamada estiver vazio, esta configuração será ignorada. O padrão é 0 para desabilitado. + +
+
+
+ ID do Horário de Cham. - Este é o ID do Horário de chamadas que será usado para restringir horários de chamada para este menu, quando a opção estiver habilitada. + +
+
+
+ Rastrear Chamadas no Relat. Tempo-Real - Este campo é onde você seleciona se deseja que as chamadas devem ser rastreadas no relatório de Tempo-Real como uma chamada de URA. O padrão é 1 para ativo. + +
+
+
+ Grupo de seguimiento de - Esta es la identificación que se puede utilizar para rastrear las llamadas a este menú de llamada cuando se mira al Informe de IVR. La lista incluye CALLMENU como predeterminado, así como todos los Grupos de In -. + +
+
+
+ Valor da Opção - Este campo é onde você define a opção de menu, as opções são: 0,1,2,3,4,5,6,7,8,9,*,#,A,B,C,D,TIMECHECK. A opção especial TIMECHECK pode ser usada somente se você habilitou a verificação de horário e existe um horário de chamadas definido para o menu. Para remover uma opção, apenas selecione a rota como REMOVE e a opção será removida quando você clicar no botão enviar. + +
+
+
+ Descrição da Opção - Este campo é onde você descreve a opção, esta descrição será colocada no plano de discagem como um comentário acima da opção. + +
+
+
+ Rota da Opção - + + +
+
+
+ Valor da rota da opção - Este campo é onde você coloca o valor que define para onde, na Opção de Rota selecionada, a chamada deve ser direcionada . + +
+
+
+ Contexto do valor da rota da opção - Este campo é opcional e somente é usado para Rotas do tipo EXTENSION. + +
+
+
+ Custom Dilplan entrada - Este campo le permite entrar en los elementos dialplan que desea para el menú de llamada. + + + + + +



+ + VICIDIAL_REMOTE_AGENTS TABELA

+
+
+ Início do ID do usuário - Esta é a ID inicial que será usada quando um agente remoto for cadastrado no sistema. Se o número de linhas estiver configurado maior que 1, este número é incrementado por um até cada linha ter sua entrada. Tenha certeza que você criou uma nova conta de usuário VICIDIAL com nível 4 ou superior se você quer que eles sejam capazes de usar a página vdremote.php para acesso remoto a esta conta. + +
+
+
+ Número de Linhas - Define quantas entradas de usuários remotos o sistema deve criar, e determina quantas linhas podem ser enviadas com segurança para o número abaixo. + +
+
+
+ IP do Servidor - Um cadastro de agente remoto só funciona em um servidor, aqui é onde você seleciona qual servidor. + +
+
+
+ Extensão Externa - Este é o número para o qual você quer que as chamadas sejam direcionadas. Tenha certeza que é um número completo do plano de discagem e que se você precisa de um 9 no começo, você o coloca aqui. Teste discando o número de um fone no sistema. + +
+
+
+ Status - Aqui é onde você desliga ou liga o agente remoto. Assim que o agente está ativo, o sistema entende que ele pode receber chamadas. Pode demorar até 30 segundos após a mudança do status para Inactive para parar de receber chamadas. + +
+
+
+ Campanha - Aqui é onde você escolhe a campanha que este agente remoto deve ser logado. Chamadas entrantes precisam usar uma campanha CLOSER e selecionar uma campanha entrante abaixo para que você receba chamadas. + +
+
+
+ Grupos de entrada - Aqui é selecionado o grupo de entrada do qual você quer receber chamadas se você selecionou uma campanha CLOSER(finalização). + + +



+ + VICIDIAL_CAMPANHA_LISTAS

+
+
+ As listas dentro desta campanha são listadas aqui, estando ativas ou desativadas será demonstrado por Y ou N e você pode ir para a tela de cadastro de listas clicando no Id na primeira coluna. + + +



+ + VICIDIAL_CAMPANHA_STATUS TABELA

+
+
+ Através do uso de status de campanha customizados, você pode ter status que somente existem para uma campanha específica. Os Status devem ter entre 1 e 8 caracteres de comprimento, a descrição deve ter entre 2-30 caracteres de comprimento e "Selectable" determina se será mostrado no VICIDIAL como um resultado. O campo RESPOSTA HUMANOA(human_answered) é usado quando é calculado o percentual de desligamento(drop), ou índice de abandono. Configurando como Y irá usar este status quando for contar chamadas atendidas por humanos A opção de categoria permite agrupar vários status em uma categoria que podem ser usados para análise estatística. + + + + 0) + { + ?> +



+ + VICIDIAL_CAMPANHA_HOTKEYS TABELA

+
+
+ Através do uso de atalhos de teclado customizados por campanha, agentes que usam o web-client do vicidial podem desligar e classificar uma chamada pressionando uma tecla do teclado. Existem duas opções de atalhos especiais que você pode usar em conjunto com discagem a Telefones Alternativos, ALTPH2 - Discar para o Tel. Alt. e ADDR3----Discagem rápida do endereço 3, permitem ao agente usar o atalho para desligar a chamada, permanecer no mesmo registro e discar outro telefone do mesmo registro. + + + + + +



+ + VICIDIAL_LEAD_RECYCLE TABELA

+
+
+ Through the use of lead recycling, you can call specific statuses of leads again at a specified interval without resetting the entire list. Lead recycling is campaign-specific and does not have to be a selected dialable status in your campaign. The attempt delay field is the number of seconds until the lead can be placed back in the hopper, this number must be at least 120 seconds. The attempt maximum field is the maximum number of times that a lead of this status can be attempted before the list needs to be reset, this number can be from 1 to 10. You can activate and deactivate a lead recycle entry with the provided links. + + + + + +



+ + STATUS DE DISCAGEM ALT.

+
+
+ Se o campo Auto Discar Alternativo estiver marcado, os registros que são finalizados sob estes status terão os números alternativos discados após qualquer um desses status de não atendidos. + + + + + +



+ + VICIDIAL CÓDIGOS DE PAUSA DO AGENTE

+
+
+ Se o Código de Pausa do Agente estiver ativa então os agentes serão capazes de escolher entre esses códigos de pausa quando clicarem no botão PAUSA em suas telas. Esta informação será então gravada na tabela de log do agente. O código de pausa deve conter somente letras e números e deve ser menor que 7 caracteres. O nome do código de pausa não pode ser maior que 30 caracteres. + + + + + +



+ + VICIDIAL_USER_GROUPS TABELA

+
+
+ Grupo de usuário - É o nome curto do grupo de usuários do Vicidial, tente não usar espaços ou caracteres especias neste campo. Máximo de 20 caracteres e mínimo de 2. + +
+
+
+ Nome do Grupo - Esta é a descrição do grupo de usuários do vicidial, máximo de 40 caracteres. + +
+
+
+ Forçar Login no Ponto - Esta opção permite você não deixar um agente entrar na interface de agente do VICIDIAL se ele não estiver logado no sistema de relógio de ponto. O padrão é N. Existe uma opção para isentar usuários admin, níveis 8 e 9. + +
+
+
+ Controle de Turno - Esta configuração permite você restringir logins do agente baseado nos turnos selecionados abaixo. OFF não irá forçar controle de turno. START irá forçar o horário de login mas não terá efeito sobre um agente que está fazendo horário além do limite final e não saiu do sistema. ALL irá forçar o horário de início e fim, retirando o agente do sistema quando o horário do turno estiver terminado. O padrão é OFF + +
+
+
+ Turnos do Grupo - Esta é uma lista selecionável de turnos que podem restringir o login do agente no sistema. + +
+
+
+ Campanhas Permitidas - Esta é uma lista selecionável de campanhas nas quais os membros deste grupo podem se logar. A opção ALL-CAMPANHAS permite aos usuários neste grupo ver e logar em qualquer campanha no sistema. + +
+
+
+ Estado del agente visible Grupos - Esta es una lista seleccionable de grupos de usuarios y las funciones de usuario al que los miembros de este grupo de usuarios pueden ver el estado de las llamadas, así como la transferencia al interior de la pantalla del agente. La opción de grupo permite a los usuarios de este grupo para ver y transferir llamadas a cualquier usuario en el sistema. La campaña-AGENTES opción permite a los usuarios en este grupo para ver y transferir llamadas a cualquier usuario en la campaña que se registran en la. + +
+
+
+ Ver estado del agente de turno - Esta opción define si el agente va a ver la cantidad de tiempo que los usuarios en su barra lateral agente han sido en su estado actual. Por defecto es n sin o con discapacidad. + + 0) + { + ?> +
+
+
+ Campanha com CQ - Esta lista selecionável de campanhas tem os membros para esse grupo de usuários que terão habilitado o controle de qualidade. A opcão ALL-CAMPANHAS permite ao usuário neste grupo fazer controle de qualidade em qualquer campanha do sistema. + +
+
+
+ Permitir CQ de Entrada- Esta é uma lista selecionável de Grupos de Entrada aos quais os membros deste grupo de usuários podem realizar Controle de Qualidade. A opção ALL-GROUPS permite que usuários deste grupo fazer Controle de Qualidade em qualquer grupo do sistema. + + + + + +



+ + VICIDIAL_SCRIPTS TABELA

+
+
+ ID do Script - Este é o nome curto do script Vicidial. É necessário que seja uma identificação única. Tente não usar espaços ou caracteres especias para este campo. Máximo de 10 caracteres, mínimo de 2 caracteres. + +
+
+ Nome do Script - Este é o título do script Vicidial. Este é um resumo curto do script. Máximo de 50 caracteres, mínimo de 2 caracteres. Não devem ser usados espaços ou caracteres especiais de qualquer forma neste campo. + +
+
+ Comentários do Script - Aqui é onde você pode colocar comentários para um Script Vicidial como: -alterado em 23 de Set.-. Máximo 255 caracteres, mínimo de 2 caracteres. + +
+
+ Texto do Script - This is where you place the content of a Vicidial Script. Minimum of 2 characters. You can have customer information be auto-populated in this script using "--A--field--B--" where field is one of the following fieldnames: vendor_lead_code, source_id, list_id, gmt_offset_now, called_since_last_reset, phone_code, phone_number, title, first_name, middle_initial, last_name, address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email, security_phrase, comments, lead_id, campaign, phone_login, group, channel_group, SQLdate, epoch, uniqueid, customer_zap_channel, server_ip, SIPexten, session_id, dialed_number, dialed_label, rank, owner, camp_script, in_script, script_width, script_height, recording_filename, recording_id. For example, this sentence would print the persons name in it----

Hello, can I speak with --A--first_name--B-- --A--last_name--B-- please? Well hello --A--title--B-- --A--last_name--B-- how are you today?

This would read----

Hello, can I speak with John Doe please? Well hello Mr. Doe how are you today?

You can also use an iframe to load a separate window within the SCRIPT tab, here is an example with prepopulated variables: + +
+ <iframe src="http://astguiclient.sf.net/test_VICIDIAL_output.php?lead_id=--A--lead_id--B--&vendor_id=--A--vendor_lead_code--B--&list_id=--A--list_id--B--&gmt_offset_now=--A--gmt_offset_now--B--&phone_code=--A--phone_code--B--&phone_number=--A--phone_number--B--&title=--A--title--B--&first_name=--A--first_name--B--&middle_initial=--A--middle_initial--B--&last_name=--A--last_name--B--&address1=--A--address1--B--&address2=--A--address2--B--&address3=--A--address3--B--&city=--A--city--B--&state=--A--state--B--&province=--A--province--B--&postal_code=--A--postal_code--B--&country_code=--A--country_code--B--&gender=--A--gender--B--&date_of_birth=--A--date_of_birth--B--&alt_phone=--A--alt_phone--B--&email=--A--email--B--&security_phrase=--A--security_phrase--B--&comments=--A--comments--B--&user=--A--user--B--&campaign=--A--campaign--B--&phone_login=--A--phone_login--B--&fronter=--A--fronter--B--&closer=--A--user--B--&group=--A--group--B--&channel_group=--A--group--B--&SQLdate=--A--SQLdate--B--&epoch=--A--epoch--B--&uniqueid=--A--uniqueid--B--&customer_zap_channel=--A--customer_zap_channel--B--&server_ip=--A--server_ip--B--&SIPexten=--A--SIPexten--B--&session_id=--A--session_id--B--&dialed_number=--A--dialed_number--B--&dialed_label=--A--dialed_label--B--&rank=--A--rank--B--&owner=--A--owner--B--&phone=--A--phone--B--&camp_script=--A--camp_script--B--&in_script=--A--in_script--B--&script_width=--A--script_width--B--&script_height=--A--script_height--B--&recording_filename=--A--recording_filename--B--&recording_id=--A--recording_id--B--&" style="width:580;height:290;background-color:transparent;" scrolling="auto" frameborder="0" allowtransparency="true" id="popupFrame" name="popupFrame" width="460" height="290" STYLE="z-index:17"> + </iframe> +
+ +
+
+
+ Ativo - Isto determina se o script pode ser selecionado para ser usado na campanha. + + + + + + 0) + { + ?> +



+ + VICIDIAL_LEAD_FILTROS TABELA

+
+
+ ID do filtro - É o nome curto para o filtro de registros. Precisa ser um identificador único. Não use espaços ou caracteres especiais para este campo. Máximo de 10 caracteres e mínimo de 2 caracteres. + +
+
+ Nome do Filtro - É um nome mais descritivo para o filtro. É um resumo da função do filtro. Máximo de 30 caracteres, mínimo de 2 caracteres. + +
+
+ Comentários do Filtro - Aqui é onde são colocados comentários para um Filtro Vicidial como por exemplo -liga para todos os registros da California-. Máximo de 255 caracteres, mínimo de 2 caracteres. + +
+
+ Filtro SQL - É onde colocamos o fragmento da consulta SQL que você deseja usar para filtrar. Não inicie nem termine com AND, isso será adicionado pelo script do hopper automaticamente. Um exemplo de consulta SQL que funcionaría é: called_count \> 4 and called_count \<8 . + + + + + +



+ + VICIDIAL_HORÁRIOS DE CHAMADA TABELA

+
+
+ ID de Horário de Chamada - Este é o nome curto para a definição do tempo de discagem do Vicidial. Precisa ser um identificador único. Não use espaços ou pontos para este campo. Máximo de 10 caracteres e mínimo de 2 caracteres. + +
+
+ Nome do Horário de Chamada - Nome mais descritivo da definição de Horário de Chamada. É um resumo do Horário de Chamada. Máximo de 30 caracteres e mínimo de 2 caracteres. + +
+
+ Comentários do Horário de Chamada - Aqui devem ser colocados os comentários para a definição de Horários de chamada, por ex: "10:00 as 16:00 com chamadas restritas". Máximo de 255 caracteres . + +
+
+ Horário de Início e Fim Padrão - Este é o padrão de horário no qual chamadas são permitidas se o dia de início na semana não estiver definido. 0 é meia noite. Para evitar chamadas a qualquer horário, coloque 2400 no início e 2400 no fim. Para permitir chamadas nas 24 horas do dia, coloque 0 e 2400 nestes campos. + +
+
+ Horários de Início e Fim em dias Úteis - Estes são os horários por dia que podem ser configurados para chamada. As mesmas regras se aplicam conforme os horários de início e fim. + +
+
+ Definição de Horários por Estado - Esta é a lista de horários específica por Estado que deve ser seguida por esta definição de horário. + +
+
+ Estado da definição de horário - Código de duas letras para o estado ao qual esta definição foi configurada. Para que funcione corretamente o horário local da campanha deve ter selecionado o horário local deste estado e os registros de clientes devem ter as mesmas letras de estado. + + + + +



+ + VICIDIAL_SHIFTS TABELA

+
+
+ ID do Turno- Este é o nome curto para uma definicao de Turno. Precisa ser um identificador único. Não usar pontos ou espaços para este campo, máximo de 20 e mínimo de 2 caracteres. + +
+
+ Nome do Turno - Este é um nome mais descritivo da definição do turno. É um resumo da definição do turno. Máximo de 50 caracteres, mínimo de 2 caracteres. + +
+
+ Início do Turno- É o horário que o turno da campanha começa. Deve ter apenas números, 9:30 seria apenas 0930 e 17:00 seria 1700. + +
+
+ Duração do Turno - Este é o tempo em horas e minutos que dura o turno. 8 horas seria 08:00 e 7 horas e 30 minutos seria 7:30. + +
+
+ Dias do Turno - Nesta sessão você deve escolher os dias da semana em que este turno funciona. + + + + + +



+
+ Audio de la tienda - Esta utilidad te permite subir archivos de audio para el servidor de forma que puedan ser distribuidos a todos los servidores de Vicidial en un multi-cluster de servidores. Una nota importante, sólo dos tipos de archivos de audio de trabajo,. Archivos WAV PCM de 16 bits que se 8k y los archivos. GSM que se 8bit 8k. Por favor, verifique que los archivos tienen el formato correcto antes de subirlos aquí. + + + +



+ + VICIDIAL_MUSIC_ON_HOLD TABELA

+
+
+ Música en espera de identificación - Este es el nombre corto de una música en espera de entrada. Esto debe ser un identificador único. No utilice espacios ni puntuacion para este campo. 100 caracteres como máximo, mínimo de 2 caracteres de. + +
+
+ Música en espera Nombre - Este es un nombre más descriptivo de la música en espera de entrada. Este es un breve resumen de la música en espera contexto y se verá como un comentario en el musiconhold archivo vicidial.conf. máximo de 255 caracteres, mínimo de 2 caracteres. + +
+
+ Ativo - Esta opción le permite definir la música en espera la entrada en activo o inactivo. Inactivo eliminará la entrada de los archivos de conf. + +
+
+ Orden aleatorio - Esta opción le permite definir la reproducción de los archivos de audio en un orden aleatorio. Si se establece a N, entonces el orden definido se utilizará. + +
+
+ Filename - Para añadir un nuevo archivo de audio a una música en espera de entrada el primer archivo debe estar en la tienda de audio, puede seleccionar el archivo y haga clic en Enviar para añadirlo a la lista de archivos. Música en espera se actualiza una vez por minuto si se han producido cambios realizados. Cualquier archivo que no figuran en la música en la entrada de reserva que están presentes en la música en la carpeta celebrar serán eliminados. + + + + +



+ + VICIDIAL_TTS_PROMPTS TABELA

+
+
+ TTS ID - Este es el nombre corto de una entrada de TTS. Esto debe ser un identificador único. No utilice espacios ni puntuacion para este campo. caracteres como máximo 50, mínimo de 2 caracteres. + +
+
+ Nombre TTS - Este es un nombre más descriptivo de la entrada TTS. Este es un breve resumen de la definición de TTS. 100 caracteres como máximo, mínimo de 2 caracteres de. + +
+
+ Ativo - Esta opción le permite establecer la entrada de TTS a activos o inactivos. + +
+
+ TTS Texto - Este es el texto real de campo de datos de voz que se envía a Cepstral para la creación del archivo de audio que deben desempeñar para el cliente. Usted puede utilizar Speech Syntesis Markup Language-SSML-en este campo, por ejemplo,, <break time='1000ms'/> de 1 segundo descanso. También puede utilizar varias variables como el nombre, apellido y el título como variables Vicidial tal como lo harías en una secuencia de comandos: - A - first_name - B -. Aquí está una lista de las variables disponibles:lead_id, entry_date, modify_date, status, user, vendor_lead_code, source_id, list_id, phone_number, title, first_name, middle_initial, last_name, address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email, security_phrase, comments, called_count, last_local_call_time, rank, owner + + + + +



+ + VICIDIAL_VOICEMAIL TABELA

+
+
+ ID de correo de voz - Este es el identificador de todos los números de este buzón. Esto no debe ser un duplicado de un mensaje de voz existentes de identificación o la identificación del correo de voz de un teléfono en el sistema, mínimo de 2 caracteres. + +
+
+ Name - Este es el nombre asociado a este buzón de voz. 100 caracteres como máximo, mínimo de 2 caracteres de. + +
+
+ Password - Esta es la contraseña que se utiliza para acceder al buzón de voz cuando se marca para revisar los mensajes máximo 10 caracteres, mínimo de 2 caracteres. + +
+
+ Ativo - Esta opción le permite configurar la casilla de correo de voz activo o inactivo. Si el cuadro está inactivo no se puede dejar mensajes en él y no se puede revisar los mensajes en él. + +
+
+ Email - Este ajuste opcional le permite tener los mensajes de correo de voz enviado a una cuenta de correo electrónico, si su sistema está configurado para enviar correo electrónico. Si este campo está vacío, entonces no los correos electrónicos se envían. + +
+
+ Eliminar correo de voz después del email - Este ajuste opcional le permite tener los mensajes de correo de voz se elimina del sistema después de haber sido enviado por correo electrónico a cabo. Por defecto es n. + + + + + 0) + { + ?> + +



+ + FUNCIONALIDADE DE CARREGADOR DE LISTA DO VICIDIAL

+
+
+ O carregador de registros baseado em Web do VICIDIAL simplesmente recebe um arquivo de registros, de até 8MB, que é delimitado por tab ou pipe e o carrega na tabela vicidial_list. O Carregador permite escolher os campos, e os formatos TXT - Texto Simples, CSV - Separado por Virgulas, e XLS - Excel. O carregador de arquivos não valida dados, mas permite que você verifique duplicidades nele próprio, na campanha ou no sistema inteiro. Também, tenha certeza que você criou a lista em que esses registros serão carregados antes de carregar o arquivo. Aqui está uma lista dos campos e sua ordem correta para o arquivo de registros: +
    +
  1. Código do Vendedor no Registro - é mostrado no campo Vendor ID na tela do agente +
  2. Código Fonte - uso interno, somente para admins e DBAs +
  3. ID da Lista - número da lista em que esses registros vão ser carregados +
  4. Código do Telefone - prefixo do número do telefone - 1 para EUA, 01144 para Reino Unido, 01161 para Australia, 55 para Brasil, etc +
  5. Número do telefone - deve ter pelo menos 8 digitos +
  6. Título - título do cliente(Sr. Sra. Srta., etc...) +
  7. Nome +
  8. Inicial do Meio +
  9. Sobrenome +
  10. Endereço, linha 1 +
  11. Endereço, linha 2 +
  12. Endereço, linha 3 +
  13. Cidade +
  14. Estado - limitado a 2 caracteres +
  15. Província +
  16. CEP +
  17. País +
  18. Sexo +
  19. Data de Nascimento +
  20. Número Alternativo +
  21. Endereço de Email +
  22. Frase de Segurança +
  23. Comentários +
+ +
ATENÇÃO: A funcionalidade de carregar registros usando arquivos EXCEL é permitida por uma série de scripts e precisa estar devidamente configurada no arquivo /etc/astguiclient.conf no servidor web. Também, alguns módulos perl devem ser carregados para que funcione, OLE-Storage_Lite e Spreadsheet-ParseExcel. Você pode verificar erros de tempo de execução neles olhando o arquivo de log do apache. Também, para verificação de duplicados na lista da campanha, a lista com os novos registros precisa existir no sistema antes de iniciar a carga. + + + + +



+ + + + + + + TABELA DE RAMAIS

+
+
+ Número do Ramal - Este campo é onde você coloca o número do ramal conforme aparece no Asterisk sem incluir o protocolo ou a barra no começo. Por exemplo: para o ramal SIP\/test101 o número do ramal seria test101. Também, para os ramais IAX2 tenha certeza de usar o nome completo: IAX2/IAXphone1@IAXphone1 seria IAXphone1@IAXphone1. Para Zap tenha certeza que você usa o canal completo: Zap/25-1 seria 25-1. Outro aviso, tenha certeza que você configura o protocolo abaixo corretamente para seu tipo de telefone. + +
+
+
+ Numero do plano de discagem - Este campo é para o número que você disca para tocar o ramal. Esse número é definido no arquivo extensions.conf do seu servidor Asterisk + +
+
+
+ Caixa Postal - Este campo é para a caixa postal de voz para onde vao as menssagens para o usuário deste ramal. Utilizamos isto para verificar as mensagens e para o usuário utilizar o botão VOICEMAIL no aplicativo astGUIclient. + +
+
+
+ Identificador de Saída - Este campo é onde deve ser colocado o número que você quer que saia no identificador para as ligações de saída feitas pelo astguiclient. Isto não funciona em linhas RTB(non-PRI) T1/E1. + +
+
+
+ Endereço IP do ramal - Este campo é para o endereço IP do ramal se for um ramal VOIP. Este campo é opcional + +
+
+
+ Endereço IP do computador - Este campo é para o endereço IP do computador do usuário. Este campo é opcional + +
+
+
+ IP do Servidor - Este menu é onde você escolhe em qual servidor está o ramal ativo. + +
+
+
+ Login - O login usado pelo usuário do ramal para logar no aplicativo client. + +
+
+
+ Senha - A senha usada pelo usuário do ramal para entrar no aplicativo client. Importante, esta es la única contraseña para la red de interfaz de usuario del agente de teléfono, para cambiar el sip.conf iax.conf o contraseña, o en secreto, para este dispositivo de teléfono que tenga que modificar el campo Archivo Secreto Conf. más abajo en esta página. + +
+
+
+ Status - O status do ramal no sistema, ATIVO e ADMIN permiten que os clientes GUI trabalhem. ADMIN permite o acceso ao Website de administração. Os outros status não permitem o acceso ao GUI ou ao Website de Admin. + +
+
+
+ Conta ativa - Se o ramal está ativado será incluído na lista do cliente GUI. + +
+
+
+ Tipo de Ramal - Somente para informação administrativa. + +
+
+
+ Nome Completo - Usado pelo GUIclient na lista de ramais ativos. + +
+
+
+ Empresa - Somente para informação administrativa. + +
+
+
+ Email do Ramal - Endereço de email associado ao ramal. Isto pode ser usado para configurações de VoiceMail. + +
+
+ Eliminar correo de voz después del email - Este ajuste opcional le permite tener los mensajes de correo de voz se elimina del sistema después de haber sido enviado por correo electrónico a cabo. Por defecto es n. + +
+
+
+ Foto - Ainda não implementado. + +
+
+
+ Novas Mensagens - Número de mensagens novas na conta de correio de voz para esse ramal no servidor Asterisk. + +
+
+
+ Mensagens Antigas - . + +
+
+
+ Protocolo Client - O protocolo que o ramal utiliza para se conectar com o servidor Asterisk: SIP, IAX2, Zap. Também, para os números Externos ou número de discagem rápida que você deseja listar como ramais. + +
+
+
+ GMT Local - A diferença a partir do horário de Greenwich, ou Horário ZULU para o local onde o ramal está localizado. NÃO AJUSTE PARA O HORÁRIO DE VERÃO. É usado pela campanha do VICIDIAL para demonstrar corretamente o horário local e o horário do cliente.. + +
+
+
+ Teléfono Anillo de tiempo de espera - Esta es la cantidad de tiempo, en segundos, que el teléfono sonará en el dialplan antes de enviar la llamada al buzón de voz. El valor predeterminado es 60 segundos. + +
+
+
+ Login de Gerenciamento- Este é o login que o client GUI para esse ramal usará para acessar o Banco de Dados onde os dados do servidor residem . + +
+
+
+ Senha de Gerenciamento - Esta é a senha que o client GUI para esse ramal usará para acessar o Banco de Dados onde os dados do servidor residem. + +
+
+
+ Usuário padrão do VICIDIAL - O valor desse campo será colocado no campo de usuário quando esse ramal entrar no aplicativo astVICIDIAL . + +
+
+
+ Senha padrão VICIDIAL - Este valor de senha será preenchido no campo da senha do usuário quando esse ramal entrar no aplicativo astVICIDIAL . + +
+
+
+ Campanha padrão do VICIDIAL - Este campo deve ser preenchido com o valor padrão para o campo da campanha quando este ramal abrir o aplicativo astVICIDIAL. Deixe em branco para nenhuma campanha. + +
+
+
+ Exten de Estacionamento - Esta é a extensão de estacionamento padrao para o aplicativo client. Verifique se a extensão funciona antes de alterar.. + +
+
+
+ Exten de Conferência - Esta é a extensão padrao para estacionamento da conferência para o aplicativo client. Verifique se a extensão funciona antes de alterar. + +
+
+
+ Extensão de estacionamento do VICIDIAL - Esta é a extensão de estacionamento para o aplicativo client VICIDIAL. Verifique se a extensão funciona antes de alterar. + +
+
+
+ Arquivo do VICIDIAL Park - Este é o nome do arquivo padrao para a extensão de estacionamento do VICIDIAL usado pelo aplicativo cliente. Verifique se um arquivo diferente funciona antes de alterar. Limitado a 10 caracteres. + +
+
+
+ Prefixo do monitor - Este é o prefixo do plano de discagem para monitorar canais automaticamente dentro do aplicativo astGUIclient. Só altere de acordo com os registros de ZapBarge do arquivo extensions.conf. + +
+
+
+ Exten de Gravação - Esta é a extensão do plano de discagem que irá entrar na sala de conferências e gravar a conversa. Normalmente dura por volta de uma hora se nao for cancelada. Verifique no arquivo extensions.conf antes de alterar. + +
+
+
+ Exten principal de VMAIL- Esta é a extensão do plano de discagem que acessa o voicemail. Verifique o arquivo extensions.conf antes de alterar. + +
+
+
+ Descarga Exten de VMAIL - Esta é a extensão do plano de discagem usada para deixar mensagens no correio de voz. + +
+
+
+ Contexto do Exten - Este es el contexto del plan de marcado que las solicitudes de agente, como Vicidial, principalmente el uso. Se supone que todos los números marcados por las aplicaciones cliente utilizan este contexto, por lo que es una buena idea para asegurarse de que este es el contexto más amplio posible. verificar con el archivo extensions.conf antes de cambiar. por defecto es por defecto. + +
+
+
+ Teléfono Contexto - Este es el contexto del plan de marcado que este teléfono se utiliza para marcar. Si está ejecutando un centro de llamadas y usted no desea que sus agentes sean capaces de marcar fuera de la aplicación Vicidial por ejemplo, entonces puedes establecer este campo a un contexto dialplan que no existe, algo como agente nodial. por defecto es por defecto. + +
+
+
+ Conf. Archivo Secreto - Este es el secreto o la contraseña, por el teléfono de la SIP IAX o auto-generados conf para este teléfono. Límite es el tablero de 20 caracteres alfanuméricos y de subrayado aceptado. El valor predeterminado es la prueba. + +
+
+
+ Canal de envio de DTMF - Este é canal usado para enviar tons DTMF nas conferencias meetme do aplicativo client. Verifique a exten e o contexto no arquivo extensions.conf. + +
+
+
+ Grupo de Saída - Este é o grupo de canais em que as chamadas saintes são feitas. Existem algumas rotinas no aplicativo cliente que usam isso. Para canais Zap você deve fazer algo como Zap/g2, para trunks IAX2 voce deve usar o prefixo completo como: IAX2/VICItest1:secret@10.10.10.15:4569. Verifique os trunks no arquivo extensions.conf, normalmente é o que voce definiu na variavel global TRUNK no inicio do arquivo. + +
+
+
+ Local do Browser - Isto se aplica apenas a clientes UNIX/LINUX, é o caminho absoluto para os browsers Mozilla ou Firefox na maquina. Verifique isso executando-o manualmente. + +
+
+
+ Diretório de Instalação - Este é o local onde os scripts do astGUIclient e astVICIDIAL estão localizados na sua maquina. Para Win32 deve ser algo como: C:\\AST_VICI e para UNIX deve ser algo como /usr/local/perl_TK. Verifique isso manualmente. + +
+
+
+ URL do Identificador - + +
+
+
+ URL default do VICIDIAL - Este é o endereço da página usada para customizar pesquisas do VICIDIAL. O endereço padrão de testes é: htpp://astguiclient.sf.net/test_VICIDIAL_output.php + +
+
+
+ Registro de chamada - Esta configuração terá valor true se o arquivo call_log.agi estiver no arquivo extensions.conf para todas as extensões de saida e de desligamento (hangup). Isso deve sempre estar true pois é obrigado para que muitas funcionalidades do astGUIclient e do VICIDIAL funcionem corretamente. + +
+
+
+ Conmutación del usuario - fije para verdad para permitir que el usuario cambie a otra cuenta del usuario. NOTA: Si los interruptores del usuario ellos pueden iniciar la grabación en la conversación de teléfono del nuevo usuario + +
+
+
+ Conferencias - Configurado como true, permite o usuário iniciar conferências de até seis telefones externos. + +
+
+
+ Hangup do Admin - Configurado como true permite que o usuário desligue qualquer linha através do astGUIclient. Uma boa ideia é somente permitir isso para usuários Admin. + +
+
+
+ Sequestro do Admin - Configure como true para permitir que o usuário consiga pegar qualquer linha e transferir para seu ramal através do astGUIclient. Uma boa ideia é permitir somente para o usuário Admin. Mas é muito útil para gerentes. + +
+
+
+ Monitoramento Admin - Configure como true para permitir que o usuário consiga pegar qualquer linha e transferir para seu ramal através do astGUIclient. Uma boa ideia é permitir somente para o usuário Admin. Mas é muito útil para gerentes. + +
+
+
+ Estacionamento de chamadas - Se configurado como true permite o usuário estacionar as chamadas pelo astGUIclient para que sejam capturadas por outros usuários do sistema. Chamadas ficam estacionadas por até meia hora e depois são desligadas. Normalmente é habilitado para todos. + +
+
+
+ Verif. de Updater - Se configurado como true, mostra um aviso em popup que o tempo do atualizador nao mudou em 20 segundos. Útil para usuários Admin. + +
+
+
+ Registro AF - Se configurado como true, grava várias ações do uso do astGUIclient para um arquivo texto no computador do usuário. + +
+
+
+ Habilitar Fila - Configure como true para que os aplicativos cliente usem o controle central de Filas do Asterisk. Requerido e recomendado para todos os usuários. + +
+
+
+ Popup do CallerID - Configurado como true permite que números configurados no arquivo extensions.conf enviem telas popup de Identificação (CallerID) para os usuários. + +
+
+
+ Botão do VMail - Configurado como true irá mostrar o botao do VOICEMAIL (correio de voz) e o contador de mensagens no astGUIclient. + +
+
+
+ Atualização Rápida - Configure como true para habilitar uma nova velocidade de atualização das informações sobre a chamada no astGUIclient. A velocidade padrão quando desabilitado é de 1000ms ou 1 segundo. Pode aumentar a carga no sistema se esse tempo for reduzido. + +
+
+
+ Tempo de Atualização Rápida - em milisegundos. Só é usado se a opção "Atualização Rápida" estiver habilitada. O valor padrão desabilitado é 1000ms, 1 segundo. Pode aumentar a carga do sistema se esse valor for reduzido. + +
+
+
+ MySQL Permanente- Se estiver habilitada, a conexão do astGUIclient permanecerá ativa ao invés de conectar a cada segundo. Útil se você tiver um tempo de atualização curto. Pode aumentar a quantidade de conexões no servidor MySQL. + +
+
+
+ Discar próximo número automaticamente- Se habilitado o aplicativo client do VICIDIAL irá discar o próximo número automaticamente no desligamento de uma chamada, a não ser que o usuário selecione "Parar Discagem" na tela de finalização da chamada. + +
+
+
+ Parar gravação após cada chamada- Se habilitado o client do VICIDIAL irá parar de gravar após o final de cada chamada. Útil se você está fazendo muitas gravações ou se está usando o formulário web para acionar a gravação. + +
+
+
+ Habilitar Mensagens SIPSAK - Se habilitado, o servidor irá mandar mensagens para o fone SIP mostrar no display quando logado no VICIDIAL. Este recurso só funciona com telefones SIP e requer o aplicativo sipsak instalado no servidor web. Padrão é 0. + +
+
+
+ Servidor DBX - O servidor de banco de dados que este usuário deve se conectar. + +
+
+
+ Base de dados DBX - A base de dados MySQL que o usuário deve se conectar. Padrão é asterisk. + +
+
+
+ Usuário do DBX - O login de usuário do MySQL que esse usuário deve usar para conectar. Default é cron. + +
+
+
+ Senha do DBX - Senha do usuário de conexão do MySQL. Padrão é 1234. + +
+
+
+ Porta DBX - A porta TCP de conexão com o MySQL que o usuário deve usar para conectar. Padrão é 3306. + +
+
+
+ Servidor DBY - O servidor de banco de dados que este usuário deve se conectar. Secundário server, não utilizado atualmente. + +
+
+
+ Base de dados DBY - A base de dados MySQL que o usuário deve se conectar. Padrão é asterisk. Secundário server, não utilizado atualmente. + +
+
+
+ Usuário do DBY - O login de usuário do MySQL que esse usuário deve usar para conectar. Default é cron. Secundário server, não utilizado atualmente. + +
+
+
+ Senha do DBY - Senha do usuário de conexão do MySQL. Padrao é 1234. Secundário server, não utilizado atualmente. + +
+
+
+ Porta DBY - A porta TCP de conexão com o MySQL que o usuário deve usar para conectar. Padrao é 3306. Secundário server, não utilizado atualmente. + +
+
+
+ ID do Alias - O ID do alias usado para permitir balanceamento de carga entre ramais. Não é permitido espacos ou caracteres especiais. Deve ter entre 2 e 20 caracteres. + +
+
+
+ Nome do Alias - O nome usado para descrever o alias do ramal, deve ter entre 2 e 50 caracteres. + +
+
+
+ Lista de Logins de Ramais - Uma lista, separada por vírgulas, logins de ramais usados quando o agente está usando ramais do balanceamento de carga. O aplicativo agente irá encontrar o servidor ativo com a menor quantidade de agentes logados e fazer a chamada a partir daquele servidor para o agente no login. + +
+
+
+ ID do Template - Este é o ID do Template de arquivo conf que este ramal irá usar para as configurações do Asterisk. O padrão é --NONE--. + +
+
+
+ Conf Override Settings - If populated, and the ID do Template is set to --NONE-- then the contents of this field are used as the conf file entries for this phone. generate_vicidial_conf for this phones server must be set to Y for this to work. This field should NOT contain the [extension] line, that will be automatically generated. + +
+
+
+ ID do Alias de Grupo - É o ID do alias de grupo usado por agentes do sistema para realizar chamadas pela interface do VICIDIAL com CallerIDs diferentes. Não é permitido uso de caracteres especiais ou espaços. Deve ter entre 2 e 20 caracteres. + +
+
+
+ Nome do Alias de Grupo - O nome usado para descrever um alias de grupo, Deve ter entre 2 e 20 caracteres de comprimento. + +
+
+
+ Número do CallerID - O Número do Caller ID usado para este alias de grupo. Deve ter apenas dígitos. + +
+
+
+ Nome do CallerID - O Nome do Caller ID que é enviado com esse Alias de Grupo. Até onde sabemos isso só funciona nos circuitos PRI do Canadá e usando trunk IAX com Asterisk. + + + + +



+ + TABELA DOS SERVIDORES

+
+
+ ID do Servidor - Este campo é onde você configura o nome dos servidores Asterisk, nao precisa ser o domínio oficial, apenas um apelido para identificar o servidor para usuários Admin. + +
+
+
+ Descrição do Servidor - O campo onde você usa uma pequena descrição para o servidor Asterisk. + +
+
+
+ Endereço IP do Servidor - O campo onde você configura o endereço IP do servidor Asterisk. + +
+
+
+ Ativo - Configure se o servidor está ativo ou não. + +
+
+
+ Carga do Sistema - Estas duas estatísticas mostram a média de carga de um sistema vezes 100 e o percentual de uso de CPU do servidor, atualizados a cada minuto. A média de carga deve ser em média menor que 100 multiplicado pelo número de núcleos de CPU que seu sistema tem, para melhor performance. O percentual de uso do CPU deve ficar abaixo de 50 para melhor performance. + +
+
+
+ Canais Falando - Este campo mostra o número atual de canais ativos no Asterisk que estão falando neste momento. É importante perceber que o número de canais do Asterisk é normalmente muito mais alto do que as chamadas atuais do sistema. Este campo é atualizado a cada minuto. + +
+
+
+ Uso do HD - Este campo irá mostrar o uso de disco para cada partição neste servidor. Este campo é atualizado a cada minuto. + +
+
+
+ Versão do Asterisk - Configure a versão do Asterisk que está instalada no servidor. Exemplos: '1.2', '1.0.8', '1.0.7', 'CVS_HEAD', 'REALLY OLD', etc... Isto é necessário pois as versões 1.0.8 e 1.0.9 tem metodos diferentes de controlar canais Local, um erro foi arrumado na CVS v1.0, e precisa ser tratado de forma diferente quando usamos os canais "Local". Também, a versão atual CVS_HEAD e a 1.2 usam managers diferentes e os resultados dos comandos devem ser tratados de forma diferente. + +
+
+
+ Qtd máxima de trunks VICIDIAL - Este campo determina o número máximo de linhas que o discador automático do VICIDIAL irá usar para chamar esse servidor. Se você quer dedicar dois canais E1 para discagem automática do VICIDIAL nesse servidor, entao você deve configurar como 60. O valor padrão é 96. + +
+
+
+ Máx. de Chamadas por Segundo - Esta configuração determina o número máximo de chamadas que podem ser feitas pelo script de discagem automática neste servidor por segundo. Deve ser de 1 a 100. O padrão é 20 + +
+
+
+ Host Telnet - Este é o endereço ou nome do servidor Asterisk e é como os aplicativos de gerenciamento se conectam a ele. Se os aplicativos de gerenciamento estiverem sendo executados no próprio servidor Asterisk, então 'localhost' está correto. + +
+
+
+ Porta Telnet - Esta é a porta para conexão com o Manager do servidor Asterisk e é como os aplicativos de gerenciamento se conectam a ele. A porta padrão é '5038' e funciona normalmente com a instalação padrão. + +
+
+
+ Usuário do Manager - O nome do usuário (login) usado para conectar genericamente ao serviço do Manager do Asterisk. O padrão é 'cron' + +
+
+
+ Senha do Manager - A senha usada para a conexão com o serviço do Manager do Asterisk. O padrão é '1234' + +
+
+
+ Usuário de atualização do Manager -O nome do usuário (login) otimizado para atualizações, para se conectar ao serviço do Manager do Asterisk. O padrão é 'updatecron' e asume que a senha é a mesma do usuário genérico. + +
+
+
+ Usuário de Escuta do Manager - O nome de usuário (login) otimizado para escutar eventos de saída, usado para conectar ao serviço de Manager do Asterisk. Padrão é 'listencron' e assume que a senha é a mesma do usuário genérico. + +
+
+
+ Usuário de envio do Manager - O nome de usuário (login) otimizado para enviar Ações para o manager, para se conectar ao serviço do Manager do Asterisk. O Valor padrão é 'sendcron' e assume que a senha é a mesma do usuário genérico. + +
+
+
+ Conf. Archivo Secreto - Este es el secreto, o la contraseña, para que el servidor en el auto iax generado conf para este servidor en otros servidores. Límite es el tablero de 20 caracteres alfanuméricos y de subrayado aceptado. El valor predeterminado es la prueba. + +
+
+
+ Diferença GMT do Servidor- A diferença em horas a partir do horário GMT de onde se encontra o servidor, nao ajustada para o horário de verão. O padrão é '-5' + +
+
+
+ Exten de descarga de Correio de Voz - É o prefixo de exten usado neste servidor para enviar chamadas diretamente pelo agc para uma caixa postal específica. O padrão é '85026666666666' + +
+
+
+ Exten DA do Vicidial - A extensão padrão caso não haja nenhuma na campanha para enviar chamadas do Discador Automático VICIDIAL. Valor Padrão é '8365' + +
+
+
+ Contexto Padrão - O contexto padrão usado para scripts que operam nesse servidor. O valor padrão é 'default' + +
+
+
+ Performance do Sistema - Configurar esta opção como Y irá habilitar a gravação de log de estatísticas de performance do sistema para o servidor, processos do sistema e canais em uso no Asterisk. O padrão é N. + +
+
+
+ Logs do Servidor - Configurando esta opção como Y irá habilitar a gravação de log de todos os scripts do VICIDIAL em arquivos texto. Configurando como N irá parar de escrever logs para os arquivos desses processos, também a gravação de log do Asterisk estará desabilitada se estiver configurada como N quando o Asterisk iniciar. O padrão é Y . + +
+
+
+ Saída AGI - Configurando esta opção como NONE irá desabilitar a saída de todos os scripts AGI do VICIDIAL. Configurando como STDERR irá enviar a saída do AGI para a CLI do Asterisk. Configurando como FILE irá enviar a saída para um arquivo no diretório de log. Configurando como BOTH irá enviar a saída para ambos CLI e o arquivo de log. O padrão é FILE. + +
+
+
+ Discagem Balanceada - Se configurado como Y irá permitir que o servidor faça chamadas balanceadas para as campanhas do VICIDIAL de forma que o nível de chamadas do servidor possa ser alcançado mesmo que nao haja agentes logados nas campanhas deste servidor. Padrão é N. + +
+
+
+ Balance Vicidial Rank - Este campo le permite establecer el orden en que este servidor se va a utilizar para la marcación de equilibrio, si está activada la marcación de equilibrio. El servidor con el rango más alto será usado primero en la colocación de Balance llenar las llamadas. Por defecto es 0. + +
+
+
+ Limites de Balanceamento do VICIDIAL - Esta configuração define o número de trunks não disponíveis ao uso balanceado do VICIDIAL. Por exemplo, se você tem 40 trunks máximos e o limite de balanceamento for 10, você só poderá usar 30 linhas do trunk para balanceamento VICIDIAL. Padrão é 0. + +
+
+
+ Link Web de Gravação - Esta configuração permite que você altere o padrão do link apresentado na tela de gravação no site admin. O padrão é SERVER_IP. + +
+
+
+ IP do Serv. Altern. de Gravação- Esta configuração é onde você pode colocar um IP do servidor ou outro nome de máquina que pode ser usado para colocar no lugar do server_ip nos links de gravação nas páginas do site admin. O padrão é vazio. + +
+
+
+ Servidor Asterisk Ativo - Se o Asterisk não estiver rodando neste servidor, ou se o VICIDIAL não deveria estar usando este servidor, ou se estiver usando este servidor para outros scripts como o de carregamento de hopper, você deve configurar para N. O padrão é Y. + +
+
+
+ Ativo Server Agent - Al establecer esta opción a N de impedir que los agentes de poder acceder a este servidor a través de la pantalla del agente Vicidial. Esto es muy útil cuando se utiliza una carga de inicio de sesión de instalación del teléfono equilibrada. Por defecto es Y. + +
+
+
+ Gerar Arquivos Conf - Se você deseja que o sistema gere automaticamente os arquivos conf do asterisk baseados nas configurações de ramal, operadoras, e balanceamento de carga no VICIDIAL então configure como Y. O padrão é Y. + +
+
+
+ Reconstruir Arquivos Conf - Se você quer forçar a reconstrução dos arquivos conf do Asterisk ou se qualquer um dos ramais ou operadoras foi alterado então isso deve ser Y. Após os aquivos conf terem sido criados e o Asterisk ter sido recarregado, então isso será alterado para N. O padrão é Y. + +
+
+
+ Volver a generar música en espera - Si desea forzar una reconstrucción de la música en los archivos de la bodega o si la música en las entradas de espera ni entradas de servidor han cambiado entonces esto debe establecerse en Y. Después de la música en espera los archivos se han sincronizado y volver a cargar entonces esto va a ser cambiado a N. defecto es Y. + +
+
+
+ Actualización de los sonidos - Si desea forzar una comprobación de los archivos de sonido en este servidor, y el almacén central de audio está activado como una configuración del sistema, este campo permitirán a los sonidos de actualización para ejecutar en la parte superior de la siguiente minuto. Toda vez que un archivo de audio se carga desde la interfaz web de este se ajusta automáticamente a Y para todos los servidores que tienen activos de Asterisk. Por defecto es n. + +
+
+
+ Grabación Vicidial Límite - Este campo es donde se define el número máximo de minutos que una grabación de la llamada iniciada por Vicidial puede ser. Por defecto es de 60 minutos. + +
+
+
+ Portador de registro activo - Esta configuración le permite registrar todos los códigos de retorno para colgar cualquier lista de marcación saliente llamadas que están haciendo. Por defecto es N. + + + + + + +



+ + vicidial_conf_templates TABELA

+
+
+ ID da Template - Este campo precisa ter pelo menos 2 caracteres de comprimento e não mais que 15 caracteres, sem espaços. Este é o ID que irá ser usado para identificar o template de conf no sistema. + +
+
+
+ Nome da Template - Este é o nome descritivo da configuração da template. + +
+
+
+ Conteúdo da Template - Este campo é onde você pode configurar itens específicos para serem usados por todos os ramais e/ou todas as operadoras que estão configuradas para usar este template. Campos que NÃO devem ser incluídos nesse ítem são: secret, accountcode, account, username e mailbox. + + + + + +



+ + vicidial_server_carriers TABELA

+
+
+ ID da Operadora - Este campo precisa ter entre 2 e 15 caracteres de comprimento, sem espaços. Este é o ID que irá ser usado para identificar a operadora no sistema. + +
+
+
+ Nome da Operadora - Este é o nome descritivo da operadora no sistema. + +
+
+
+ Descripción Carrier - Éste se coloca en los comentarios de los archivos de conf asterisco encima del dialplan y anotaciones en cuenta. Máximo 255 caracteres. + +
+
+
+ String de Registro - Este campo é onde você coloca a string necessária na configuração do IAX ou SIP para registrar a operadora. Opcional mas altamente recomendado se sua operadora permite registro . + +
+
+
+ ID do Template - Este campo opcional permite você escolha um template para esta configuração de operadora. + +
+
+
+ Dados da Conta - Este campo é usado se você não selecionou um template para ser usado, e é onde você pode entrar com configurações específicas para serem usadas para esta operadora. Se você receberá chamadas entrantes desta operadora, você deve configurar o context=trunkinbound neste campo para que possa ser usado o processo de controle de DDR do VICIDIAL. + +
+
+
+ Protocolo - Este campo permite que você defina o protocolo a ser usado para esta configuração de operadora. Atualmente somente IAX e SIP são suportados. + +
+
+
+ String Global- Este campo opcional permite definir uma variável global para uso desta operadora no plano de discagem. + +
+
+
+ Plano de Discagem- Este campo opcional permite definir um conjunto de entradas no plano de discagem para serem usados com esta operadora. + +
+
+
+ IP do Servidor - Este é o servidor que este registro de operadora está configurado. + +
+
+
+ Ativo - Isto define se a operadora irá ser incluída nos arquivos conf gerados automáticamente ou não. + + + + + +



+ + TABELA DE CONFERÊNCIAS

+
+
+ Número da Conferência - Este é o campo onde deve ser colocado o número do plano de discagem da conferência. Também é recomendado que o número da conferência esteja também no arquivo meetme.conf. É usado para as conferências do astGUIclient e para funcionalidade de chamada a três no VICIDIAL. + +
+
+
+ IP do Servidor - Deve ser selecionado qual servidor Asterisk esta conferência está configurada. + + + + + 0) + { + ?> +



+ + VICIDIAL_SERVER_TRUNKS TABELA

+
+
+ Trunks do Servidor VICIDIAL permitem que você limite as linhas que são usadas para saída neste servidor para discagem de campanhas ou por cada campanha. Você tem a opção de reservar um número específico de linhas a serem usadas por apenas uma campanha assim como permitir que esta campanha rode nas linhas garantidas a ela e usar linhas que estão abertas, somente se a quantidade total de linhas usadas for menor que a configuração de máximo. Não havendo nenhuma dessas configurações irá permitir que a campanha que discar primeiro, ter quantas linhas ela puder pegar até a quantidade máxima configurada. + + + + + +



+ + SYSTEM_SETTINGS TABELA

+
+
+ Uso Não-Latino - Esta opção permite configurar o padrão de visualização para usar caracteres UTF8 e não filtrar com expressões regulares os caracteres da família dos latinos ou mostrar formatação. Padrão é 0. + +
+
+
+ Raiz Web Gravável - Esta configuração permite que você define se os arquivos temporários e de autenticação devem ser gravados na raiz do website ou do servidor web. Padrão é 1. + +
+
+
+ Mostrar Bloqueio ao Agente VICIDIAL - Este campo é usado para selecionar quando mostrar para um agente que sua sessão foi bloqueada pelo sistema, ação do gerente ou ocorrência externa. A configuração NOT_ACTIVE irá desabilitar a mensagem na tela do agente. A configuração LIVE_AGENTE só irá mostrar a mensagem de bloqueio quando o registro da vicidial_auto_calls for removido, nas situações de logout forçado ou logout de emergência. + +
+
+
+ Permitir Mensagens SIPSAK - Se configurada como 1, irá permitir que a configuração da tabela de ramais funcione corretamente, o servidor irá enviar mensagens para o telefone SIP mostrar no Mostrar LCD quando logado no VICIDIAL. Este recurso só funciona em telefones SIP e requer o aplicativo sipsak instalado no servidor web. O padrão é 0. + +
+
+
+ API do Agente Ativa - Se configurado como 1, irá permitir que a interface API do agente Funcione. O padrão é 0. + +
+
+
+ URL Home do Admin - É a URL do site que você irá se clicar no link HOME no topo da página admin.php. + +
+
+
+ Habilitar Log de Transf.- Esta opção irá gravar um regsitro de ocorrências em um arquivo no servidor web cada vez que uma chamada for transferida para um agente. O padrão é 0, desabilitado. + +
+
+
+ Fim do dia - Esta configuração define quando os usuários devem ser retirados do sistema de ponto automaticamente. Só roda uma vez por dia. Deve ter somente 4 caracteres, 2 para hora e 2 para os minutos no formato 24 horas. O padrão é 0000. + +
+
+
+ Último Sair Automático do Ponto - Este campo mostra a data do último logout automático -. + +
+
+
+ Formato da data do cabeçalho da tela do agente - Este menu permite você escolher o formato da data que é mostrada na parte de cima da tela do agente. As opções para esta configuração são: o padrão é MS_DASH_24HR
+ MS_DASH_24HR 2008-06-24 23:59:59 - Formato de data Padrão com ano mês dia seguido por horário 24 horas
+ US_SLASH_24HR 06/24/2008 23:59:59 - Formato de data dos EUA com mês dia ano seguido por horário 24 horas
+ EU_SLASH_24HR 24/06/2008 23:59:59 - Formato de data Europeu com dia mês ano seguido por horário 24 horas
+ AL_TEXT_24HR JUN 24 23:59:59 - Formato de data abreviada em texto com mes e dia seguido por horário 24 horas
+ MS_DASH_AMPM 2008-06-24 11:59:59 PM - Formato de data Padrão com ano mês dia seguido por horário 12 horas
+ US_SLASH_AMPM 06/24/2008 11:59:59 PM - Formato de data dos EUA com mês dia ano seguido por horário 12 horas
+ EU_SLASH_AMPM 24/06/2008 11:59:59 PM - Formato de data Europeu com dia mês ano seguido por horário 12 horas
+ AL_TEXT_AMPM JUN 24 11:59:59 PM - Formato de data abreviada em texto com mes e dia seguido por horário 12 horas
+ +
+
+
+ Formato da data do cliente na tela do agente - Este menú permite você selecionar o formato para a data no fuso horário do cliente que aparece no topo das informações sobre o cliente na tela do agente. As opções para esta configuração são: o padrão é AL_TEXT_AMPM
+ MS_DASH_24HR 2008-06-24 23:59:59 - Formato de data Padrão com ano mês dia seguido por horário 24 horas
+ US_SLASH_24HR 06/24/2008 23:59:59 - Formato de data dos EUA com mês dia ano seguido por horário 24 horas
+ EU_SLASH_24HR 24/06/2008 23:59:59 - Formato de data Europeu com dia mês ano seguido por horário 24 horas
+ AL_TEXT_24HR JUN 24 23:59:59 - Formato de data abreviada em texto com mes e dia seguido por horário 24 horas
+ MS_DASH_AMPM 2008-06-24 11:59:59 PM - Formato de data Padrão com ano mês dia seguido por horário 12 horas
+ US_SLASH_AMPM 06/24/2008 11:59:59 PM - Formato de data dos EUA com mês dia ano seguido por horário 12 horas
+ EU_SLASH_AMPM 24/06/2008 11:59:59 PM - Formato de data Europeu com dia mês ano seguido por horário 12 horas
+ AL_TEXT_AMPM JUN 24 11:59:59 PM - Formato de data abreviada em texto com mes e dia seguido por horário 12 horas
+ +
+
+
+ Formato do Telefone do Cliente na Tela do Agente - Este menú permite escolher o formato do telefone do cliente que é mostrado na seção de status da tela do agente. As opções são: o padrão é US_PARN
+ US_DASH 000-000-0000 - USA número separado por traço
+ US_PARN (000)000-0000 - USA número separado por traço, ddd entre parentesis
+ MS_NODS 0000000000 - Sem Formatação
+ UK_DASH 00 0000-0000 - UK número separado por traço com espaço após o código da cidade
+ AU_SPAC 000 000 000 - Australia número separado por espaços
+ IT_DASH 0000-000-000 - Italy número separado por traço
+ FR_SPAC 00 00 00 00 00 - France número separado por espaços
+ +
+
+
+ Agent interface API Access Ativo - This option allows you to enable or disable the agent interface API. Default is 0. + +
+
+
+ Trava para Agendamento Vinculado - Esta opção define se Agendamento Vinculado(AGENTONLY) serão travados para a campanha que o a gente originalmente agendou. Configurando como 1 significa que o agente somente pode discar para eles a partir da campanha que os configurou, 0 significa que o agente pode acessar os agendamentos não importando a campanha que eles foram criados. O padrão é 1. + +
+
+
+ Controle Central de Audio Ativado - Esta opção define se o sistema de sincronia de som está ativado entre todos os servidores. O padrão é 0 para inativo. + +
+
+
+ Servidor Web de Sons - Este é o nome do servidor ou endereço IP para o servidor web que estará controlando os arquivos de audio no sistema, isto deve combinar com o nome do servidor ou endereço IP no qual você está tentando acessar a página audio_store.php. O padrão é 127.0.0.1. + +
+
+
+ Diretório Web de Sons - Esta auto-generado nombre del directorio es creado al azar por el sistema como el lugar que la tienda de audio se mantendrá. Todos los archivos de audio residir en este directorio. + +
+
+
+ Servidor de correo de voz activo - En sistemas multi-servidor, este es el servidor que se encargará de todas las casillas de correo de voz. Este servidor es también donde la línea telefónica en mensajes generados se cargan desde el 8168 grabaciones. + +
+
+
+ Discagem Automática Ativa- Esta opção permite você habilitar ou desabilitar a discagem automática de saída do VICIDIAL, configurando este campo como 0 irá remover as seções de LISTAS e FILTROS e vários campos das telas de configuração de Campanha. Discagem Manual ainda será permitida pela tela do agente, mas a discagem por listas não será possível. O padrão é 1 para ativo. + +
+
+
+ Ratio Dial Limit - Este es el límite máximo de la escala de marcación automática en la pantalla de la campaña. + +
+
+
+ Máx. de Cham. Trasnf. por Segundo - Esta configuração determina o número máximo de chamadas que podem ser feitas pelo discador automático de saída para todos os servidores, por segundo. Deve ter entre 1 e 200 caracteres. O padrão é 40. + +
+
+
+ Permitir Custom Dialplan entradas - Esta opción le permite introducir líneas personalizadas dialplan en llamadas menús. El valor predeterminado es 0 para los inactivos. + +
+
+
+ Territorios de usuario de Ativo - Esta configuración le permite habilitar la setttings territorios de usuario desde la pantalla de modificación del usuario. Esta característica se agregó para permitir una mayor integración con una instalación personalizada Vtiger pero puede tener aplicaciones en un sistema de Vicidial pura también. Por defecto es 0 para discapacitados. + +
+
+
+ Formulario de Asistencia Segunda Habilitar - This setting allows you to have a second web form for campaigns and in-groups in the agent interface. Default is 0 for disabled. + +
+
+
+ Habilitar TTS Integración - Esta configuración le permite habilitar Texto a la integración de voz con Cepstral. Esto sólo está disponible actualmente para las campañas de tipo de encuesta de salida. Por defecto es 0 para discapacitados. + +
+
+
+ Recursos de CQ Ativos - Esta opção permite habilitar ou desabilitar os recursos de CQ ou Controle de Qualidade. O padrão é 0 para Inativo. + +
+
+
+ Habilitar Log para o QueueMetrics - Esta configuração permite que você defina se o VICIDIAL irá enviar registros de log para a base de dados queue_log conforme a atividade de Queues do Asterisk faz. QueueMetrics é um programa de fonte fechado para analise estatística. Você deve ter o QueueMetrics instalado e configurado antes de habilitar este recurso. O padrão é 0. + +
+
+
+ IP do servidor do QueueMetrics - É o IP do servidor do QueueMetrics. + +
+
+
+ Nome do BD do QueueMetrics - É o nome do banco de Dados do QueueMetrics. + +
+
+
+ Login do BD do QueueMetrics - éste es el nombre delusuario usado para abrirse una sesión a su base de datos deQueueMetrics. + +
+
+
+ Senha do BD do QueueMetrics - É a senha a ser usada para logar no DB do QueueMetrics. + +
+
+
+ URL do QueueMetrics - É a URL ou endereço do site usado para entrar na sua instalação do QueueMetrics. + +
+
+
+ ID do Log do QueueMetrics - É o ID do servidor que o VICIDIAL coloca no BD do QueueMetrics para identificação de cada registro. + +
+
+
+ Prefixo QueueMetrics EnterQueue - Este campo é usado para permitir prefixar um dos campos da tabela vicidial_list na frente do número do telefone do cliente para relatórios customizados no QueueMetrics. O padrão é NONE para não colocar nada. + +
+
+
+ Habilitar Integração com Vtiger - Esta configuração permite que seja habilitada a integração entre VICIDIAL e VTIGER. Atualmente o único tipo de integração disponível são links para o site de administração, pesquisa e replicação do cadastro de usuários. O padrão é 0. + +
+
+
+ IP do Serv. BD Vtiger - É o endereço IP do servidor de banco de dados da instalação do Vtiger. + +
+
+
+ Base de Dados Vtiger - Este é o nome da base de dados para o Vtiger. + +
+
+
+ Login do BD do Vtiger - É o nome do usuário usado para acessar o BD do Vtiger. + +
+
+
+ Senha do BD Vtiger - É a senha usada para acessar o BD do Vtiger. + +
+
+
+ URL do Vtiger - Esta é a URL ou endereço do site usado para acessar o Vtiger. + + +



+ + VICIDIAL_STATUS TABELA

+
+
+ Com o uso do status do sistema, você pode ter status que existem para campanhas e grupos de entrada. O Status deve ter entre 1 e 6 caracteres de comprimento, a descrição deve ter entre 2 e 30 caracteres de comprimento e Selecionável define se será mostrado no VICIDIAL na finalização da chamada. O campo human_answered é usado para calcular o percentual de drop, ou índice de abandono. Configurando human_answered para Y irá usar este status quando contando as chamadas atendidas por humanos. A opção de Categoria permite agrupar vários status em uma categoria que pode ser usada para análise estatística. Existem também 5 configurações adicionais que irão definir o tipo do status: sale, dnc, customer contact, not interested, unworkable. + + + +



+ + VICIDIAL_STATUS_CATEGORIES TABELA

+
+
+ Através do uso de categoria de status de sistema, você pode agrupar status para permitir análise estatística em um grupo de status. O ID da categoria deve ter entre 2 e 20 caracteres sem espaços, o nome deve ter entre 2 e 50 caracteres, a descrição é opicional e o Mostrar TimeonVDAD define se o status deve ser um dos 4 status que podem ser calculados e mostrados no relatório em tempo real Time On VDAD . A Categoria de Venda e a Categoria Registro Ruim são ambas usadas pelo sistema de Sugestão de Listas quando analisando as estatisticas da lista. + + + 0) + { + ?> +



+ + CÓDIGOS DE STATUS DE CONTROLE DE QUALIDADE

+
+
+ O sistema de Controle de Qualidade do VICIDIAL tem seu conjunto de status separados daqueles usados na finalização de chamadas do VICIDIAL. Os códigos de CQ devem ter entre 2 e 8 caracteres de comprimento e não podem conter caracteres especiais como espaços ou virgulas. A descrição do código de status de CQ deve ter entre 2 e 30 caracteres + + + + +







+







+ FIM +
+ \n"; + echo "\n"; + echo "\n"; + echo ""; + + $stmt="SELECT dial_statuses,local_call_time,lead_filter_id,drop_lockout_time from vicidial_campaigns where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $dial_statuses = $row[0]; + $local_call_time = $row[1]; + $drop_lockout_time = $row[3]; + if ($lead_filter_id=='') + { + $lead_filter_id = $row[2]; + if ($lead_filter_id=='') + { + $lead_filter_id='NONE'; + } + } + + $stmt="SELECT list_id,active,list_name from vicidial_lists where campaign_id='$campaign_id'"; + $rslt=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rslt); + $camp_lists=''; + $o=0; + while ($lists_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $o++; + if (ereg("Y", $rowx[1])) {$camp_lists .= "'$rowx[0]',";} + } + $camp_lists = eregi_replace(".$","",$camp_lists); + + $filterSQL = $filtersql_list[$lead_filter_id]; + $filterSQL = preg_replace("/\\\\/","",$filterSQL); + $filterSQL = eregi_replace("^and|and$|^or|or$","",$filterSQL); + if (strlen($filterSQL)>4) + {$fSQL = "and $filterSQL";} + else + {$fSQL = '';} + + + echo "

\n"; + echo "Mostrar Quantidade de Registros Discáveis -

\n"; + echo "CAMPANHA: $campaign_id
\n"; + echo "LISTAS: $camp_lists
\n"; + echo "STATUS: $dial_statuses
\n"; + echo "FILTER: $lead_filter_id
\n"; + echo "CALL TIME: $local_call_time

\n"; + + ### call function to calculate and print dialable leads + dialable_leads($DB,$link,$local_call_time,$dial_statuses,$camp_lists,$drop_lockout_time,$fSQL); + + echo "

\n"; + echo "\n"; + + exit; + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=7111111 view sample script with test variables +###################### + +if ($ADD==7111111) + { + ##### TEST VARIABLES ##### + $vendor_lead_code = 'VENDOR:LEAD;CODE'; + $list_id = 'LISTID'; + $gmt_offset_now = 'GMTOFFSET'; + $phone_code = '1'; + $phone_number = '7275551212'; + $title = 'Mr.'; + $first_name = 'JOHN'; + $middle_initial = 'Q'; + $last_name = 'PUBLIC'; + $address1 = '1234 Main St.'; + $address2 = 'Apt. 3'; + $address3 = 'ADDRESS3'; + $city = 'CHICAGO'; + $state = 'IL'; + $province = 'PROVINCE'; + $postal_code = '33760'; + $country_code = 'USA'; + $gender = 'M'; + $date_of_birth = '1970-01-01'; + $alt_phone = '3125551111'; + $email = 'test@test.com'; + $security_phrase = 'SECUTIRY'; + $comments = 'COMMENTS FIELD'; + $RGfullname = 'JOE AGENT'; + $RGuser = '6666'; + $RGlead_id = '1234'; + $RGcampaign = 'TESTCAMP'; + $RGphone_login = 'gs102'; + $RGgroup = 'TESTCAMP'; + $RGchannel_group = 'TESTCAMP'; + $RGSQLdate = date("Y-m-d H:i:s"); + $RGepoch = date("U"); + $RGuniqueid = '1163095830.4136'; + $RGcustomer_zap_channel = 'Zap/1-1'; + $RGserver_ip = '10.10.10.15'; + $RGSIPexten = 'SIP/gs102'; + $RGsession_id = '8600051'; + $RGdialed_number = '3125551111'; + $RGdialed_label = 'ALT'; + $RGrank = '99'; + $RGowner = '6666'; + $RGcamp_script = 'TESTSCRIPT'; + $RGin_script = ''; + $script_width = '600'; + $script_height = '400'; + $recording_filename = '20091204-1639_6666_7275551212'; + $recording_id = '1235'; + $user_custom_one = 'custom one'; + $user_custom_two = 'custom two'; + $user_custom_three = 'custom three'; + $user_custom_four = 'custom four'; + $user_custom_five = 'custom five'; + $preset_number_a = 'preset_a'; + $preset_number_b = 'preset_b'; + $preset_number_c = 'preset_c'; + $preset_number_d = 'preset_d'; + $preset_number_e = 'preset_e'; + $preset_number_f = 'preset_f'; + $preset_dtmf_a = 'preset_dtmf_a'; + $preset_dtmf_b = 'preset_dtmf_b'; + + echo "\n"; + echo "\n"; + echo "\n"; + echo ""; + + $stmt="SELECT script_id,script_name,script_comments,script_text,active from vicidial_scripts where script_id='$script_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $script_name = $row[1]; + $script_text = stripslashes($row[3]); + + if (eregi("iframe src",$script_text)) + { + $vendor_lead_code = eregi_replace(' ','+',$vendor_lead_code); + $list_id = eregi_replace(' ','+',$list_id); + $gmt_offset_now = eregi_replace(' ','+',$gmt_offset_now); + $phone_code = eregi_replace(' ','+',$phone_code); + $phone_number = eregi_replace(' ','+',$phone_number); + $title = eregi_replace(' ','+',$title); + $first_name = eregi_replace(' ','+',$first_name); + $middle_initial = eregi_replace(' ','+',$middle_initial); + $last_name = eregi_replace(' ','+',$last_name); + $address1 = eregi_replace(' ','+',$address1); + $address2 = eregi_replace(' ','+',$address2); + $address3 = eregi_replace(' ','+',$address2); + $city = eregi_replace(' ','+',$city); + $state = eregi_replace(' ','+',$state); + $province = eregi_replace(' ','+',$province); + $postal_code = eregi_replace(' ','+',$postal_code); + $country_code = eregi_replace(' ','+',$country_code); + $gender = eregi_replace(' ','+',$gender); + $date_of_birth = eregi_replace(' ','+',$date_of_birth); + $alt_phone = eregi_replace(' ','+',$alt_phone); + $email = eregi_replace(' ','+',$email); + $security_phrase = eregi_replace(' ','+',$security_phrase); + $comments = eregi_replace(' ','+',$comments); + $RGfullname = eregi_replace(' ','+',$RGfullname); + $RGuser = eregi_replace(' ','+',$RGuser); + $RGlead_id = eregi_replace(' ','+',$RGlead_id); + $RGcampaign = eregi_replace(' ','+',$RGcampaign); + $RGphone_login = eregi_replace(' ','+',$RGphone_login); + $RGgroup = eregi_replace(' ','+',$RGgroup); + $RGchannel_group = eregi_replace(' ','+',$RGchannel_group); + $RGSQLdate = eregi_replace(' ','+',$RGSQLdate); + $RGepoch = eregi_replace(' ','+',$RGepoch); + $RGuniqueid = eregi_replace(' ','+',$RGuniqueid); + $RGcustomer_zap_channel = eregi_replace(' ','+',$RGcustomer_zap_channel); + $RGserver_ip = eregi_replace(' ','+',$RGserver_ip); + $RGSIPexten = eregi_replace(' ','+',$RGSIPexten); + $RGsession_id = eregi_replace(' ','+',$RGsession_id); + $RGdialed_number = eregi_replace(' ','+',$RGdialed_number); + $RGdialed_label = eregi_replace(' ','+',$RGdialed_label); + $RGrank = eregi_replace(' ','+',$RGrank); + $RGowner = eregi_replace(' ','+',$RGowner); + $RGcamp_script = eregi_replace(' ','+',$RGcamp_script); + $RGin_script = eregi_replace(' ','+',$RGin_script); + $script_width = eregi_replace(' ','+',$script_width); + $script_height = eregi_replace(' ','+',$script_height); + $recording_filename = eregi_replace(' ','+',$recording_filename); + $recording_id = eregi_replace(' ','+',$recording_id); + $user_custom_one = eregi_replace(' ','+',$user_custom_one); + $user_custom_two = eregi_replace(' ','+',$user_custom_two); + $user_custom_three = eregi_replace(' ','+',$user_custom_three); + $user_custom_four = eregi_replace(' ','+',$user_custom_four); + $user_custom_five = eregi_replace(' ','+',$user_custom_five); + $preset_number_a = eregi_replace(' ','+',$preset_number_a); + $preset_number_b = eregi_replace(' ','+',$preset_number_b); + $preset_number_c = eregi_replace(' ','+',$preset_number_c); + $preset_number_d = eregi_replace(' ','+',$preset_number_d); + $preset_number_e = eregi_replace(' ','+',$preset_number_e); + $preset_number_f = eregi_replace(' ','+',$preset_number_f); + $preset_dtmf_a = eregi_replace(' ','+',$preset_dtmf_a); + $preset_dtmf_b = eregi_replace(' ','+',$preset_dtmf_b); + } + + $script_text = eregi_replace('--A--vendor_lead_code--B--',"$vendor_lead_code",$script_text); + $script_text = eregi_replace('--A--list_id--B--',"$list_id",$script_text); + $script_text = eregi_replace('--A--gmt_offset_now--B--',"$gmt_offset_now",$script_text); + $script_text = eregi_replace('--A--phone_code--B--',"$phone_code",$script_text); + $script_text = eregi_replace('--A--phone_number--B--',"$phone_number",$script_text); + $script_text = eregi_replace('--A--title--B--',"$title",$script_text); + $script_text = eregi_replace('--A--first_name--B--',"$first_name",$script_text); + $script_text = eregi_replace('--A--middle_initial--B--',"$middle_initial",$script_text); + $script_text = eregi_replace('--A--last_name--B--',"$last_name",$script_text); + $script_text = eregi_replace('--A--address1--B--',"$address1",$script_text); + $script_text = eregi_replace('--A--address2--B--',"$address2",$script_text); + $script_text = eregi_replace('--A--address3--B--',"$address3",$script_text); + $script_text = eregi_replace('--A--city--B--',"$city",$script_text); + $script_text = eregi_replace('--A--state--B--',"$state",$script_text); + $script_text = eregi_replace('--A--province--B--',"$province",$script_text); + $script_text = eregi_replace('--A--postal_code--B--',"$postal_code",$script_text); + $script_text = eregi_replace('--A--country_code--B--',"$country_code",$script_text); + $script_text = eregi_replace('--A--gender--B--',"$gender",$script_text); + $script_text = eregi_replace('--A--date_of_birth--B--',"$date_of_birth",$script_text); + $script_text = eregi_replace('--A--alt_phone--B--',"$alt_phone",$script_text); + $script_text = eregi_replace('--A--email--B--',"$email",$script_text); + $script_text = eregi_replace('--A--security_phrase--B--',"$security_phrase",$script_text); + $script_text = eregi_replace('--A--comments--B--',"$comments",$script_text); + $script_text = eregi_replace('--A--fullname--B--',"$RGfullname",$script_text); + $script_text = eregi_replace('--A--fronter--B--',"$RGuser",$script_text); + $script_text = eregi_replace('--A--user--B--',"$RGuser",$script_text); + $script_text = eregi_replace('--A--lead_id--B--',"$RGlead_id",$script_text); + $script_text = eregi_replace('--A--campaign--B--',"$RGcampaign",$script_text); + $script_text = eregi_replace('--A--phone_login--B--',"$RGphone_login",$script_text); + $script_text = eregi_replace('--A--group--B--',"$RGgroup",$script_text); + $script_text = eregi_replace('--A--channel_group--B--',"$RGchannel_group",$script_text); + $script_text = eregi_replace('--A--SQLdate--B--',"$RGSQLdate",$script_text); + $script_text = eregi_replace('--A--epoch--B--',"$RGepoch",$script_text); + $script_text = eregi_replace('--A--uniqueid--B--',"$RGuniqueid",$script_text); + $script_text = eregi_replace('--A--customer_zap_channel--B--',"$RGcustomer_zap_channel",$script_text); + $script_text = eregi_replace('--A--server_ip--B--',"$RGserver_ip",$script_text); + $script_text = eregi_replace('--A--SIPexten--B--',"$RGSIPexten",$script_text); + $script_text = eregi_replace('--A--session_id--B--',"$RGsession_id",$script_text); + $script_text = eregi_replace('--A--dialed_number--B--',"$RGdialed_number",$script_text); + $script_text = eregi_replace('--A--dialed_label--B--',"$RGdialed_label",$script_text); + $script_text = eregi_replace('--A--rank--B--',"$RGrank",$script_text); + $script_text = eregi_replace('--A--owner--B--',"$RGowner",$script_text); + $script_text = eregi_replace('--A--camp_script--B--',"$RGcamp_script",$script_text); + $script_text = eregi_replace('--A--in_script--B--',"$RGin_script",$script_text); + $script_text = eregi_replace('--A--script_width--B--',"$script_width",$script_text); + $script_text = eregi_replace('--A--script_height--B--',"$script_height",$script_text); + $script_text = eregi_replace('--A--recording_filename--B--',"$recording_filename",$script_text); + $script_text = eregi_replace('--A--recording_id--B--',"$recording_id",$script_text); + $script_text = eregi_replace('--A--user_custom_one--B--',"$user_custom_one",$script_text); + $script_text = eregi_replace('--A--user_custom_two--B--',"$user_custom_two",$script_text); + $script_text = eregi_replace('--A--user_custom_three--B--',"$user_custom_three",$script_text); + $script_text = eregi_replace('--A--user_custom_four--B--',"$user_custom_four",$script_text); + $script_text = eregi_replace('--A--user_custom_five--B--',"$user_custom_five",$script_text); + $script_text = eregi_replace('--A--preset_number_a--B--',"$preset_number_a",$script_text); + $script_text = eregi_replace('--A--preset_number_b--B--',"$preset_number_b",$script_text); + $script_text = eregi_replace('--A--preset_number_c--B--',"$preset_number_c",$script_text); + $script_text = eregi_replace('--A--preset_number_d--B--',"$preset_number_d",$script_text); + $script_text = eregi_replace('--A--preset_number_e--B--',"$preset_number_e",$script_text); + $script_text = eregi_replace('--A--preset_number_f--B--',"$preset_number_f",$script_text); + $script_text = eregi_replace('--A--preset_dtmf_a--B--',"$preset_dtmf_a",$script_text); + $script_text = eregi_replace('--A--preset_dtmf_b--B--',"$preset_dtmf_b",$script_text); + $script_text = eregi_replace("\n","
",$script_text); + + + echo ""; + + echo "Pré-Visualizar Script: $script_id
\n"; + echo "
\n"; + echo "
$script_name
\n"; + echo "$script_text\n"; + echo "
\n"; + + echo "\n"; + + exit; + } + + +$ADMIN=$PHP_SELF; +require("admin_header.php"); + + + + + +###################################################################################################### +###################################################################################################### +####### 1 series, ADD NEW forms for inserting new records into the database +###################################################################################################### +###################################################################################################### + + +###################### +# ADD=1 display the ADD NEW USER FORM SCREEN +###################### + +if ($ADD=="1") + { + if ($LOGmodify_users==1) + { + ##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value ##### + $stmt = "SELECT count(*) FROM vicidial_override_ids where id_table='vicidial_users' and active='1';"; + $rslt=mysql_query($stmt, $link); + $voi_ct = mysql_num_rows($rslt); + if ($voi_ct > 0) + { + $row=mysql_fetch_row($rslt); + $voi_count = "$row[0]"; + } + ##### END ID override optional section ##### + + echo "
\n"; + echo ""; + + echo "
INCLUIR USUÁRIO
\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + if ($voi_count > 0) + { + echo "\n"; + } + else + { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "$NWB#vicidial_users-user_group$NWE\n"; + echo "\n"; + echo "
Número do usuário: Auto-Generated $NWB#vicidial_users-user$NWE
Número do usuário: $NWB#vicidial_users-user$NWE
Senha: $NWB#vicidial_users-pass$NWE
Nome Completo: $NWB#vicidial_users-full_name$NWE
Nível do Usuário: $NWB#vicidial_users-user_level$NWE
Grupo do Usuário:
Login do Ramal: $NWB#vicidial_users-phone_login$NWE
Senha do Ramal: $NWB#vicidial_users-phone_pass$NWE
\n"; + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=1A display the COPY USER FORM SCREEN +###################### + +if ($ADD=="1A") + { + if ($LOGmodify_users==1) + { + ##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value ##### + $stmt = "SELECT count(*) FROM vicidial_override_ids where id_table='vicidial_users' and active='1';"; + $rslt=mysql_query($stmt, $link); + $voi_ct = mysql_num_rows($rslt); + if ($voi_ct > 0) + { + $row=mysql_fetch_row($rslt); + $voi_count = "$row[0]"; + } + ##### END ID override optional section ##### + + echo "
\n"; + echo ""; + + echo "
COPIAR USUÁRIO\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + if ($voi_count > 0) + { + echo "\n"; + } + else + { + echo "\n"; + } + echo "\n"; + echo "\n"; + + if ($LOGuser_level==9) {$levelMAX=10;} + else {$levelMAX=$LOGuser_level;} + + echo "\n"; + echo "\n"; + echo "
Número do usuário: Auto-Generated $NWB#vicidial_users-user$NWE
Número do usuário: $NWB#vicidial_users-user$NWE
Senha: $NWB#vicidial_users-pass$NWE
Nome Completo: $NWB#vicidial_users-full_name$NWE
Source Usuário: $NWB#vicidial_users-user$NWE
\n"; + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=11 display the ADD NEW CAMPAIGN FORM SCREEN +###################### + +if ($ADD==11) + { + if ($LOGmodify_campaigns==1) + { + ##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value ##### + $stmt = "SELECT count(*) FROM vicidial_override_ids where id_table='vicidial_campaigns' and active='1';"; + $rslt=mysql_query($stmt, $link); + $voi_ct = mysql_num_rows($rslt); + if ($voi_ct > 0) + { + $row=mysql_fetch_row($rslt); + $voi_count = "$row[0]"; + } + ##### END ID override optional section ##### + + echo "
\n"; + echo ""; + + echo "
NOVA CAMPANHA\n"; + echo "\n"; + echo "
\n"; + if ($voi_count > 0) + { + echo "\n"; + } + else + { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + if ($SSoutbound_autodial_active > 0) + { + echo "\n"; + echo "\n"; + echo "\n"; + } + echo "\n"; + echo "\n"; + if ($SSoutbound_autodial_active > 0) + { + echo "\n"; + } + echo "\n"; + + $eswHTML=''; + if ($SSenable_second_webform > 0) + {$eswHTML = '';} + echo "\n"; + echo "\n"; + echo "
ID da Campanha: Auto-Generated $NWB#vicidial_campaigns-campaign_id$NWE
ID da Campanha: $NWB#vicidial_campaigns-campaign_id$NWE
Nome da Campanha: $NWB#vicidial_campaigns-campaign_name$NWE
Descrição da Campanha: $NWB#vicidial_campaigns-campaign_description$NWE
Ativo: $NWB#vicidial_campaigns-active$NWE
Extensão de Estacionamento: $NWB#vicidial_campaigns-park_ext$NWE
Nome do arquivo de Estacionamento: $NWB#vicidial_campaigns-park_file_name$NWE
Formulário Web: $NWB#vicidial_campaigns-web_form_address$NWE
Permitir Finalizadores (Closers): $NWB#vicidial_campaigns-allow_closers$NWE
Nível do Hopper: $NWB#vicidial_campaigns-hopper_level$NWE
Nível de Discagem Automática: (0 = off)$NWB#vicidial_campaigns-auto_dial_level$NWE
Próximo Agente a chamar: $NWB#vicidial_campaigns-next_agent_call$NWE
Horário Local da Chamada: $NWB#vicidial_campaigns-local_call_time$NWE
Correio de Voz: $NWB#vicidial_campaigns-voicemail_ext$NWE
Script: $NWB#vicidial_campaigns-campaign_script$NWE
Pegar lançamento da chamada: $NWB#vicidial_campaigns-get_call_launch$NWE
\n"; + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=12 display the COPY CAMPAIGN FORM SCREEN +###################### + +if ($ADD==12) + { + if ($LOGmodify_campaigns==1) + { + ##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value ##### + $stmt = "SELECT count(*) FROM vicidial_override_ids where id_table='vicidial_campaigns' and active='1';"; + $rslt=mysql_query($stmt, $link); + $voi_ct = mysql_num_rows($rslt); + if ($voi_ct > 0) + { + $row=mysql_fetch_row($rslt); + $voi_count = "$row[0]"; + } + ##### END ID override optional section ##### + + echo "
\n"; + echo ""; + + echo "
COPIAR CAMPANHA\n"; + echo "\n"; + echo "
\n"; + if ($voi_count > 0) + { + echo "\n"; + } + else + { + echo "\n"; + } + echo "\n"; + + echo "\n"; + + echo "\n"; + echo "\n"; + echo "
ID da Campanha: Auto-Generated $NWB#vicidial_campaigns-campaign_id$NWE
ID da Campanha: $NWB#vicidial_campaigns-campaign_id$NWE
Nome da Campanha: $NWB#vicidial_campaigns-campaign_name$NWE
Campanha Origem:$NWB#vicidial_campaigns-campaign_id$NWE
ATENÇÃO: Copiar uma campanha irá copiar todas as configurações da campanha que você escolher, mas não irá copiar a lista de bloqueio específica da campanha que você selecionar.
\n"; + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=111 display the ADD NEW LIST FORM SCREEN +###################### + +if ($ADD==111) + { + if ($LOGmodify_lists==1) + { + ##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value ##### + $stmt = "SELECT count(*) FROM vicidial_override_ids where id_table='vicidial_lists' and active='1';"; + $rslt=mysql_query($stmt, $link); + $voi_ct = mysql_num_rows($rslt); + if ($voi_ct > 0) + { + $row=mysql_fetch_row($rslt); + $voi_count = "$row[0]"; + } + ##### END ID override optional section ##### + + echo "
\n"; + echo ""; + + echo "
ADD A NEW LIST\n"; + echo "\n"; + echo "
\n"; + if ($voi_count > 0) + { + echo "\n"; + } + else + { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
ID da Lista: Auto-Generated $NWB#vicidial_lists-list_id$NWE
ID da Lista: (somente dígitos)$NWB#vicidial_lists-list_id$NWE
Nome da Lista: $NWB#vicidial_lists-list_name$NWE
Descrição da Lista: $NWB#vicidial_lists-list_description$NWE
Campanha: $NWB#vicidial_lists-campaign_id$NWE
Ativo: $NWB#vicidial_lists-active$NWE
\n"; + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=121 display the ADD NUMBER TO DNC FORM SCREEN and add a new number +###################### + +if ($ADD==121) + { + echo "
\n"; + echo ""; + + $campaigns_list = "\n"; + + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns where use_campaign_dnc IN('Y','AREACODE') order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $campaigns_to_print = mysql_num_rows($rslt); + + $o=0; + while ($campaigns_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $campaigns_list .= "\n"; + $o++; + } + + if (strlen($phone_numbers) > 2) + { + $PN = explode("\n",$phone_numbers); + $PNct = count($PN); + $p=0; + while ($p < $PNct) + { + if ( (ereg('delete',$stage)) and ($LOGdelete_from_dnc > 0) ) + { + ##### BEGIN DELETE FROM DNC ##### + if (ereg('SYSTEM_INTERNAL',$campaign_id)) + { + $stmt="SELECT count(*) from vicidial_dnc where phone_number='$PN[$p]';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] < 1) + {echo "
BLOQUEIO NÃO REMOVIDO - Este número de telefone não está na lista de bloqueio: $PN[$p]\n";} + else + { + $stmt="DELETE FROM vicidial_dnc where phone_number='$PN[$p]';"; + $rslt=mysql_query($stmt, $link); + + echo "
BLOQUEIO REMOVIDO: $PN[$p]\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='LISTAS', event_type='DELETE', record_id='$PN[$p]', event_code='ADMIN DELETE NUMBER FROM DNC LIST', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + else + { + $stmt="SELECT count(*) from vicidial_campaign_dnc where phone_number='$PN[$p]' and campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] < 1) + {echo "
BLOQUEIO NÃO REMOVIDO - Este número de telefone não está na lista de bloqueio: $PN[$p] $campaign_id\n";} + else + { + $stmt="DELETE FROM vicidial_campaign_dnc where phone_number='$PN[$p]' and campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
BLOQUEIO REMOVIDO: $PN[$p] $campaign_id\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='LISTAS', event_type='DELETE', record_id='$PN[$p]', event_code='ADMIN DELETE NUMBER FROM CAMPANHA DNC LIST $campaign_id', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + ##### END DELETE FROM DNC ##### + } + else + { + ##### BEGIN ADD TO DNC ##### + if (ereg('SYSTEM_INTERNAL',$campaign_id)) + { + $stmt="SELECT count(*) from vicidial_dnc where phone_number='$PN[$p]';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
Bloqueio não Cadastrado - Este número já existe na lista de bloqueio: $PN[$p]\n";} + else + { + $stmt="INSERT INTO vicidial_dnc (phone_number) values('$PN[$p]');"; + $rslt=mysql_query($stmt, $link); + + echo "
Bloqueio Adicionado: $PN[$p]\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='LISTAS', event_type='ADD', record_id='$PN[$p]', event_code='ADMIN INCLUIR NÚMERO AO BLOQUEIO LIST', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + else + { + $stmt="SELECT count(*) from vicidial_campaign_dnc where phone_number='$PN[$p]' and campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
Bloqueio não Cadastrado - Este número já existe na lista de bloqueio: $PN[$p] $campaign_id\n";} + else + { + $stmt="INSERT INTO vicidial_campaign_dnc (phone_number,campaign_id) values('$PN[$p]','$campaign_id');"; + $rslt=mysql_query($stmt, $link); + + echo "
Bloqueio Adicionado: $PN[$p] $campaign_id\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='LISTAS', event_type='ADD', record_id='$PN[$p]', event_code='ADMIN ADD NUMBER TO CAMPANHA DNC LIST $campaign_id', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + ##### END ADD TO DNC ##### + } + $p++; + } + } + + if ($LOGdelete_from_dnc > 0) + {echo "
INCLUIR OU REMOVER TELEFONES DA LISTA DE BLOQUEIO\n";} + else + {echo "
INCLUIR NÚMEROS PARA LISTA DE BLOQUEIO\n";} + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + if ($LOGdelete_from_dnc > 0) + { + echo "\n"; + } + echo "\n"; + echo "
List:
Números de Telefone:

(somente um telefone por linha)
$NWB#vicidial_list-dnc$NWE
Incluir ou Remover:
\n"; + } + + +###################### +# ADD=1111 display the ADD NEW INBOUND GROUP SCREEN +###################### + +if ($ADD==1111) + { + if ($LOGmodify_ingroups==1) + { + ##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value ##### + $stmt = "SELECT count(*) FROM vicidial_override_ids where id_table='vicidial_inbound_groups' and active='1';"; + $rslt=mysql_query($stmt, $link); + $voi_ct = mysql_num_rows($rslt); + if ($voi_ct > 0) + { + $row=mysql_fetch_row($rslt); + $voi_count = "$row[0]"; + } + ##### END ID override optional section ##### + + echo "
\n"; + echo ""; + + echo "
NOVO GRUPO DE ENTRADA\n"; + echo "\n"; + echo "
\n"; + if ($voi_count > 0) + { + echo "\n"; + } + else + { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $eswHTML=''; + if ($SSenable_second_webform > 0) + {$eswHTML = '';} + echo "\n"; + echo "\n"; + echo "
ID do Grupo: Auto-Generated $NWB#vicidial_inbound_groups-group_id$NWE
ID do Grupo: (no spaces)$NWB#vicidial_inbound_groups-group_id$NWE
Nome do Grupo: $NWB#vicidial_inbound_groups-group_name$NWE
Cor do Grupo: $NWB#vicidial_inbound_groups-group_color$NWE
Ativo: $NWB#vicidial_inbound_groups-active$NWE
Formulário Web: $NWB#vicidial_inbound_groups-web_form_address$NWE
Correio de Voz: $NWB#vicidial_inbound_groups-voicemail_ext$NWE
Próximo Agente a chamar: $NWB#vicidial_inbound_groups-next_agent_call$NWE
Mostrar Fronter: $NWB#vicidial_inbound_groups-fronter_display$NWE
Script: $NWB#vicidial_inbound_groups-ingroup_script$NWE
Pegar lançamento da chamada: $NWB#vicidial_inbound_groups-get_call_launch$NWE
\n"; + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=1211 display the COPY INBOUND GROUP SCREEN +###################### + +if ($ADD==1211) + { + if ($LOGmodify_ingroups==1) + { + ##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value ##### + $stmt = "SELECT count(*) FROM vicidial_override_ids where id_table='vicidial_inbound_groups' and active='1';"; + $rslt=mysql_query($stmt, $link); + $voi_ct = mysql_num_rows($rslt); + if ($voi_ct > 0) + { + $row=mysql_fetch_row($rslt); + $voi_count = "$row[0]"; + } + ##### END ID override optional section ##### + + echo "
\n"; + echo ""; + + echo "
COPIAR GRUPO DE ENTRADA\n"; + echo "\n"; + echo "
\n"; + if ($voi_count > 0) + { + echo "\n"; + } + else + { + echo "\n"; + } + echo "\n"; + + echo "\n"; + + echo "\n"; + echo "
ID do Grupo: Auto-Generated $NWB#vicidial_inbound_groups-group_id$NWE
ID do Grupo: (no spaces)$NWB#vicidial_inbound_groups-group_id$NWE
Nome do Grupo: $NWB#vicidial_inbound_groups-group_name$NWE
Source ID do Grupo: $NWB#vicidial_inbound_groups-group_id$NWE
\n"; + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=1311 display the ADD NEW DID SCREEN +###################### + +if ($ADD==1311) + { + if ($LOGmodify_dids==1) + { + echo "
\n"; + echo ""; + + echo "
INCLUIR DDR\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Extensão DDR: (no spaces or dashes)$NWB#vicidial_inbound_dids-did_pattern$NWE
Descrição DDR:$NWB#vicidial_inbound_dids-did_description$NWE
\n"; + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=1411 display the COPY DID SCREEN +###################### + +if ($ADD==1411) + { + if ($LOGmodify_dids==1) + { + echo "
\n"; + echo ""; + + echo "
COPIAR DDR\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + + echo "\n"; + echo "
Extensão DDR: (no spaces or dashes)$NWB#vicidial_inbound_dids-did_pattern$NWE
Descrição DDR:$NWB#vicidial_inbound_dids-did_description$NWE
DDR Origem:$NWB#vicidial_inbound_dids-did_pattern$NWE
\n"; + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=1511 display the ADD NEW CALL MENU SCREEN +###################### + +if ($ADD==1511) + { + if ($LOGmodify_dids==1) + { + ##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value ##### + $stmt = "SELECT count(*) FROM vicidial_override_ids where id_table='vicidial_call_menu' and active='1';"; + $rslt=mysql_query($stmt, $link); + $voi_ct = mysql_num_rows($rslt); + if ($voi_ct > 0) + { + $row=mysql_fetch_row($rslt); + $voi_count = "$row[0]"; + } + ##### END ID override optional section ##### + + echo "
\n"; + echo ""; + + echo "
INCLUIR UM MENU\n"; + echo "\n"; + echo "
\n"; + if ($voi_count > 0) + { + echo "\n"; + } + else + { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "
ID do Menu: Auto-Generated $NWB#vicidial_call_menu-menu_id$NWE
ID do Menu: (no spaces or special characters)$NWB#vicidial_call_menu-menu_id$NWE
Nome do Menu: $NWB#vicidial_call_menu-menu_name$NWE
\n"; + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=1611 display the COPY CALL MENU SCREEN +###################### + +if ($ADD==1611) + { + if ($LOGmodify_dids==1) + { + ##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value ##### + $stmt = "SELECT count(*) FROM vicidial_override_ids where id_table='vicidial_call_menu' and active='1';"; + $rslt=mysql_query($stmt, $link); + $voi_ct = mysql_num_rows($rslt); + if ($voi_ct > 0) + { + $row=mysql_fetch_row($rslt); + $voi_count = "$row[0]"; + } + ##### END ID override optional section ##### + + echo "
\n"; + echo ""; + + echo "
COPIAR UM MENU\n"; + echo "\n"; + echo "
\n"; + if ($voi_count > 0) + { + echo "\n"; + } + else + { + echo "\n"; + } + echo "\n"; + + echo "\n"; + + echo "\n"; + echo "
ID do Menu: Auto-Generated $NWB#vicidial_call_menu-menu_id$NWE
ID do Menu: (no spaces or special characters)$NWB#vicidial_call_menu-menu_id$NWE
Nome do Menu: $NWB#vicidial_call_menu-menu_name$NWE
Menu Origem: $NWB#vicidial_call_menu-menu_id$NWE
\n"; + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=11111 display the ADD NEW REMOTE AGENTS SCREEN +###################### + +if ($ADD==11111) + { + if ($LOGmodify_remoteagents==1) + { + echo "
\n"; + echo ""; + + echo "
NOVO AGENTE REMOTO\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Início do ID do Usuário: (somente números, incremented)$NWB#vicidial_remote_agents-user_start$NWE
Número de linhas: (somente números)$NWB#vicidial_remote_agents-number_of_lines$NWE
IP do Servidor: $NWB#vicidial_remote_agents-server_ip$NWE
Extensão Externa: (número do plano de discagem para ligar para agentes)$NWB#vicidial_remote_agents-conf_exten$NWE
Status: $NWB#vicidial_remote_agents-status$NWE
Campanha: $NWB#vicidial_remote_agents-campaign_id$NWE
Grupos de Entrada: \n"; + echo "$groups_list"; + echo "$NWB#vicidial_remote_agents-closer_campaigns$NWE
\n"; + echo "AVISO: Pode demorar até 30 segundos para que as alterações enviadas por essa tela se tornem ativas\n"; + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=111111 display the ADD NEW USERS GROUP SCREEN +###################### + +if ($ADD==111111) + { + if ($LOGmodify_usergroups==1) + { + ##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value ##### + $stmt = "SELECT count(*) FROM vicidial_override_ids where id_table='vicidial_user_groups' and active='1';"; + $rslt=mysql_query($stmt, $link); + $voi_ct = mysql_num_rows($rslt); + if ($voi_ct > 0) + { + $row=mysql_fetch_row($rslt); + $voi_count = "$row[0]"; + } + ##### END ID override optional section ##### + + echo "
\n"; + echo ""; + + echo "
NOVO GRUPO DE USUÁRIOS\n"; + echo "\n"; + echo "
\n"; + if ($voi_count > 0) + { + echo "\n"; + } + else + { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "
Grupo: Auto-Generated $NWB#vicidial_user_groups-user_group$NWE
Grupo: (sem espaços ou pontos)$NWB#vicidial_user_groups-user_group$NWE
Descrição: (descrição do grupo)$NWB#vicidial_user_groups-group_name$NWE
\n"; + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=1111111 display the ADD NEW SCRIPT SCREEN +###################### + +if ($ADD==1111111) + { + if ($LOGmodify_scripts==1) + { + ##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value ##### + $stmt = "SELECT count(*) FROM vicidial_override_ids where id_table='vicidial_scripts' and active='1';"; + $rslt=mysql_query($stmt, $link); + $voi_ct = mysql_num_rows($rslt); + if ($voi_ct > 0) + { + $row=mysql_fetch_row($rslt); + $voi_count = "$row[0]"; + } + ##### END ID override optional section ##### + + echo "
\n"; + echo ""; + + echo "
ADD NEW SCRIPT\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + if ($voi_count > 0) + { + echo "\n"; + } + else + { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
ID do Script: Auto-Generated $NWB#vicidial_scripts-script_id$NWE
ID do Script: (sem espaços ou pontos)$NWB#vicidial_scripts-script_id$NWE
Nome do Script: (título do script)$NWB#vicidial_scripts-script_name$NWE
Comentários do Script: $NWB#vicidial_scripts-script_comments$NWE
Ativo: $NWB#vicidial_scripts-active$NWE
Texto do Script: "; + # BEGIN Insert Field + echo ""; + echo "
"; + # END Insert Field + echo " $NWB#vicidial_scripts-script_text$NWE
\n"; + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=11111111 display the ADD NEW FILTER SCREEN +###################### + +if ($ADD==11111111) + { + if ($LOGmodify_filters==1) + { + ##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value ##### + $stmt = "SELECT count(*) FROM vicidial_override_ids where id_table='vicidial_lead_filters' and active='1';"; + $rslt=mysql_query($stmt, $link); + $voi_ct = mysql_num_rows($rslt); + if ($voi_ct > 0) + { + $row=mysql_fetch_row($rslt); + $voi_count = "$row[0]"; + } + ##### END ID override optional section ##### + + echo "
\n"; + echo ""; + + echo "
INCLUIR NOVO FILTRO\n"; + echo "\n"; + echo "
\n"; + if ($voi_count > 0) + { + echo "\n"; + } + else + { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
ID do Filtro:Auto-Generated $NWB#vicidial_lead_filters-lead_filter_id$NWE
ID do Filtro: (sem espaços ou pontos)$NWB#vicidial_lead_filters-lead_filter_id$NWE
Nome do Filtro: (descrição simples do filtro)$NWB#vicidial_lead_filters-lead_filter_name$NWE
Comentários do filtro: $NWB#vicidial_lead_filters-lead_filter_comments$NWE
Filtro SQL: $NWB#vicidial_lead_filters-lead_filter_sql$NWE
\n"; + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=111111111 display the ADD NEW CALL TIME SCREEN +###################### + +if ($ADD==111111111) + { + if ($LOGmodify_call_times==1) + { + echo "
\n"; + echo ""; + + echo "
NOVO HORÁRIO DE CHAM.\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "
ID do Horário de Cham.: (sem espaços ou pontos)$NWB#vicidial_call_times-call_time_id$NWE
Nome do Horário de Cham.: (descrição curta do horário de chamada)$NWB#vicidial_call_times-call_time_name$NWE
Comentários do Horário de cham.: $NWB#vicidial_call_times-call_time_comments$NWE
Opções de dia e hora irão aparecer assim que você crie definições de Horário de Chamada
\n"; + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=1111111111 display the ADD NEW STATE CALL TIME SCREEN +###################### + +if ($ADD==1111111111) + { + if ($LOGmodify_call_times==1) + { + echo "
\n"; + echo ""; + + echo "
NOVO HORÁRIO DE CHAM. POR ESTADO\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "
ID do horário de chamada por estado: (sem espaços ou pontos)$NWB#vicidial_call_times-call_time_id$NWE
State Call Time State: (sem espaços ou pontos)$NWB#vicidial_call_times-state_call_time_state$NWE
Nome do horário de chamada por estado: (descrição curta do horário de chamada)$NWB#vicidial_call_times-call_time_name$NWE
Comentários do horário de chamada por estado: $NWB#vicidial_call_times-call_time_comments$NWE
Opções de dia e hora irão aparecer assim que você crie definições de Horário de Chamada
\n"; + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=131111111 display the ADD NEW SHIFT SCREEN +###################### + +if ($ADD==131111111) + { + if ($LOGmodify_call_times==1) + { + echo "
\n"; + echo ""; + + echo "
ADD NEW SHIFT\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
ID do Turno: (sem espaços ou pontos)$NWB#vicidial_shifts-shift_id$NWE
Nome do Turno: (descrição curta do turno)$NWB#vicidial_shifts-shift_name$NWE
Início do Turno:\n"; + echo "   Final do Turno:\n"; + echo " $NWB#vicidial_shifts-shift_start_time$NWE
Duração do Turno: $NWB#vicidial_shifts-shift_length$NWE
Dias do Turno:
$NWB#vicidial_shifts-shift_weekdays$NWE
\n"; + echo "Domingo
\n"; + echo "Segunda
\n"; + echo "Terça
\n"; + echo "Quarta
\n"; + echo "Quinta
\n"; + echo "Sexta
\n"; + echo "Sábado
\n"; + echo "
\n"; + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=11111111111 display the ADD NEW PHONE SCREEN +###################### + +if ($ADD==11111111111) + { + if ($LOGast_admin_access==1) + { + ##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value ##### + $stmt = "SELECT count(*) FROM vicidial_override_ids where id_table='phones' and active='1';"; + $rslt=mysql_query($stmt, $link); + $voi_ct = mysql_num_rows($rslt); + if ($voi_ct > 0) + { + $row=mysql_fetch_row($rslt); + $voi_count = "$row[0]"; + } + ##### END ID override optional section ##### + + echo "
\n"; + echo ""; + + echo "
INCLUIR RAMAL\n"; + echo "\n"; + echo "
\n"; + + echo "
\n"; + if ($voi_count > 0) + { + echo "\n"; + } + else + { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Extensão do Ramal: Auto-Generated $NWB#phones-extension$NWE
Extensão do Ramal: $NWB#phones-extension$NWE
Número no Plano de Discagem: (somente dígitos)$NWB#phones-dialplan_number$NWE
Caixa do Correio de Voz: (somente dígitos)$NWB#phones-voicemail_id$NWE
CallerID de Saída: (somente dígitos)$NWB#phones-outbound_cid$NWE
Endereço IP do Ramal: (optional)$NWB#phones-phone_ip$NWE
Endereço IP do Computador: (optional)$NWB#phones-computer_ip$NWE
IP do Servidor: $NWB#phones-server_ip$NWE
Login: $NWB#phones-login$NWE
Senha: $NWB#phones-pass$NWE
Status: $NWB#phones-status$NWE
Conta Ativa: $NWB#phones-active$NWE
Tipo de Ramal: $NWB#phones-phone_type$NWE
Nome Completo: $NWB#phones-fullname$NWE
Empresa: $NWB#phones-company$NWE
Foto: $NWB#phones-picture$NWE
Protocolo do Cliente: $NWB#phones-protocol$NWE
GMT Local: (NÃO ajuste para o horário de verão)$NWB#phones-local_gmt$NWE
\n"; + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=12111111111 display the ADD NEW PHONE ALIAS SCREEN +###################### + +if ($ADD==12111111111) + { + if ($LOGast_admin_access==1) + { + echo "
\n"; + echo ""; + + echo "
INCLUIR ALIAS DE RAMAL\n"; + echo "\n"; + echo "
\n"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "
ID do Alias:$NWB#phones-alias_id$NWE
Nome do Alias: $NWB#phones-alias_name$NWE
Lista de Logins de Ramal: (comma separated)$NWB#phones-logins_list$NWE
\n"; + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=13111111111 display the ADD NEW GROUP ALIAS SCREEN +###################### + +if ($ADD==13111111111) + { + if ($LOGast_admin_access==1) + { + echo "
\n"; + echo ""; + + echo "
INCLUIR NOVO ALIAS DE GRUPO\n"; + echo "\n"; + echo "
\n"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "
ID do Alias: $NWB#phones-group_alias_id$NWE
Nome do Alias: $NWB#phones-group_alias_name$NWE
Número CallerID: $NWB#phones-caller_id_number$NWE
Nome CallerID: $NWB#phones-caller_id_name$NWE
Ativo:
\n"; + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=111111111111 display the ADD NEW SERVER SCREEN +###################### + +if ($ADD==111111111111) + { + if ($LOGmodify_servers==1) + { + echo "
\n"; + echo ""; + + echo "
INCLUIR SERVIDOR\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
ID do Servidor: $NWB#servers-server_id$NWE
Descrição do Servidor: $NWB#servers-server_description$NWE
Endereço IP do Servidor: $NWB#servers-server_ip$NWE
Ativo: $NWB#servers-active$NWE
Versão do Asterisk: $NWB#servers-asterisk_version$NWE
\n"; + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=131111111111 display the ADD NEW CONF TEMPLATE SCREEN +###################### + +if ($ADD==131111111111) + { + if ($LOGmodify_servers==1) + { + echo "
\n"; + echo ""; + + echo "
INCLUIR TEMPLATE CONF\n"; + echo "\n"; + echo "
\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
ID do Template: $NWB#vicidial_conf_templates-template_id$NWE
Nome do Template: $NWB#vicidial_conf_templates-template_name$NWE
Conteúdo do Template: $NWB#vicidial_conf_templates-template_contents$NWE
\n"; + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=141111111111 display the ADD NEW CARRIER SCREEN +###################### + +if ($ADD==141111111111) + { + if ($LOGmodify_servers==1) + { + echo "
\n"; + echo ""; + + echo "
Incluir Operadora\n"; + echo "\n"; + echo "
\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + echo "
ID da Operadora: $NWB#vicidial_server_carriers-carrier_id$NWE
Nome da Operadora: $NWB#vicidial_server_carriers-carrier_name$NWE
Descripción Carrier: $NWB#vicidial_server_carriers-carrier_description$NWE
String de Registro: $NWB#vicidial_server_carriers-registration_string$NWE
ID do Template: $NWB#vicidial_server_carriers-template_id$NWE
Dados da Conta: $NWB#vicidial_server_carriers-account_entry$NWE
Protocolo: $NWB#vicidial_server_carriers-protocol$NWE
String Global: $NWB#vicidial_server_carriers-globals_string$NWE
Plano de Discagem: $NWB#vicidial_server_carriers-dialplan_entry$NWE
IP do Servidor: $NWB#vicidial_server_carriers-server_ip$NWE
\n"; + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=151111111111 display the ADD NEW TTS ENTRY SCREEN +###################### + +if ($ADD==151111111111) + { + if ($LOGmodify_servers==1) + { + echo "
\n"; + echo ""; + + echo "
ADD NEW TTS ENTRADA\n"; + echo "\n"; + echo "
\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "
TTS ID: $NWB#vicidial_tts_prompts-tts_id$NWE
Nombre TTS: $NWB#vicidial_tts_prompts-tts_name$NWE
Ativo:
\n"; + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=161111111111 display the ADD NEW MUSIC ON HOLD ENTRY SCREEN +###################### + +if ($ADD==161111111111) + { + if ($LOGmodify_servers==1) + { + echo "
\n"; + echo ""; + + echo "
ADD NEW MUSIC EN ESPERA DE ENTRADA\n"; + echo "\n"; + echo "
\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "
Música en espera de identificación: $NWB#vicidial_music_on_hold-moh_id$NWE
Música en espera Nombre: $NWB#vicidial_music_on_hold-moh_name$NWE
Orden aleatorio:
\n"; + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=171111111111 display the ADD NEW VOICEMAIL BOX SCREEN +###################### + +if ($ADD==171111111111) + { + if ($LOGmodify_servers==1) + { + echo "
\n"; + echo ""; + + echo "
ADD NEW contestador\n"; + echo "\n"; + echo "
\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "
ID de correo de voz: $NWB#vicidial_voicemail-voicemail_id$NWE
Pass: $NWB#vicidial_voicemail-pass$NWE
Name: $NWB#vicidial_voicemail-fullname$NWE
Ativo:
Email:$NWB#vicidial_voicemail-email$NWE
\n"; + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=1111111111111 display the ADD NEW CONFERENCE SCREEN +###################### + +if ($ADD==1111111111111) + { + if ($LOGast_admin_access==1) + { + echo "
\n"; + echo ""; + + echo "
INCLUIR CONFERÊNCIA\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Número da Conferência: (somente dígitos)$NWB#conferences-conf_exten$NWE
IP do Servidor: $NWB#conferences-server_ip$NWE
\n"; + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=11111111111111 display the ADD NEW VICIDIAL CONFERENCE SCREEN +###################### + +if ($ADD==11111111111111) + { + if ($LOGast_admin_access==1) + { + echo "
\n"; + echo ""; + + echo "
ADD A NEW VICIDIAL CONFERENCE\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Número da Conferência: (somente dígitos)$NWB#conferences-conf_exten$NWE
IP do Servidor: $NWB#conferences-server_ip$NWE
\n"; + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + + +###################################################################################################### +###################################################################################################### +####### 2 series, validates form data and inserts the new record into the database +###################################################################################################### +###################################################################################################### + + +###################### +# ADD=2 adds the new user to the system +###################### + +if ($ADD=="2") + { + ##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value ##### + $stmt = "SELECT value FROM vicidial_override_ids where id_table='vicidial_users' and active='1';"; + $rslt=mysql_query($stmt, $link); + $voi_ct = mysql_num_rows($rslt); + if ($voi_ct > 0) + { + $row=mysql_fetch_row($rslt); + $user = ($row[0] + 1); + + $stmt="UPDATE vicidial_override_ids SET value='$user' where id_table='vicidial_users' and active='1';"; + $rslt=mysql_query($stmt, $link); + } + ##### END ID override optional section ##### + + echo ""; + $stmt="SELECT count(*) from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
USUÁRIO NÃO ADICIONADO - já existe um usuário no sistema com esse número\n";} + else + { + if (ereg('AUTOGENERA',$user)) + { + $user = 'AUTOGENERA'; + } + if ( (strlen($user) < 2) or (strlen($pass) < 2) or (strlen($full_name) < 2) or (strlen($user_group) < 2) or ( (strlen($user) > 20) and (!ereg('AUTOGENERA',$user)) ) ) + { + echo "
USUÁRIO NÃO ADICIONADO - Por favor volte e verifique os dados digitados\n"; + echo "
user id must be between 2 and 20 characters long\n"; + echo "
nome completo e senha devem ter pelo menos 2 caracteres de comprimento\n"; + echo "
usted debe seleccionar un grupo de usuarios\n"; + } + else + { + if (ereg('AUTOGENERA',$user)) + { + $new_user=0; + $auto_user_add_value=0; + while ($new_user < 2) + { + if ($new_user < 1) + { + $stmt = "SELECT auto_user_add_value FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + $ss_auav_ct = mysql_num_rows($rslt); + if ($ss_auav_ct > 0) + { + $row=mysql_fetch_row($rslt); + $auto_user_add_value = $row[0]; + } + $new_user++; + } + $stmt = "SELECT count(*) FROM vicidial_users where user='$auto_user_add_value';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] < 1) + { + $new_user++; + } + else + { + echo "\n"; + $auto_user_add_value = ($auto_user_add_value + 7); + } + } + $user = $auto_user_add_value; + echo "
user_id has been auto-generated: $user
\n"; + + $stmt="UPDATE system_settings SET auto_user_add_value='$user';"; + $rslt=mysql_query($stmt, $link); + } + echo "
USUÁRIO ADICIONADO: $user\n"; + + $stmt="INSERT INTO vicidial_users (user,pass,full_name,user_level,user_group,phone_login,phone_pass) values('$user','$pass','$full_name','$user_level','$user_group','$phone_login','$phone_pass');"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='USUÁRIOS', event_type='ADD', record_id='$user', event_code='ADMIN ADD USER', event_sql=\"$SQL_log\", event_notes='user: $user';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + ############################################################### + ##### START SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP ##### + $stmt = "SELECT enable_vtiger_integration,vtiger_server_ip,vtiger_dbname,vtiger_login,vtiger_pass,vtiger_url FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $ss_conf_ct = mysql_num_rows($rslt); + if ($ss_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $enable_vtiger_integration = $row[0]; + $vtiger_server_ip = $row[1]; + $vtiger_dbname = $row[2]; + $vtiger_login = $row[3]; + $vtiger_pass = $row[4]; + $vtiger_url = $row[5]; + } + ##### END SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP ##### + ############################################################# + + if ($enable_vtiger_integration > 0) + { + ### connect to your vtiger database + $linkV=mysql_connect("$vtiger_server_ip", "$vtiger_login","$vtiger_pass"); + if (!$linkV) {die("Could not connect: $vtiger_server_ip|$vtiger_dbname|$vtiger_login|$vtiger_pass" . mysql_error());} + echo 'Connected successfully'; + mysql_select_db("$vtiger_dbname", $linkV); + + $user_name = $user; + $user_password = $pass; + $last_name = $full_name; + $is_admin = 'off'; + $roleid = 'H5'; + $status = 'Ativo'; + $groupid = '1'; + if ($user_level >= 7) {$roleid = 'H3';} + if ($user_level >= 8) {$roleid = 'H4';} + if ($user_level >= 9) {$roleid = 'H2';} + if ($user_level >= 9) {$is_admin = 'on';} + $salt = substr($user_name, 0, 2); + $salt = '$1$' . $salt . '$'; + $encrypted_password = crypt($user_password, $salt); + + ###################################### + ##### BEGIN Add/Update group info in Vtiger + $stmt="SELECT count(*) from vtiger_groups where groupname='$user_group';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $group_found_count = $row[0]; + + ### group exists in vtiger, update it + if ($group_found_count > 0) + { + $stmt="SELECT groupid from vtiger_groups where groupname='$user_group';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $groupid = $row[0]; + } + + ### user doesn't exist in vtiger, insert it + else + { + #### BEGIN CREATE NEW GROUP RECORD IN VTIGER + # Get next available id from vtiger_users_seq to use as groupid + $stmt="SELECT id from vtiger_users_seq;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + $row=mysql_fetch_row($rslt); + $groupid = ($row[0] + 1); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + # Increase next available groupid with 1 so next record gets proper id + $stmt="UPDATE vtiger_users_seq SET id = '$groupid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtA = "INSERT INTO vtiger_groups SET groupid='$groupid',groupname='$user_group',description='';"; + if ($DB) {echo "|$stmtA|\n";} + $rslt=mysql_query($stmtA, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #### END CREATE NEW GROUP RECORD IN VTIGER + } + ##### END Add/Update group info in Vtiger + ###################################### + + ###################################### + ##### BEGIN Add/Update user info in Vtiger + $stmt="SELECT count(*) from vtiger_users where user_name='$user_name';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $found_count = $row[0]; + + ### user exists in vtiger, update it + if ($found_count > 0) + { + $stmt="SELECT id from vtiger_users where user_name='$user_name';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $userid = $row[0]; + + $stmt="SELECT count(*) from vtiger_users2group WHERE userid='$userid' and groupid='$groupid';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $usergroupcount = $row[0]; + + $stmtA = "UPDATE vtiger_users SET user_password='$encrypted_password',last_name='$last_name',is_admin='$is_admin',status='$status' where id='$userid';"; + if ($DB) {echo "|$stmtA|\n";} + $rslt=mysql_query($stmtA, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtB = "UPDATE vtiger_user2role SET roleid='$roleid' where userid='$userid';"; + if ($DB) {echo "|$stmtB|\n";} + $rslt=mysql_query($stmtB, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + if ($usergroupcount < 1) + { + $stmt="SELECT user_group FROM vicidial_user_groups;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VD_groups_ct = mysql_num_rows($rslt); + $k=0; + $VD_groups_list=''; + while ($k < $VD_groups_ct) + { + $row=mysql_fetch_row($rslt); + $VD_groups_list .= "'$row[0]',"; + $k++; + } + $VD_groups_list = preg_replace("/.$/",'',$VD_groups_list); + + $stmtC = "DELETE FROM vtiger_users2group WHERE userid='$userid' and groupid IN(SELECT groupid from vtiger_groups where groupname IN($VD_groups_list));"; + if ($DB) {echo "|$stmtC|\n";} + $rslt=mysql_query($stmtC, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtD = "INSERT INTO vtiger_users2group SET userid='$userid',groupid='$groupid';"; + if ($DB) {echo "|$stmtD|\n";} + $rslt=mysql_query($stmtD, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + } + } + + ### user doesn't exist in vtiger, insert it + else + { + #### BEGIN CREATE NEW USER RECORD IN VTIGER + $stmtA = "INSERT INTO vtiger_users SET user_name='$user_name',user_password='$encrypted_password',last_name='$last_name',is_admin='$is_admin',status='$status',date_format='yyyy-mm-dd',first_name='',reports_to_id='',description='',title='',department='',phone_home='',phone_mobile='',phone_work='',phone_other='',phone_fax='',email1='',email2='',yahoo_id='',signature='',address_street='',address_city='',address_state='',address_country='',address_postalcode='',user_preferences='',imagename='';"; + if ($DB) {echo "|$stmtA|\n";} + $rslt=mysql_query($stmtA, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $userid = mysql_insert_id($linkV); + + $stmtB = "INSERT INTO vtiger_user2role SET userid='$userid',roleid='$roleid';"; + if ($DB) {echo "|$stmtB|\n";} + $rslt=mysql_query($stmtB, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtC = "INSERT INTO vtiger_users2group SET userid='$userid',groupid='$groupid';"; + if ($DB) {echo "|$stmtC|\n";} + $rslt=mysql_query($stmtC, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtD = "UPDATE vtiger_users_seq SET id='$userid';"; + if ($DB) {echo "|$stmtD|\n";} + $rslt=mysql_query($stmtD, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #### END CREATE NEW USER RECORD IN VTIGER + } + ##### END Add/Update user info in Vtiger + ###################################### + } + ### END vtiger integration + } + } + + $ADD=3; + } + +###################### +# ADD=2A adds the copied new user to the system +###################### + +if ($ADD=="2A") + { + ##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value ##### + $stmt = "SELECT value FROM vicidial_override_ids where id_table='vicidial_users' and active='1';"; + $rslt=mysql_query($stmt, $link); + $voi_ct = mysql_num_rows($rslt); + if ($voi_ct > 0) + { + $row=mysql_fetch_row($rslt); + $user = ($row[0] + 1); + + $stmt="UPDATE vicidial_override_ids SET value='$user' where id_table='vicidial_users' and active='1';"; + $rslt=mysql_query($stmt, $link); + } + ##### END ID override optional section ##### + + echo ""; + $stmt="SELECT count(*) from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
USUÁRIO NÃO ADICIONADO - já existe um usuário no sistema com esse número\n";} + else + { + if ( (strlen($user) < 2) or (strlen($pass) < 2) or (strlen($full_name) < 2) or (strlen($user) > 20) ) + { + echo "
USUÁRIO NÃO ADICIONADO - Por favor volte e verifique os dados digitados\n"; + echo "
user id must be between 2 and 20 characters long\n"; + echo "
nome completo e senha devem ter pelo menos 2 caracteres de comprimento\n"; + echo "\n"; + } + else + { + if (ereg('AUTOGEN',$user)) + { + $new_user=0; + $auto_user_add_value=0; + while ($new_user < 2) + { + if ($new_user < 1) + { + $stmt = "SELECT auto_user_add_value FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + $ss_auav_ct = mysql_num_rows($rslt); + if ($ss_auav_ct > 0) + { + $row=mysql_fetch_row($rslt); + $auto_user_add_value = $row[0]; + } + $new_user++; + } + $stmt = "SELECT count(*) FROM vicidial_users where user='$auto_user_add_value';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] < 1) + { + $new_user++; + } + else + { + echo "\n"; + $auto_user_add_value = ($auto_user_add_value + 7); + } + } + $user = $auto_user_add_value; + echo "
user_id has been auto-generated: $user
\n"; + + $stmt="UPDATE system_settings SET auto_user_add_value='$user';"; + $rslt=mysql_query($stmt, $link); + } + $stmt="INSERT INTO vicidial_users (user,pass,full_name,user_level,user_group,phone_login,phone_pass,delete_users,delete_user_groups,delete_lists,delete_campaigns,delete_ingroups,delete_remote_agents,load_leads,campaign_detail,ast_admin_access,ast_delete_phones,delete_scripts,modify_leads,hotkeys_active,change_agent_campaign,agent_choose_ingroups,closer_campaigns,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,delete_filters,alter_agent_interface_options,closer_default_blended,delete_call_times,modify_call_times,modify_users,modify_campaigns,modify_lists,modify_scripts,modify_filters,modify_ingroups,modify_usergroups,modify_remoteagents,modify_servers,view_reports,vicidial_recording_override,alter_custdata_override,qc_enabled,qc_user_level,qc_pass,qc_finish,qc_commit,add_timeclock_log,modify_timeclock_log,delete_timeclock_log,alter_custphone_override,vdc_agent_api_access,modify_inbound_dids,delete_inbound_dids,active,alert_enabled,download_lists,agent_shift_enforcement_override,manager_shift_enforcement_override,export_reports,delete_from_dnc,email,user_code,territory,allow_alerts,agent_choose_territories,custom_one,custom_two,custom_three,custom_four,custom_five) SELECT \"$user\",\"$pass\",\"$full_name\",user_level,user_group,phone_login,phone_pass,delete_users,delete_user_groups,delete_lists,delete_campaigns,delete_ingroups,delete_remote_agents,load_leads,campaign_detail,ast_admin_access,ast_delete_phones,delete_scripts,modify_leads,hotkeys_active,change_agent_campaign,agent_choose_ingroups,closer_campaigns,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,delete_filters,alter_agent_interface_options,closer_default_blended,delete_call_times,modify_call_times,modify_users,modify_campaigns,modify_lists,modify_scripts,modify_filters,modify_ingroups,modify_usergroups,modify_remoteagents,modify_servers,view_reports,vicidial_recording_override,alter_custdata_override,qc_enabled,qc_user_level,qc_pass,qc_finish,qc_commit,add_timeclock_log,modify_timeclock_log,delete_timeclock_log,alter_custphone_override,vdc_agent_api_access,modify_inbound_dids,delete_inbound_dids,active,alert_enabled,download_lists,agent_shift_enforcement_override,manager_shift_enforcement_override,export_reports,delete_from_dnc,email,user_code,territory,allow_alerts,agent_choose_territories,custom_one,custom_two,custom_three,custom_four,custom_five from vicidial_users where user=\"$source_user_id\";"; + $rslt=mysql_query($stmt, $link); + + $stmtA="INSERT INTO vicidial_inbound_group_agents (user,group_id,group_rank,group_weight,calls_today) SELECT \"$user\",group_id,group_rank,group_weight,\"0\" from vicidial_inbound_group_agents where user=\"$source_user_id\";"; + $rslt=mysql_query($stmtA, $link); + + $stmtA="INSERT INTO vicidial_campaign_agents (user,campaign_id,campaign_rank,campaign_weight,calls_today) SELECT \"$user\",campaign_id,campaign_rank,campaign_weight,\"0\" from vicidial_campaign_agents where user=\"$source_user_id\";"; + $rslt=mysql_query($stmtA, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='USUÁRIOS', event_type='COPY', record_id='$user', event_code='ADMIN COPIAR USUÁRIO', event_sql=\"$SQL_log\", event_notes='user: $user';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + ############################################################### + ##### START SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP ##### + $stmt = "SELECT enable_vtiger_integration,vtiger_server_ip,vtiger_dbname,vtiger_login,vtiger_pass,vtiger_url FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $ss_conf_ct = mysql_num_rows($rslt); + if ($ss_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $enable_vtiger_integration = $row[0]; + $vtiger_server_ip = $row[1]; + $vtiger_dbname = $row[2]; + $vtiger_login = $row[3]; + $vtiger_pass = $row[4]; + $vtiger_url = $row[5]; + } + ##### END SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP ##### + ############################################################# + + if ($enable_vtiger_integration > 0) + { + ### connect to your vtiger database + $linkV=mysql_connect("$vtiger_server_ip", "$vtiger_login","$vtiger_pass"); + if (!$linkV) {die("Could not connect: $vtiger_server_ip|$vtiger_dbname|$vtiger_login|$vtiger_pass" . mysql_error());} + echo 'Connected successfully'; + mysql_select_db("$vtiger_dbname", $linkV); + + $user_name = $user; + $user_password = $pass; + $last_name = $full_name; + $is_admin = 'off'; + $roleid = 'H5'; + $status = 'Ativo'; + $groupid = '1'; + if ($user_level >= 7) {$roleid = 'H3';} + if ($user_level >= 8) {$roleid = 'H4';} + if ($user_level >= 9) {$roleid = 'H2';} + if ($user_level >= 9) {$is_admin = 'on';} + $salt = substr($user_name, 0, 2); + $salt = '$1$' . $salt . '$'; + $encrypted_password = crypt($user_password, $salt); + + ###################################### + ##### BEGIN Add/Update group info in Vtiger + $stmt="SELECT count(*) from vtiger_groups where groupname='$user_group';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $group_found_count = $row[0]; + + ### group exists in vtiger, update it + if ($group_found_count > 0) + { + $stmt="SELECT groupid from vtiger_groups where groupname='$user_group';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $groupid = $row[0]; + } + + ### user doesn't exist in vtiger, insert it + else + { + #### BEGIN CREATE NEW GROUP RECORD IN VTIGER + # Get next available id from vtiger_users_seq to use as groupid + $stmt="SELECT id from vtiger_users_seq;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + $row=mysql_fetch_row($rslt); + $groupid = ($row[0] + 1); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + # Increase next available groupid with 1 so next record gets proper id + $stmt="UPDATE vtiger_users_seq SET id = '$groupid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtA = "INSERT INTO vtiger_groups SET groupid='$groupid',groupname='$user_group',description='';"; + if ($DB) {echo "|$stmtA|\n";} + $rslt=mysql_query($stmtA, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #### END CREATE NEW GROUP RECORD IN VTIGER + } + ##### END Add/Update group info in Vtiger + ###################################### + + ###################################### + ##### BEGIN Add/Update user info in Vtiger + $stmt="SELECT count(*) from vtiger_users where user_name='$user_name';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $found_count = $row[0]; + + ### user exists in vtiger, update it + if ($found_count > 0) + { + $stmt="SELECT id from vtiger_users where user_name='$user_name';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $userid = $row[0]; + + $stmt="SELECT count(*) from vtiger_users2group WHERE userid='$userid' and groupid='$groupid';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $usergroupcount = $row[0]; + + $stmtA = "UPDATE vtiger_users SET user_password='$encrypted_password',last_name='$last_name',is_admin='$is_admin',status='$status' where id='$userid';"; + if ($DB) {echo "|$stmtA|\n";} + $rslt=mysql_query($stmtA, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtB = "UPDATE vtiger_user2role SET roleid='$roleid' where userid='$userid';"; + if ($DB) {echo "|$stmtB|\n";} + $rslt=mysql_query($stmtB, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + if ($usergroupcount < 1) + { + $stmt="SELECT user_group FROM vicidial_user_groups;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VD_groups_ct = mysql_num_rows($rslt); + $k=0; + $VD_groups_list=''; + while ($k < $VD_groups_ct) + { + $row=mysql_fetch_row($rslt); + $VD_groups_list .= "'$row[0]',"; + $k++; + } + $VD_groups_list = preg_replace("/.$/",'',$VD_groups_list); + + $stmtC = "DELETE FROM vtiger_users2group WHERE userid='$userid' and groupid IN(SELECT groupid from vtiger_groups where groupname IN($VD_groups_list));"; + if ($DB) {echo "|$stmtC|\n";} + $rslt=mysql_query($stmtC, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtD = "INSERT INTO vtiger_users2group SET userid='$userid',groupid='$groupid';"; + if ($DB) {echo "|$stmtD|\n";} + $rslt=mysql_query($stmtD, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + } + } + + ### user doesn't exist in vtiger, insert it + else + { + #### BEGIN CREATE NEW USER RECORD IN VTIGER + $stmtA = "INSERT INTO vtiger_users SET user_name='$user_name',user_password='$encrypted_password',last_name='$last_name',is_admin='$is_admin',status='$status',date_format='yyyy-mm-dd',first_name='',reports_to_id='',description='',title='',department='',phone_home='',phone_mobile='',phone_work='',phone_other='',phone_fax='',email1='',email2='',yahoo_id='',signature='',address_street='',address_city='',address_state='',address_country='',address_postalcode='',user_preferences='',imagename='';"; + if ($DB) {echo "|$stmtA|\n";} + $rslt=mysql_query($stmtA, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $userid = mysql_insert_id($linkV); + + $stmtB = "INSERT INTO vtiger_user2role SET userid='$userid',roleid='$roleid';"; + if ($DB) {echo "|$stmtB|\n";} + $rslt=mysql_query($stmtB, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtC = "INSERT INTO vtiger_users2group SET userid='$userid',groupid='$groupid';"; + if ($DB) {echo "|$stmtC|\n";} + $rslt=mysql_query($stmtC, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtD = "UPDATE vtiger_users_seq SET id='$userid';"; + if ($DB) {echo "|$stmtD|\n";} + $rslt=mysql_query($stmtD, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #### END CREATE NEW USER RECORD IN VTIGER + } + ##### END Add/Update user info in Vtiger + ###################################### + } + ### END vtiger integration + + echo "
USER COPIED: $user copied from $source_user_id\n"; + echo "

\n"; + echo "Click here to go to the user record\n"; + echo "

\n"; + + } + } + exit; + } + +###################### +# ADD=21 adds the new campaign to the system +###################### + +if ($ADD==21) + { + ##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value ##### + $stmt = "SELECT value FROM vicidial_override_ids where id_table='vicidial_campaigns' and active='1';"; + $rslt=mysql_query($stmt, $link); + $voi_ct = mysql_num_rows($rslt); + if ($voi_ct > 0) + { + $row=mysql_fetch_row($rslt); + $campaign_id = ($row[0] + 1); + + $stmt="UPDATE vicidial_override_ids SET value='$campaign_id' where id_table='vicidial_campaigns' and active='1';"; + $rslt=mysql_query($stmt, $link); + } + ##### END ID override optional section ##### + + echo ""; + $stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CAMPANHA NÃO ADICIONADA - já existe uma campanha com esse ID no sistema\n";} + else + { + $stmt="SELECT count(*) from vicidial_inbound_groups where group_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CAMPANHA NOT ADDED - there is already an inbound group in the system with this ID\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($campaign_id) > 8) or (strlen($campaign_name) < 6) or (strlen($campaign_name) > 40) ) + { + echo "
CAMPANHA NÃO ADICIONADA - Por favor volte e verifique os dados digitados\n"; + echo "
ID da campanha deve ter entre 2 e 8 caracteres de comprimento\n"; + echo "
o nome da campanha deve ter entre 6 e 40 caracteres de comprimento\n"; + } + else + { + echo "
CAMPANHA ADICIONADA: $campaign_id\n"; + + $stmt="INSERT INTO vicidial_campaigns (campaign_id,campaign_name,campaign_description,active,dial_status_a,lead_order,park_ext,park_file_name,web_form_address,allow_closers,hopper_level,auto_dial_level,next_agent_call,local_call_time,voicemail_ext,campaign_script,get_call_launch,campaign_changedate,campaign_stats_refresh,list_order_mix,web_form_address_two,start_call_url,dispo_call_url) values('$campaign_id','$campaign_name','$campaign_description','$active','NEW','DOWN','$park_ext','$park_file_name','" . mysql_real_escape_string($web_form_address) . "','$allow_closers','$hopper_level','$auto_dial_level','$next_agent_call','$local_call_time','$voicemail_ext','$script_id','$get_call_launch','$SQLdate','Y','DISABLED','','','');"; + $rslt=mysql_query($stmt, $link); + + $stmtA="INSERT INTO vicidial_campaign_stats (campaign_id) values('$campaign_id');"; + $rslt=mysql_query($stmtA, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPANHAS', event_type='ADD', record_id='$campaign_id', event_code='ADMIN NOVA CAMPANHA', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + } + $ADD=31; + } + +###################### +# ADD=20 adds copied new campaign to the system +###################### + +if ($ADD==20) + { + ##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value ##### + $stmt = "SELECT value FROM vicidial_override_ids where id_table='vicidial_campaigns' and active='1';"; + $rslt=mysql_query($stmt, $link); + $voi_ct = mysql_num_rows($rslt); + if ($voi_ct > 0) + { + $row=mysql_fetch_row($rslt); + $campaign_id = ($row[0] + 1); + + $stmt="UPDATE vicidial_override_ids SET value='$campaign_id' where id_table='vicidial_campaigns' and active='1';"; + $rslt=mysql_query($stmt, $link); + } + ##### END ID override optional section ##### + + echo ""; + $stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CAMPANHA NÃO ADICIONADA - já existe uma campanha com esse ID no sistema\n";} + else + { + $stmt="SELECT count(*) from vicidial_inbound_groups where group_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CAMPANHA NOT ADDED - there is already an inbound group in the system with this ID\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($campaign_id) > 8) or (strlen($campaign_name) < 2) or (strlen($source_campaign_id) < 2) or (strlen($source_campaign_id) > 8) ) + { + echo "
CAMPANHA NÃO ADICIONADA - Por favor volte e verifique os dados digitados\n"; + echo "
ID da campanha deve ter entre 2 e 8 caracteres de comprimento\n"; + echo "
source ID da campanha deve ter entre 2 e 8 caracteres de comprimento\n"; + } + else + { + echo "
CAMPANHA COPIED: $campaign_id copied from $source_campaign_id\n"; + + $stmt="INSERT INTO vicidial_campaigns (campaign_name,campaign_id,active,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,park_ext,park_file_name,web_form_address,allow_closers,hopper_level,auto_dial_level,next_agent_call,local_call_time,voicemail_ext,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,amd_send_to_vmx,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,lead_filter_id,drop_call_seconds,drop_action,safe_harbor_exten,display_dialable_count,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc,allcalls_delay,omit_phone_code,dial_method,available_only_ratio_tally,adaptive_dropped_percentage,adaptive_maximum_level,adaptive_latest_server_time,adaptive_intensity,adaptive_dl_diff_target,concurrent_transfers,auto_alt_dial,auto_alt_dial_statuses,agent_pause_codes_active,campaign_description,campaign_changedate,campaign_stats_refresh,campaign_logindate,dial_statuses,disable_alter_custdata,no_hopper_leads_logins,list_order_mix,campaign_allow_inbound,manual_dial_list_id,default_xfer_group,queue_priority,drop_inbound_group,qc_enabled,qc_statuses,qc_lists,qc_web_form_address,qc_script,survey_first_audio_file,survey_dtmf_digits,survey_ni_digit,survey_opt_in_audio_file,survey_ni_audio_file,survey_method,survey_no_response_action,survey_ni_status,survey_response_digit_map,survey_xfer_exten,survey_camp_record_dir,disable_alter_custphone,display_queue_count,qc_get_record_launch,qc_show_recording,qc_shift_id,manual_dial_filter,agent_clipboard_copy,agent_extended_alt_dial,use_campaign_dnc,three_way_call_cid,three_way_dial_prefix,web_form_target,vtiger_search_category,vtiger_create_call_record,vtiger_create_lead_record,vtiger_screen_login,cpd_amd_action,agent_allow_group_alias,default_group_alias,vtiger_search_dead,vtiger_status_call,survey_third_digit,survey_fourth_digit,survey_third_audio_file,survey_fourth_audio_file,survey_third_status,survey_fourth_status,survey_third_exten,survey_fourth_exten,drop_lockout_time,quick_transfer_button,prepopulate_transfer_preset,drop_rate_group,view_calls_in_queue,view_calls_in_queue_launch,grab_calls_in_queue,call_requeue_button,pause_after_each_call,no_hopper_dialing,agent_dial_owner_only,agent_display_dialable_leads,web_form_address_two,waitforsilence_options,agent_select_territories,crm_popup_login,crm_login_address,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number) SELECT \"$campaign_name\",\"$campaign_id\",\"N\",dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,park_ext,park_file_name,web_form_address,allow_closers,hopper_level,auto_dial_level,next_agent_call,local_call_time,voicemail_ext,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,amd_send_to_vmx,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,lead_filter_id,drop_call_seconds,drop_action,safe_harbor_exten,display_dialable_count,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc,allcalls_delay,omit_phone_code,dial_method,available_only_ratio_tally,adaptive_dropped_percentage,adaptive_maximum_level,adaptive_latest_server_time,adaptive_intensity,adaptive_dl_diff_target,concurrent_transfers,auto_alt_dial,auto_alt_dial_statuses,agent_pause_codes_active,campaign_description,campaign_changedate,campaign_stats_refresh,campaign_logindate,dial_statuses,disable_alter_custdata,no_hopper_leads_logins,\"DISABLED\",campaign_allow_inbound,manual_dial_list_id,default_xfer_group,queue_priority,drop_inbound_group,qc_enabled,qc_statuses,qc_lists,qc_web_form_address,qc_script,survey_first_audio_file,survey_dtmf_digits,survey_ni_digit,survey_opt_in_audio_file,survey_ni_audio_file,survey_method,survey_no_response_action,survey_ni_status,survey_response_digit_map,survey_xfer_exten,survey_camp_record_dir,disable_alter_custphone,display_queue_count,qc_get_record_launch,qc_show_recording,qc_shift_id,manual_dial_filter,agent_clipboard_copy,agent_extended_alt_dial,use_campaign_dnc,three_way_call_cid,three_way_dial_prefix,web_form_target,vtiger_search_category,vtiger_create_call_record,vtiger_create_lead_record,vtiger_screen_login,cpd_amd_action,agent_allow_group_alias,default_group_alias,vtiger_search_dead,vtiger_status_call,survey_third_digit,survey_fourth_digit,survey_third_audio_file,survey_fourth_audio_file,survey_third_status,survey_fourth_status,survey_third_exten,survey_fourth_exten,drop_lockout_time,quick_transfer_button,prepopulate_transfer_preset,drop_rate_group,view_calls_in_queue,view_calls_in_queue_launch,grab_calls_in_queue,call_requeue_button,pause_after_each_call,no_hopper_dialing,agent_dial_owner_only,agent_display_dialable_leads,web_form_address_two,waitforsilence_options,agent_select_territories,crm_popup_login,crm_login_address,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number from vicidial_campaigns where campaign_id='$source_campaign_id';"; + $rslt=mysql_query($stmt, $link); + + $stmtA="INSERT INTO vicidial_campaign_stats (campaign_id) values('$campaign_id');"; + $rslt=mysql_query($stmtA, $link); + + $stmtA="INSERT INTO vicidial_campaign_statuses (status,status_name,selectable,campaign_id,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable) SELECT status,status_name,selectable,\"$campaign_id\",human_answered,category,sale,dnc,customer_contact,not_interested,unworkable from vicidial_campaign_statuses where campaign_id='$source_campaign_id';"; + $rslt=mysql_query($stmtA, $link); + + $stmtA="INSERT INTO vicidial_campaign_hotkeys (status,hotkey,status_name,selectable,campaign_id) SELECT status,hotkey,status_name,selectable,\"$campaign_id\" from vicidial_campaign_hotkeys where campaign_id='$source_campaign_id';"; + $rslt=mysql_query($stmtA, $link); + + $stmtA="INSERT INTO vicidial_lead_recycle (status,attempt_delay,attempt_maximum,active,campaign_id) SELECT status,attempt_delay,attempt_maximum,active,\"$campaign_id\" from vicidial_lead_recycle where campaign_id='$source_campaign_id';"; + $rslt=mysql_query($stmtA, $link); + + $stmtA="INSERT INTO vicidial_pause_codes (pause_code,pause_code_name,billable,campaign_id) SELECT pause_code,pause_code_name,billable,\"$campaign_id\" from vicidial_pause_codes where campaign_id='$source_campaign_id';"; + $rslt=mysql_query($stmtA, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPANHAS', event_type='COPY', record_id='$campaign_id', event_code='ADMIN COPY CAMPANHA', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + } + $ADD=31; + } + +###################### +# ADD=22 adds the new campaign status to the system +###################### + +if ($ADD==22) + { + echo ""; + $stmt="SELECT count(*) from vicidial_campaign_statuses where campaign_id='$campaign_id' and status='$status_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
STATUS DE CAMPANHA NAO ADICIONADO - já existe um status/campanha no sistema com esse nome\n";} + else + { + $stmt="SELECT count(*) from vicidial_statuses where status='$status_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
STATUS DE CAMPANHA NÃO ADICIONADO - já existe um status global do sistema com esse nome\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($status_id) < 1) or (strlen($status_name) < 2) ) + { + echo "
STATUS DE CAMPANHA NÃO ADICIONADO- Por favor volte e verifique os dados digitados\n"; + echo "
status deve ter entre 1 e 8 caracteres de comprimento\n"; + echo "
nome do status deve ter entre 2 e 30 caracteres de comprimento\n"; + } + else + { + echo "
STATUS DE CAMPANHA ADICIONADO: $campaign_id - $status_id\n"; + + $stmt="INSERT INTO vicidial_campaign_statuses (status,status_name,selectable,campaign_id,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable) values('$status_id','$status_name','$selectable','$campaign_id','$human_answered','$category','$sale','$dnc','$customer_contact','$not_interested','$unworkable');"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPANHA_STATUS', event_type='ADD', record_id='$campaign_id', event_code='ADMIN NOVA CAMPANHA STATUS', event_sql=\"$SQL_log\", event_notes='Status: $status_id';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + } + $SUB=22; + $ADD=31; + } + + +###################### +# ADD=23 adds the new campaign hotkey to the system +###################### + +if ($ADD==23) + { + $HKstatus_data = explode('-----',$HKstatus); + $status = $HKstatus_data[0]; + $status_name = $HKstatus_data[1]; + + echo ""; + $stmt="SELECT count(*) from vicidial_campaign_hotkeys where campaign_id='$campaign_id' and hotkey='$hotkey' and hotkey='$hotkey';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CAMPANHA HOT KEY NOT ADDED - there is already a campaign-hotkey in the system with this hotkey\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or (strlen($hotkey) < 1) ) + { + echo "
TECLA DE ATALHO DA CAMPANHA NÃO ADICIONADA - Por favor volte e verifique os dados digitados\n"; + echo "
hotkey must be a single character between 1 and 9 \n"; + echo "
status deve ter entre 1 e 8 caracteres de comprimento\n"; + } + else + { + echo "
ATALHO DA CAMPANHA ADICIONADO: $campaign_id - $status - $hotkey\n"; + + $stmt="INSERT INTO vicidial_campaign_hotkeys values('$status','$hotkey','$status_name','$selectable','$campaign_id');"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPANHA_HOTKEY', event_type='ADD', record_id='$campaign_id', event_code='ADMIN NOVA CAMPANHA HOTKEY', event_sql=\"$SQL_log\", event_notes='Status: $status|HotKey: $hotkey';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + $SUB=23; + $ADD=31; + } + + +###################### +# ADD=25 adds the new campaign lead recycle entry to the system +###################### + +if ($ADD==25) + { + $status = eregi_replace("-----.*",'',$status); + echo ""; + $stmt="SELECT count(*) from vicidial_lead_recycle where campaign_id='$campaign_id' and status='$status';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
RECICLAGEM DE REGISTROS DA CAMPANHA NÃO ADICIONADO - já existe um registro de reciclagem nessa campanha para esse status\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or ($attempt_delay < 120) or ($attempt_delay >= 43200) or ($attempt_maximum < 1) or ($attempt_maximum > 10) ) + { + echo "
CAMPANHA LEAD RECYCLE NOT ADDED - Por favor, volte e verifique os dados digitados\n"; + echo "
status deve ter entre 1 e 6 caracteres\n"; + echo "
tempo de tentativa deve ter pelo menos 120 segundos e menos de 43200 segundos ou 12 horas\n"; + echo "
quantidade máxima de tentativas deve ser entre 1 e 10\n"; + } + else + { + echo "
RECICLAGEM DE REGISTROS DA CAMPANHA ADICIONADO: $campaign_id - $status - $attempt_delay\n"; + + $stmt="INSERT INTO vicidial_lead_recycle(campaign_id,status,attempt_delay,attempt_maximum,active) values('$campaign_id','$status','$attempt_delay','$attempt_maximum','$active');"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPANHA_RECYCLE', event_type='ADD', record_id='$campaign_id', event_code='ADMIN NOVA CAMPANHA LEAD RECYCLE', event_sql=\"$SQL_log\", event_notes='Status: $status';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + $SUB=25; + $ADD=31; + } + + +###################### +# ADD=26 adds the new auto alt dial status to the campaign +###################### + +if ($ADD==26) + { + $status = eregi_replace("-----.*",'',$status); + echo ""; + $stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$campaign_id' and auto_alt_dial_statuses LIKE \"% $status %\";"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
STATUS DE DISCAGEM DE NÚM. ALT. NÃO INCLUÍDO - já existe uma entrada para esta campanha com este status\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) ) + { + echo "
STATUS DE DISCAGEM DE NÚM. ALT. NÃO INCLUÍDO - Por favor, volte e verifique os dados digitados\n"; + echo "
status deve ter entre 1 e 6 caracteres\n"; + } + else + { + echo "
STATUS DE DISCAGEM PARA NÚM. ALT. INCLUÍDO: $campaign_id - $status\n"; + + $stmt="SELECT auto_alt_dial_statuses from vicidial_campaigns where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + + if (strlen($row[0])<2) {$row[0] = ' -';} + $auto_alt_dial_statuses = " $status$row[0]"; + $stmt="UPDATE vicidial_campaigns set auto_alt_dial_statuses='$auto_alt_dial_statuses' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPANHA_ALTDIAL', event_type='ADD', record_id='$campaign_id', event_code='ADMIN NOVA CAMPANHA ALT DIAL', event_sql=\"$SQL_log\", event_notes='Status: $auto_alt_dial_statuses';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + $SUB=26; + $ADD=31; + } + + +###################### +# ADD=27 adds the new campaign agent pause code entry to the system +###################### + +if ($ADD==27) + { + echo ""; + $stmt="SELECT count(*) from vicidial_pause_codes where campaign_id='$campaign_id' and pause_code='$pause_code';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CÓDIGO DE PAUSA NAO INCLUÍDO - já existe uma entrada para esta campanha e este código de pausa\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($pause_code) < 1) or (strlen($pause_code) > 6) or (strlen($pause_code_name) < 2) ) + { + echo "
CÓDIGO DE PAUSA NAO INCLUÍDO - Por favor, volte e verifique os dados digitados\n"; + echo "
pause code must be between 1 and 6 characters in length\n"; + echo "
pause nome do código deve ter entre 2 e 30 caracteres de comprimento\n"; + } + else + { + echo "
CÓDIGO DE PAUSA INCLUÍDO: $campaign_id - $pause_code - $pause_code_name\n"; + + $stmt="INSERT INTO vicidial_pause_codes(campaign_id,pause_code,pause_code_name,billable) values('$campaign_id','$pause_code','$pause_code_name','$billable');"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPANHA_PAUSECODE', event_type='ADD', record_id='$campaign_id', event_code='ADMIN NOVA CAMPANHA PAUSE CODE', event_sql=\"$SQL_log\", event_notes='Código de Pausa: $pause_code';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + $SUB=27; + $ADD=31; + } + + +###################### +# ADD=28 adds new status to the campaign dial statuses +###################### + +if ($ADD==28) + { + $status = eregi_replace("-----.*",'',$status); + echo ""; + $stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$campaign_id' and dial_statuses LIKE \"% $status %\";"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
STATUS DE DISCAGEM NÃO INCLUÍDO - já existe uma entrada para esta campanha com este status\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) ) + { + echo "
STATUS DE DISCAGEM NÃO INCLUÍDO - Por favor, volte e verifique os dados digitados\n"; + echo "
status deve ter entre 1 e 6 caracteres\n"; + } + else + { + echo "
STATUS DE DISCAGEM INCLUÍDO: $campaign_id - $status\n"; + + $stmt="SELECT dial_statuses from vicidial_campaigns where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + + if (strlen($row[0])<2) {$row[0] = ' -';} + $dial_statuses = " $status$row[0]"; + $stmt="UPDATE vicidial_campaigns set dial_statuses='$dial_statuses' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPANHA_DIALSTATUS', event_type='ADD', record_id='$campaign_id', event_code='ADMIN NOVA CAMPANHA DIAL STATUS', event_sql=\"$SQL_log\", event_notes='Status: $statuses';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + #$SUB=28; + $ADD=31; + } + + +###################### +# ADD=211 adds the new list to the system +###################### + +if ($ADD==211) + { + ##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value ##### + $stmt = "SELECT value FROM vicidial_override_ids where id_table='vicidial_lists' and active='1';"; + $rslt=mysql_query($stmt, $link); + $voi_ct = mysql_num_rows($rslt); + if ($voi_ct > 0) + { + $row=mysql_fetch_row($rslt); + $list_id = ($row[0] + 1); + + $stmt="UPDATE vicidial_override_ids SET value='$list_id' where id_table='vicidial_lists' and active='1';"; + $rslt=mysql_query($stmt, $link); + } + ##### END ID override optional section ##### + + echo ""; + $stmt="SELECT count(*) from vicidial_lists where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
LISTA NÃO ADICIONADA - já existe uma lista no sistema com essa ID\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($list_name) < 2) or ($list_id < 100) or (strlen($list_id) > 8) ) + { + echo "
LISTA NÃO ADICIONADA - por favor volte e verifique os dados digitados\n"; + echo "
A ID da lista deve ter entre 2 e 8 caracteres de comprimento\n"; + echo "
O Nome da Lista deve ter até 2 caracteres de comprimento\n"; + echo "
ID da Lista must be greater than 100\n"; + } + else + { + echo "
LISTA ADICIONADA: $list_id\n"; + + $stmt="INSERT INTO vicidial_lists (list_id,list_name,campaign_id,active,list_description,list_changedate) values('$list_id','$list_name','$campaign_id','$active','$list_description','$SQLdate');"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='LISTAS', event_type='ADD', record_id='$list_id', event_code='ADMIN ADD LIST', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + $ADD=311; + } + + + +###################### +# ADD=2111 adds the new inbound group to the system +###################### + +if ($ADD==2111) + { + ##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value ##### + $stmt = "SELECT value FROM vicidial_override_ids where id_table='vicidial_inbound_groups' and active='1';"; + $rslt=mysql_query($stmt, $link); + $voi_ct = mysql_num_rows($rslt); + if ($voi_ct > 0) + { + $row=mysql_fetch_row($rslt); + $group_id = ($row[0] + 1); + + $stmt="UPDATE vicidial_override_ids SET value='$group_id' where id_table='vicidial_inbound_groups' and active='1';"; + $rslt=mysql_query($stmt, $link); + } + ##### END ID override optional section ##### + + echo ""; + $stmt="SELECT count(*) from vicidial_inbound_groups where group_id='$group_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
GRUPO NÃO ADICIONADO - já existe um grupo com essa ID no sistema\n";} + else + { + $stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$group_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
GROUP NOT ADDED - there is already a campaign in the system with this ID\n";} + else + { + if ( (strlen($group_id) < 2) or (strlen($group_name) < 2) or (strlen($group_color) < 2) or (strlen($group_id) > 20) or (eregi(' ',$group_id)) or (eregi("\-",$group_id)) or (eregi("\+",$group_id)) ) + { + echo "
GRUPO NÃO ADICIONADO - por favor volte e verifique os dados digitados\n"; + echo "
A ID do grupo deve ter entre 2 e 20 caracteres de comprimento ' -+'.\n"; + echo "
O nome e a cor do grupo devem ter pelo menos 2 caracteres de comprimento\n"; + } + else + { + $stmt="INSERT INTO vicidial_inbound_groups (group_id,group_name,group_color,active,web_form_address,voicemail_ext,next_agent_call,fronter_display,ingroup_script,get_call_launch,web_form_address_two,start_call_url,dispo_call_url) values('$group_id','$group_name','$group_color','$active','" . mysql_real_escape_string($web_form_address) . "','$voicemail_ext','$next_agent_call','$fronter_display','$script_id','$get_call_launch','','','');"; + $rslt=mysql_query($stmt, $link); + + $stmtA="INSERT INTO vicidial_campaign_stats (campaign_id) values('$group_id');"; + $rslt=mysql_query($stmtA, $link); + + echo "
GRUPO ADICIONADO: $group_id\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='INGROUPS', event_type='ADD', record_id='$group_id', event_code='ADMIN ADD ENTRANTE GROUP', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + } + $ADD=3111; + } + + +###################### +# ADD=2011 adds copied inbound group to the system +###################### + +if ($ADD==2011) + { + ##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value ##### + $stmt = "SELECT value FROM vicidial_override_ids where id_table='vicidial_inbound_groups' and active='1';"; + $rslt=mysql_query($stmt, $link); + $voi_ct = mysql_num_rows($rslt); + if ($voi_ct > 0) + { + $row=mysql_fetch_row($rslt); + $group_id = ($row[0] + 1); + + $stmt="UPDATE vicidial_override_ids SET value='$group_id' where id_table='vicidial_inbound_groups' and active='1';"; + $rslt=mysql_query($stmt, $link); + } + ##### END ID override optional section ##### + + echo ""; + $stmt="SELECT count(*) from vicidial_inbound_groups where group_id='$group_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
GRUPO NÃO ADICIONADO - já existe um grupo com essa ID no sistema\n";} + else + { + $stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$group_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
GROUP NOT ADDED - there is already a campaign in the system with this ID\n";} + else + { + if ( (strlen($group_id) < 2) or (strlen($group_name) < 2) or (strlen($group_id) > 20) or (eregi(' ',$group_id)) or (eregi("\-",$group_id)) or (eregi("\+",$group_id)) ) + { + echo "
GRUPO NÃO ADICIONADO - por favor volte e verifique os dados digitados\n"; + echo "
A ID do grupo deve ter entre 2 e 20 caracteres de comprimento ' -+'.\n"; + echo "
O nome e a cor do grupo devem ter pelo menos 2 caracteres de comprimento\n"; + } + else + { + $stmt="INSERT INTO vicidial_inbound_groups (group_id,group_name,group_color,active,web_form_address,voicemail_ext,next_agent_call,fronter_display,ingroup_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,drop_call_seconds,drop_action,drop_exten,call_time_id,after_hours_action,after_hours_message_filename,after_hours_exten,after_hours_voicemail,welcome_message_filename,moh_context,onhold_prompt_filename,prompt_interval,agent_alert_exten,agent_alert_delay,default_xfer_group,queue_priority,drop_inbound_group,ingroup_recording_override,ingroup_rec_filename,afterhours_xfer_group,qc_enabled,qc_statuses,qc_shift_id,qc_get_record_launch,qc_show_recording,qc_web_form_address,qc_script,play_place_in_line,play_estimate_hold_time,hold_time_option,hold_time_option_seconds,hold_time_option_exten,hold_time_option_voicemail,hold_time_option_xfer_group,hold_time_option_callback_filename,hold_time_option_callback_list_id,hold_recall_xfer_group,no_delay_call_route,play_welcome_message,answer_sec_pct_rt_stat_one,answer_sec_pct_rt_stat_two,default_group_alias,no_agent_no_queue,no_agent_action,no_agent_action_value,web_form_address_two,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number) SELECT \"$group_id\",\"$group_name\",group_color,\"N\",web_form_address,voicemail_ext,next_agent_call,fronter_display,ingroup_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,drop_call_seconds,drop_action,drop_exten,call_time_id,after_hours_action,after_hours_message_filename,after_hours_exten,after_hours_voicemail,welcome_message_filename,moh_context,onhold_prompt_filename,prompt_interval,agent_alert_exten,agent_alert_delay,default_xfer_group,queue_priority,drop_inbound_group,ingroup_recording_override,ingroup_rec_filename,afterhours_xfer_group,qc_enabled,qc_statuses,qc_shift_id,qc_get_record_launch,qc_show_recording,qc_web_form_address,qc_script,play_place_in_line,play_estimate_hold_time,hold_time_option,hold_time_option_seconds,hold_time_option_exten,hold_time_option_voicemail,hold_time_option_xfer_group,hold_time_option_callback_filename,hold_time_option_callback_list_id,hold_recall_xfer_group,no_delay_call_route,play_welcome_message,answer_sec_pct_rt_stat_one,answer_sec_pct_rt_stat_two,default_group_alias,no_agent_no_queue,no_agent_action,no_agent_action_value,web_form_address_two,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number from vicidial_inbound_groups where group_id=\"$source_group_id\";"; + $rslt=mysql_query($stmt, $link); + + echo "
GRUPO ADICIONADO: $group_id\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='INGROUPS', event_type='COPY', record_id='$group_id', event_code='ADMIN COPIAR GRUPO DE ENTRADA', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + } + $ADD=3111; + } + + +###################### +# ADD=2311 adds the new did to the system +###################### + +if ($ADD==2311) + { + echo ""; + $stmt="SELECT count(*) from vicidial_inbound_dids where did_pattern='$did_pattern';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
DDR NÃO INCLUÍDO - já existe um DDR com este ID no sistema\n";} + else + { + $stmt="SELECT count(*) from vicidial_inbound_dids where did_pattern='$did_pattern';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
DDR NÃO INCLUÍDO - já existe um DDR com esta extensão no sistema\n";} + else + { + if ( (strlen($did_pattern) < 2) or (eregi(' ',$did_pattern)) or (eregi('-',$did_pattern)) or (eregi("\+",$did_pattern)) ) + { + echo "
DDR NÃO INCLUÍDO - Por favor, volte e verifique os dados digitados\n"; + echo "
DID Extension must be between 2 and 20 characters in length and contain no ' -+'.\n"; + } + else + { + $stmt="INSERT INTO vicidial_inbound_dids (did_pattern,did_description) values('$did_pattern','$did_description');"; + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT did_id from vicidial_inbound_dids where did_pattern='$did_pattern';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $did_id = $row[0]; + + echo "
DID ADDED: $did_pattern $did_description - $did_id\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='DIDS', event_type='ADD', record_id='$did_id', event_code='ADMIN ADD DID', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + } + $ADD=3311; + } + + +###################### +# ADD=2411 adds copied did to the system +###################### + +if ($ADD==2411) + { + echo ""; + $stmt="SELECT count(*) from vicidial_inbound_dids where did_pattern='$did_pattern';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
DDR NÃO INCLUÍDO - já existe um DDR com esta extensão no sistema\n";} + else + { + if ( (strlen($source_did) < 1) or (strlen($did_pattern) < 1) or (eregi(' ',$source_did)) or (eregi(' ',$did_pattern)) or (eregi("\+",$source_did)) ) + { + echo "
DDR NÃO INCLUÍDO - Por favor, volte e verifique os dados digitados\n"; + echo "
DID Extension must be between 2 and 20 characters in length and contain no ' -+'.\n"; + } + else + { + $stmt="INSERT INTO vicidial_inbound_dids (did_pattern,did_description,did_active,did_route,extension,exten_context,voicemail_ext,phone,server_ip,user,user_unavailable_action,user_route_settings_ingroup,group_id,call_handle_method,agent_search_method,list_id,campaign_id,phone_code,menu_id) SELECT \"$did_pattern\",\"$did_description\",did_active,did_route,extension,exten_context,voicemail_ext,phone,server_ip,user,user_unavailable_action,user_route_settings_ingroup,group_id,call_handle_method,agent_search_method,list_id,campaign_id,phone_code,menu_id from vicidial_inbound_dids where did_id=\"$source_did\";"; + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT did_id from vicidial_inbound_dids where did_pattern='$did_pattern';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $did_id = $row[0]; + + echo "
DID ADDED: $did_pattern - $did_id\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='DIDS', event_type='COPY', record_id='$did_id', event_code='ADMIN COPIAR DDR', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + $ADD=3311; + } + + +###################### +# ADD=2511 adds the new call menu to the system +###################### + +if ($ADD==2511) + { + ##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value ##### + $stmt = "SELECT value FROM vicidial_override_ids where id_table='vicidial_call_menu' and active='1';"; + $rslt=mysql_query($stmt, $link); + $voi_ct = mysql_num_rows($rslt); + if ($voi_ct > 0) + { + $row=mysql_fetch_row($rslt); + $menu_id = ($row[0] + 1); + + $stmt="UPDATE vicidial_override_ids SET value='$menu_id' where id_table='vicidial_call_menu' and active='1';"; + $rslt=mysql_query($stmt, $link); + } + ##### END ID override optional section ##### + + echo ""; + $stmt="SELECT count(*) from vicidial_call_menu where menu_id='$menu_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
MENU NÃO INCLUÍDO - there is already a CALL MENU in the system with this ID\n";} + else + { + if ( (strlen($menu_id) < 2) or (eregi(' ',$menu_id)) ) + { + echo "
MENU NÃO INCLUÍDO - Por favor, volte e verifique os dados digitados\n"; + echo "
O ID do menu deve ter entre 2 e 50 caracteres de comprimento e nao conter ' '.\n"; + } + else + { + $stmt="INSERT INTO vicidial_call_menu (menu_id,menu_name) values('$menu_id','$menu_name');"; + $rslt=mysql_query($stmt, $link); + + echo "
MENU INCLUÍDO: $menu_id $menu_name\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CALLMENUS', event_type='ADD', record_id='$menu_id', event_code='ADMIN ADD CALL MENU', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + $ADD=3511; + } + + +###################### +# ADD=2611 adds copied call menu to the system +###################### + +if ($ADD==2611) + { + ##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value ##### + $stmt = "SELECT value FROM vicidial_override_ids where id_table='vicidial_call_menu' and active='1';"; + $rslt=mysql_query($stmt, $link); + $voi_ct = mysql_num_rows($rslt); + if ($voi_ct > 0) + { + $row=mysql_fetch_row($rslt); + $menu_id = ($row[0] + 1); + + $stmt="UPDATE vicidial_override_ids SET value='$menu_id' where id_table='vicidial_call_menu' and active='1';"; + $rslt=mysql_query($stmt, $link); + } + ##### END ID override optional section ##### + + echo ""; + $stmt="SELECT count(*) from vicidial_call_menu where menu_id='$menu_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
MENU NÃO INCLUÍDO - there is already a CALL MENU in the system with this ID\n";} + else + { + if ( (strlen($menu_id) < 2) or (eregi(' ',$menu_id)) or (strlen($source_menu) < 2) or (eregi(' ',$source_menu)) ) + { + echo "
MENU NÃO INCLUÍDO - Por favor, volte e verifique os dados digitados\n"; + echo "
O ID do menu deve ter entre 2 e 50 caracteres de comprimento e nao conter ' '.\n"; + } + else + { + $stmt="INSERT INTO vicidial_call_menu (menu_id,menu_name,menu_prompt,menu_timeout,menu_timeout_prompt,menu_invalid_prompt,menu_repeat,menu_time_check,call_time_id,track_in_vdac,custom_dialplan_entry,tracking_group) SELECT \"$menu_id\",\"$menu_name\",menu_prompt,menu_timeout,menu_timeout_prompt,menu_invalid_prompt,menu_repeat,menu_time_check,call_time_id,track_in_vdac,custom_dialplan_entry,tracking_group from vicidial_call_menu where menu_id=\"$source_menu\";"; + $rslt=mysql_query($stmt, $link); + + $stmtA="INSERT INTO vicidial_call_menu_options (menu_id,option_value,option_description,option_route,option_route_value,option_route_value_context) SELECT \"$menu_id\",option_value,option_description,option_route,option_route_value,option_route_value_context from vicidial_call_menu_options where menu_id='$source_menu';"; + $rslt=mysql_query($stmtA, $link); + + echo "
MENU INCLUÍDO: $menu_id - $menu_name\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|$stmtA"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CALLMENUS', event_type='COPY', record_id='$menu_id', event_code='ADMIN COPY MENU', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + $ADD=3511; + } + + +###################### +# ADD=21111 adds new remote agents to the system +###################### + +if ($ADD==21111) + { + echo ""; + $stmt="SELECT count(*) from vicidial_remote_agents where server_ip='$server_ip' and user_start='$user_start';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
AGENTES REMOTOS NÃO ADICIONADOS - já existe um usuário remoto com esse ID no sistema\n";} + else + { + if ( (strlen($server_ip) < 2) or (strlen($user_start) < 2) or (strlen($campaign_id) < 2) or (strlen($conf_exten) < 2) ) + { + echo "
AGENTES REMOTOS NÃO ADICIONADOS - Por favor volte e verifique os dados digitados\n"; + echo "
Início da ID e extensão externa devem ter no mínimo 2 caracteres de comprimento\n"; + } + else + { + $stmt="INSERT INTO vicidial_remote_agents values('','$user_start','$number_of_lines','$server_ip','$conf_exten','$status','$campaign_id','$groups_value');"; + $rslt=mysql_query($stmt, $link); + + echo "
AGENTES REMOTOS ADICIONADOS: $user_start\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='REMOTEAGENTS', event_type='ADD', record_id='$user_start', event_code='ADMIN ADD REMOTE AGENT', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + $ADD=10000; + } + +###################### +# ADD=211111 adds new user group to the system +###################### + +if ($ADD==211111) + { + ##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value ##### + $stmt = "SELECT value FROM vicidial_override_ids where id_table='vicidial_user_groups' and active='1';"; + $rslt=mysql_query($stmt, $link); + $voi_ct = mysql_num_rows($rslt); + if ($voi_ct > 0) + { + $row=mysql_fetch_row($rslt); + $user_group = ($row[0] + 1); + + $stmt="UPDATE vicidial_override_ids SET value='$user_group' where id_table='vicidial_user_groups' and active='1';"; + $rslt=mysql_query($stmt, $link); + } + ##### END ID override optional section ##### + + echo ""; + $stmt="SELECT count(*) from vicidial_user_groups where user_group='$user_group';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
GRUPO DE USUÁRIO NÃO ADICIONADO - já existe um grupo de usuários com este nome\n";} + else + { + if ( (strlen($user_group) < 2) or (strlen($group_name) < 2) ) + { + echo "
GRUPO DE USUÁRIOS NÃO ADICIONADO - Por favor volte e verifique os dados digitados\n"; + echo "
Nome e descrição do grupo devem ter pelo menos 2 caracteres de comprimento\n"; + } + else + { + $stmt="INSERT INTO vicidial_user_groups(user_group,group_name,allowed_campaigns) values('$user_group','$group_name','-ALL-CAMPANHAS-');"; + $rslt=mysql_query($stmt, $link); + + echo "
GRUPO DE USUÁRIOS ADICIONADOS: $user_group\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='USERGROUPS', event_type='ADD', record_id='$user_group', event_code='ADMIN NOVO GRUPO DE USUÁRIO', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + ############################################################### + ##### START SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP ##### + $stmt = "SELECT enable_vtiger_integration,vtiger_server_ip,vtiger_dbname,vtiger_login,vtiger_pass,vtiger_url FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $ss_conf_ct = mysql_num_rows($rslt); + if ($ss_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $enable_vtiger_integration = $row[0]; + $vtiger_server_ip = $row[1]; + $vtiger_dbname = $row[2]; + $vtiger_login = $row[3]; + $vtiger_pass = $row[4]; + $vtiger_url = $row[5]; + } + ##### END SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP ##### + ############################################################# + + if ($enable_vtiger_integration > 0) + { + ### connect to your vtiger database + $linkV=mysql_connect("$vtiger_server_ip", "$vtiger_login","$vtiger_pass"); + if (!$linkV) {die("Could not connect: $vtiger_server_ip|$vtiger_dbname|$vtiger_login|$vtiger_pass" . mysql_error());} + echo 'Connected successfully'; + mysql_select_db("$vtiger_dbname", $linkV); + + ###################################### + ##### BEGIN Add/Update group info in Vtiger + $stmt="SELECT count(*) from vtiger_groups where groupname='$user_group';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $group_found_count = $row[0]; + + ### group exists in vtiger, update it + if ($group_found_count > 0) + { + $stmt="SELECT groupid from vtiger_groups where groupname='$user_group';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $groupid = $row[0]; + } + + ### user doesn't exist in vtiger, insert it + else + { + #### BEGIN CREATE NEW GROUP RECORD IN VTIGER + # Get next available id from vtiger_users_seq to use as groupid + $stmt="SELECT id from vtiger_users_seq;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + $row=mysql_fetch_row($rslt); + $groupid = ($row[0] + 1); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + # Increase next available groupid with 1 so next record gets proper id + $stmt="UPDATE vtiger_users_seq SET id = '$groupid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtA = "INSERT INTO vtiger_groups SET groupid='$groupid',groupname='$user_group',description='$group_name';"; + if ($DB) {echo "|$stmtA|\n";} + $rslt=mysql_query($stmtA, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #### END CREATE NEW GROUP RECORD IN VTIGER + } + ##### END Add/Update group info in Vtiger + ###################################### + } + } + } + $ADD=100000; + } + +###################### +# ADD=2111111 adds new script to the system +###################### + +if ($ADD==2111111) + { + ##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value ##### + $stmt = "SELECT value FROM vicidial_override_ids where id_table='vicidial_scripts' and active='1';"; + $rslt=mysql_query($stmt, $link); + $voi_ct = mysql_num_rows($rslt); + if ($voi_ct > 0) + { + $row=mysql_fetch_row($rslt); + $script_id = ($row[0] + 1); + + $stmt="UPDATE vicidial_override_ids SET value='$script_id' where id_table='vicidial_scripts' and active='1';"; + $rslt=mysql_query($stmt, $link); + } + ##### END ID override optional section ##### + + echo ""; + $stmt="SELECT count(*) from vicidial_scripts where script_id='$script_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
SCRIPT NÃO ADICIONADO - já existe um script com este nome no sistema\n";} + else + { + if ( (strlen($script_id) < 2) or (strlen($script_name) < 2) or (strlen($script_text) < 2) ) + { + echo "
SCRIPT NÃO ADICIONADO - Por favor, volte e verifique os dados digitados\n"; + echo "
Nome do script, descrição e texto devem ter no mínimo 2 caracteres de comprimento\n"; + } + else + { + $stmt="INSERT INTO vicidial_scripts values('$script_id','$script_name','$script_comments','" . mysql_real_escape_string($script_text) . "','$active');"; + $rslt=mysql_query($stmt, $link); + if ($DB > 0) {echo "|$stmt|";} + echo "
SCRIPT ADICIONADO: $script_id\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='SCRIPTS', event_type='ADD', record_id='$script_id', event_code='ADMIN INCLUIR SCRIPT', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + $ADD=1000000; + } + + +###################### +# ADD=21111111 adds new filter to the system +###################### + +if ($ADD==21111111) + { + ##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value ##### + $stmt = "SELECT value FROM vicidial_override_ids where id_table='vicidial_lead_filters' and active='1';"; + $rslt=mysql_query($stmt, $link); + $voi_ct = mysql_num_rows($rslt); + if ($voi_ct > 0) + { + $row=mysql_fetch_row($rslt); + $lead_filter_id = ($row[0] + 1); + + $stmt="UPDATE vicidial_override_ids SET value='$lead_filter_id' where id_table='vicidial_lead_filters' and active='1';"; + $rslt=mysql_query($stmt, $link); + } + ##### END ID override optional section ##### + + echo ""; + $stmt="SELECT count(*) from vicidial_lead_filters where lead_filter_id='$lead_filter_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
FILTRO NÃO ADICIONADO - já existe um filtro com esse ID\n";} + else + { + if ( (strlen($lead_filter_id) < 2) or (strlen($lead_filter_name) < 2) or (strlen($lead_filter_sql) < 2) ) + { + echo "
FILTRO NAO ADICIONADO - Por favor, volte e verifique os dados digitados\n"; + echo "
ID do Filtro, nome e SQL devem ter pelo menos 2 caracteres de comprimento\n"; + } + else + { + $stmt="INSERT INTO vicidial_lead_filters SET lead_filter_id='$lead_filter_id',lead_filter_name='$lead_filter_name',lead_filter_comments='$lead_filter_comments',lead_filter_sql='" . mysql_real_escape_string($lead_filter_sql) . "';"; + $rslt=mysql_query($stmt, $link); + + if ($DB > 0) {echo "|$stmt|";} + echo "
FILTRO CRIADO: $lead_filter_id\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='FILTROS', event_type='ADD', record_id='$lead_filter_id', event_code='ADMIN INCLUIR FILTRO', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + $ADD=10000000; + } + + +###################### +# ADD=211111111 adds new call time definition to the system +###################### + +if ($ADD==211111111) + { + echo ""; + $stmt="SELECT count(*) from vicidial_call_times where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CONFIGURAÇÃO DE HORÁRIO DE CHAMADA NAO INCLUÍDO - já existe uma entrada de Horário para este ID\n";} + else + { + if ( (strlen($call_time_id) < 2) or (strlen($call_time_name) < 2) ) + { + echo "
CONFIGURAÇÃO DE HORÁRIO DE CHAMADA NAO INCLUÍDO - Por favor, volte e verifique os dados digitados\n"; + echo "
ID e nome do Horário de Chamada deve ter pelo menos 2 caracteres de comprimento\n"; + } + else + { + $stmt="INSERT INTO vicidial_call_times SET call_time_id='$call_time_id',call_time_name='$call_time_name',call_time_comments='$call_time_comments';"; + $rslt=mysql_query($stmt, $link); + if ($DB > 0) {echo "|$stmt|";} + + echo "
HORÁRIO DE CHAMADA ADICIONADA: $call_time_id\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CALLTIMES', event_type='ADD', record_id='$call_time_id', event_code='ADMIN ADD CALL TIME', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + $ADD=311111111; + } + + +###################### +# ADD=2111111111 adds new state call time definition to the system +###################### + +if ($ADD==2111111111) + { + echo ""; + $stmt="SELECT count(*) from vicidial_state_call_times where state_call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CONFIGURAÇÃO DO HORÁRIO DE CHAMADA POR ESTADO NAO ADICIONADA - já existe uma entrada de Horário para este ID\n";} + else + { + if ( (strlen($call_time_id) < 2) or (strlen($call_time_name) < 2) or (strlen($state_call_time_state) < 2) ) + { + echo "
CONFIGURAÇÃO DO HORÁRIO DE CHAMADA POR ESTADO NAO ADICIONADA - Por favor, volte e verifique os dados digitados\n"; + echo "
ID da configuração de chamada por estado, nome e estado devem ter no mínimo 2 caracteres de comprimento\n"; + } + else + { + $stmt="INSERT INTO vicidial_state_call_times SET state_call_time_id='$call_time_id',state_call_time_name='$call_time_name',state_call_time_comments='$call_time_comments',state_call_time_state='$state_call_time_state';"; + $rslt=mysql_query($stmt, $link); + if ($DB > 0) {echo "|$stmt|";} + + echo "
HORÁRIO DE CHAMADA POR ESTADO ADICIONADA: $call_time_id\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CALLTIMES_STATE', event_type='ADD', record_id='$call_time_id', event_code='ADMIN ADD STATE CALL TIME', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + $ADD=3111111111; + } + + +###################### +# ADD=231111111 adds new shift definition to the system +###################### + +if ($ADD==231111111) + { + ##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value ##### + $stmt = "SELECT value FROM vicidial_override_ids where id_table='vicidial_shifts' and active='1';"; + $rslt=mysql_query($stmt, $link); + $voi_ct = mysql_num_rows($rslt); + if ($voi_ct > 0) + { + $row=mysql_fetch_row($rslt); + $shift_id = ($row[0] + 1); + + $stmt="UPDATE vicidial_override_ids SET value='$shift_id' where id_table='vicidial_shifts' and active='1';"; + $rslt=mysql_query($stmt, $link); + } + ##### END ID override optional section ##### + + echo ""; + $stmt="SELECT count(*) from vicidial_shifts where shift_id='$shift_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CONFIGURAÇÃO DE TURNO NÃO INCLUÍDA - já existe uma entrada de turno com este ID\n";} + else + { + $shift_length_test = eregi_replace(':','',$shift_length); + if ( (strlen($shift_id) < 2) or (strlen($shift_name) < 2) or (strlen($shift_start_time) < 4) or (strlen($shift_start_time) > 4) or (strlen($shift_length) < 5) or (strlen($shift_length) > 5) or ($shift_start_time > 2359) or ($shift_length_test > 2400) ) + { + echo "
CONFIGURAÇÃO DE TURNO NÃO INCLUÍDA - Por favor, volte e verifique os dados digitados\n"; + echo "
ID e Nome do turno devem ter pelo menos 2 caracteres\n"; + echo "
Horário de início deve ter 4 caracteres e ser um horário válido\n"; + echo "
Duração do Turno deve ter 5 caracteres e 24 horas ou menos\n"; + } + else + { + $p=0; + $shift_weekdays_ct = count($shift_weekdays); + while ($p <= $shift_weekdays_ct) + { + $SHIFT_weekdays .= "$shift_weekdays[$p]"; + $p++; + } + $stmt="INSERT INTO vicidial_shifts SET shift_id='$shift_id',shift_name='$shift_name',shift_start_time='$shift_start_time',shift_length='$shift_length',shift_weekdays='$SHIFT_weekdays';"; + $rslt=mysql_query($stmt, $link); + if ($DB > 0) {echo "|$stmt|";} + + echo "
TURNO INCLUÍDO:$shift_id\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='SHIFTS', event_type='ADD', record_id='$shift_id', event_code='ADMIN ADD SHIFT', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + $ADD=331111111; + } + + +###################### +# ADD=21111111111 adds new phone to the system +###################### + +if ($ADD==21111111111) + { + ##### BEGIN ID override optional section, if enabled it increments user by 1 ignoring entered value ##### + $stmt = "SELECT value FROM vicidial_override_ids where id_table='phones' and active='1';"; + $rslt=mysql_query($stmt, $link); + $voi_ct = mysql_num_rows($rslt); + if ($voi_ct > 0) + { + $row=mysql_fetch_row($rslt); + $extension = ($row[0] + 1); + + $stmt="UPDATE vicidial_override_ids SET value='$extension' where id_table='phones' and active='1';"; + $rslt=mysql_query($stmt, $link); + } + ##### END ID override optional section ##### + + echo ""; + $stmt="SELECT count(*) from phones where extension='$extension' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
RAMAL NÃO ADICIONADO - já existe um Ramal no sistema com essa extensão\/servidor\n";} + else + { + $stmt="SELECT count(*) from phones where login='$login';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
PHONE NOT ADDED - já existe um Ramal no sistema com este login\n";} + else + { + $stmt="SELECT count(*) from phones_alias where alias_id='$login';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
PHONE NOT ADDED - já existe um alias de Ramal no sistema com esse login\n";} + else + { + $stmt="SELECT count(*) from vicidial_voicemail where voicemail_id='$voicemail_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
PHONE NOT ADDED - there is already a ID de correo de voz in the system with this ID\n";} + else + { + if ( (strlen($extension) < 1) or (strlen($server_ip) < 7) or (strlen($dialplan_number) < 1) or (strlen($voicemail_id) < 1) or (strlen($login) < 1) or (strlen($pass) < 1)) + { + echo "
RAMAL NÃO ADICIONADO - Por favor volte e verifique os dados digitados\n"; + echo "
Los siguientes campos deben disponer de datos: extension, server_ip, dialplan_number, voicemail_id, login, pass\n"; + } + else + { + echo "
RAMAL ADICIONADO\n"; + + $stmt="INSERT INTO phones (extension,dialplan_number,voicemail_id,phone_ip,computer_ip,server_ip,login,pass,status,active,phone_type,fullname,company,picture,protocol,local_gmt,outbound_cid) values('$extension','$dialplan_number','$voicemail_id','$phone_ip','$computer_ip','$server_ip','$login','$pass','$status','$active','$phone_type','$fullname','$company','$picture','$protocol','$local_gmt','$outbound_cid');"; + $rslt=mysql_query($stmt, $link); + + $stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$server_ip';"; + $rslt=mysql_query($stmtA, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='PHONES', event_type='ADD', record_id='$extension', event_code='ADMIN ADD PHONE', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + } + } + } + $ADD=31111111111; + } + + +###################### +# ADD=22111111111 adds new phone alias to the system +###################### + +if ($ADD==22111111111) + { + echo ""; + $stmt="SELECT count(*) from phones_alias where alias_id='$alias_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
ALIAS DE RAMAL NÃO INCLUIDO - já existe um Alias de Ramal no sistema com esse ID\n";} + else + { + $stmt="SELECT count(*) from phones where login='$alias_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
ALIAS DE RAMAL NÃO INCLUIDO - ja existe um Login no sistema com esse ID\n";} + else + { + if ( (strlen($alias_id) < 1) or (strlen($alias_name) < 2) ) + {echo "
ALIAS DE RAMAL NÃO INCLUIDO - Por favor, volte e verifique os dados digitados\n";} + else + { + echo "
ALIAS DE RAMAL INCLUÍDO\n"; + + $stmt="INSERT INTO phones_alias (alias_id,alias_name,logins_list) values('$alias_id','$alias_name','$logins_list');"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='PHONEALIASES', event_type='ADD', record_id='$alias_id', event_code='ADMIN ADD ALIAS DE RAMAL', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + } + $ADD=32111111111; + } + + +###################### +# ADD=23111111111 adds new group alias to the system +###################### + +if ($ADD==23111111111) + { + echo ""; + $stmt="SELECT count(*) from groups_alias where group_alias_id='$group_alias_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
ALIAS DE GRUPO NÃO INCLUÍDO - já existe um Alias de Ramal no sistema com esse ID\n";} + else + { + if (preg_match("/AGENT_PHONE|CUSTOMER|CAMPANHA|NONE/",$group_alias_id)) + {echo "
ALIAS DE GRUPO NÃO INCLUÍDO - não pode ser usado palavras reservadas neste alias de grupo\n";} + else + { + if ( (strlen($group_alias_id) < 1) or (strlen($group_alias_name) < 2) ) + {echo "
ALIAS DE GRUPO NÃO INCLUÍDO - Por favor, volte e verifique os dados digitados\n";} + else + { + echo "
ALIAS DE GRUPO INCLUÍDO\n"; + + $stmt="INSERT INTO groups_alias (group_alias_id,group_alias_name,caller_id_number,caller_id_name,active) values('$group_alias_id','$group_alias_name','$caller_id_number','$caller_id_name','$active');"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='GROUPALIASES', event_type='ADD', record_id='$group_alias_id', event_code='ADMIN ADD GROUP ALIAS', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + } + $ADD=33111111111; + } + + +###################### +# ADD=211111111111 adds new server to the system +###################### + +if ($ADD==211111111111) + { + echo ""; + $stmt="SELECT count(*) from servers where server_id='$server_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
SERVIDOR NÃO ADICIONADO - já existe um servidor no sistema com essa ID\n";} + else + { + if ( (strlen($server_id) < 1) or (strlen($server_ip) < 7) ) + {echo "
SERVIDOR NÃO ADICIONADO - por favor volte e verifique os dados digitados\n";} + else + { + echo "
SERVIDOR ADICIONADO\n"; + + $stmt="INSERT INTO servers (server_id,server_description,server_ip,active,asterisk_version) values('$server_id','$server_description','$server_ip','$active','$asterisk_version');"; + $rslt=mysql_query($stmt, $link); + + $stmtA="UPDATE servers SET rebuild_conf_files='Y',rebuild_music_on_hold='Y',sounds_update='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$server_ip';"; + $rslt=mysql_query($stmtA, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='SERVERS', event_type='ADD', record_id='$server_id', event_code='ADMIN ADD SERVER', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + $ADD=311111111111; + } + + +###################### +# ADD=221111111111 adds the new vicidial server trunk record to the system +###################### + +if ($ADD==221111111111) + { + echo ""; + $stmt="SELECT max_vicidial_trunks from servers where server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $MAXvicidial_trunks = $rowx[0]; + + $stmt="SELECT sum(dedicated_trunks) from vicidial_server_trunks where server_ip='$server_ip' and campaign_id !='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $SUMvicidial_trunks = ($rowx[0] + $dedicated_trunks); + + if ($SUMvicidial_trunks > $MAXvicidial_trunks) + { + echo "
REGISTRO DE TRUNK VICIDIAL NÃO ADICIONADO - o número de trunk vicidial é muito alto: $SUMvicidial_trunks / $MAXvicidial_trunks\n"; + } + else + { + $stmt="SELECT count(*) from vicidial_server_trunks where campaign_id='$campaign_id' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
REGISTRO DE TRUNK VICIDIAL NÃO ADICIONADO - já existe um registro de trunk para esta campanha\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($server_ip) < 7) or (strlen($dedicated_trunks) < 1) or (strlen($trunk_restriction) < 1) ) + { + echo "
REGISTRO DE TRUNK VICIDIAL NÃO ADICIONADO - Por favor, volte e verifique os dados digitados\n"; + echo "
campanha deve ter entre 3 e 8 caracteres de comprimento\n"; + echo "
delay do IP do servidor deve ser pelo menos 7 caracteres\n"; + echo "
trunks devem ter um digito entre 0 e 9999\n"; + } + else + { + echo "
REGISTRO DE TRUNK VICIDIAL INCLUÍDO: $campaign_id - $server_ip - $dedicated_trunks - $trunk_restriction\n"; + + $stmt="INSERT INTO vicidial_server_trunks(server_ip,campaign_id,dedicated_trunks,trunk_restriction) values('$server_ip','$campaign_id','$dedicated_trunks','$trunk_restriction');"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='SERVERS_TRUNK', event_type='ADD', record_id='$server_ip', event_code='ADMIN ADD SERVIDOR TRUNK', event_sql=\"$SQL_log\", event_notes='campaign: $campaign_id';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + } + $ADD=311111111111; + } + + +###################### +# ADD=231111111111 adds new conf template to the system +###################### + +if ($ADD==231111111111) + { + echo ""; + $stmt="SELECT count(*) from vicidial_conf_templates where template_id='$template_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
TEMPLATE DE CONF NÃO INCLUÍDA - já existe um template no sistema com esse ID\n";} + else + { + if (strlen($template_id) < 2) + {echo "
TEMPLATE DE CONF NÃO INCLUÍDA - Por favor, volte e verifique os dados digitados\n";} + else + { + echo "
TEMPLATE DE CONF INCLUÍDO\n"; + + $stmt="INSERT INTO vicidial_conf_templates (template_id,template_name,template_contents) values('$template_id','$template_name','$template_contents');"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CONFTEMPLATES', event_type='ADD', record_id='$template_id', event_code='ADMIN ADD CONF TEMPLATE', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + $ADD=331111111111; + } + + +###################### +# ADD=241111111111 adds new server carrier to the system +###################### + +if ($ADD==241111111111) + { + echo ""; + $stmt="SELECT count(*) from vicidial_server_carriers where carrier_id='$carrier_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
OPERADORA NÃO INCLUÍDA - já existe uma operadora no sistema com este ID\n";} + else + { + if ( (strlen($carrier_id) < 2) or (strlen($server_ip) < 7) ) + {echo "
OPERADORA NÃO INCLUÍDA - Por favor, volte e verifique os dados digitados\n";} + else + { + echo "
CARRIER ADDED\n"; + + $stmt="INSERT INTO vicidial_server_carriers (carrier_id,carrier_name,registration_string,template_id,account_entry,protocol,globals_string,dialplan_entry,server_ip,active,carrier_description) values('$carrier_id','$carrier_name','$registration_string','$template_id','$account_entry','$protocol','$globals_string','$dialplan_entry','$server_ip','N','$carrier_description');"; + $rslt=mysql_query($stmt, $link); + + $stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$server_ip';"; + $rslt=mysql_query($stmtA, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CARRIERS', event_type='ADD', record_id='$carrier_id', event_code='ADMIN ADD CARRIER', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + $ADD=341111111111; + } + + +###################### +# ADD=251111111111 adds new tts entry to the system +###################### + +if ($ADD==251111111111) + { + echo ""; + $stmt="SELECT count(*) from vicidial_tts_prompts where tts_id='$tts_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
TTS entrada no AGREGADOS - ya hay una entrada de TTS en el sistema con este ID\n";} + else + { + if ( (strlen($tts_id) < 2) or (strlen($tts_name) < 3) ) + {echo "
TTS entrada no AGREGADOS - Por favor, volte e verifique os dados digitados\n";} + else + { + echo "
TTS añadido la entrada de\n"; + + $stmt="INSERT INTO vicidial_tts_prompts SET tts_id='$tts_id',tts_name='$tts_name',active='$active';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='TTS', event_type='ADD', record_id='$tts_id', event_code='ADMIN ADD TTS', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + $ADD=351111111111; + } + + +###################### +# ADD=261111111111 adds new music on hold entry to the system +###################### + +if ($ADD==261111111111) + { + echo ""; + $stmt="SELECT count(*) from vicidial_music_on_hold where moh_id='$moh_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
MÚSICA EN ESPERA entrada no AGREGADOS - ya hay una entrada en el Ministerio de Salud en el sistema con este ID\n";} + else + { + if ( (strlen($moh_id) < 2) or (strlen($moh_name) < 3) or ($moh_id=='sounds') or ($moh_id=='agi-bin') or ($moh_id=='astdb') or ($moh_id=='keys') ) + {echo "
MÚSICA EN ESPERA entrada no AGREGADOS - Por favor, volte e verifique os dados digitados\n";} + else + { + echo "
MÚSICA EN ESPERA añadido la entrada de\n"; + + $stmt="INSERT INTO vicidial_music_on_hold SET moh_id='$moh_id',moh_name='$moh_name',random='$random';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='MOH', event_type='ADD', record_id='$moh_id', event_code='ADMIN ADD MOH', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + $ADD=361111111111; + } + + +###################### +# ADD=271111111111 adds new voicemail box to the system +###################### + +if ($ADD==271111111111) + { + echo ""; + $stmt="SELECT count(*) from vicidial_voicemail where voicemail_id='$voicemail_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
Contestador NO AGREGADOS - ya existe un buzón de voz en el sistema con este ID\n";} + else + { + $stmt="SELECT count(*) from phones where voicemail_id='$voicemail_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
Contestador NO AGREGADOS - ya hay un teléfono en el sistema de correo de voz con este ID\n";} + else + { + if ( (strlen($voicemail_id) < 2) or (strlen($pass) < 2) or (strlen($fullname) < 3) ) + {echo "
Contestador NO AGREGADOS - Por favor, volte e verifique os dados digitados\n";} + else + { + echo "
Contestador AGREGADOS\n"; + + $stmt="INSERT INTO vicidial_voicemail SET voicemail_id='$voicemail_id',pass='$pass',email='$email',fullname='$fullname',active='$active';"; + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT active_voicemail_server from system_settings;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $active_voicemail_server = $row[0]; + + $stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$active_voicemail_server';"; + $rslt=mysql_query($stmtA, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='VOICEMAIL', event_type='ADD', record_id='$voicemail_id', event_code='ADMIN ADD VOICEMAIL', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + } + $ADD=371111111111; + } + + +###################### +# ADD=2111111111111 adds new conference to the system +###################### + +if ($ADD==2111111111111) + { + echo ""; + $stmt="SELECT count(*) from conferences where conf_exten='$conf_exten' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CONFERÊNCIA NÃO ADICIONADA - já existe no sistema uma conferência com este ID e servidor\n";} + else + { + if ( (strlen($conf_exten) < 1) or (strlen($server_ip) < 7) ) + {echo "
CONFERÊNCIA NÃO ADICIONADA - Por favor volte e verifique os dados digitados\n";} + else + { + echo "
CONFERÊNCIA ADICIONADA\n"; + + $stmt="INSERT INTO conferences (conf_exten,server_ip) values('$conf_exten','$server_ip');"; + $rslt=mysql_query($stmt, $link); + } + } + $ADD=3111111111111; + } + + +###################### +# ADD=21111111111111 adds new vicidial conference to the system +###################### + +if ($ADD==21111111111111) + { + echo ""; + $stmt="SELECT count(*) from vicidial_conferences where conf_exten='$conf_exten' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
VICIDIAL CONFERENCE NOT ADDED - there is already a vicidial conference in the system with this ID and server\n";} + else + { + if ( (strlen($conf_exten) < 1) or (strlen($server_ip) < 7) ) + {echo "
VICIDIAL CONFERÊNCIA NÃO ADICIONADA - Por favor volte e verifique os dados digitados\n";} + else + { + echo "
VICIDIAL CONFERÊNCIA ADICIONADA\n"; + + $stmt="INSERT INTO vicidial_conferences (conf_exten,server_ip) values('$conf_exten','$server_ip');"; + $rslt=mysql_query($stmt, $link); + } + } + $ADD=31111111111111; + } + + +###################### +# ADD=221111111111111 adds the new system status to the system +###################### + +if ($ADD==221111111111111) + { + echo ""; + $stmt="SELECT count(*) from vicidial_campaign_statuses where status='$status_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
STATUS DE SISTEMA NÃO INCLUÍDO - there is already a campaign-status in the system with this name: $row[0]\n";} + else + { + $stmt="SELECT count(*) from vicidial_statuses where status='$status_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
STATUS DE SISTEMA NÃO INCLUÍDO - there is already a global-status in the system with this name\n";} + else + { + if ( (strlen($status_id) < 1) or (strlen($status_name) < 2) ) + { + echo "
STATUS DE SISTEMA NÃO INCLUÍDO - Por favor, volte e verifique os dados digitados\n"; + echo "
status deve ter entre 1 e 8 caracteres de comprimento\n"; + echo "
nome do status deve ter entre 2 e 30 caracteres de comprimento\n"; + } + else + { + echo "
STATUS DE SISTEMA INCLUÍDO: $status_name - $status_id\n"; + + $stmt="INSERT INTO vicidial_statuses (status,status_name,selectable,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable) values('$status_id','$status_name','$selectable','$human_answered','$category','$sale','$dnc','$customer_contact','$not_interested','$unworkable');"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='SYSTEMSTATUS', event_type='ADD', record_id='$status_id', event_code='ADMIN ADD SYSTEM STATUS', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + } + $ADD=321111111111111; + } + + +###################### +# ADD=231111111111111 adds the new status category to the system +###################### + +if ($ADD==231111111111111) + { + echo ""; + $stmt="SELECT count(*) from vicidial_status_categories where vsc_id='$vsc_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CATEGORIA NÃO INCLUIDA - já existe uma categoria de status com esse ID no sistema: $row[0]\n";} + else + { + if ( (strlen($vsc_id) < 2) or (strlen($vsc_id) > 20) or (strlen($vsc_name) < 2) ) + { + echo "
CATEGORIA NÃO INCLUIDA - Por favor, volte e verifique os dados digitados\n"; + echo "
ID deve ter entre 2 e 20 caracteres \n"; + echo "
o nome deve ter entre 2 e 50 caracteres\n"; + } + else + { + echo "
STATUS CATEGORIA ADDED: $vsc_id - $vsc_name\n"; + + $stmt="SELECT count(*) from vicidial_status_categories where tovdad_display='Y' and vsc_id NOT IN('$vsc_id');"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ( ($row[0] > 3) and (ereg('Y',$tovdad_display)) ) + { + $tovdad_display = 'N'; + echo "
ERRO: Já existem 4 Categorias de Status no Relatório TimeOnVDAD\n"; + } + + $stmt="INSERT INTO vicidial_status_categories (vsc_id,vsc_name,vsc_description,tovdad_display,sale_category,dead_lead_category) values('$vsc_id','$vsc_name','$vsc_description','$tovdad_display','$sale_category','$dead_lead_category');"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='STATUSCATEGORIES', event_type='ADD', record_id='$vsc_id', event_code='ADMIN ADD STATUS CATEGORIA', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + $ADD=331111111111111; + } + + + +###################### +# ADD=241111111111111 adds the new qc status code to the system +###################### + +if ($ADD==241111111111111) + { + echo ""; + $stmt="SELECT count(*) from vicidial_qc_codes where code='$code';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CÓDIGO DE STATUS CQ NÃO INCLUÍDO- já existe um código de status cq no sistema com esse nome: $row[0]\n";} + else + { + if ( (strlen($code) < 1) or (strlen($code_name) < 2) ) + { + echo "
CÓDIGO DE STATUS CQ NÃO INCLUÍDO- Por favor, volte e verifique os dados digitados\n"; + echo "
código deve ter entre 1 e 8 caracteres de comprimento\n"; + echo "
nome do código deve ter entre 2 e 30 caracteres de comprimento\n"; + } + else + { + echo "
CÓDIGO DE STATUS CQ ADICIONADO:$code_name - $code\n"; + + $stmt="INSERT INTO vicidial_qc_codes (code,code_name) values('$code','$code_name');"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='QCSTATUS', event_type='ADD', record_id='$code', event_code='ADMIN ADD QC STATUS', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + $ADD=341111111111111; + } + + + +###################################################################################################### +###################################################################################################### +####### 4 series, record modifications submitted and DB is modified, then on to 3 series forms below +###################################################################################################### +###################################################################################################### + + + +###################### +# ADD=4A submit user modifications to the system - ADMIN +###################### + +if ($ADD=="4A") + { + if ($LOGmodify_users==1) + { + echo ""; + + if ( (strlen($pass) < 2) or (strlen($full_name) < 2) or (strlen($user_level) < 1) ) + { + echo "
USUÁRIO NÃO ALTERADO - Por favor volte e verifique os dados digitados\n"; + echo "
Senha e Nome Completo devem ter no mínimo 2 caracteres de comprimento\n"; + } + else + { + if ($SSoutbound_autodial_active < 1) + { + $closer_default_blended = '0'; + $delete_filters = '0'; + $load_leads = '0'; + } + echo "
USUÁRIO ALTERADO - ADMIN: $user\n"; + + $stmt="UPDATE vicidial_users set pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass',delete_users='$delete_users',delete_user_groups='$delete_user_groups',delete_lists='$delete_lists',delete_campaigns='$delete_campaigns',delete_ingroups='$delete_ingroups',delete_remote_agents='$delete_remote_agents',load_leads='$load_leads',campaign_detail='$campaign_detail',ast_admin_access='$ast_admin_access',ast_delete_phones='$ast_delete_phones',delete_scripts='$delete_scripts',modify_leads='$modify_leads',hotkeys_active='$hotkeys_active',change_agent_campaign='$change_agent_campaign',agent_choose_ingroups='$agent_choose_ingroups',closer_campaigns='$groups_value',scheduled_callbacks='$scheduled_callbacks',agentonly_callbacks='$agentonly_callbacks',agentcall_manual='$agentcall_manual',vicidial_recording='$vicidial_recording',vicidial_transfers='$vicidial_transfers',delete_filters='$delete_filters',alter_agent_interface_options='$alter_agent_interface_options',closer_default_blended='$closer_default_blended',delete_call_times='$delete_call_times',modify_call_times='$modify_call_times',modify_users='$modify_users',modify_campaigns='$modify_campaigns',modify_lists='$modify_lists',modify_scripts='$modify_scripts',modify_filters='$modify_filters',modify_ingroups='$modify_ingroups',modify_usergroups='$modify_usergroups',modify_remoteagents='$modify_remoteagents',modify_servers='$modify_servers',view_reports='$view_reports',vicidial_recording_override='$vicidial_recording_override',alter_custdata_override='$alter_custdata_override',qc_enabled='$qc_enabled',qc_user_level='$qc_user_level',qc_pass='$qc_pass',qc_finish='$qc_finish',qc_commit='$qc_commit',add_timeclock_log='$add_timeclock_log',modify_timeclock_log='$modify_timeclock_log',delete_timeclock_log='$delete_timeclock_log',alter_custphone_override='$alter_custphone_override',vdc_agent_api_access='$vdc_agent_api_access',modify_inbound_dids='$modify_inbound_dids',delete_inbound_dids='$delete_inbound_dids',active='$active',download_lists='$download_lists',agent_shift_enforcement_override='$agent_shift_enforcement_override',manager_shift_enforcement_override='$manager_shift_enforcement_override',export_reports='$export_reports',delete_from_dnc='$delete_from_dnc',email='$email',user_code='$user_code',territory='$territory',allow_alerts='$allow_alerts',agent_choose_territories='$agent_choose_territories',custom_one='$custom_one',custom_two='$custom_two',custom_three='$custom_three',custom_four='$custom_four',custom_five='$custom_five' where user='$user';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|$stmt_grp_values|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='USUÁRIOS', event_type='MODIFY', record_id='$user', event_code='ADMIN MODIFY USER', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + ############################################################### + ##### START SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP ##### + $stmt = "SELECT enable_vtiger_integration,vtiger_server_ip,vtiger_dbname,vtiger_login,vtiger_pass,vtiger_url FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $ss_conf_ct = mysql_num_rows($rslt); + if ($ss_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $enable_vtiger_integration = $row[0]; + $vtiger_server_ip = $row[1]; + $vtiger_dbname = $row[2]; + $vtiger_login = $row[3]; + $vtiger_pass = $row[4]; + $vtiger_url = $row[5]; + } + ##### END SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP ##### + ############################################################# + + if ($enable_vtiger_integration > 0) + { + ### connect to your vtiger database + $linkV=mysql_connect("$vtiger_server_ip", "$vtiger_login","$vtiger_pass"); + if (!$linkV) {die("Could not connect: $vtiger_server_ip|$vtiger_dbname|$vtiger_login|$vtiger_pass" . mysql_error());} + echo 'Connected successfully'; + mysql_select_db("$vtiger_dbname", $linkV); + + $user_name = $user; + $user_password = $pass; + $last_name = $full_name; + $is_admin = 'off'; + $roleid = 'H5'; + $status = 'Ativo'; + $groupid = '1'; + if ($user_level >= 7) {$roleid = 'H3';} + if ($user_level >= 8) {$roleid = 'H4';} + if ($user_level >= 9) {$roleid = 'H2';} + if ($user_level >= 9) {$is_admin = 'on';} + $salt = substr($user_name, 0, 2); + $salt = '$1$' . $salt . '$'; + $encrypted_password = crypt($user_password, $salt); + + ###################################### + ##### BEGIN Add/Update group info in Vtiger + $stmt="SELECT count(*) from vtiger_groups where groupname='$user_group';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $group_found_count = $row[0]; + + ### group exists in vtiger, update it + if ($group_found_count > 0) + { + $stmt="SELECT groupid from vtiger_groups where groupname='$user_group';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $groupid = $row[0]; + } + + ### user doesn't exist in vtiger, insert it + else + { + #### BEGIN CREATE NEW GROUP RECORD IN VTIGER + # Get next available id from vtiger_users_seq to use as groupid + $stmt="SELECT id from vtiger_users_seq;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + $row=mysql_fetch_row($rslt); + $groupid = ($row[0] + 1); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + # Increase next available groupid with 1 so next record gets proper id + $stmt="UPDATE vtiger_users_seq SET id = '$groupid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtA = "INSERT INTO vtiger_groups SET groupid='$groupid',groupname='$user_group',description='';"; + if ($DB) {echo "|$stmtA|\n";} + $rslt=mysql_query($stmtA, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #### END CREATE NEW GROUP RECORD IN VTIGER + } + ##### END Add/Update group info in Vtiger + ###################################### + + ###################################### + ##### BEGIN Add/Update user info in Vtiger + $stmt="SELECT count(*) from vtiger_users where user_name='$user_name';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $found_count = $row[0]; + + ### user exists in vtiger, update it + if ($found_count > 0) + { + $stmt="SELECT id from vtiger_users where user_name='$user_name';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $userid = $row[0]; + + $stmt="SELECT count(*) from vtiger_users2group WHERE userid='$userid' and groupid='$groupid';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $usergroupcount = $row[0]; + + $stmtA = "UPDATE vtiger_users SET user_password='$encrypted_password',last_name='$last_name',is_admin='$is_admin',status='$status' where id='$userid';"; + if ($DB) {echo "|$stmtA|\n";} + $rslt=mysql_query($stmtA, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtB = "UPDATE vtiger_user2role SET roleid='$roleid' where userid='$userid';"; + if ($DB) {echo "|$stmtB|\n";} + $rslt=mysql_query($stmtB, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + if ($usergroupcount < 1) + { + $stmt="SELECT user_group FROM vicidial_user_groups;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VD_groups_ct = mysql_num_rows($rslt); + $k=0; + $VD_groups_list=''; + while ($k < $VD_groups_ct) + { + $row=mysql_fetch_row($rslt); + $VD_groups_list .= "'$row[0]',"; + $k++; + } + $VD_groups_list = preg_replace("/.$/",'',$VD_groups_list); + + $stmtC = "DELETE FROM vtiger_users2group WHERE userid='$userid' and groupid IN(SELECT groupid from vtiger_groups where groupname IN($VD_groups_list));"; + if ($DB) {echo "|$stmtC|\n";} + $rslt=mysql_query($stmtC, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtD = "INSERT INTO vtiger_users2group SET userid='$userid',groupid='$groupid';"; + if ($DB) {echo "|$stmtD|\n";} + $rslt=mysql_query($stmtD, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + } + } + + ### user doesn't exist in vtiger, insert it + else + { + #### BEGIN CREATE NEW USER RECORD IN VTIGER + $stmtA = "INSERT INTO vtiger_users SET user_name='$user_name',user_password='$encrypted_password',last_name='$last_name',is_admin='$is_admin',status='$status',date_format='yyyy-mm-dd',first_name='',reports_to_id='',description='',title='',department='',phone_home='',phone_mobile='',phone_work='',phone_other='',phone_fax='',email1='',email2='',yahoo_id='',signature='',address_street='',address_city='',address_state='',address_country='',address_postalcode='',user_preferences='',imagename='';"; + if ($DB) {echo "|$stmtA|\n";} + $rslt=mysql_query($stmtA, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $userid = mysql_insert_id($linkV); + + $stmtB = "INSERT INTO vtiger_user2role SET userid='$userid',roleid='$roleid';"; + if ($DB) {echo "|$stmtB|\n";} + $rslt=mysql_query($stmtB, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtC = "INSERT INTO vtiger_users2group SET userid='$userid',groupid='$groupid';"; + if ($DB) {echo "|$stmtC|\n";} + $rslt=mysql_query($stmtC, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtD = "UPDATE vtiger_users_seq SET id='$userid';"; + if ($DB) {echo "|$stmtD|\n";} + $rslt=mysql_query($stmtD, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #### END CREATE NEW USER RECORD IN VTIGER + } + ##### END Add/Update user info in Vtiger + ###################################### + } + ### END vtiger integration + + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $ADD=3; # go to user modification below + } + + +###################### +# ADD=4B submit user modifications to the system - ADMIN +###################### + +if ($ADD=="4B") + { + if ($LOGmodify_users==1) + { + echo ""; + + if ( (strlen($pass) < 2) or (strlen($full_name) < 2) or (strlen($user_level) < 1) ) + { + echo "
USUÁRIO NÃO ALTERADO - Por favor volte e verifique os dados digitados\n"; + echo "
Senha e Nome Completo devem ter no mínimo 2 caracteres de comprimento\n"; + } + else + { + if ($SSoutbound_autodial_active < 1) + { + $closer_default_blended = '0'; + $delete_filters = '0'; + $load_leads = '0'; + } + echo "
USUÁRIO ALTERADO - ADMIN: $user\n"; + + $stmt="UPDATE vicidial_users set pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass',hotkeys_active='$hotkeys_active',agent_choose_ingroups='$agent_choose_ingroups',closer_campaigns='$groups_value',scheduled_callbacks='$scheduled_callbacks',agentonly_callbacks='$agentonly_callbacks',agentcall_manual='$agentcall_manual',vicidial_recording='$vicidial_recording',vicidial_transfers='$vicidial_transfers',closer_default_blended='$closer_default_blended',vicidial_recording_override='$vicidial_recording_override',alter_custdata_override='$alter_custdata_override',qc_enabled='$qc_enabled',qc_user_level='$qc_user_level',qc_pass='$qc_pass',qc_finish='$qc_finish',qc_commit='$qc_commit',alter_custphone_override='$alter_custphone_override',active='$active',agent_shift_enforcement_override='$agent_shift_enforcement_override',email='$email',user_code='$user_code',territory='$territory',allow_alerts='$allow_alerts',agent_choose_territories='$agent_choose_territories',custom_one='$custom_one',custom_two='$custom_two',custom_three='$custom_three',custom_four='$custom_four',custom_five='$custom_five' where user='$user';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='USUÁRIOS', event_type='MODIFY', record_id='$user', event_code='ADMIN MODIFY USER', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + ############################################################### + ##### START SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP ##### + $stmt = "SELECT enable_vtiger_integration,vtiger_server_ip,vtiger_dbname,vtiger_login,vtiger_pass,vtiger_url FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $ss_conf_ct = mysql_num_rows($rslt); + if ($ss_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $enable_vtiger_integration = $row[0]; + $vtiger_server_ip = $row[1]; + $vtiger_dbname = $row[2]; + $vtiger_login = $row[3]; + $vtiger_pass = $row[4]; + $vtiger_url = $row[5]; + } + ##### END SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP ##### + ############################################################# + + if ($enable_vtiger_integration > 0) + { + ### connect to your vtiger database + $linkV=mysql_connect("$vtiger_server_ip", "$vtiger_login","$vtiger_pass"); + if (!$linkV) {die("Could not connect: $vtiger_server_ip|$vtiger_dbname|$vtiger_login|$vtiger_pass" . mysql_error());} + echo 'Connected successfully'; + mysql_select_db("$vtiger_dbname", $linkV); + + $user_name = $user; + $user_password = $pass; + $last_name = $full_name; + $is_admin = 'off'; + $roleid = 'H5'; + $status = 'Ativo'; + $groupid = '1'; + if ($user_level >= 7) {$roleid = 'H3';} + if ($user_level >= 8) {$roleid = 'H4';} + if ($user_level >= 9) {$roleid = 'H2';} + if ($user_level >= 9) {$is_admin = 'on';} + $salt = substr($user_name, 0, 2); + $salt = '$1$' . $salt . '$'; + $encrypted_password = crypt($user_password, $salt); + + ###################################### + ##### BEGIN Add/Update group info in Vtiger + $stmt="SELECT count(*) from vtiger_groups where groupname='$user_group';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $group_found_count = $row[0]; + + ### group exists in vtiger, update it + if ($group_found_count > 0) + { + $stmt="SELECT groupid from vtiger_groups where groupname='$user_group';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $groupid = $row[0]; + } + + ### user doesn't exist in vtiger, insert it + else + { + #### BEGIN CREATE NEW GROUP RECORD IN VTIGER + # Get next available id from vtiger_users_seq to use as groupid + $stmt="SELECT id from vtiger_users_seq;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + $row=mysql_fetch_row($rslt); + $groupid = ($row[0] + 1); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + # Increase next available groupid with 1 so next record gets proper id + $stmt="UPDATE vtiger_users_seq SET id = '$groupid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtA = "INSERT INTO vtiger_groups SET groupid='$groupid',groupname='$user_group',description='';"; + if ($DB) {echo "|$stmtA|\n";} + $rslt=mysql_query($stmtA, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #### END CREATE NEW GROUP RECORD IN VTIGER + } + ##### END Add/Update group info in Vtiger + ###################################### + + ###################################### + ##### BEGIN Add/Update user info in Vtiger + $stmt="SELECT count(*) from vtiger_users where user_name='$user_name';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $found_count = $row[0]; + + ### user exists in vtiger, update it + if ($found_count > 0) + { + $stmt="SELECT id from vtiger_users where user_name='$user_name';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $userid = $row[0]; + + $stmt="SELECT count(*) from vtiger_users2group WHERE userid='$userid' and groupid='$groupid';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $usergroupcount = $row[0]; + + $stmtA = "UPDATE vtiger_users SET user_password='$encrypted_password',last_name='$last_name',is_admin='$is_admin',status='$status' where id='$userid';"; + if ($DB) {echo "|$stmtA|\n";} + $rslt=mysql_query($stmtA, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtB = "UPDATE vtiger_user2role SET roleid='$roleid' where userid='$userid';"; + if ($DB) {echo "|$stmtB|\n";} + $rslt=mysql_query($stmtB, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + if ($usergroupcount < 1) + { + $stmt="SELECT user_group FROM vicidial_user_groups;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VD_groups_ct = mysql_num_rows($rslt); + $k=0; + $VD_groups_list=''; + while ($k < $VD_groups_ct) + { + $row=mysql_fetch_row($rslt); + $VD_groups_list .= "'$row[0]',"; + $k++; + } + $VD_groups_list = preg_replace("/.$/",'',$VD_groups_list); + + $stmtC = "DELETE FROM vtiger_users2group WHERE userid='$userid' and groupid IN(SELECT groupid from vtiger_groups where groupname IN($VD_groups_list));"; + if ($DB) {echo "|$stmtC|\n";} + $rslt=mysql_query($stmtC, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtD = "INSERT INTO vtiger_users2group SET userid='$userid',groupid='$groupid';"; + if ($DB) {echo "|$stmtD|\n";} + $rslt=mysql_query($stmtD, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + } + } + + ### user doesn't exist in vtiger, insert it + else + { + #### BEGIN CREATE NEW USER RECORD IN VTIGER + $stmtA = "INSERT INTO vtiger_users SET user_name='$user_name',user_password='$encrypted_password',last_name='$last_name',is_admin='$is_admin',status='$status',date_format='yyyy-mm-dd',first_name='',reports_to_id='',description='',title='',department='',phone_home='',phone_mobile='',phone_work='',phone_other='',phone_fax='',email1='',email2='',yahoo_id='',signature='',address_street='',address_city='',address_state='',address_country='',address_postalcode='',user_preferences='',imagename='';"; + if ($DB) {echo "|$stmtA|\n";} + $rslt=mysql_query($stmtA, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $userid = mysql_insert_id($linkV); + + $stmtB = "INSERT INTO vtiger_user2role SET userid='$userid',roleid='$roleid';"; + if ($DB) {echo "|$stmtB|\n";} + $rslt=mysql_query($stmtB, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtC = "INSERT INTO vtiger_users2group SET userid='$userid',groupid='$groupid';"; + if ($DB) {echo "|$stmtC|\n";} + $rslt=mysql_query($stmtC, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtD = "UPDATE vtiger_users_seq SET id='$userid';"; + if ($DB) {echo "|$stmtD|\n";} + $rslt=mysql_query($stmtD, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #### END CREATE NEW USER RECORD IN VTIGER + } + ##### END Add/Update user info in Vtiger + ###################################### + } + ### END vtiger integration + + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $ADD=3; # go to user modification below + } + + +###################### +# ADD=4 submit user modifications to the system +###################### + +if ($ADD==4) + { + if ($LOGmodify_users==1) + { + echo ""; + + if ( (strlen($pass) < 2) or (strlen($full_name) < 2) or (strlen($user_level) < 1) ) + { + echo "
USUÁRIO NÃO ALTERADO - Por favor volte e verifique os dados digitados\n"; + echo "
Senha e Nome Completo devem ter no mínimo 2 caracteres de comprimento\n"; + } + else + { + echo "
USUÁRIO ALTERADO: $user\n"; + + $stmt="UPDATE vicidial_users set pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass',active='$active',email='$email',user_code='$user_code',territory='$territory' where user='$user';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='USUÁRIOS', event_type='MODIFY', record_id='$user', event_code='ADMIN MODIFY USER', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + ############################################################### + ##### START SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP ##### + $stmt = "SELECT enable_vtiger_integration,vtiger_server_ip,vtiger_dbname,vtiger_login,vtiger_pass,vtiger_url FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $ss_conf_ct = mysql_num_rows($rslt); + if ($ss_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $enable_vtiger_integration = $row[0]; + $vtiger_server_ip = $row[1]; + $vtiger_dbname = $row[2]; + $vtiger_login = $row[3]; + $vtiger_pass = $row[4]; + $vtiger_url = $row[5]; + } + ##### END SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP ##### + ############################################################# + + if ($enable_vtiger_integration > 0) + { + ### connect to your vtiger database + $linkV=mysql_connect("$vtiger_server_ip", "$vtiger_login","$vtiger_pass"); + if (!$linkV) {die("Could not connect: $vtiger_server_ip|$vtiger_dbname|$vtiger_login|$vtiger_pass" . mysql_error());} + echo 'Connected successfully'; + mysql_select_db("$vtiger_dbname", $linkV); + + $user_name = $user; + $user_password = $pass; + $last_name = $full_name; + $is_admin = 'off'; + $roleid = 'H5'; + $status = 'Ativo'; + $groupid = '1'; + if ($user_level >= 7) {$roleid = 'H3';} + if ($user_level >= 8) {$roleid = 'H4';} + if ($user_level >= 9) {$roleid = 'H2';} + if ($user_level >= 9) {$is_admin = 'on';} + $salt = substr($user_name, 0, 2); + $salt = '$1$' . $salt . '$'; + $encrypted_password = crypt($user_password, $salt); + + ###################################### + ##### BEGIN Add/Update group info in Vtiger + $stmt="SELECT count(*) from vtiger_groups where groupname='$user_group';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $group_found_count = $row[0]; + + ### group exists in vtiger, update it + if ($group_found_count > 0) + { + $stmt="SELECT groupid from vtiger_groups where groupname='$user_group';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $groupid = $row[0]; + } + + ### user doesn't exist in vtiger, insert it + else + { + #### BEGIN CREATE NEW GROUP RECORD IN VTIGER + # Get next available id from vtiger_users_seq to use as groupid + $stmt="SELECT id from vtiger_users_seq;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + $row=mysql_fetch_row($rslt); + $groupid = ($row[0] + 1); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + # Increase next available groupid with 1 so next record gets proper id + $stmt="UPDATE vtiger_users_seq SET id = '$groupid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtA = "INSERT INTO vtiger_groups SET groupid='$groupid',groupname='$user_group',description='';"; + if ($DB) {echo "|$stmtA|\n";} + $rslt=mysql_query($stmtA, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #### END CREATE NEW GROUP RECORD IN VTIGER + } + ##### END Add/Update group info in Vtiger + ###################################### + + ###################################### + ##### BEGIN Add/Update user info in Vtiger + $stmt="SELECT count(*) from vtiger_users where user_name='$user_name';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $found_count = $row[0]; + + ### user exists in vtiger, update it + if ($found_count > 0) + { + $stmt="SELECT id from vtiger_users where user_name='$user_name';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $userid = $row[0]; + + $stmt="SELECT count(*) from vtiger_users2group WHERE userid='$userid' and groupid='$groupid';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $usergroupcount = $row[0]; + + $stmtA = "UPDATE vtiger_users SET user_password='$encrypted_password',last_name='$last_name',is_admin='$is_admin',status='$status' where id='$userid';"; + if ($DB) {echo "|$stmtA|\n";} + $rslt=mysql_query($stmtA, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtB = "UPDATE vtiger_user2role SET roleid='$roleid' where userid='$userid';"; + if ($DB) {echo "|$stmtB|\n";} + $rslt=mysql_query($stmtB, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + if ($usergroupcount < 1) + { + $stmt="SELECT user_group FROM vicidial_user_groups;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VD_groups_ct = mysql_num_rows($rslt); + $k=0; + $VD_groups_list=''; + while ($k < $VD_groups_ct) + { + $row=mysql_fetch_row($rslt); + $VD_groups_list .= "'$row[0]',"; + $k++; + } + $VD_groups_list = preg_replace("/.$/",'',$VD_groups_list); + + $stmtC = "DELETE FROM vtiger_users2group WHERE userid='$userid' and groupid IN(SELECT groupid from vtiger_groups where groupname IN($VD_groups_list));"; + if ($DB) {echo "|$stmtC|\n";} + $rslt=mysql_query($stmtC, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtD = "INSERT INTO vtiger_users2group SET userid='$userid',groupid='$groupid';"; + if ($DB) {echo "|$stmtD|\n";} + $rslt=mysql_query($stmtD, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + } + } + + ### user doesn't exist in vtiger, insert it + else + { + #### BEGIN CREATE NEW USER RECORD IN VTIGER + $stmtA = "INSERT INTO vtiger_users SET user_name='$user_name',user_password='$encrypted_password',last_name='$last_name',is_admin='$is_admin',status='$status',date_format='yyyy-mm-dd',first_name='',reports_to_id='',description='',title='',department='',phone_home='',phone_mobile='',phone_work='',phone_other='',phone_fax='',email1='',email2='',yahoo_id='',signature='',address_street='',address_city='',address_state='',address_country='',address_postalcode='',user_preferences='',imagename='';"; + if ($DB) {echo "|$stmtA|\n";} + $rslt=mysql_query($stmtA, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $userid = mysql_insert_id($linkV); + + $stmtB = "INSERT INTO vtiger_user2role SET userid='$userid',roleid='$roleid';"; + if ($DB) {echo "|$stmtB|\n";} + $rslt=mysql_query($stmtB, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtC = "INSERT INTO vtiger_users2group SET userid='$userid',groupid='$groupid';"; + if ($DB) {echo "|$stmtC|\n";} + $rslt=mysql_query($stmtC, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtD = "UPDATE vtiger_users_seq SET id='$userid';"; + if ($DB) {echo "|$stmtD|\n";} + $rslt=mysql_query($stmtD, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #### END CREATE NEW USER RECORD IN VTIGER + } + ##### END Add/Update user info in Vtiger + ###################################### + } + ### END vtiger integration + + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $ADD=3; # go to user modification below + } + +###################### +# ADD=41 submit campaign modifications to the system - DETAIL +###################### + +if ($ADD==41) + { + if ($LOGmodify_campaigns==1) + { + echo ""; + + if ($SSoutbound_autodial_active < 1) + { + $adaptive_dl_diff_target = '0'; + $adaptive_dropped_percentage = '99'; + $adaptive_intensity = '0'; + $adaptive_latest_server_time = '2359'; + $adaptive_maximum_level = '1.0'; + $agent_extended_alt_dial = 'N'; + $alt_number_dialing = 'N'; + $am_message_exten = '8320'; + $amd_send_to_vmx = 'N'; + $auto_alt_dial = 'N'; + $auto_dial_level = '1.0'; + $available_only_ratio_tally = 'Y'; + $campaign_allow_inbound = 'Y'; + $campaign_vdad_exten = '8368'; + $concurrent_transfers = 'AUTO'; + $dial_method = 'RATIO'; + $dial_status = ''; + $dial_timeout = '60'; + $drop_action = 'HANGUP'; + $drop_call_seconds = '5'; + $drop_inbound_group = '---NONE---'; + $force_reset_hopper = 'N'; + $hopper_level = '5'; + $lead_filter_id = 'NONE'; + $lead_order = 'DOWN'; + $list_order_mix = 'DISABLED'; + $no_hopper_leads_logins = 'Y'; + $queue_priority = '50'; + $safe_harbor_exten = '8300'; + $survey_camp_record_dir = '/home/survey'; + $survey_dtmf_digits = '1238'; + $survey_first_audio_file = 'US_pol_survey_hello'; + $survey_method = 'AGENT_XFER'; + $survey_ni_audio_file = ''; + $survey_ni_digit = '8'; + $survey_ni_status = 'NI'; + $survey_no_response_action = 'OPTIN'; + $survey_opt_in_audio_file = 'US_pol_survey_transfer'; + $survey_response_digit_map = '1-DEMOCRAT|2-REPUBLICAN|3-INDEPENDANT|8-OPTOUT|X-NO RESPONSE|'; + $survey_xfer_exten = '8300'; + $voicemail_ext = ''; + $cpd_amd_action = 'DISABLED'; + $drop_lockout_time = '0'; + } + if (ereg('list_activation',$stage)) + { + $p=0; + echo "
LISTAS ATIVAS ALTERADAS"; + $list_active_change_ct = count($list_active_change); + while ($p < $list_active_change_ct) + { + $LIST_ACTIVATE .= "'$list_active_change[$p]',"; + $p++; + } + + $stmt = "UPDATE vicidial_lists SET active='Y' where list_id IN($LIST_ACTIVATE'') and campaign_id='$campaign_id';"; + $stmtB = "UPDATE vicidial_lists SET active='N' where list_id NOT IN($LIST_ACTIVATE'') and campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $rslt=mysql_query($stmtB, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|$stmtB|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPANHAS', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN MODIFY CAMPANHA ACTIVE LISTAS', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + if ($DB > 0) {echo "|$stmt|\n|$stmtB|\n";} + } + else + { + if ( (strlen($campaign_name) < 6) or (strlen($active) < 1) ) + { + echo "
CAMPANHA NÃO ALTERADA - Por favor volte e verifique os dados digitados\n"; + echo "
o nome da campanha precisa ter no mínimo 6 caracteres de comprimento\n"; + echo "
|$campaign_name|$active|\n"; + } + else + { + echo "
CAMPANHA ALTERADA: $campaign_id\n"; + + if ( ($dial_method != 'MANUAL') and ($dial_method != 'ENTRANTE_MAN') ) + { + $no_hopper_dialing='N'; + $agent_dial_owner_only='NONE'; + } + if ($no_hopper_dialing == 'Y') + { + $auto_alt_dial='NONE'; + $list_order_mix='DISABLED'; + } + if ($dial_method == 'MANUAL') + { + $auto_dial_level='0'; + $adlSQL = "auto_dial_level='0',"; + $campaign_allow_inbound='N'; + } + else + { + if ($dial_level_override > 0) + { + $adlSQL = "auto_dial_level='$auto_dial_level',"; + } + else + { + if ($dial_method == 'RATIO') + { + if ($auto_dial_level < 1) {$auto_dial_level = "1.0";} + $adlSQL = "auto_dial_level='$auto_dial_level',"; + } + else + { + $adlSQL = ""; + if ($auto_dial_level < 1) + { + $auto_dial_level = "1.0"; + $adlSQL = "auto_dial_level='$auto_dial_level',"; + } + } + } + } + if ( (!ereg("DISABLED",$list_order_mix)) and ($hopper_level < 100) ) + {$hopper_level='100';} + + $stmtA="UPDATE vicidial_campaigns set campaign_name='$campaign_name',active='$active',dial_status_a='$dial_status_a',dial_status_b='$dial_status_b',dial_status_c='$dial_status_c',dial_status_d='$dial_status_d',dial_status_e='$dial_status_e',lead_order='$lead_order',allow_closers='$allow_closers',hopper_level='$hopper_level', $adlSQL next_agent_call='$next_agent_call', local_call_time='$local_call_time', voicemail_ext='$voicemail_ext', dial_timeout='$dial_timeout', dial_prefix='$dial_prefix', campaign_cid='$campaign_cid', campaign_vdad_exten='$campaign_vdad_exten', web_form_address='" . mysql_real_escape_string($web_form_address) . "', park_ext='$park_ext', park_file_name='$park_file_name', campaign_rec_exten='$campaign_rec_exten', campaign_recording='$campaign_recording', campaign_rec_filename='$campaign_rec_filename', campaign_script='$script_id', get_call_launch='$get_call_launch', am_message_exten='$am_message_exten', amd_send_to_vmx='$amd_send_to_vmx', xferconf_a_dtmf='$xferconf_a_dtmf',xferconf_a_number='$xferconf_a_number',xferconf_b_dtmf='$xferconf_b_dtmf',xferconf_b_number='$xferconf_b_number',lead_filter_id='$lead_filter_id',alt_number_dialing='$alt_number_dialing',scheduled_callbacks='$scheduled_callbacks',drop_action='$drop_action',drop_call_seconds='$drop_call_seconds',safe_harbor_exten='$safe_harbor_exten',wrapup_seconds='$wrapup_seconds',wrapup_message='$wrapup_message',closer_campaigns='$groups_value',use_internal_dnc='$use_internal_dnc',allcalls_delay='$allcalls_delay',omit_phone_code='$omit_phone_code',dial_method='$dial_method',available_only_ratio_tally='$available_only_ratio_tally',adaptive_dropped_percentage='$adaptive_dropped_percentage',adaptive_maximum_level='$adaptive_maximum_level',adaptive_latest_server_time='$adaptive_latest_server_time',adaptive_intensity='$adaptive_intensity',adaptive_dl_diff_target='$adaptive_dl_diff_target',concurrent_transfers='$concurrent_transfers',auto_alt_dial='$auto_alt_dial',agent_pause_codes_active='$agent_pause_codes_active',campaign_description='$campaign_description',campaign_changedate='$SQLdate',campaign_stats_refresh='$campaign_stats_refresh',disable_alter_custdata='$disable_alter_custdata',no_hopper_leads_logins='$no_hopper_leads_logins',list_order_mix='$list_order_mix',campaign_allow_inbound='$campaign_allow_inbound',manual_dial_list_id='$manual_dial_list_id',default_xfer_group='$default_xfer_group',xfer_groups='$XFERgroups_value',queue_priority='$queue_priority',drop_inbound_group='$drop_inbound_group',disable_alter_custphone='$disable_alter_custphone',display_queue_count='$display_queue_count',manual_dial_filter='$manual_dial_filter',agent_clipboard_copy='$agent_clipboard_copy',agent_extended_alt_dial='$agent_extended_alt_dial',use_campaign_dnc='$use_campaign_dnc',three_way_call_cid='$three_way_call_cid',three_way_dial_prefix='$three_way_dial_prefix',web_form_target='$web_form_target',vtiger_search_category='$vtiger_search_category',vtiger_create_call_record='$vtiger_create_call_record',vtiger_create_lead_record='$vtiger_create_lead_record',vtiger_screen_login='$vtiger_screen_login',cpd_amd_action='$cpd_amd_action',agent_allow_group_alias='$agent_allow_group_alias',default_group_alias='$default_group_alias',vtiger_search_dead='$vtiger_search_dead',vtiger_status_call='$vtiger_status_call',drop_lockout_time='$drop_lockout_time',quick_transfer_button='$quick_transfer_button',prepopulate_transfer_preset='$prepopulate_transfer_preset',drop_rate_group='$drop_rate_group',view_calls_in_queue='$view_calls_in_queue',view_calls_in_queue_launch='$view_calls_in_queue_launch',grab_calls_in_queue='$grab_calls_in_queue',call_requeue_button='$call_requeue_button',pause_after_each_call='$pause_after_each_call',no_hopper_dialing='$no_hopper_dialing',agent_dial_owner_only='$agent_dial_owner_only',agent_display_dialable_leads='$agent_display_dialable_leads',web_form_address_two='" . mysql_real_escape_string($web_form_address_two) . "',waitforsilence_options='$waitforsilence_options',agent_select_territories='$agent_select_territories',crm_popup_login='$crm_popup_login',crm_login_address='" . mysql_real_escape_string($crm_login_address) . "',timer_action='$timer_action',timer_action_message='$timer_action_message',timer_action_seconds='$timer_action_seconds',start_call_url='" . mysql_real_escape_string($start_call_url) . "',dispo_call_url='" . mysql_real_escape_string($dispo_call_url) . "',xferconf_c_number='$xferconf_c_number',xferconf_d_number='$xferconf_d_number',xferconf_e_number='$xferconf_e_number' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmtA, $link); + + if ($reset_hopper == 'Y') + { + echo "
REAJUSTE DE LA TOLVA DEL PLOMO DE LA CAMPAÚA\n"; + echo "
- Aguarde 1 minuto antes de discar o próximo número\n"; + $stmt="DELETE from vicidial_hopper where campaign_id='$campaign_id' and status IN('READY','QUEUE','DONE');"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPANHAS', event_type='RESET', record_id='$campaign_id', event_code='ADMIN RESET CAMPANHA LEAD HOPPER', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmtA|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPANHAS', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN MODIFY CAMPANHA', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $ADD=31; # go to campaign modification form below + } + + +###################### +# ADD=42 modify/delete campaign status in the system +###################### + +if ($ADD==42) + { + if ($LOGmodify_campaigns==1) + { + echo ""; + + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) ) + { + echo "
STATUS DA CAMPANHA NÃO ALTERADO - Por favor retorne e verifique os dados digitados\n"; + echo "
o id da campanha precisa ter no mínimo 2 caracteres de comprimento\n"; + echo "
o status da campanha precisa ter no mínimo 1 caracter de comprimento\n"; + } + else + { + if (ereg('delete',$stage)) + { + echo "
STATUS CUSTOMIZADO DA CAMPANHA REMOVIDO: $campaign_id - $status\n"; + + $stmt="DELETE FROM vicidial_campaign_statuses where campaign_id='$campaign_id' and status='$status';"; + $rslt=mysql_query($stmt, $link); + + $stmtA="DELETE FROM vicidial_campaign_hotkeys where campaign_id='$campaign_id' and status='$status';"; + $rslt=mysql_query($stmtA, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPANHA_STATUS', event_type='DELETE', record_id='$campaign_id', event_code='ADMIN DELETE CAMPANHA STATUS', event_sql=\"$SQL_log\", event_notes='Status: $status';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + if (ereg('modify',$stage)) + { + echo "
STATUS CUSTOMIZADO ALTERADO: $campaign_id - $status\n"; + + $stmt="UPDATE vicidial_campaign_statuses SET status_name='$status_name',selectable='$selectable',human_answered='$human_answered',category='$category',sale='$sale',dnc='$dnc',customer_contact='$customer_contact',not_interested='$not_interested',unworkable='$unworkable' where campaign_id='$campaign_id' and status='$status';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPANHA_STATUS', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN MODIFY CAMPANHA STATUS', event_sql=\"$SQL_log\", event_notes='Status: $status';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $SUB=22; + $ADD=31; # go to campaign modification form below + } + + +###################### +# ADD=43 delete campaign hotkey in the system +###################### + +if ($ADD==43) + { + if ($LOGmodify_campaigns==1) + { + echo ""; + + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or (strlen($hotkey) < 1) ) + { + echo "
ATALHO DE TECLADO DA CAMPANHA NÃO ALTERADO - Por favor volte e verifique os dados digitados\n"; + echo "
o id da campanha precisa ter no mínimo 2 caracteres de comprimento\n"; + echo "
o status da campanha precisa ter no mínimo 1 caracter de comprimento\n"; + echo "
the campaign hotkey needs to be at least 1 characters in length\n"; + } + else + { + echo "
ATALHO DE TECLADO DA CAMPANHA REMOVIDO: $campaign_id - $status - $hotkey\n"; + + $stmt="DELETE FROM vicidial_campaign_hotkeys where campaign_id='$campaign_id' and status='$status' and hotkey='$hotkey';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPANHA_HOTKEY', event_type='DELETE', record_id='$campaign_id', event_code='ADMIN DELETE CAMPANHA HOTKEY', event_sql=\"$SQL_log\", event_notes='Status: $status|HotKey: $hotkey';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $SUB=23; + $ADD=31; # go to campaign modification form below + } + + +###################### +# ADD=44 submit campaign modifications to the system - Basic View +###################### + +if ($ADD==44) + { + if ($LOGmodify_campaigns==1) + { + echo ""; + + if ($SSoutbound_autodial_active < 1) + { + $adaptive_dl_diff_target = '0'; + $adaptive_dropped_percentage = '99'; + $adaptive_intensity = '0'; + $adaptive_latest_server_time = '2359'; + $adaptive_maximum_level = '1.0'; + $agent_extended_alt_dial = 'N'; + $alt_number_dialing = 'N'; + $am_message_exten = '8320'; + $amd_send_to_vmx = 'N'; + $auto_alt_dial = 'N'; + $auto_dial_level = '1.0'; + $available_only_ratio_tally = 'Y'; + $campaign_allow_inbound = 'Y'; + $campaign_vdad_exten = '8368'; + $concurrent_transfers = 'AUTO'; + $dial_method = 'RATIO'; + $dial_status = ''; + $dial_timeout = '60'; + $drop_action = 'HANGUP'; + $drop_call_seconds = '5'; + $drop_inbound_group = '---NONE---'; + $force_reset_hopper = 'N'; + $hopper_level = '5'; + $lead_filter_id = 'NONE'; + $lead_order = 'DOWN'; + $list_order_mix = 'DISABLED'; + $no_hopper_leads_logins = 'Y'; + $queue_priority = '50'; + $safe_harbor_exten = '8300'; + $voicemail_ext = ''; + } + if (ereg('list_activation',$stage)) + { + $p=0; + echo "
LISTAS ATIVAS ALTERADAS"; + $list_active_change_ct = count($list_active_change); + while ($p < $list_active_change_ct) + { + $LIST_ACTIVATE .= "'$list_active_change[$p]',"; + $p++; + } + + $stmt = "UPDATE vicidial_lists SET active='Y' where list_id IN($LIST_ACTIVATE'') and campaign_id='$campaign_id';"; + $stmtB = "UPDATE vicidial_lists SET active='N' where list_id NOT IN($LIST_ACTIVATE'') and campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $rslt=mysql_query($stmtB, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|$stmtB|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPANHAS', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN MODIFY CAMPANHA ACTIVE LISTAS', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + if ($DB > 0) {echo "|$stmt|\n|$stmtB|\n";} + } + else + { + if ( (strlen($campaign_name) < 6) or (strlen($active) < 1) ) + { + echo "
CAMPANHA NÃO ALTERADA - Por favor volte e verifique os dados digitados\n"; + echo "
o nome da campanha precisa ter no mínimo 6 caracteres de comprimento\n"; + } + else + { + echo "
CAMPANHA ALTERADA: $campaign_id\n"; + + if ($dial_method == 'RATIO') + { + if ($auto_dial_level < 1) {$auto_dial_level = "1.0";} + $adlSQL = "auto_dial_level='$auto_dial_level',"; + } + else + { + if ($dial_method == 'MANUAL') + { + $auto_dial_level='0'; + $adlSQL = "auto_dial_level='0',"; + } + else + { + $adlSQL = ""; + if ($auto_dial_level < 1) + { + $auto_dial_level = "1.0"; + $adlSQL = "auto_dial_level='$auto_dial_level',"; + } + } + } + if ( (!ereg("DISABLED",$list_order_mix)) and ($hopper_level < 100) ) + {$hopper_level='100';} + + $stmtA="UPDATE vicidial_campaigns set campaign_name='$campaign_name',active='$active',dial_status_a='$dial_status_a',dial_status_b='$dial_status_b',dial_status_c='$dial_status_c',dial_status_d='$dial_status_d',dial_status_e='$dial_status_e',lead_order='$lead_order',hopper_level='$hopper_level', $adlSQL lead_filter_id='$lead_filter_id',dial_method='$dial_method',adaptive_intensity='$adaptive_intensity',campaign_changedate='$SQLdate',list_order_mix='$list_order_mix' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmtA, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmtA|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPANHAS', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN MODIFY CAMPANHA', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + if ($reset_hopper == 'Y') + { + echo "
REAJUSTE DE LA TOLVA DEL PLOMO DE LA CAMPAÚA\n"; + echo "
- Aguarde 1 minuto antes de discar o próximo número\n"; + $stmt="DELETE from vicidial_hopper where campaign_id='$campaign_id' and status IN('READY','QUEUE','DONE');;"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPANHAS', event_type='RESET', record_id='$campaign_id', event_code='ADMIN RESET CAMPANHA LEAD HOPPER', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $ADD=34; # go to campaign modification form below + } + + +###################### +# ADD=45 modify campaign lead recycle in the system +###################### + +if ($ADD==45) + { + if ($LOGmodify_campaigns==1) + { + echo ""; + + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or ($attempt_delay < 120) or ($attempt_delay >= 43200) or ($attempt_maximum < 1) or ($attempt_maximum > 10) ) + { + echo "
CAMPANHA LEAD RECYCLE NOT MODIFIED - Por favor, volte e verifique os dados digitados\n"; + echo "
status deve ter entre 1 e 6 caracteres\n"; + echo "
tempo de tentativa deve ter pelo menos 120 segundos e menos de 43200 segundos ou 12 horas\n"; + echo "
quantidade máxima de tentativas deve ser entre 1 e 10\n"; + } + else + { + echo "
CAMPANHA LEAD MODIFIED: $campaign_id - $status - $attempt_delay\n"; + + $stmt="UPDATE vicidial_lead_recycle SET attempt_delay='$attempt_delay',attempt_maximum='$attempt_maximum',active='$active' where campaign_id='$campaign_id' and status='$status';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPANHA_RECYCLE', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN MODIFY CAMPANHA LEAD RECYCLE', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $SUB=25; + $ADD=31; # go to campaign modification form below + } + + +###################### +# ADD=47 modify agent pause code in the system +###################### + +if ($ADD==47) + { + if ($LOGmodify_campaigns==1) + { + echo ""; + + if ( (strlen($campaign_id) < 2) or (strlen($pause_code) < 1) or (strlen($pause_code) > 6) or (strlen($pause_code_name) < 2) ) + { + echo "
CÓDIGO DE PAUSA NÃO ALTERADO - Por favor, volte e verifique os dados digitados\n"; + echo "
pause_code must be between 1 and 6 characters in length\n"; + echo "
pause_nome do código deve ter entre 2 e 30 caracteres de comprimento\n"; + } + else + { + echo "
AGENTE PAUSE CODE MODIFIED: $campaign_id - $pause_code - $pause_code_name\n"; + + $stmt="UPDATE vicidial_pause_codes SET pause_code_name='$pause_code_name',billable='$billable' where campaign_id='$campaign_id' and pause_code='$pause_code';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPANHA_PAUSECODE', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN MODIFY CAMPANHA PAUSE CODE', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $SUB=27; + $ADD=31; # go to campaign modification form below + } + + +###################### +# ADD=48 modify campaign QC settings in the system +###################### +if ($ADD==48) + { + if ( ($LOGmodify_campaigns==1) and ($SSqc_features_active) ) + { + echo ""; + + if (strlen($campaign_id) < 2) + { + echo "
CONFIG. DE CQ NÃO ALTERADAS - Por favor, volte e verifique os dados digitados\n"; + } + else + { + $p=0; + $qc_statuses_ct = count($qc_statuses); + while ($p < $qc_statuses_ct) + { + $QC_statuses .= " $qc_statuses[$p]"; + $p++; + } + $p=0; + $qc_lists_ct = count($qc_lists); + while ($p < $qc_lists_ct) + { + $QC_lists .= " $qc_lists[$p]"; + $p++; + } + + if (strlen($QC_statuses)>0) {$QC_statuses .= " -";} + if (strlen($QC_lists)>0) {$QC_lists .= " -";} + + echo "
CONFIG. DE CQ ALTERADAS: $campaign_id\n"; + + $stmt="UPDATE vicidial_campaigns SET qc_enabled='$qc_enabled',qc_statuses='$QC_statuses',qc_lists='$QC_lists',qc_web_form_address='$qc_web_form_address',qc_script='$qc_script',qc_get_record_launch='$qc_get_record_launch',qc_show_recording='$qc_show_recording',qc_shift_id='$qc_shift_id' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPANHA_QC', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN MODIFY CAMPANHA QC SETTINGS', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $SUB=28; + $ADD=31; # go to campaign modification form below + } + + +###################### +# ADD=40A modify campaign survey settings in the system +###################### + +if ($ADD=='40A') + { + if ($LOGmodify_campaigns==1) + { + echo ""; + + if (strlen($campaign_id) < 2) + { + echo "
CONFIGURAÇÃO DE PESQUISA NÃO ALTERADA - Por favor, volte e verifique os dados digitados\n"; + } + else + { + echo "
CONFIGURAÇÃO DE PESQUISA ALTERADA: $campaign_id\n"; + + $stmt="UPDATE vicidial_campaigns SET survey_first_audio_file='$survey_first_audio_file',survey_dtmf_digits='$survey_dtmf_digits',survey_ni_digit='$survey_ni_digit',survey_opt_in_audio_file='$survey_opt_in_audio_file',survey_ni_audio_file='$survey_ni_audio_file',survey_method='$survey_method',survey_no_response_action='$survey_no_response_action',survey_ni_status='$survey_ni_status',survey_response_digit_map='$survey_response_digit_map',survey_xfer_exten='$survey_xfer_exten',survey_camp_record_dir='$survey_camp_record_dir',voicemail_ext='$voicemail_ext',survey_third_digit='$survey_third_digit',survey_fourth_digit='$survey_fourth_digit',survey_third_audio_file='$survey_third_audio_file',survey_fourth_audio_file='$survey_fourth_audio_file',survey_third_status='$survey_third_status',survey_fourth_status='$survey_fourth_status',survey_third_exten='$survey_third_exten',survey_fourth_exten='$survey_fourth_exten' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPANHA_SURVEY', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN MODIFY CAMPANHA SURVEY', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $SUB='20A'; + $ADD=31; # go to campaign modification form below + } + + +###################### +# ADD=49 modify campaign list mix in the system +###################### + +if ($ADD==49) + { + if ($LOGmodify_campaigns==1) + { + ##### MODIFY a list mix container entry ##### + if ($stage=='MODIFY') + { + echo ""; + + $Flist_mix_container = "list_mix_container_$vcl_id"; + $Fmix_method = "mix_method_$vcl_id"; + $Fstatus = "status_$vcl_id"; + $Fvcl_name = "vcl_name_$vcl_id"; + + if (isset($_GET[$Flist_mix_container])) {$list_mix_container=$_GET[$Flist_mix_container];} + elseif (isset($_POST[$Flist_mix_container])) {$list_mix_container=$_POST[$Flist_mix_container];} + if (isset($_GET[$Fmix_method])) {$mix_method=$_GET[$Fmix_method];} + elseif (isset($_POST[$Fmix_method])) {$mix_method=$_POST[$Fmix_method];} + if (isset($_GET[$Fstatus])) {$status=$_GET[$Fstatus];} + elseif (isset($_POST[$Fstatus])) {$status=$_POST[$Fstatus];} + if (isset($_GET[$Fvcl_name])) {$vcl_name=$_GET[$Fvcl_name];} + elseif (isset($_POST[$Fvcl_name])) {$vcl_name=$_POST[$Fvcl_name];} + $list_mix_container = preg_replace("/:$/","",$list_mix_container); + + if ( (strlen($campaign_id) < 2) or (strlen($vcl_id) < 1) or (strlen($list_mix_container) < 6) or (strlen($vcl_name) < 2) ) + { + echo "
MESCLAGEM DE LISTA NÃO ALTERADA - Por favor, volte e verifique os dados digitados\n"; + echo "
vcl_id must be between 1 and 20 characters in length\n"; + echo "
vcl_name name must be between 2 and 30 characters in length\n"; + } + else + { + $stmt="UPDATE vicidial_campaigns_list_mix SET vcl_name='$vcl_name',mix_method='$mix_method',list_mix_container='$list_mix_container' where campaign_id='$campaign_id' and vcl_id='$vcl_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPANHA_LISTMIX', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN MODIFY CAMPANHA LIST MIX', event_sql=\"$SQL_log\", event_notes='Mesclagem de Lista: $vcl_id';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
MESCLAGEM DE LISTA ALTERADA: $campaign_id - $vcl_id - $vcl_name\n"; + } + } + + ##### ADD a list mix container entry ##### + if ($stage=='ADD') + { + echo ""; + + if ( (strlen($campaign_id) < 2) or (strlen($vcl_id) < 1) or (strlen($list_id) < 1) ) + { + echo "
MESCLAGEM DE LISTA NÃO ALTERADA - Por favor, volte e verifique os dados digitados\n"; + echo "
vcl_id must be between 1 and 20 characters in length\n"; + echo "
list_id must be at least 2 characters in length\n"; + } + else + { + $stmt="SELECT list_mix_container from vicidial_campaigns_list_mix where campaign_id='$campaign_id' and vcl_id='$vcl_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $OLDlist_mix_container = $row[0]; + $NEWlist_mix_container = "$OLDlist_mix_container:$list_id|10|0| -|"; + + $stmt="UPDATE vicidial_campaigns_list_mix SET list_mix_container='$NEWlist_mix_container' where campaign_id='$campaign_id' and vcl_id='$vcl_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPANHA_LISTMIX', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN MODIFY CAMPANHA LIST MIX', event_sql=\"$SQL_log\", event_notes='Mesclagem de Lista: $vcl_id';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
MESCLAGEM DE LISTA ALTERADA: $campaign_id - $vcl_id - $list_id\n"; + } + } + + ##### REMOVE a list mix container entry ##### + if ($stage=='REMOVE') + { + echo ""; + + if ( (strlen($campaign_id) < 2) or (strlen($vcl_id) < 1) or (strlen($list_id) < 1) ) + { + echo "
MESCLAGEM DE LISTA NÃO ALTERADA - Por favor, volte e verifique os dados digitados\n"; + echo "
vcl_id must be between 1 and 20 characters in length\n"; + echo "
list_id must be at least 2 characters in length\n"; + } + else + { + $stmt="SELECT list_mix_container from vicidial_campaigns_list_mix where campaign_id='$campaign_id' and vcl_id='$vcl_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $MIXentries = $MT; + $MIXentries = explode(":", $row[0]); + $Ms_to_print = (count($MIXentries) - 0); + + if ($Ms_to_print < 2) + { + echo "
MESCLAGEM DE LISTA NÃO ALTERADA: Você não pode apagar a última entrada de lista para uma mesclagem de lista\n"; + } + else + { + $MIXdetailsPCT = explode('|', $MIXentries[$mix_container_item]); + $MIXpercentPCT = $MIXdetailsPCT[2]; + + $q=0; + while ($Ms_to_print > $q) + { + if ( ($mix_container_item > $q) or ($mix_container_item < $q) ) + { + if ( ($q==0) and ($mix_container_item > 0) ) + { + $MIXdetailsONE = explode('|', $MIXentries[$q]); + $MIXpercentONE = ($MIXdetailsONE[2] + $MIXpercentPCT); + $NEWlist_mix_container .= "$MIXdetailsONE[0]|$MIXdetailsONE[1]|$MIXpercentONE|$MIXdetailsONE[3]|:"; + } + else + { + if ( ($q==1) and ($mix_container_item < 1) ) + { + $MIXdetailsONE = explode('|', $MIXentries[$q]); + $MIXpercentONE = ($MIXdetailsONE[2] + $MIXpercentPCT); + $NEWlist_mix_container .= "$MIXdetailsONE[0]|$MIXdetailsONE[1]|$MIXpercentONE|$MIXdetailsONE[3]|:"; + } + else + { + $NEWlist_mix_container .= "$MIXentries[$q]:"; + } + } + } + $q++; + } + $NEWlist_mix_container = preg_replace("/.$/",'',$NEWlist_mix_container); + + $stmt="UPDATE vicidial_campaigns_list_mix SET list_mix_container='$NEWlist_mix_container' where campaign_id='$campaign_id' and vcl_id='$vcl_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPANHA_LISTMIX', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN MODIFY CAMPANHA LIST MIX', event_sql=\"$SQL_log\", event_notes='Mesclagem de Lista: $vcl_id';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
MESCLAGEM DE LISTA ALTERADA: $campaign_id - $vcl_id - $list_id - $mix_container_item\n"; + } + } + } + + ##### ADD a NEW list mix ##### + if ($stage=='NEWMIX') + { + echo ""; + + if ( (strlen($campaign_id) < 2) or (strlen($vcl_id) < 1) or (strlen($vcl_name) < 2) ) + { + echo "
MESCLAGEM NÃO INCLUÍDA- Por favor, volte e verifique os dados digitados\n"; + echo "
vcl_id must be between 1 and 20 characters in length\n"; + echo "
vcl_name must be at least 2 characters in length\n"; + } + else + { + $stmt="SELECT count(*) from vicidial_campaigns_list_mix where vcl_id='$vcl_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + { + echo "
MESCLAGEM NÃO INCLUÍDA- Já existe uma mesclagem de lista com esse ID no sistema\n"; + } + else + { + $stmt="INSERT INTO vicidial_campaigns_list_mix SET list_mix_container='$list_id|1|100| $status -|',campaign_id='$campaign_id',vcl_id='$vcl_id',vcl_name='$vcl_name',mix_method='$mix_method',status='INACTIVE';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPANHA_LISTMIX', event_type='ADD', record_id='$campaign_id', event_code='ADMIN NOVA CAMPANHA LIST MIX', event_sql=\"$SQL_log\", event_notes='Mesclagem de Lista: $vcl_id';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
MESCLAGEM INCLUÍDA:$campaign_id - $vcl_id - $vcl_name\n"; + } + } + } + + ##### DELETE an existing list mix ##### + if ($stage=='DELMIX') + { + echo ""; + + if ( (strlen($campaign_id) < 2) or (strlen($vcl_id) < 1) ) + { + echo "
MESCLAGEM NÃO REMOVIDA - Por favor, volte e verifique os dados digitados\n"; + echo "
vcl_id must be between 1 and 20 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_campaigns_list_mix where vcl_id='$vcl_id' and campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPANHA_LISTMIX', event_type='DELETE', record_id='$campaign_id', event_code='ADMIN DELETE CAMPANHA LIST MIX', event_sql=\"$SQL_log\", event_notes='Mesclagem de Lista: $vcl_id';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
MESCLAGEM REMOVIDA:$campaign_id - $vcl_id - $vcl_name\n"; + } + } + + ##### Set list mix entry to active ##### + if ($stage=='SETACTIVE') + { + echo ""; + + if ( (strlen($campaign_id) < 2) or (strlen($vcl_id) < 1) ) + { + echo "
MESCLAGEM NÃO ATIVADA - Por favor, volte e verifique os dados digitados\n"; + echo "
vcl_id must be between 1 and 20 characters in length\n"; + } + else + { + $stmt="UPDATE vicidial_campaigns_list_mix SET status='INACTIVE' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + + $stmt="UPDATE vicidial_campaigns_list_mix SET status='ACTIVE' where vcl_id='$vcl_id' and campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPANHA_LISTMIX', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN MODIFY CAMPANHA LIST MIX ACTIVE', event_sql=\"$SQL_log\", event_notes='Mesclagem de Lista: $vcl_id';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
MESCLAGEM ATIVADA: $campaign_id - $vcl_id - $vcl_name\n"; + } + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $SUB=29; + $ADD=31; # go to campaign modification form below + } + + +###################### +# ADD=411 submit list modifications to the system +###################### + +if ($ADD==411) + { + if ($LOGmodify_lists==1) + { + echo ""; + + if ( (strlen($list_name) < 2) or (strlen($campaign_id) < 2) ) + { + echo "
LISTA NÃO ALTERADA - Por favor volte e verifique os dados digitados\n"; + echo "
o nome da lista precisa ter no mínimo 2 caracteres de comprimento\n"; + } + else + { + if (strlen($reset_time) < 4) {$reset_time='';} + + echo "
LISTA ALTERADA: $list_id\n"; + + $stmt="UPDATE vicidial_lists set list_name='$list_name',campaign_id='$campaign_id',active='$active',list_description='$list_description',list_changedate='$SQLdate',reset_time='$reset_time',agent_script_override='$agent_script_override',campaign_cid_override='$campaign_cid_override',am_message_exten_override='$am_message_exten_override',drop_inbound_group_override='$drop_inbound_group_override',xferconf_a_number='$xferconf_a_number',xferconf_b_number='$xferconf_b_number',xferconf_c_number='$xferconf_c_number',xferconf_d_number='$xferconf_d_number',xferconf_e_number='$xferconf_e_number' where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='LISTAS', event_type='MODIFY', record_id='$list_id', event_code='ADMIN MODIFY LIST', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + if ($reset_list == 'Y') + { + echo "
ZERANDO O STATUS DE CHAMADA DA LISTA\n"; + $stmtB="UPDATE vicidial_list set called_since_last_reset='N' where list_id='$list_id';"; + $rslt=mysql_query($stmtB, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='LISTAS', event_type='RESET', record_id='$list_id', event_code='ADMIN RESET LIST', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + if ($campaign_id != "$old_campaign_id") + { + echo "
REMOVENDO REGISTROS HOPPERS DO HOPPER DA CAMPANHA ANTIGA ($old_campaign_id)\n"; + $stmtC="DELETE from vicidial_hopper where list_id='$list_id' and campaign_id='$old_campaign_id';"; + $rslt=mysql_query($stmtC, $link); + } + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $ADD=311; # go to list modification form below + } + + +###################### +# ADD=4111 modify in-group info in the system +###################### + +if ($ADD==4111) + { + if ($LOGmodify_ingroups==1) + { + echo ""; + + if ( (strlen($group_name) < 2) or (strlen($group_color) < 2) ) + { + echo "
GRUPO NÃO ALTERADO - Por favor volte e verifique os dados digitados\n"; + echo "
a cor e o nome do grupo deve ter pelo menos 2 carcteres\n"; + } + else + { + $p=0; + $qc_statuses_ct = count($qc_statuses); + while ($p < $qc_statuses_ct) + { + $QC_statuses .= " $qc_statuses[$p]"; + $p++; + } + $p=0; + $qc_lists_ct = count($qc_lists); + while ($p < $qc_lists_ct) + { + $QC_lists .= " $qc_lists[$p]"; + $p++; + } + + if (strlen($QC_statuses)>0) {$QC_statuses .= " -";} + if (strlen($QC_lists)>0) {$QC_lists .= " -";} + + + if ($no_agent_action == "INGROUP") + { + if (isset($_GET["IGgroup_id_no_agent_action"])) {$IGgroup_id=$_GET["IGgroup_id_no_agent_action"];} + elseif (isset($_POST["IGgroup_id_no_agent_action"])) {$IGgroup_id=$_POST["IGgroup_id_no_agent_action"];} + if (isset($_GET["IGhandle_method_no_agent_action"])) {$IGhandle_method=$_GET["IGhandle_method_no_agent_action"];} + elseif (isset($_POST["IGhandle_method_no_agent_action"])) {$IGhandle_method=$_POST["IGhandle_method_no_agent_action"];} + if (isset($_GET["IGsearch_method_no_agent_action"])) {$IGsearch_method=$_GET["IGsearch_method_no_agent_action"];} + elseif (isset($_POST["IGsearch_method_no_agent_action"])) {$IGsearch_method=$_POST["IGsearch_method_no_agent_action"];} + if (isset($_GET["IGlist_id_no_agent_action"])) {$IGlist_id=$_GET["IGlist_id_no_agent_action"];} + elseif (isset($_POST["IGlist_id_no_agent_action"])) {$IGlist_id=$_POST["IGlist_id_no_agent_action"];} + if (isset($_GET["IGcampaign_id_no_agent_action"])) {$IGcampaign_id=$_GET["IGcampaign_id_no_agent_action"];} + elseif (isset($_POST["IGcampaign_id_no_agent_action"])) {$IGcampaign_id=$_POST["IGcampaign_id_no_agent_action"];} + if (isset($_GET["IGphone_code_no_agent_action"])) {$IGphone_code=$_GET["IGphone_code_no_agent_action"];} + elseif (isset($_POST["IGphone_code_no_agent_action"])) {$IGphone_code=$_POST["IGphone_code_no_agent_action"];} + + $no_agent_action_value = "$IGgroup_id,$IGhandle_method,$IGsearch_method,$IGlist_id,$IGcampaign_id,$IGphone_code"; + } + + if ($no_agent_action == "EXTENSION") + { + if (isset($_GET["EXextension_no_agent_action"])) {$EXextension=$_GET["EXextension_no_agent_action"];} + elseif (isset($_POST["EXextension_no_agent_action"])) {$EXextension=$_POST["EXextension_no_agent_action"];} + if (isset($_GET["EXcontext_no_agent_action"])) {$EXcontext=$_GET["EXcontext_no_agent_action"];} + elseif (isset($_POST["EXcontext_no_agent_action"])) {$EXcontext=$_POST["EXcontext_no_agent_action"];} + + $no_agent_action_value = "$EXextension,$EXcontext"; + } + + $no_agent_action_value = ereg_replace("[^-\/\|\_\#\*\,\.\_0-9a-zA-Z]","",$no_agent_action_value); + + echo "
GRUPO ALTERADO: $group_id\n"; + + $stmt="UPDATE vicidial_inbound_groups set group_name='$group_name', group_color='$group_color', active='$active', web_form_address='" . mysql_real_escape_string($web_form_address) . "', voicemail_ext='$voicemail_ext', next_agent_call='$next_agent_call', fronter_display='$fronter_display', ingroup_script='$script_id', get_call_launch='$get_call_launch', xferconf_a_dtmf='$xferconf_a_dtmf',xferconf_a_number='$xferconf_a_number', xferconf_b_dtmf='$xferconf_b_dtmf',xferconf_b_number='$xferconf_b_number',drop_action='$drop_action',drop_call_seconds='$drop_call_seconds',drop_exten='$drop_exten',call_time_id='$call_time_id',after_hours_action='$after_hours_action',after_hours_message_filename='$after_hours_message_filename',after_hours_exten='$after_hours_exten',after_hours_voicemail='$after_hours_voicemail',welcome_message_filename='$welcome_message_filename',moh_context='$moh_context',onhold_prompt_filename='$onhold_prompt_filename',prompt_interval='$prompt_interval',agent_alert_exten='$agent_alert_exten',agent_alert_delay='$agent_alert_delay',default_xfer_group='$default_xfer_group',queue_priority='$queue_priority',drop_inbound_group='$drop_inbound_group',ingroup_recording_override='$ingroup_recording_override',ingroup_rec_filename='$ingroup_rec_filename',afterhours_xfer_group='$afterhours_xfer_group',qc_enabled='$qc_enabled',qc_statuses='$QC_statuses',qc_shift_id='$qc_shift_id',qc_get_record_launch='$qc_get_record_launch',qc_show_recording='$qc_show_recording',qc_web_form_address='$qc_web_form_address',qc_script='$qc_script',play_place_in_line='$play_place_in_line',play_estimate_hold_time='$play_estimate_hold_time',hold_time_option='$hold_time_option',hold_time_option_seconds='$hold_time_option_seconds',hold_time_option_exten='$hold_time_option_exten',hold_time_option_voicemail='$hold_time_option_voicemail',hold_time_option_xfer_group='$hold_time_option_xfer_group',hold_time_option_callback_filename='$hold_time_option_callback_filename',hold_time_option_callback_list_id='$hold_time_option_callback_list_id',hold_recall_xfer_group='$hold_recall_xfer_group',no_delay_call_route='$no_delay_call_route',play_welcome_message='$play_welcome_message',answer_sec_pct_rt_stat_one='$answer_sec_pct_rt_stat_one',answer_sec_pct_rt_stat_two='$answer_sec_pct_rt_stat_two',default_group_alias='$default_group_alias',no_agent_no_queue='$no_agent_no_queue',no_agent_action='$no_agent_action',no_agent_action_value='$no_agent_action_value',web_form_address_two='" . mysql_real_escape_string($web_form_address_two) . "',timer_action='$timer_action',timer_action_message='$timer_action_message',timer_action_seconds='$timer_action_seconds',start_call_url='" . mysql_real_escape_string($start_call_url) . "',dispo_call_url='" . mysql_real_escape_string($dispo_call_url) . "',xferconf_c_number='$xferconf_c_number',xferconf_d_number='$xferconf_d_number',xferconf_e_number='$xferconf_e_number' where group_id='$group_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='INGROUPS', event_type='MODIFY', record_id='$group_id', event_code='ADMIN MODIFY INGROUP', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $ADD=3111; # go to in-group modification form below + } + + +###################### +# ADD=4311 modify did info in the system +###################### + +if ($ADD==4311) + { + if ($LOGmodify_dids==1) + { + echo ""; + + if ( (strlen($did_id) < 1) or (strlen($did_pattern) < 1) ) + { + echo "
DDR NÃO ALTERADO - Por favor, volte e verifique os dados digitados\n"; + echo "
did_extension must be at least 1 character in length\n"; + } + else + { + echo "
DDR ALTERADO: $did_pattern\n"; + + $stmt="UPDATE vicidial_inbound_dids set did_pattern='$did_pattern',did_description='$did_description',did_active='$did_active',did_route='$did_route',extension='$extension',exten_context='$exten_context',voicemail_ext='$voicemail_ext',phone='$phone',server_ip='$server_ip',user='$user',user_unavailable_action='$user_unavailable_action',user_route_settings_ingroup='$user_route_settings_ingroup',group_id='$group_id',call_handle_method='$call_handle_method',agent_search_method='$agent_search_method',list_id='$list_id',campaign_id='$campaign_id',phone_code='$phone_code',menu_id='$menu_id' where did_id='$did_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='DIDS', event_type='MODIFY', record_id='$did_id', event_code='ADMIN MODIFY DID', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $ADD=3311; # go to did modification form below + } + + +###################### +# ADD=4511 modify call menu info in the system +###################### + +if ($ADD==4511) + { + if ($LOGmodify_dids==1) + { + echo ""; + + if (strlen($menu_id) < 1) + { + echo "
MENU NÃO ALTERADO - Por favor, volte e verifique os dados digitados\n"; + echo "
menu_id must be at least 1 character in length\n"; + } + else + { + echo "
MENU ALTERADO: $menu_id\n"; + + $stmt="UPDATE vicidial_call_menu set menu_name='$menu_name',menu_prompt='$menu_prompt',menu_timeout='$menu_timeout',menu_timeout_prompt='$menu_timeout_prompt',menu_invalid_prompt='$menu_invalid_prompt',menu_repeat='$menu_repeat',menu_time_check='$menu_time_check',call_time_id='$call_time_id',track_in_vdac='$track_in_vdac',custom_dialplan_entry='$custom_dialplan_entry',tracking_group='$tracking_group' where menu_id='$menu_id';"; + $rslt=mysql_query($stmt, $link); + + $h=0; + $option_value_list='|'; + while ($h <= 18) + { + $option_value=''; $option_description=''; $option_route=''; $option_route_value=''; $option_route_value_context=''; + + if (isset($_GET["option_value_$h"])) {$option_value=$_GET["option_value_$h"];} + elseif (isset($_POST["option_value_$h"])) {$option_value=$_POST["option_value_$h"];} + if (isset($_GET["option_description_$h"])) {$option_description=$_GET["option_description_$h"];} + elseif (isset($_POST["option_description_$h"])) {$option_description=$_POST["option_description_$h"];} + if (isset($_GET["option_route_$h"])) {$option_route=$_GET["option_route_$h"];} + elseif (isset($_POST["option_route_$h"])) {$option_route=$_POST["option_route_$h"];} + if (isset($_GET["option_route_value_$h"])) {$option_route_value=$_GET["option_route_value_$h"];} + elseif (isset($_POST["option_route_value_$h"])) {$option_route_value=$_POST["option_route_value_$h"];} + if (isset($_GET["option_route_value_context_$h"])) {$option_route_value_context=$_GET["option_route_value_context_$h"];} + elseif (isset($_POST["option_route_value_context_$h"])) {$option_route_value_context=$_POST["option_route_value_context_$h"];} + + if ($option_route == "INGROUP") + { + if (isset($_GET["IGhandle_method_$h"])) {$IGhandle_method=$_GET["IGhandle_method_$h"];} + elseif (isset($_POST["IGhandle_method_$h"])) {$IGhandle_method=$_POST["IGhandle_method_$h"];} + if (isset($_GET["IGsearch_method_$h"])) {$IGsearch_method=$_GET["IGsearch_method_$h"];} + elseif (isset($_POST["IGsearch_method_$h"])) {$IGsearch_method=$_POST["IGsearch_method_$h"];} + if (isset($_GET["IGlist_id_$h"])) {$IGlist_id=$_GET["IGlist_id_$h"];} + elseif (isset($_POST["IGlist_id_$h"])) {$IGlist_id=$_POST["IGlist_id_$h"];} + if (isset($_GET["IGcampaign_id_$h"])) {$IGcampaign_id=$_GET["IGcampaign_id_$h"];} + elseif (isset($_POST["IGcampaign_id_$h"])) {$IGcampaign_id=$_POST["IGcampaign_id_$h"];} + if (isset($_GET["IGphone_code_$h"])) {$IGphone_code=$_GET["IGphone_code_$h"];} + elseif (isset($_POST["IGphone_code_$h"])) {$IGphone_code=$_POST["IGphone_code_$h"];} + + $option_route_value_context = "$IGhandle_method,$IGsearch_method,$IGlist_id,$IGcampaign_id,$IGphone_code"; + } + + if ($non_latin < 1) + { + $option_value = ereg_replace("[^-\_0-9A-Z]","",$option_value); + $option_description = ereg_replace("[^- \:\/\_0-9a-zA-Z]","",$option_description); + $option_route = ereg_replace("[^-_0-9a-zA-Z]","",$option_route); + $option_route_value = ereg_replace("[^-\/\|\_\#\*\,\.\_0-9a-zA-Z]","",$option_route_value); + $option_route_value_context = ereg_replace("[^,-_0-9a-zA-Z]","",$option_route_value_context); + } + + if (strlen($option_route) > 0) + { + $stmtA="SELECT count(*) from vicidial_call_menu_options where menu_id='$menu_id' and option_value='$option_value';"; + $rslt=mysql_query($stmtA, $link); + $row=mysql_fetch_row($rslt); + $option_exists = $row[0]; + + if ($option_exists > 0) + { + $stmtA="UPDATE vicidial_call_menu_options SET option_description='$option_description',option_route='$option_route',option_route_value='$option_route_value',option_route_value_context='$option_route_value_context' where menu_id='$menu_id' and option_value='$option_value';"; + $rslt=mysql_query($stmtA, $link); + $stmtAX .= "$stmtA|"; + } + else + { + $stmtA="INSERT INTO vicidial_call_menu_options SET menu_id='$menu_id',option_value='$option_value',option_description='$option_description',option_route='$option_route',option_route_value='$option_route_value',option_route_value_context='$option_route_value_context';"; + $rslt=mysql_query($stmtA, $link); + $stmtAX .= "$stmtA|"; + } + } + else + { + $stmtA="SELECT count(*) from vicidial_call_menu_options where menu_id='$menu_id' and option_value='$option_value';"; + $rslt=mysql_query($stmtA, $link); + $row=mysql_fetch_row($rslt); + $option_exists_db = $row[0]; + + if ($option_exists_db > 0) + { + $stmtA="DELETE FROM vicidial_call_menu_options where menu_id='$menu_id' and option_value='$option_value';"; + $rslt=mysql_query($stmtA, $link); + $stmtAX .= "$stmtA|"; + } + } + $option_value_list .= "$option_value|"; + $h++; + } + ## delete existing database records that were not in the submit + while ($h <= 18) + { + if (!preg_match("/\|$dtmf[$h]\|/i",$option_value_list)) + { + $stmtA="SELECT count(*) from vicidial_call_menu_options where menu_id='$menu_id' and option_value='$dtmf[$h]';"; + $rslt=mysql_query($stmtA, $link); + $row=mysql_fetch_row($rslt); + $option_exists_db = $row[0]; + + if ($option_exists_db > 0) + { + $stmtA="DELETE FROM vicidial_call_menu_options where menu_id='$menu_id' and option_value='$dtmf[$h]';"; + $rslt=mysql_query($stmtA, $link); + $stmtAX .= "$stmtA|"; + } + } + $h++; + } + + $stmtA="UPDATE servers set rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y';"; + $rslt=mysql_query($stmtA, $link); + $stmtAX .= "$stmtA|"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|$stmtAX"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CALLMENUS', event_type='MODIFY', record_id='$menu_id', event_code='ADMIN MODIFY CALL MENU', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $ADD=3511; # go to call menu modification form below + } + + +###################### +# ADD=41111 modify remote agents info in the system +###################### + +if ($ADD==41111) + { + if ($LOGmodify_remoteagents==1) + { + echo ""; + + if ( (strlen($server_ip) < 2) or (strlen($user_start) < 2) or (strlen($campaign_id) < 2) or (strlen($conf_exten) < 2) ) + { + echo "
AGENTES REMOTOS NÃO ALTERADOS - Por favor volte e verifique os dados digitados\n"; + echo "
O início do ID e a Extensão Externa deve ter pelo menos 2 caracteres de comprimento\n"; + } + else + { + $stmt="UPDATE vicidial_remote_agents set user_start='$user_start', number_of_lines='$number_of_lines', server_ip='$server_ip', conf_exten='$conf_exten', status='$status', campaign_id='$campaign_id', closer_campaigns='$groups_value' where remote_agent_id='$remote_agent_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
AGENTES REMOTOS ALTERADOS\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='REMOTEAGENTS', event_type='MODIFY', record_id='$remote_agent_id', event_code='ADMIN MODIFY REMOTE AGENT', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $ADD=31111; # go to remote agents modification form below + } + + +###################### +# ADD=411111 modify user group info in the system +###################### + +if ($ADD==411111) + { + if ($LOGmodify_usergroups==1) + { + echo ""; + + if ( (strlen($user_group) < 2) or (strlen($group_name) < 2) ) + { + echo "
GRUPO DE USUÁRIOS NÃO MODIFICADO - Por favor volte e verifique os dados digitados\n"; + echo "
Nome e descrição do grupo devem ter pelo menos 2 caracteres de comprimento\n"; + } + else + { + $p=0; + $GROUP_shifts=' '; + $group_shifts_ct = count($group_shifts); + while ($p <= $group_shifts_ct) + { + $group_shifts[$p] = ereg_replace("[^ -_0-9a-zA-Z]","",$group_shifts[$p]); + $GROUP_shifts .= "$group_shifts[$p] "; + $p++; + } + $p=0; + $VGROUP_vgroups=' '; + $vgroup_vgroups_ct = count($agent_status_viewable_groups); + while ($p <= $vgroup_vgroups_ct) + { + $agent_status_viewable_groups[$p] = ereg_replace("[^ -_0-9a-zA-Z]","",$agent_status_viewable_groups[$p]); + $VGROUP_vgroups .= "$agent_status_viewable_groups[$p] "; + $p++; + } + + $stmt="UPDATE vicidial_user_groups set user_group='$user_group', group_name='$group_name',allowed_campaigns='$campaigns_value',qc_allowed_campaigns='$qc_campaigns_value',qc_allowed_inbound_groups='$qc_groups_value',group_shifts='$GROUP_shifts',forced_timeclock_login='$forced_timeclock_login',shift_enforcement='$shift_enforcement',agent_status_viewable_groups='$VGROUP_vgroups',agent_status_view_time='$agent_status_view_time' where user_group='$OLDuser_group';"; + $rslt=mysql_query($stmt, $link); + + echo "
GRUPO DE USUÁRIOS ALTERADO\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='USERGROUPS', event_type='MODIFY', record_id='$user_group', event_code='ADMIN MODIFY GRUPO DE USUÁRIOS', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + ############################################################### + ##### START SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP ##### + $stmt = "SELECT enable_vtiger_integration,vtiger_server_ip,vtiger_dbname,vtiger_login,vtiger_pass,vtiger_url FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $ss_conf_ct = mysql_num_rows($rslt); + if ($ss_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $enable_vtiger_integration = $row[0]; + $vtiger_server_ip = $row[1]; + $vtiger_dbname = $row[2]; + $vtiger_login = $row[3]; + $vtiger_pass = $row[4]; + $vtiger_url = $row[5]; + } + ##### END SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP ##### + ############################################################# + + if ($enable_vtiger_integration > 0) + { + ### connect to your vtiger database + $linkV=mysql_connect("$vtiger_server_ip", "$vtiger_login","$vtiger_pass"); + if (!$linkV) {die("Could not connect: $vtiger_server_ip|$vtiger_dbname|$vtiger_login|$vtiger_pass" . mysql_error());} + echo 'Connected successfully'; + mysql_select_db("$vtiger_dbname", $linkV); + + ###################################### + ##### BEGIN Add/Update group info in Vtiger + $stmt="SELECT count(*) from vtiger_groups where groupname='$user_group';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $group_found_count = $row[0]; + + ### group exists in vtiger, update it + if ($group_found_count > 0) + { + $stmt="SELECT groupid from vtiger_groups where groupname='$user_group';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $groupid = $row[0]; + + $stmtA = "UPDATE vtiger_groups SET description='$group_name' where groupid='$groupid';"; + if ($DB) {echo "|$stmtA|\n";} + $rslt=mysql_query($stmtA, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + } + + ### user doesn't exist in vtiger, insert it + else + { + #### BEGIN CREATE NEW GROUP RECORD IN VTIGER + # Get next available id from vtiger_users_seq to use as groupid + $stmt="SELECT id from vtiger_users_seq;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + $row=mysql_fetch_row($rslt); + $groupid = ($row[0] + 1); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + # Increase next available groupid with 1 so next record gets proper id + $stmt="UPDATE vtiger_users_seq SET id = '$groupid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtA = "INSERT INTO vtiger_groups SET groupid='$groupid',groupname='$user_group',description='$group_name';"; + if ($DB) {echo "|$stmtA|\n";} + $rslt=mysql_query($stmtA, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #### END CREATE NEW GROUP RECORD IN VTIGER + } + ##### END Add/Update group info in Vtiger + ###################################### + } + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $ADD=311111; # go to user group modification form below + } + + +###################### +# ADD=4111111 modify script in the system +###################### + +if ($ADD==4111111) + { + if ($LOGmodify_scripts==1) + { + echo "\n"; + echo "\n"; + echo ""; + + if ( (strlen($script_id) < 2) or (strlen($script_name) < 2) or (strlen($script_text) < 2) ) + { + echo "
SCRIPT NÃO ALTERADO - Por favor, volte e verifique os dados digitados\n"; + echo "
Nome do script, descrição e texto devem ter no mínimo 2 caracteres de comprimento\n"; + } + else + { + $stmt="UPDATE vicidial_scripts set script_name='$script_name', script_comments='$script_comments', script_text='" . mysql_real_escape_string($script_text) . "', active='$active' where script_id='$script_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
SCRIPT ALTERADO\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='SCRIPTS', event_type='MODIFY', record_id='$script_id', event_code='ADMIN MODIFY SCRIPT', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $ADD=3111111; # go to script modification form below + } + + +###################### +# ADD=41111111 modify filter in the system +###################### + +if ($ADD==41111111) + { + if ($LOGmodify_filters==1) + { + echo "\n"; + echo "\n"; + echo ""; + + if ( (strlen($lead_filter_id) < 2) or (strlen($lead_filter_name) < 2) or (strlen($lead_filter_sql) < 2) ) + { + echo "
FILTRO NÃO ALTERADO - Por favor, volte e verifique os dados digitados\n"; + echo "
ID do Filtro, nome e SQL devem ter pelo menos 2 caracteres de comprimento\n"; + } + else + { + $stmt="UPDATE vicidial_lead_filters set lead_filter_name='$lead_filter_name', lead_filter_comments='$lead_filter_comments', lead_filter_sql='" . mysql_real_escape_string($lead_filter_sql) . "' where lead_filter_id='$lead_filter_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
FILTRO ALTERADO\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='FILTROS', event_type='MODIFY', record_id='$lead_filter_id', event_code='ADMIN MODIFY FILTER', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $ADD=31111111; # go to filter modification form below + } + + +###################### +# ADD=411111111 modify call time in the system +###################### + +if ($ADD==411111111) + { + if ($LOGmodify_call_times==1) + { + echo ""; + + if ( (strlen($call_time_id) < 2) or (strlen($call_time_name) < 2) ) + { + echo "
HORÁRIO DE CHAMADA NÃO ALTERADO - Por favor, volte e verifique os dados digitados\n"; + echo "
ID e nome do Horário de Chamada deve ter pelo menos 2 caracteres de comprimento\n"; + } + else + { + $ct_default_start = preg_replace('/\D/', '', $ct_default_start); + $ct_default_stop = preg_replace('/\D/', '', $ct_default_stop); + $ct_sunday_start = preg_replace('/\D/', '', $ct_sunday_start); + $ct_sunday_stop = preg_replace('/\D/', '', $ct_sunday_stop); + $ct_monday_start = preg_replace('/\D/', '', $ct_monday_start); + $ct_monday_stop = preg_replace('/\D/', '', $ct_monday_stop); + $ct_tuesday_start = preg_replace('/\D/', '', $ct_tuesday_start); + $ct_tuesday_stop = preg_replace('/\D/', '', $ct_tuesday_stop); + $ct_wednesday_start = preg_replace('/\D/', '', $ct_wednesday_start); + $ct_wednesday_stop = preg_replace('/\D/', '', $ct_wednesday_stop); + $ct_thursday_start = preg_replace('/\D/', '', $ct_thursday_start); + $ct_thursday_stop = preg_replace('/\D/', '', $ct_thursday_stop); + $ct_friday_start = preg_replace('/\D/', '', $ct_friday_start); + $ct_friday_stop = preg_replace('/\D/', '', $ct_friday_stop); + $ct_saturday_start = preg_replace('/\D/', '', $ct_saturday_start); + $ct_saturday_stop = preg_replace('/\D/', '', $ct_saturday_stop); + $stmt="UPDATE vicidial_call_times set call_time_name='$call_time_name', call_time_comments='$call_time_comments', ct_default_start='$ct_default_start', ct_default_stop='$ct_default_stop', ct_sunday_start='$ct_sunday_start', ct_sunday_stop='$ct_sunday_stop', ct_monday_start='$ct_monday_start', ct_monday_stop='$ct_monday_stop', ct_tuesday_start='$ct_tuesday_start', ct_tuesday_stop='$ct_tuesday_stop', ct_wednesday_start='$ct_wednesday_start', ct_wednesday_stop='$ct_wednesday_stop', ct_thursday_start='$ct_thursday_start', ct_thursday_stop='$ct_thursday_stop', ct_friday_start='$ct_friday_start', ct_friday_stop='$ct_friday_stop', ct_saturday_start='$ct_saturday_start', ct_saturday_stop='$ct_saturday_stop' where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
HORÁRIO DE CHAMADA ALTERADO\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CALLTIMES', event_type='MODIFY', record_id='$call_time_id', event_code='ADMIN MODIFY CALL TIME', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $ADD=311111111; # go to call time modification form below + } + + +###################### +# ADD=4111111111 modify state call time in the system +###################### + +if ($ADD==4111111111) + { + if ($LOGmodify_call_times==1) + { + echo ""; + + if ( (strlen($call_time_id) < 2) or (strlen($call_time_name) < 2) or (strlen($state_call_time_state) < 2) ) + { + echo "
HORÁRIO DE CHAMADA POR ESTADO NÃO ALTERADO - Por favor, volte e verifique os dados digitados\n"; + echo "
ID da configuração de chamada por estado, nome e estado devem ter no mínimo 2 caracteres de comprimento\n"; + } + else + { + $ct_default_start = preg_replace('/\D/', '', $ct_default_start); + $ct_default_stop = preg_replace('/\D/', '', $ct_default_stop); + $ct_sunday_start = preg_replace('/\D/', '', $ct_sunday_start); + $ct_sunday_stop = preg_replace('/\D/', '', $ct_sunday_stop); + $ct_monday_start = preg_replace('/\D/', '', $ct_monday_start); + $ct_monday_stop = preg_replace('/\D/', '', $ct_monday_stop); + $ct_tuesday_start = preg_replace('/\D/', '', $ct_tuesday_start); + $ct_tuesday_stop = preg_replace('/\D/', '', $ct_tuesday_stop); + $ct_wednesday_start = preg_replace('/\D/', '', $ct_wednesday_start); + $ct_wednesday_stop = preg_replace('/\D/', '', $ct_wednesday_stop); + $ct_thursday_start = preg_replace('/\D/', '', $ct_thursday_start); + $ct_thursday_stop = preg_replace('/\D/', '', $ct_thursday_stop); + $ct_friday_start = preg_replace('/\D/', '', $ct_friday_start); + $ct_friday_stop = preg_replace('/\D/', '', $ct_friday_stop); + $ct_saturday_start = preg_replace('/\D/', '', $ct_saturday_start); + $ct_saturday_stop = preg_replace('/\D/', '', $ct_saturday_stop); + $stmt="UPDATE vicidial_state_call_times set state_call_time_name='$call_time_name', state_call_time_comments='$call_time_comments', sct_default_start='$ct_default_start', sct_default_stop='$ct_default_stop', sct_sunday_start='$ct_sunday_start', sct_sunday_stop='$ct_sunday_stop', sct_monday_start='$ct_monday_start', sct_monday_stop='$ct_monday_stop', sct_tuesday_start='$ct_tuesday_start', sct_tuesday_stop='$ct_tuesday_stop', sct_wednesday_start='$ct_wednesday_start', sct_wednesday_stop='$ct_wednesday_stop', sct_thursday_start='$ct_thursday_start', sct_thursday_stop='$ct_thursday_stop', sct_friday_start='$ct_friday_start', sct_friday_stop='$ct_friday_stop', sct_saturday_start='$ct_saturday_start', sct_saturday_stop='$ct_saturday_stop', state_call_time_state='$state_call_time_state' where state_call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
HORÁRIO DE CHAMADA POR ESTADO ALTERADO\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CALLTIMES', event_type='MODIFY', record_id='$call_time_id', event_code='ADMIN MODIFY STATE CALL TIME', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $ADD=3111111111; # go to state call time modification form below + } + + +###################### +# ADD=431111111 modify shift in the system +###################### + +if ($ADD==431111111) + { + if ($LOGmodify_call_times==1) + { + echo ""; + + $shift_length_test = eregi_replace(':','',$shift_length); + if ( (strlen($shift_id) < 2) or (strlen($shift_name) < 2) or (strlen($shift_start_time) < 4) or (strlen($shift_start_time) > 4) or (strlen($shift_length) < 5) or (strlen($shift_length) > 5) or ($shift_start_time > 2359) or ($shift_length_test > 2400) ) + { + echo "
SHIFT DEFINITION NOT MODIFIED - Por favor, volte e verifique os dados digitados\n"; + echo "
ID e Nome do turno devem ter pelo menos 2 caracteres\n"; + echo "
Horário de início deve ter 4 caracteres e ser um horário válido\n"; + echo "
Duração do Turno deve ter 5 caracteres e 24 horas ou menos\n"; + } + else + { + $p=0; + $shift_weekdays_ct = count($shift_weekdays); + while ($p <= $shift_weekdays_ct) + { + $SHIFT_weekdays .= "$shift_weekdays[$p]"; + $p++; + } + $shift_start_time = preg_replace('/\D/', '', $shift_start_time); + $stmt="UPDATE vicidial_shifts set shift_name='$shift_name', shift_start_time='$shift_start_time', shift_length='$shift_length', shift_weekdays='$SHIFT_weekdays' where shift_id='$shift_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
TURNOS ALTERADOS\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='SHIFTS', event_type='MODIFY', record_id='$shift_id', event_code='ADMIN MODIFY SHIFT', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $ADD=331111111; # go to shift modification form below + } + + +###################### +# ADD=41111111111 modify phone record in the system +###################### + +if ($ADD==41111111111) + { + if ($LOGast_admin_access==1) + { + echo ""; + + $stmt="SELECT count(*) from phones where extension='$extension' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ( ($row[0] > 0) && ( ($extension != $old_extension) or ($server_ip != $old_server_ip) ) ) + {echo "
RAMAL NÃO MODIFICADO - já existe no sistema um ramal com esta extensão e servidor\n";} + else + { + if ( (strlen($extension) < 1) or (strlen($server_ip) < 7) or (strlen($dialplan_number) < 1) or (strlen($voicemail_id) < 1) or (strlen($login) < 1) or (strlen($pass) < 1)) + {echo "
RAMAL NÃO MODIFICADO - Por favor volte e verifique os dados digitados\n";} + else + { + echo "
RAMAL ALTERADO: $extension\n"; + + $stmt="UPDATE phones set extension='$extension', dialplan_number='$dialplan_number', voicemail_id='$voicemail_id', phone_ip='$phone_ip', computer_ip='$computer_ip', server_ip='$server_ip', login='$login', pass='$pass', status='$status', active='$active', phone_type='$phone_type', fullname='$fullname', company='$company', picture='$picture', protocol='$protocol', local_gmt='$local_gmt', ASTmgrUSERNAME='$ASTmgrUSERNAME', ASTmgrSECRET='$ASTmgrSECRET', login_user='$login_user', login_pass='$login_pass', login_campaign='$login_campaign', park_on_extension='$park_on_extension', conf_on_extension='$conf_on_extension', VICIDIAL_park_on_extension='$VICIDIAL_park_on_extension', VICIDIAL_park_on_filename='$VICIDIAL_park_on_filename', monitor_prefix='$monitor_prefix', recording_exten='$recording_exten', voicemail_exten='$voicemail_exten', voicemail_dump_exten='$voicemail_dump_exten', ext_context='$ext_context', dtmf_send_extension='$dtmf_send_extension', call_out_number_group='$call_out_number_group', client_browser='$client_browser', install_directory='$install_directory', local_web_callerID_URL='" . mysql_real_escape_string($local_web_callerID_URL) . "', VICIDIAL_web_URL='" . mysql_real_escape_string($VICIDIAL_web_URL) . "', AGI_call_logging_enabled='$AGI_call_logging_enabled', user_switching_enabled='$user_switching_enabled', conferencing_enabled='$conferencing_enabled', admin_hangup_enabled='$admin_hangup_enabled', admin_hijack_enabled='$admin_hijack_enabled', admin_monitor_enabled='$admin_monitor_enabled', call_parking_enabled='$call_parking_enabled', updater_check_enabled='$updater_check_enabled', AFLogging_enabled='$AFLogging_enabled', QUEUE_ACTION_enabled='$QUEUE_ACTION_enabled', CallerID_popup_enabled='$CallerID_popup_enabled', voicemail_button_enabled='$voicemail_button_enabled', enable_fast_refresh='$enable_fast_refresh', fast_refresh_rate='$fast_refresh_rate', enable_persistant_mysql='$enable_persistant_mysql', auto_dial_next_number='$auto_dial_next_number', VDstop_rec_after_each_call='$VDstop_rec_after_each_call', DBX_server='$DBX_server', DBX_database='$DBX_database', DBX_user='$DBX_user', DBX_pass='$DBX_pass', DBX_port='$DBX_port', DBY_server='$DBY_server', DBY_database='$DBY_database', DBY_user='$DBY_user', DBY_pass='$DBY_pass', DBY_port='$DBY_port', outbound_cid='$outbound_cid', enable_sipsak_messages='$enable_sipsak_messages', email='$email', template_id='$template_id', conf_override='$conf_override',phone_context='$phone_context',phone_ring_timeout='$phone_ring_timeout',conf_secret='$conf_secret', delete_vm_after_email='$delete_vm_after_email' where extension='$old_extension' and server_ip='$old_server_ip';"; + $rslt=mysql_query($stmt, $link); + + $stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$server_ip';"; + $rslt=mysql_query($stmtA, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='PHONES', event_type='MODIFY', record_id='$extension', event_code='ADMIN ALTERAR RAMAL', event_sql=\"$SQL_log\", event_notes='IP do Servidor: $server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $ADD=31111111111; # go to phone modification form below + } + + +###################### +# ADD=42111111111 modify phone alias record in the system +###################### + +if ($ADD==42111111111) + { + if ($LOGast_admin_access==1) + { + echo ""; + + $stmt="SELECT count(*) from phones_alias where alias_id='$alias_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ( (strlen($alias_id) < 1) or (strlen($alias_name) < 2) ) + {echo "
ALIAS DE RAMAL NÃO ALTERADO - Por favor, volte e verifique os dados digitados\n";} + else + { + echo "
ALIAS DE RAMAL ALTERADO: $alias_id\n"; + + $stmt="UPDATE phones_alias set alias_name='$alias_name', logins_list='$logins_list' where alias_id='$alias_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='PHONEALIASES', event_type='MODIFY', record_id='$alias_id', event_code='ADMIN ALTERAR ALIAS DE RAMAL', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $ADD=32111111111; # go to phone alias modification form below + } + + +###################### +# ADD=43111111111 modify group alias record in the system +###################### + +if ($ADD==43111111111) + { + if ($LOGast_admin_access==1) + { + echo ""; + + $stmt="SELECT count(*) from groups_alias where group_alias_id='$group_alias_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ( (strlen($group_alias_id) < 1) or (strlen($group_alias_name) < 2) ) + {echo "
ALIAS DE GRUPO NÃO ALTERADO - Por favor, volte e verifique os dados digitados\n";} + else + { + echo "
ALIAS DE GRUPO ALTERADO: $alias_id\n"; + + $stmt="UPDATE groups_alias set group_alias_name='$group_alias_name', caller_id_number='$caller_id_number', caller_id_name='$caller_id_name', active='$active' where group_alias_id='$group_alias_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='GROUPALIASES', event_type='MODIFY', record_id='$group_alias_id', event_code='ADMIN ALTERAR ALIAS DE GRUPO', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $ADD=33111111111; # go to group alias modification form below + } + + +###################### +# ADD=411111111111 modify server record in the system +###################### + +if ($ADD==411111111111) + { + if ($LOGmodify_servers==1) + { + echo ""; + + $stmt="SELECT count(*) from servers where server_id='$server_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ( ($row[0] > 0) && ($server_id != $old_server_id) ) + {echo "
SERVIDOR NOT MODIFIED - there is already a server in the system with this server_id\n";} + else + { + $stmt="SELECT count(*) from servers where server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ( ($row[0] > 0) && ($server_ip != $old_server_ip) ) + {echo "
SERVIDOR NÃO ALTERADO - já existe no sistema um servidor com este IP\n";} + else + { + if ( (strlen($server_id) < 1) or (strlen($server_ip) < 7) ) + {echo "
SERVIDOR NÃO ALTERADO - Por favor volte e verifique os dados digitados\n";} + else + { + $stmt="UPDATE servers set server_id='$server_id',server_description='$server_description',server_ip='$server_ip',active='$active',asterisk_version='$asterisk_version', max_vicidial_trunks='$max_vicidial_trunks', telnet_host='$telnet_host', telnet_port='$telnet_port', ASTmgrUSERNAME='$ASTmgrUSERNAME', ASTmgrSECRET='$ASTmgrSECRET', ASTmgrUSERNAMEupdate='$ASTmgrUSERNAMEupdate', ASTmgrUSERNAMElisten='$ASTmgrUSERNAMElisten', ASTmgrUSERNAMEsend='$ASTmgrUSERNAMEsend', local_gmt='$local_gmt', voicemail_dump_exten='$voicemail_dump_exten', answer_transfer_agent='$answer_transfer_agent', ext_context='$ext_context', sys_perf_log='$sys_perf_log', vd_server_logs='$vd_server_logs', agi_output='$agi_output', vicidial_balance_active='$vicidial_balance_active',balance_trunks_offlimits='$balance_trunks_offlimits',recording_web_link='$recording_web_link',alt_server_ip='$alt_server_ip',active_asterisk_server='$active_asterisk_server',generate_vicidial_conf='$generate_vicidial_conf',rebuild_conf_files='$rebuild_conf_files',outbound_calls_per_second='$outbound_calls_per_second',sounds_update='$sounds_update',vicidial_recording_limit='$vicidial_recording_limit',carrier_logging_active='$carrier_logging_active',vicidial_balance_rank='$vicidial_balance_rank',rebuild_music_on_hold='$rebuild_music_on_hold',active_agent_login_server='$active_agent_login_server',conf_secret='$conf_secret' where server_id='$old_server_id';"; + $rslt=mysql_query($stmt, $link); + + $stmtA="UPDATE servers SET rebuild_conf_files='Y',rebuild_music_on_hold='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y';"; + $rslt=mysql_query($stmtA, $link); + + echo "
SERVIDOR MODIFICADO: $server_ip\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='SERVERS', event_type='MODIFY', record_id='$server_id', event_code='ADMIN ALTERAR SERVIDOR', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $ADD=311111111111; # go to server modification form below + } + + +###################### +# ADD=421111111111 modify vicidial server trunks record in the system +###################### + +if ($ADD==421111111111) + { + if ($LOGmodify_servers==1) + { + echo ""; + $stmt="SELECT max_vicidial_trunks from servers where server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $MAXvicidial_trunks = $rowx[0]; + + $stmt="SELECT sum(dedicated_trunks) from vicidial_server_trunks where server_ip='$server_ip' and campaign_id !='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $SUMvicidial_trunks = ($rowx[0] + $dedicated_trunks); + + if ($SUMvicidial_trunks > $MAXvicidial_trunks) + { + echo "
REGISTRO DE TRUNK VICIDIAL NÃO ADICIONADO - o número de trunk vicidial é muito alto: $SUMvicidial_trunks / $MAXvicidial_trunks\n"; + } + else + { + if ( (strlen($campaign_id) < 2) or (strlen($server_ip) < 7) or (strlen($dedicated_trunks) < 1) or (strlen($trunk_restriction) < 1) ) + { + echo "
REGISTRO DE TRUNK VICIDIAL NÃO INCLUÍDO - Por favor, volte e verifique os dados digitados\n"; + echo "
campanha deve ter entre 3 e 8 caracteres de comprimento\n"; + echo "
delay do IP do servidor deve ser pelo menos 7 caracteres\n"; + echo "
trunks devem ter um digito entre 0 e 9999\n"; + } + else + { + $stmt="UPDATE vicidial_server_trunks SET dedicated_trunks='$dedicated_trunks',trunk_restriction='$trunk_restriction' where campaign_id='$campaign_id' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + + echo "
REGISTRO DE TRUNK VICIDIAL ALTERADO: $campaign_id - $server_ip - $dedicated_trunks - $trunk_restriction\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='SERVERTRUNKS', event_type='MODIFY', record_id='$server_ip', event_code='ADMIN ALTERAR SERVIDOR TRUNK', event_sql=\"$SQL_log\", event_notes='Campanha: $campaign_id';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $ADD=311111111111; # go to server modification form below + } + + +###################### +# ADD=431111111111 modify conf template record in the system +###################### '$template_id','$template_name','$template_contents' + +if ($ADD==431111111111) + { + if ($LOGmodify_servers==1) + { + echo ""; + + if ( (strlen($template_id) < 1) or (strlen($template_name) < 1) ) + {echo "
TEMPLATE DE CONF NÃO ALTERADO - Por favor, volte e verifique os dados digitados\n";} + else + { + $stmt="UPDATE vicidial_conf_templates set template_name='$template_name',template_contents='$template_contents' where template_id='$template_id';"; + $rslt=mysql_query($stmt, $link); + + $stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y';"; + $rslt=mysql_query($stmtA, $link); + + echo "
CONF TEMPLATE MODIFIED: $template_id\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CONFTEMPLATES', event_type='MODIFY', record_id='$template_id', event_code='ADMIN ALTERAR TEMPLATE CONF', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $ADD=331111111111; # go to conf template modification form below + } + + +###################### +# ADD=441111111111 modify carrier record in the system +###################### + +if ($ADD==441111111111) + { + if ($LOGmodify_servers==1) + { + echo ""; + + if ( (strlen($carrier_id) < 1) or (strlen($server_ip) < 7) or (strlen($protocol) < 1) ) + {echo "
OPERADORA NÃO ALTERADA - Por favor, volte e verifique os dados digitados\n";} + else + { + $stmt="UPDATE vicidial_server_carriers set carrier_name='$carrier_name',registration_string='$registration_string',template_id='$template_id',account_entry='$account_entry',protocol='$protocol',globals_string='$globals_string',dialplan_entry='$dialplan_entry',server_ip='$server_ip',active='$active',carrier_description='$carrier_description' where carrier_id='$carrier_id';"; + $rslt=mysql_query($stmt, $link); + + $stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$server_ip';"; + $rslt=mysql_query($stmtA, $link); + + echo "
OPERADORA ALTERADA: $carrier_id\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CARRIERS', event_type='MODIFY', record_id='$carrier_id', event_code='ADMIN ALTERAR OPERADORA', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $ADD=341111111111; # go to carrier modification form below + } + + +###################### +# ADD=451111111111 modify tts record in the system +###################### + +if ($ADD==451111111111) + { + if ($LOGmodify_servers==1) + { + echo ""; + + if ( (strlen($tts_id) < 2) or (strlen($tts_name) < 5) ) + {echo "
TTS ENTRADA SIN MODIFICAR - Por favor, volte e verifique os dados digitados\n";} + else + { + $stmt="UPDATE vicidial_tts_prompts set tts_name='$tts_name',active='$active',tts_text=\"$tts_text\" where tts_id='$tts_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
TTS entrada modificada: $tts_id\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='TTS', event_type='MODIFY', record_id='$tts_id', event_code='ADMIN MODIFY TTS', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $ADD=351111111111; # go to tts entry modification form below + } + + +###################### +# ADD=461111111111 modify music on hold record in the system +###################### + +if ($ADD==461111111111) + { + if ($LOGmodify_servers==1) + { + echo ""; + + if ($stage == "FILEDELETE") + { + if ( (strlen($moh_id) < 2) or (strlen($filename) < 1) or ($moh_id=='sounds') or ($moh_id=='agi-bin') or ($moh_id=='astdb') or ($moh_id=='keys') ) + {echo "
MÚSICA EN ESPERA DE ENTRADA SIN MODIFICAR - Por favor, volte e verifique os dados digitados\n";} + else + { + $stmt="DELETE FROM vicidial_music_on_hold_files where moh_id='$moh_id' and filename='$filename';"; + $rslt=mysql_query($stmt, $link); + + $stmtA="UPDATE servers SET rebuild_conf_files='Y',rebuild_music_on_hold='Y',sounds_update='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y';"; + $rslt=mysql_query($stmtA, $link); + + echo "
MÚSICA EN ESPERA entrada modificada: $moh_id - $filename\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|$stmtA|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='MOH', event_type='MODIFY', record_id='$moh_id', event_code='ADMIN MODIFY MOH', event_sql=\"$SQL_log\", event_notes='FILE DELETE';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + else + { + if ( (strlen($moh_id) < 2) or (strlen($moh_name) < 5) or ($moh_id=='sounds') or ($moh_id=='agi-bin') or ($moh_id=='astdb') or ($moh_id=='keys') ) + {echo "
MÚSICA EN ESPERA DE ENTRADA SIN MODIFICAR - Por favor, volte e verifique os dados digitados\n";} + else + { + $stmt="UPDATE vicidial_music_on_hold set moh_name='$moh_name',active='$active',random='$random' where moh_id='$moh_id';"; + $rslt=mysql_query($stmt, $link); + $stmtLIST = $stmt; + + $stmt="SELECT filename,rank from vicidial_music_on_hold_files where moh_id='$moh_id' order by rank;"; + $rsltx=mysql_query($stmt, $link); + $mohfiles_to_print = mysql_num_rows($rsltx); + $ranks = ($mohfiles_to_print + 1); + $o=0; + while ($mohfiles_to_print > $o) + { + $rowx=mysql_fetch_row($rsltx); + $mohfiles[$o] = $rowx[0]; + $mohranks[$o] = $rowx[1]; + $o++; + } + + $o=0; + while ($mohfiles_to_print > $o) + { + $new_rank=0; + $Ffilename = $mohfiles[$o]; + if (isset($_GET[$Ffilename])) {$new_rank=$_GET[$Ffilename];} + elseif (isset($_POST[$Ffilename])) {$new_rank=$_POST[$Ffilename];} + + $stmt="UPDATE vicidial_music_on_hold_files set rank='$new_rank' where moh_id='$moh_id' and filename='$mohfiles[$o]';"; + $rslt=mysql_query($stmt, $link); + $stmtLIST .= "|$stmt"; + $o++; + } + + if (strlen($filename) > 0) + { + $stmt="INSERT INTO vicidial_music_on_hold_files set filename='$filename',rank='$ranks',moh_id='$moh_id';"; + $rslt=mysql_query($stmt, $link); + $stmtLIST .= "|$stmt"; + } + + $stmtA="UPDATE servers SET rebuild_conf_files='Y',rebuild_music_on_hold='Y',sounds_update='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y';"; + $rslt=mysql_query($stmtA, $link); + + echo "
MÚSICA EN ESPERA entrada modificada: $moh_id\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmtLIST|$stmtA|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='MOH', event_type='MODIFY', record_id='$moh_id', event_code='ADMIN MODIFY MOH', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $ADD=361111111111; # go to music on hold entry modification form below + } + + +###################### +# ADD=471111111111 modify voicemail record in the system +###################### + +if ($ADD==471111111111) + { + if ($LOGmodify_servers==1) + { + echo ""; + + if ( (strlen($voicemail_id) < 2) or (strlen($fullname) < 2) ) + {echo "
Contestador SIN MODIFICAR - Por favor, volte e verifique os dados digitados\n";} + else + { + $stmt="UPDATE vicidial_voicemail set fullname='$fullname',active='$active',pass='$pass',email='$email',delete_vm_after_email='$delete_vm_after_email' where voicemail_id='$voicemail_id';"; + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT active_voicemail_server from system_settings;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $active_voicemail_server = $row[0]; + + $stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$active_voicemail_server';"; + $rslt=mysql_query($stmtA, $link); + + echo "
Contestador MODIFICADOS: $voicemail_id\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='VOICEMAIL', event_type='MODIFY', record_id='$voicemail_id', event_code='ADMIN MODIFY VOICEMAIL', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $ADD=371111111111; # go to voicemail entry modification form below + } + + +###################### +# ADD=4111111111111 modify conference record in the system +###################### + +if ($ADD==4111111111111) + { + if ($LOGast_admin_access==1) + { + echo ""; + + $stmt="SELECT count(*) from conferences where conf_exten='$conf_exten' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ( ($row[0] > 0) && ( ($conf_exten != $old_conf_exten) or ($server_ip != $old_server_ip) ) ) + {echo "
CONFERÊNCIA NÃO ALTERADA - já existe no sistema uma conferência com esta extensão e servidor\n";} + else + { + if ( (strlen($conf_exten) < 1) or (strlen($server_ip) < 7) ) + {echo "
CONFERÊNCIA NÃO ALTERADA - Por favor volte e verifique os dados digitados\n";} + else + { + echo "
CONFERÊNCIA ALTERADA: $conf_exten\n"; + + $stmt="UPDATE conferences set conf_exten='$conf_exten',server_ip='$server_ip',extension='$extension' where conf_exten='$old_conf_exten';"; + $rslt=mysql_query($stmt, $link); + } + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $ADD=3111111111111; # go to conference modification form below + } + + +###################### +# ADD=41111111111111 modify vicidial conference record in the system +###################### + +if ($ADD==41111111111111) + { + if ($LOGast_admin_access==1) + { + echo ""; + + $stmt="SELECT count(*) from vicidial_conferences where conf_exten='$conf_exten' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ( ($row[0] > 0) && ( ($conf_exten != $old_conf_exten) or ($server_ip != $old_server_ip) ) ) + {echo "
VICIDIAL CONFERÊNCIA NÃO ALTERADA - já existe no sistema uma conferência com esta extensão e servidor\n";} + else + { + if ( (strlen($conf_exten) < 1) or (strlen($server_ip) < 7) ) + {echo "
VICIDIAL CONFERÊNCIA NÃO ALTERADA - Por favor volte e verifique os dados digitados\n";} + else + { + echo "
VICIDIAL CONFERÊNCIA ALTERADA: $conf_exten\n"; + + $stmt="UPDATE vicidial_conferences set conf_exten='$conf_exten',server_ip='$server_ip',extension='$extension' where conf_exten='$old_conf_exten';"; + $rslt=mysql_query($stmt, $link); + + } + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $ADD=31111111111111; # go to vicidial conference modification form below + } + + +###################### +# ADD=411111111111111 modify vicidial system settings +###################### + +if ($ADD==411111111111111) + { + if ($LOGmodify_servers==1) + { + echo ""; + + echo "
CONFIGURAÇÕES DE SISTEMA ALTERADAS\n"; + + $stmt="UPDATE system_settings set use_non_latin='$use_non_latin',webroot_writable='$webroot_writable',enable_queuemetrics_logging='$enable_queuemetrics_logging',queuemetrics_server_ip='$queuemetrics_server_ip',queuemetrics_dbname='$queuemetrics_dbname',queuemetrics_login='$queuemetrics_login',queuemetrics_pass='$queuemetrics_pass',queuemetrics_url='$queuemetrics_url',queuemetrics_log_id='$queuemetrics_log_id',queuemetrics_eq_prepend='$queuemetrics_eq_prepend',vicidial_agent_disable='$vicidial_agent_disable',allow_sipsak_messages='$allow_sipsak_messages',admin_home_url='$admin_home_url',enable_agc_xfer_log='$enable_agc_xfer_log',timeclock_end_of_day='$timeclock_end_of_day',vdc_header_date_format='$vdc_header_date_format',vdc_customer_date_format='$vdc_customer_date_format',vdc_header_phone_format='$vdc_header_phone_format',vdc_agent_api_active='$vdc_agent_api_active',enable_vtiger_integration='$enable_vtiger_integration',vtiger_server_ip='$vtiger_server_ip',vtiger_dbname='$vtiger_dbname',vtiger_login='$vtiger_login',vtiger_pass='$vtiger_pass',vtiger_url='$vtiger_url',qc_features_active='$qc_features_active',outbound_autodial_active='$outbound_autodial_active',outbound_calls_per_second='$outbound_calls_per_second',enable_tts_integration='$enable_tts_integration',agentonly_callback_campaign_lock='$agentonly_callback_campaign_lock',sounds_central_control_active='$sounds_central_control_active',sounds_web_server='$sounds_web_server',sounds_web_directory='$sounds_web_directory',active_voicemail_server='$active_voicemail_server',auto_dial_limit='$auto_dial_limit',user_territories_active='$user_territories_active',allow_custom_dialplan='$allow_custom_dialplan',enable_second_webform='$enable_second_webform';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='SYSTEMSETTINGS', event_type='MODIFY', record_id='system_settings', event_code='ADMIN MODIFY SYSTEM SETTINGS', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $ADD=311111111111111; # go to vicidial system settings form below + } + + +###################### +# ADD=421111111111111 modify/delete system status in the system +###################### + +if ($ADD==421111111111111) + { + if ($LOGmodify_servers==1) + { + echo ""; + + if (ereg('delete',$stage)) + { + if ( (strlen($status) < 1) or (preg_match("/^B$|^NA$|^DNC$|^NA$|^DROP$|^INCALL$|^QUEUE$|^NEW$/i",$status)) ) + { + echo "
STATUS DE SISTEMA NÃO REMOVIDO - Por favor, volte e verifique os dados digitados\n"; + echo "
el estado de sistema no puede ser un estado reservado:B,NA,DNC,NA,DROP,INCALL,QUEUE,NEW\n"; + echo "
el estado de sistema necesita ser por lo menos los caracteres 1 enlongitud\n"; + } + else + { + echo "
SYSTEM STATUS DELETED: $status\n"; + + $stmt="DELETE FROM vicidial_statuses where status='$status';"; + $rslt=mysql_query($stmt, $link); + + $stmtA="DELETE FROM vicidial_campaign_hotkeys where status='$status';"; + $rslt=mysql_query($stmtA, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='SYSTEMSTATUS', event_type='DELETE', record_id='$status', event_code='ADMIN DELETE SYSTEM STATUS', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + if (ereg('modify',$stage)) + { + if ( (strlen($status) < 1) or (strlen($status_name) < 2) ) + { + echo "
STATUS DO SISTEMA NÃO ALTERADO - Por favor, volte e verifique os dados digitados\n"; + echo "
el estado de sistema necesita ser por lo menos los caracteres 1 enlongitud\n"; + echo "
o nome do status deve ter pelo menos 1 caractere de comprimento\n"; + } + else + { + echo "
STATUS DO SISTEMA ALTERADO: $status\n"; + + $stmt="UPDATE vicidial_statuses SET status_name='$status_name',selectable='$selectable',human_answered='$human_answered',category='$category',sale='$sale',dnc='$dnc',customer_contact='$customer_contact',not_interested='$not_interested',unworkable='$unworkable' where status='$status';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='SYSTEMSTATUS', event_type='MODIFY', record_id='$status', event_code='ADMIN MODIFY SYSTEM STATUS', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $ADD=321111111111111; # go to system settings modification form below + } + + +###################### +# ADD=431111111111111 modify/delete status category in the system +###################### + +if ($ADD==431111111111111) + { + if ($LOGmodify_servers==1) + { + echo ""; + + if ( (strlen($vsc_id) < 2) or (preg_match("/^UNDEFINED$/i",$vsc_id)) ) + { + echo "
CATEGORIA NÃO ALTERADA - Por favor, volte e verifique os dados digitados\n"; + echo "
a categoria de status não pode ser uma categoria reservada:UNDEFINED\n"; + echo "
a categoria de status precisa ter pelo menos 2 caracteres\n"; + } + else + { + if (ereg('delete',$stage)) + { + echo "
CATEGORIA REMOVIDA: $vsc_id\n"; + + $stmt="DELETE FROM vicidial_status_categories where vsc_id='$vsc_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='STATUSCATEGORIES', event_type='DELETE', record_id='$vsc_id', event_code='ADMIN DELETE STATUS CATEGORIA', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + if (ereg('modify',$stage)) + { + echo "
CATEGORIA ALTERADA: $vsc_id\n"; + + $stmt="SELECT count(*) from vicidial_status_categories where tovdad_display='Y' and vsc_id NOT IN('$vsc_id');"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ( ($row[0] > 3) and (ereg('Y',$tovdad_display)) ) + { + $tovdad_display = 'N'; + echo "
ERRO: Já existem 4 Categorias de Status no Relatório TimeOnVDAD\n"; + } + + $stmt="UPDATE vicidial_status_categories SET vsc_name='$vsc_name',vsc_description='$vsc_description',tovdad_display='$tovdad_display',sale_category='$sale_category',dead_lead_category='$dead_lead_category' where vsc_id='$vsc_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='STATUSCATEGORIES', event_type='MODIFY', record_id='$vsc_id', event_code='ADMIN MODIFY STATUS CATEGORIA', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $ADD=331111111111111; # go to system settings modification form below + } + + +###################### +# ADD=441111111111111 modify/delete qc status code in the system +###################### + +if ($ADD==441111111111111) + { + if ( ($LOGmodify_servers==1) and ($SSqc_features_active > 0) ) + { + echo ""; + + if (ereg('delete',$stage)) + { + if ( (strlen($code) < 1) or (preg_match("/^B$|^NA$|^DNC$|^NA$|^DROP$|^INCALL$|^QUEUE$|^NEW$/i",$code)) ) + { + echo "
CÓDIGO DE STATUS CQ NÃO REMOVIDO - Por favor, volte e verifique os dados digitados\n"; + echo "
the qc status code cannot be a reserved status: B,NA,DNC,NA,DROP,INCALL,QUEUE,NEW\n"; + echo "
o código de status cq precisa ter pelo menos 1 caracter de comprimento\n"; + } + else + { + echo "
CÓDIGO DE STATUS CQ REMOVIDO:$code\n"; + + $stmt="DELETE FROM vicidial_qc_codes where code='$code';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='QCCODES', event_type='DELETE', record_id='$vsc_id', event_code='ADMIN DELETE QC CODES', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + if (ereg('modify',$stage)) + { + if ( (strlen($code) < 1) or (strlen($code_name) < 2) ) + { + echo "
CÓDIGO DE STATUS CQ NÃO ALTERADO- Por favor, volte e verifique os dados digitados\n"; + echo "
o código de status cq precisa ter pelo menos 1 caracter de comprimento\n"; + echo "
o nome do status cq precisa ter pelo menos 1 caracter de comprimento\n"; + } + else + { + echo "
CÓDIGO DE STATUS CQ ALTERADO:$code\n"; + + $stmt="UPDATE vicidial_qc_codes SET code_name='$code_name' where code='$code';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='QCCODES', event_type='MODIFY', record_id='$vsc_id', event_code='ADMIN MODIFY QC CODES', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $ADD=341111111111111; # go to qc status code modification form below + } + + + + +###################################################################################################### +###################################################################################################### +####### 5 series, delete records confirmation +###################################################################################################### +###################################################################################################### + + +###################### +# ADD=5 confirmation before deletion of user +###################### + +if ($ADD==5) + { + echo ""; + + if ( (strlen($user) < 2) or ($LOGdelete_users < 1) ) + { + echo "
USUÁRIO NÃO APAGADO - Por favor, volte e verifique os dados digitados\n"; + echo "
Usuário be at least 2 characters in length\n"; + } + else + { + echo "
CONFIRMAÇÃO DE REMOÇÃO DO USUÁRIO: $user\n"; + echo "

Clique aqui para apagar o usuário $user


\n"; + } + + $ADD='3'; # go to user modification below + } + +###################### +# ADD=51 confirmation before deletion of campaign +###################### + +if ($ADD==51) + { + echo ""; + + if ( (strlen($campaign_id) < 2) or ($LOGdelete_campaigns < 1) ) + { + echo "
CAMPANHA NÃO APAGADA - Por favor, volte e verifique os dados digitados\n"; + echo "
Campanha_id be at least 2 characters in length\n"; + } + else + { + echo "
CONFIRMAÇÃO DE REMOÇÃO DA CAMPANHA: $campaign_id\n"; + echo "

Clique aqui para apagar a campanha $campaign_id


\n"; + } + + $ADD='31'; # go to campaign modification below + } + +###################### +# ADD=52 confirmation before logging all agents out of campaign of campaign +###################### + +if ($ADD==52) + { + echo ""; + + if (strlen($campaign_id) < 2) + { + echo "
AGENTES NÃO DESLIGADOS DA CAMPANHA - Por favor, volte e verifique os dados digitados\n"; + echo "
Campanha_id be at least 2 characters in length\n"; + } + else + { + echo "
CONFIRMAÇÃO DE SAÍDA FORÇADA DOS AGENTES: $campaign_id\n"; + echo "

Clique aqui para desconectar todos os agentes $campaign_id


\n"; + } + + $ADD='31'; # go to campaign modification below + } + +###################### +# ADD=53 confirmation before Emergency VDAC Jam Clear - deletes oldest LIVE vicidial_auto_call record +###################### + +if ($ADD==53) + { + if (eregi('IN',$stage)) + {$group_id=$campaign_id;} + echo ""; + + if (strlen($campaign_id) < 2) + { + echo "
VDAC NÃO LIMPO PARA CAMPANHA - Por favor, volte e verifique os dados digitados\n"; + echo "
Campanha_id be at least 2 characters in length\n"; + } + else + { + echo "
CONFIRMAR LIMPEZA DO VDAC: $campaign_id\n"; + echo "

Clique aqui para apagar o registro mais velho do VDAC para $campaign_id


\n"; + } + + # go to campaign modification below + if (eregi('IN',$stage)) + {$ADD='3111';} + else + {$ADD='31';} + } + +###################### +# ADD=511 confirmation before deletion of list +###################### + +if ($ADD==511) + { + echo ""; + + if ( (strlen($list_id) < 2) or ($LOGdelete_lists < 1) ) + { + echo "
LISTA NÃO APAGADA - Por favor, volte e verifique os dados digitados\n"; + echo "
List_id be at least 2 characters in length\n"; + } + else + { + echo "
COMFIRMAÇÃO DE REMOÇÃO DA LISTA: $list_id\n"; + echo "

Clique aqui para apagar a lista e todos os seus registros $list_id


\n"; + } + + $ADD='311'; # go to campaign modification below + } + +###################### +# ADD=5111 confirmation before deletion of in-group +###################### + +if ($ADD==5111) + { + echo ""; + + if ( (strlen($group_id) < 2) or ($LOGdelete_ingroups < 1) ) + { + echo "
GRUPO DE ENTRADA NÃO APAGADO - Por favor, volte e verifique os dados digitados\n"; + echo "
Group_id be at least 2 characters in length\n"; + } + else + { + echo "
CONFIRMAÇÃO DE REMOÇÃO DE GRUPO DE ENTRADA: $group_id\n"; + echo "

Clique aqui para apagar este grupo de entrada $group_id


\n"; + } + + $ADD='3111'; # go to in-group modification below + } + +###################### +# ADD=5311 confirmation before deletion of did +###################### + +if ($ADD==5311) + { + echo ""; + + if ( (strlen($did_id) < 1) or ($LOGdelete_dids < 1) ) + { + echo "
DDR NÃO REMOVIDO - Por favor, volte e verifique os dados digitados\n"; + echo "
did_id be at least 1 characters in length\n"; + } + else + { + echo "
CONFIRMAÇÃO DE REMOÇÃO DO DDR: $menu_id\n"; + echo "

Clique aqui para removerDID $did_id


\n"; + } + + $ADD='3311'; # go to did modification below + } + +###################### +# ADD=5511 confirmation before deletion of call menu +###################### + +if ($ADD==5511) + { + echo ""; + + if ( (strlen($menu_id) < 2) or ($LOGdelete_dids < 1) ) + { + echo "
MENU NÃO REMOVIDO - Por favor, volte e verifique os dados digitados\n"; + echo "
menu_id be at least 2 characters in length\n"; + } + else + { + echo "
CONFIRMAÇÃO DE REMOÇÃO DE MENU: $menu_id\n"; + echo "

Clique aqui para remover o MENU $menu_id


\n"; + } + + $ADD='3511'; # go to call menu modification below + } + +###################### +# ADD=51111 confirmation before deletion of remote agent record +###################### + +if ($ADD==51111) + { + echo ""; + + if ( (strlen($remote_agent_id) < 1) or ($LOGdelete_remote_agents < 1) ) + { + echo "
AGENTE REMOTO NÃO APAGADO - Por favor, volte e verifique os dados digitados\n"; + echo "
Remote_agent_id be at least 2 characters in length\n"; + } + else + { + echo "
CONFIRMAÇÃO DE REMOÇÃO DE AGENTE REMOTO: $remote_agent_id\n"; + echo "

Clique aqui para apagar este usuário remoto $remote_agent_id


\n"; + } + + $ADD='31111'; # go to remote agent modification below + } + +###################### +# ADD=511111 confirmation before deletion of user group record +###################### + +if ($ADD==511111) + { + echo ""; + + if ( (strlen($user_group) < 2) or ($LOGdelete_user_groups < 1) ) + { + echo "
GRUPO DE USUÁRIOS NÃO APAGADO - Por favor, volte e verifique os dados digitados\n"; + echo "
Usuário_group be at least 2 characters in length\n"; + } + else + { + echo "
CONFIRMAÇÃO DE REMOÇÃO DE GRUPO DE USUÁRIO: $user_group\n"; + echo "

Clique aqui para apagar este grupo de usuários $user_group


\n"; + } + + $ADD='311111'; # go to user group modification below + } + +###################### +# ADD=5111111 confirmation before deletion of script record +###################### + +if ($ADD==5111111) + { + echo ""; + + if ( (strlen($script_id) < 2) or ($LOGdelete_scripts < 1) ) + { + echo "
SCRIPT NÃO APAGADO - Por favor, volte e verifique os dados digitados\n"; + echo "
Script_id must be at least 2 characters in length\n"; + } + else + { + echo "
CONFIRMAÇÃO DE REMOÇÃO DE SCRIPT: $script_id\n"; + echo "

Clique aqui para apagar o script $script_id


\n"; + } + + $ADD='3111111'; # go to script modification below + } + +###################### +# ADD=51111111 confirmation before deletion of filter record +###################### + +if ($ADD==51111111) + { + echo ""; + + if ( (strlen($lead_filter_id) < 2) or ($LOGdelete_filters < 1) ) + { + echo "
FILTRO NÃO REMOVIDO - Por favor, volte e verifique os dados digitados\n"; + echo "
ID do filtro deve ter pelo menos 2 caracteres de comprimento\n"; + } + else + { + echo "
FILTER DELETION CONFIRMATION: $lead_filter_id\n"; + echo "

Clique aqui para apagar o filtro$lead_filter_id


\n"; + } + + $ADD='31111111'; # go to filter modification below + } + +###################### +# ADD=511111111 confirmation before deletion of call time record +###################### + +if ($ADD==511111111) + { + echo ""; + + if ( (strlen($call_time_id) < 2) or ($LOGdelete_call_times < 1) ) + { + echo "
HORÁRIO DE CHAMADA NÃO REMOVIDO - Por favor, volte e verifique os dados digitados\n"; + echo "
ID do horário de cham. deve ter pelo menos 2 caracteres\n"; + } + else + { + echo "
CONFIRMAÇÃO DE REMOÇÃO DO HORÁRIO DE CHAMADAS: $call_time_id\n"; + echo "

Clique aqui para removercall time $call_time_id


\n"; + } + + $ADD='311111111'; # go to call time modification below + } + +###################### +# ADD=5111111111 confirmation before deletion of state call time record +###################### + +if ($ADD==5111111111) + { + echo ""; + + if ( (strlen($call_time_id) < 2) or ($LOGdelete_call_times < 1) ) + { + echo "
HORÁRIO DE CHAM. POR ESTADO NÃO REMOVIDO - Por favor, volte e verifique os dados digitados\n"; + echo "
ID do horário de cham. deve ter pelo menos 2 caracteres\n"; + } + else + { + echo "
CONFIRMAÇÃO DE REMOÇÃO DO HORÁRIO DE CHAM. POR ESTADO: $call_time_id\n"; + echo "

Clique aqui para removerstate call time $call_time_id


\n"; + } + + $ADD='3111111111'; # go to state call time modification below + } + +###################### +# ADD=531111111 confirmation before deletion of shift record +###################### + +if ($ADD==531111111) + { + echo ""; + + if ( (strlen($shift_id) < 2) or ($LOGdelete_call_times < 1) ) + { + echo "
TURNO NÃO REMOVIDO - Por favor, volte e verifique os dados digitados\n"; + echo "
Shift ID must be at least 2 characters in length\n"; + } + else + { + echo "
CONFIRMAÇÃO DE REMOÇÃO DE TURNO:$shift_id\n"; + echo "

Clique aqui para remover o turno $shift_id


\n"; + } + + $ADD='331111111'; # go to call time modification below + } + +###################### +# ADD=51111111111 confirmation before deletion of phone record +###################### + +if ($ADD==51111111111) + { + echo ""; + + if ( (strlen($extension) < 2) or (strlen($server_ip) < 7) or ($LOGast_delete_phones < 1) ) + { + echo "
RAMAL NÃO APAGADO - Por favor, volte e verifique os dados digitados\n"; + echo "
Extension be at least 2 characters in length\n"; + echo "
IP do Servidor be at least 7 characters in length\n"; + } + else + { + echo "
CONFIRMAÇÃO DE REMOÇÃO DE RAMAL: $extension - $server_ip\n"; + echo "

Clique aqui para apagar este ramal $extension - $server_ip


\n"; + } + $ADD='31111111111'; # go to phone modification below + } + + +###################### +# ADD=52111111111 confirmation before deletion of phone alias record +###################### + +if ($ADD==52111111111) + { + echo ""; + + if ( (strlen($alias_id) < 1) or ($LOGast_delete_phones < 1) ) + { + echo "
ALIAS DE RAMAL NÃO REMOVIDO - Por favor, volte e verifique os dados digitados\n"; + echo "
Alias ID must be at least 2 characters in length\n"; + } + else + { + echo "
CONFIRMAÇÃO DE REMOÇÃO DE ALIAS: $alias_id\n"; + echo "

Clique aqui para remover o alias de ramal $alias_id


\n"; + } + $ADD='32111111111'; # go to phone alias modification below + } + + +###################### +# ADD=53111111111 confirmation before deletion of group alias record +###################### + +if ($ADD==53111111111) + { + echo ""; + + if ( (strlen($group_alias_id) < 1) or ($LOGast_delete_phones < 1) ) + { + echo "
ALIAS DE GRUPO NÃO REMOVIDO - Por favor, volte e verifique os dados digitados\n"; + echo "
ID do Alias must be at least 2 characters in length\n"; + } + else + { + echo "
CONFIRMAÇÃO DE REMOÇÃO DE ALIAS DE GRUPO: $group_alias_id\n"; + echo "

Clique aqui para remover alias de grupo $group_alias_id


\n"; + } + $ADD='33111111111'; # go to group alias modification below + } + + +###################### +# ADD=511111111111 confirmation before deletion of server record +###################### + +if ($ADD==511111111111) + { + echo ""; + + if ( (strlen($server_id) < 2) or (strlen($server_ip) < 7) or ($LOGast_delete_phones < 1) ) + { + echo "
SERVIDOR NOT DELETED - Por favor, volte e verifique os dados digitados\n"; + echo "
ID do Servidor be at least 2 characters in length\n"; + echo "
IP do Servidor be at least 7 characters in length\n"; + } + else + { + echo "
SERVIDOR DELETION CONFIRMATION: $server_id - $server_ip\n"; + echo "

Clique aqui para apagar este ramal $server_id - $server_ip


\n"; + } + $ADD='311111111111'; # go to server modification below + } + + +###################### +# ADD=531111111111 confirmation before deletion of conf template record +###################### + +if ($ADD==531111111111) + { + echo ""; + + if (strlen($template_id) < 2) + { + echo "
TEMPLATE DE CONF NÃO REMOVIDO - Por favor, volte e verifique os dados digitados\n"; + echo "
ID do template deve ter pelo menos 2 caracteres\n"; + } + else + { + echo "
CONFIRMAR REMOÇÃO DO TEMPLATE DE CONF: $template_id - $template_name\n"; + echo "

Clique aqui para remover esta template de conf $template_id - $template_name


\n"; + } + $ADD='331111111111'; # go to conf template modification below + } + + +###################### +# ADD=541111111111 confirmation before deletion of carrier record +###################### + +if ($ADD==541111111111) + { + echo ""; + + if (strlen($carrier_id) < 2) + { + echo "
OPERADORA NÃO REMOVIDA - Por favor, volte e verifique os dados digitados\n"; + echo "
O ID da operadora precisa ter pelo menos 2 caracteres\n"; + } + else + { + echo "
CONFIRMAR REMOÇÃO DA OPERADORA: $carrier_id - $carrier_name\n"; + echo "

Clique aqui para remover a operadora $carrier_id - $carrier_name


\n"; + } + $ADD='341111111111'; # go to carrier modification below + } + + +###################### +# ADD=551111111111 confirmation before deletion of tts record +###################### + +if ($ADD==551111111111) + { + echo ""; + + if (strlen($tts_id) < 2) + { + echo "
TTS entrada no DELETED - Por favor, volte e verifique os dados digitados\n"; + echo "
TTS ID be at least 2 characters in length\n"; + } + else + { + echo "
TTS DE ENTRADA SUPRESIÓN DE CONFIRMACIÓN: $tts_id - $tts_name\n"; + echo "

Haga clic aquí para eliminar TTS entrada $tts_id - $tts_name


\n"; + } + $ADD='351111111111'; # go to tts entry modification below + } + + +###################### +# ADD=561111111111 confirmation before deletion of music on hold record +###################### + +if ($ADD==561111111111) + { + echo ""; + + if (strlen($moh_id) < 2) + { + echo "
MÚSICA EN ESPERA DE ENTRADA no se eliminan - Por favor, volte e verifique os dados digitados\n"; + echo "
MOH ID be at least 2 characters in length\n"; + } + else + { + echo "
MÚSICA EN ESPERA DE ENTRADA SUPRESIÓN DE CONFIRMACIÓN: $moh_id - $moh_name\n"; + echo "

Haga clic aquí para borrar música en espera de entrada $moh_id - $moh_name


\n"; + } + $ADD='361111111111'; # go to music on hold entry modification below + } + + +###################### +# ADD=571111111111 confirmation before deletion of voicemail record +###################### + +if ($ADD==571111111111) + { + echo ""; + + if (strlen($voicemail_id) < 2) + { + echo "
Contestador no se eliminan - Por favor, volte e verifique os dados digitados\n"; + echo "
ID de correo de voz be at least 2 characters in length\n"; + } + else + { + echo "
Contestador SUPRESIÓN DE CONFIRMACIÓN: $voicemail_id - $fullname\n"; + echo "

Haga clic aquí para eliminar buzón de voz $voicemail_id - $fullname


\n"; + } + $ADD='371111111111'; # go to voicemail entry modification below + } + + +###################### +# ADD=5111111111111 confirmation before deletion of conference record +###################### + +if ($ADD==5111111111111) + { + echo ""; + + if ( (strlen($conf_exten) < 2) or (strlen($server_ip) < 7) or ($LOGast_delete_phones < 1) ) + { + echo "
CONFERENCE NOT DELETED - Por favor, volte e verifique os dados digitados\n"; + echo "
Conference must be at least 2 characters in length\n"; + echo "
IP do Servidor be at least 7 characters in length\n"; + } + else + { + echo "
CONFERENCE DELETION CONFIRMATION: $conf_exten - $server_ip\n"; + echo "

Clique aqui para apagar este ramal $conf_exten - $server_ip


\n"; + } + $ADD='3111111111111'; # go to conference modification below + } + + +###################### +# ADD=51111111111111 confirmation before deletion of vicidial conference record +###################### + +if ($ADD==51111111111111) + { + echo ""; + + if ( (strlen($conf_exten) < 2) or (strlen($server_ip) < 7) or ($LOGast_delete_phones < 1) ) + { + echo "
VICIDIAL CONFERENCE NOT DELETED - Por favor, volte e verifique os dados digitados\n"; + echo "
Conference must be at least 2 characters in length\n"; + echo "
IP do Servidor be at least 7 characters in length\n"; + } + else + { + echo "
VICIDIAL CONFERENCE DELETION CONFIRMATION: $conf_exten - $server_ip\n"; + echo "

Clique aqui para apagar este ramal $conf_exten - $server_ip


\n"; + } + $ADD='31111111111111'; # go to vicidial conference modification below + } + + + +###################################################################################################### +###################################################################################################### +####### 6 series, delete records +###################################################################################################### +###################################################################################################### + + +###################### +# ADD=6 delete user record +###################### + +if ($ADD==6) + { + echo ""; + + if ( ( strlen($user) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_users < 1) ) + { + echo "
USUÁRIO NÃO APAGADO - Por favor, volte e verifique os dados digitados\n"; + echo "
Usuário be at least 2 characters in length\n"; + } + else + { + $stmtA="DELETE from vicidial_users where user='$user' limit 1;"; + $rslt=mysql_query($stmtA, $link); + + $stmt="DELETE from vicidial_campaign_agents where user='$user';"; + $rslt=mysql_query($stmt, $link); + + $stmt="DELETE from vicidial_inbound_group_agents where user='$user';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmtA|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='USUÁRIOS', event_type='DELETE', record_id='$user', event_code='ADMIN DELETE USER', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
REMOÇÃO DO USUÁRIO CONCLUÍDA: $user\n"; + echo "

\n"; + } + + $ADD='0'; # go to user list + } + +###################### +# ADD=61 delete campaign record +###################### + +if ($ADD==61) + { + echo ""; + + if ( ( strlen($campaign_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_campaigns < 1) ) + { + echo "
CAMPANHA NÃO APAGADA - Por favor, volte e verifique os dados digitados\n"; + echo "
Campanha_id be at least 2 characters in length\n"; + } + else + { + $stmtA="DELETE from vicidial_campaigns where campaign_id='$campaign_id' limit 1;"; + $rslt=mysql_query($stmtA, $link); + + $stmt="DELETE from vicidial_campaign_agents where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + + $stmt="DELETE from vicidial_live_agents where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + + $stmt="DELETE from vicidial_campaign_statuses where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + + $stmt="DELETE from vicidial_campaign_hotkeys where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + + $stmt="DELETE from vicidial_callbacks where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + + $stmt="DELETE from vicidial_campaign_stats where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + + $stmt="DELETE from vicidial_lead_recycle where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + + $stmt="DELETE from vicidial_campaign_server_stats where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + + $stmt="DELETE from vicidial_server_trunks where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + + $stmt="DELETE from vicidial_pause_codes where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + + $stmt="DELETE from vicidial_campaigns_list_mix where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
REMOVENDO REGISTROS HOPPERS DO HOPPER DA CAMPANHA ANTIGA ($campaign_id)\n"; + $stmt="DELETE from vicidial_hopper where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmtA|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPANHAS', event_type='DELETE', record_id='$campaign_id', event_code='ADMIN DELETE CAMPANHA', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
REMOÇÃO DA CAMPANHA CONCLUÍDA: $campaign_id\n"; + echo "

\n"; + } + + $ADD='10'; # go to campaigns list + } + + +###################### +# ADD=62 Logout all agents from a campaign +###################### + +if ($ADD==62) + { + if ($LOGmodify_campaigns==1) + { + echo ""; + + if (strlen($campaign_id) < 2) + { + echo "
AGENTES NÃO DESLIGADOS DA CAMPANHA - Por favor, volte e verifique os dados digitados\n"; + echo "
Campanha_id be at least 2 characters in length\n"; + } + else + { + $now_date_epoch = date('U'); + $inactive_epoch = ($now_date_epoch - 60); + $stmt = "SELECT user,campaign_id,UNIX_TIMESTAMP(last_update_time) from vicidial_live_agents where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "
$stmt\n";} + $vla_ct = mysql_num_rows($rslt); + $k=0; + while ($vla_ct > $k) + { + $row=mysql_fetch_row($rslt); + $VLA_user[$k] = $row[0]; + $VLA_campaign_id[$k] = $row[1]; + $VLA_update_time[$k] = $row[2]; + $k++; + } + + $k=0; + while ($vla_ct > $k) + { + if ($VLA_update_time[$k] > $inactive_epoch) + { + $lead_active=0; + $stmt = "SELECT agent_log_id,user,server_ip,event_time,lead_id,campaign_id,pause_epoch,pause_sec,wait_epoch,wait_sec,talk_epoch,talk_sec,dispo_epoch,dispo_sec,status,user_group,comments,sub_status,dead_epoch,dead_sec from vicidial_agent_log where user='$VLA_user[$k]' order by agent_log_id desc LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "
$stmt\n";} + $val_ct = mysql_num_rows($rslt); + if ($val_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VAL_agent_log_id = $row[0]; + $VAL_user = $row[1]; + $VAL_server_ip = $row[2]; + $VAL_event_time = $row[3]; + $VAL_lead_id = $row[4]; + $VAL_campaign_id = $row[5]; + $VAL_pause_epoch = $row[6]; + $VAL_pause_sec = $row[7]; + $VAL_wait_epoch = $row[8]; + $VAL_wait_sec = $row[9]; + $VAL_talk_epoch = $row[10]; + $VAL_talk_sec = $row[11]; + $VAL_dispo_epoch = $row[12]; + $VAL_dispo_sec = $row[13]; + $VAL_status = $row[14]; + $VAL_user_group = $row[15]; + $VAL_comments = $row[16]; + $VAL_sub_status = $row[17]; + $VAL_dead_epoch = $row[18]; + $VAL_dead_sec = $row[19]; + + if ($DB) {echo "\n
VAL VALUES: $VAL_agent_log_id|$VAL_status|$VAL_lead_id\n";} + + if ( ($VAL_wait_epoch < 1) || ( ($VAL_status == 'PAUSE') && ($VAL_dispo_epoch < 1) ) ) + { + $VAL_pause_sec = ( ($now_date_epoch - $VAL_pause_epoch) + $VAL_pause_sec); + $stmt = "UPDATE vicidial_agent_log SET wait_epoch='$now_date_epoch', pause_sec='$VAL_pause_sec' where agent_log_id='$VAL_agent_log_id';"; + } + else + { + if ($VAL_talk_epoch < 1) + { + $VAL_wait_sec = ( ($now_date_epoch - $VAL_wait_epoch) + $VAL_wait_sec); + $stmt = "UPDATE vicidial_agent_log SET talk_epoch='$now_date_epoch', wait_sec='$VAL_wait_sec' where agent_log_id='$VAL_agent_log_id';"; + } + else + { + $lead_active++; + $status_update_SQL=''; + if ( ( (strlen($VAL_status) < 1) or ($VAL_status == 'NULL') ) and ($VAL_lead_id > 0) ) + { + $status_update_SQL = ", status='PU'"; + $stmt="UPDATE vicidial_list SET status='PU' where lead_id='$VAL_lead_id';"; + if ($DB) {echo "
$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + if ($VAL_dispo_epoch < 1) + { + $VAL_talk_sec = ($now_date_epoch - $VAL_talk_epoch); + $stmt = "UPDATE vicidial_agent_log SET dispo_epoch='$now_date_epoch', talk_sec='$VAL_talk_sec'$status_update_SQL where agent_log_id='$VAL_agent_log_id';"; + } + else + { + if ($VAL_dispo_sec < 1) + { + $VAL_dispo_sec = ($now_date_epoch - $VAL_dispo_epoch); + $stmt = "UPDATE vicidial_agent_log SET dispo_sec='$VAL_dispo_sec' where agent_log_id='$VAL_agent_log_id';"; + } + } + } + } + + if ($DB) {echo "
$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + } + + $stmt="DELETE from vicidial_live_agents where user='$VLA_user[$k]';"; + if ($DB) {echo "
$stmt\n";} + $rslt=mysql_query($stmt, $link); + + if (strlen($VAL_user_group) < 1) + { + $stmt = "SELECT user_group FROM vicidial_users where user='$VLA_user[$k]';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "
$stmt\n";} + $val_ct = mysql_num_rows($rslt); + if ($val_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VAL_user_group = $row[0]; + } + } + + $stmt = "INSERT INTO vicidial_user_log (user,event,campaign_id,event_date,event_epoch,user_group) values('$VLA_user[$k]','LOGOUT','$VLA_campaign_id[$k]','$NOW_TIME','$now_date_epoch','$VAL_user_group');"; + if ($DB) {echo "
$stmt\n";} + $rslt=mysql_query($stmt, $link); + + + ############################################# + ##### START QUEUEMETRICS LOGGING LOOKUP ##### + $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "
$stmt\n";} + $qm_conf_ct = mysql_num_rows($rslt); + if ($qm_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $enable_queuemetrics_logging = $row[0]; + $queuemetrics_server_ip = $row[1]; + $queuemetrics_dbname = $row[2]; + $queuemetrics_login = $row[3]; + $queuemetrics_pass = $row[4]; + $queuemetrics_log_id = $row[5]; + } + ##### END QUEUEMETRICS LOGGING LOOKUP ##### + ########################################### + if ($enable_queuemetrics_logging > 0) + { + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); + mysql_select_db("$queuemetrics_dbname", $linkB); + + $agents='@agents'; + $agent_logged_in=''; + $time_logged_in=''; + + $stmtB = "SELECT agent,time_id FROM queue_log where agent='Agent/$VLA_user[$k]' and verb='AGENTLOGIN' order by time_id desc limit 1;"; + $rsltB=mysql_query($stmtB, $linkB); + if ($DB) {echo "
$stmtB\n";} + $qml_ct = mysql_num_rows($rsltB); + if ($qml_ct > 0) + { + $row=mysql_fetch_row($rsltB); + $agent_logged_in = $row[0]; + $time_logged_in = $row[1]; + } + + $time_logged_in = ($now_date_epoch - $time_logged_in); + if ($time_logged_in > 1000000) {$time_logged_in=1;} + + $stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$now_date_epoch',call_id='NONE',queue='NONE',agent='$agent_logged_in',verb='AGENTLOGOFF',serverid='$queuemetrics_log_id',data1='$VLA_user[$k]$agents',data2='$time_logged_in';"; + if ($DB) {echo "
$stmtB\n";} + $rsltB=mysql_query($stmtB, $linkB); + } + + echo "\n"; + + $k++; + } + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPANHAS', event_type='LOGOUT', record_id='$campaign_id', event_code='ADMIN LOGOUT CAMPANHA AGENTS', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
DESCONEXÃO DE AGENTES CONCLUÍDA: $campaign_id\n"; + echo "

\n"; + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $ADD='31'; # go to campaign modification below + } + + +###################### +# ADD=63 Emergency VDAC Jam Clear +###################### + +if ($ADD==63) + { + if ($LOGmodify_campaigns==1) + { + if (eregi('IN',$stage)) + {$group_id=$campaign_id;} + echo ""; + + if (strlen($campaign_id) < 2) + { + echo "
VDAC NÃO LIMPO PARA CAMPANHA - Por favor, volte e verifique os dados digitados\n"; + echo "
Campanha_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_auto_calls where status='LIVE' and campaign_id='$campaign_id' order by call_time limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPANHAS', event_type='RESET', record_id='$campaign_id', event_code='ADMIN RESET CAMPANHA JAM', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
ÚLTIMO REGISTRO VDAC LIMPO PARA CAMPANHA: $campaign_id\n"; + echo "

\n"; + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + # go to campaign modification below + if (eregi('IN',$stage)) + {$ADD='3111';} + else + {$ADD='31';} + } + + +###################### +# ADD=65 delete campaign lead recycle in the system +###################### + +if ($ADD==65) + { + if ($LOGmodify_campaigns==1) + { + echo ""; + + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) ) + { + echo "
RECICLAGEM DE REGISTROS DA CAMPANHA NÃO REMOVIDO - Por favor, volte e verifique os dados digitados\n"; + echo "
status deve ter entre 1 e 6 caracteres\n"; + echo "
tempo de tentativa deve ter pelo menos 120 segundos\n"; + echo "
quantidade máxima de tentativas deve ser entre 1 e 10\n"; + } + else + { + echo "
RECICLAGEM DE REGISTROS DA CAMPANHA REMOVIDO: $campaign_id - $status - $attempt_delay\n"; + + $stmt="DELETE FROM vicidial_lead_recycle where campaign_id='$campaign_id' and status='$status';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPANHA_RECYCLE', event_type='DELETE', record_id='$campaign_id', event_code='ADMIN DELETE CAMPANHA LEAD RECYCLE', event_sql=\"$SQL_log\", event_notes='Status: $status';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $SUB=25; + $ADD=31; # go to campaign modification form below + } + + +###################### +# ADD=66 delete auto alt dial status from the campaign +###################### + +if ($ADD==66) + { + if ($LOGmodify_campaigns==1) + { + echo ""; + $stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$campaign_id' and auto_alt_dial_statuses LIKE \"% $status %\";"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] < 1) + {echo "
STATUS DE DISCAGEM PARA NÚM. ALT. NÃO REMOVIDO - este status de discagem do número alt. não está na campanha\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) ) + { + echo "
STATUS DE DISCAGEM PARA NÚM. ALT. NÃO REMOVIDO - Por favor, volte e verifique os dados digitados\n"; + echo "
status deve ter entre 1 e 6 caracteres\n"; + } + else + { + echo "
STATUS DE DISC. PARA NÚMERO ALT. REMOVIDO: $campaign_id - $status\n"; + + $stmt="SELECT auto_alt_dial_statuses from vicidial_campaigns where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + + $auto_alt_dial_statuses = eregi_replace(" $status "," ",$row[0]); + $stmt="UPDATE vicidial_campaigns set auto_alt_dial_statuses='$auto_alt_dial_statuses' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPANHA_ALTDIALS', event_type='DELETE', record_id='$campaign_id', event_code='ADMIN DELETE CAMPANHA ALT DIAL', event_sql=\"$SQL_log\", event_notes='Status: $status';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $SUB=26; + $ADD=31; # go to campaign modification form below + } + + +###################### +# ADD=67 delete agent pause code in the system +###################### + +if ($ADD==67) + { + if ($LOGmodify_campaigns==1) + { + echo ""; + + if ( (strlen($campaign_id) < 2) or (strlen($pause_code) < 1) ) + { + echo "
CÓDIGO DE PAUSA DA CAMPANHA NÃO REMOVIDO - Por favor, volte e verifique os dados digitados\n"; + echo "
pause code must be between 1 and 6 characters in length\n"; + } + else + { + echo "
CAMPANHA PAUSE CODE DELETED: $campaign_id - $pause_code\n"; + + $stmt="DELETE FROM vicidial_pause_codes where campaign_id='$campaign_id' and pause_code='$pause_code';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPANHA_PAUSECODES', event_type='DELETE', record_id='$campaign_id', event_code='ADMIN DELETE CAMPANHA PAUSE CODE', event_sql=\"$SQL_log\", event_notes='Status: $pause_code';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $SUB=27; + $ADD=31; # go to campaign modification form below + } + + +###################### +# ADD=68 remove campaign dial status +###################### + +if ($ADD==68) + { + if ($LOGmodify_campaigns==1) + { + echo ""; + $stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$campaign_id' and dial_statuses LIKE \"% $status %\";"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] < 1) + {echo "
STATUS DE DISCAGEM NÃO REMOVIDO - esse status de discagem não está selecionado para esta campanha\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) ) + { + echo "
STATUS DE DISCAGEM NÃO REMOVIDO - Por favor, volte e verifique os dados digitados\n"; + echo "
status deve ter entre 1 e 6 caracteres\n"; + } + else + { + echo "
STATUS DE DISCAGEM REMOVIDO: $campaign_id - $status\n"; + + $stmt="SELECT dial_statuses from vicidial_campaigns where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + + $dial_statuses = eregi_replace(" $status "," ",$row[0]); + $stmt="UPDATE vicidial_campaigns set dial_statuses='$dial_statuses' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPANHA_DIALSTATUS', event_type='DELETE', record_id='$campaign_id', event_code='ADMIN DELETE CAMPANHA DIAL STATUS', event_sql=\"$SQL_log\", event_notes='Status: $status';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + #$SUB=28; + $ADD=31; # go to campaign modification form below + } + +###################### +# ADD=611 delete list record and all leads within it +###################### + +if ($ADD==611) + { + echo ""; + + if ( ( strlen($list_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_lists < 1) ) + { + echo "
LISTA NÃO APAGADA - Por favor, volte e verifique os dados digitados\n"; + echo "
List_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_lists where list_id='$list_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + echo "
REMOVENDO REGISTROS HOPPERS DO HOPPER DA CAMPANHA ANTIGA ($list_id)\n"; + $stmt="DELETE from vicidial_hopper where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
REMOVENDO REGISTROS DA LISTA DA TABELA VICIDIAL_LIST\n"; + $stmt="DELETE from vicidial_list where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='LISTAS', event_type='DELETE', record_id='$list_id', event_code='ADMIN DELETE LIST', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
REMOÇÃO DA LISTA CONCLUÍDA: $list_id\n"; + echo "

\n"; + } + + $ADD='100'; # go to lists list + } + +###################### +# ADD=6111 delete in-group record +###################### + +if ($ADD==6111) + { + echo ""; + + if ( (strlen($group_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_ingroups < 1) ) + { + echo "
GRUPO DE ENTRADA NÃO APAGADO - Por favor, volte e verifique os dados digitados\n"; + echo "
Group_id be at least 2 characters in length\n"; + } + else + { + $stmtA="DELETE from vicidial_inbound_groups where group_id='$group_id' and group_id NOT IN('AGENTDIRECT') limit 1;"; + $rslt=mysql_query($stmtA, $link); + + $stmt="DELETE from vicidial_inbound_group_agents where group_id='$group_id';"; + $rslt=mysql_query($stmt, $link); + + $stmt="DELETE from vicidial_live_inbound_agents where group_id='$group_id';"; + $rslt=mysql_query($stmt, $link); + + $stmt="DELETE from vicidial_campaign_stats where campaign_id='$group_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmtA|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='INGROUPS', event_type='DELETE', record_id='$group_id', event_code='ADMIN DELETE INGROUP', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
REMOÇÃO DE GRUPO DE ENTRADA CONCLUÍDA: $group_id\n"; + echo "

\n"; + } + + $ADD='1000'; # go to in-group list + } + + +###################### +# ADD=6311 delete did record +###################### + +if ($ADD==6311) + { + echo ""; + + if ( (strlen($did_id) < 1) or ($CoNfIrM != 'YES') or ($LOGdelete_dids < 1) ) + { + echo "
DDR NÃO REMOVIDO - Por favor, volte e verifique os dados digitados\n"; + echo "
did_id be at least 1 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_inbound_dids where did_id='$did_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='DIDS', event_type='DELETE', record_id='$did_id', event_code='ADMIN DELETE DID', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
REMOÇÃO DO DDR FINALIZADA: $did_id\n"; + echo "

\n"; + } + + $ADD='1300'; # go to did list + } + +###################### +# ADD=6511 delete call menu record +###################### + +if ($ADD==6511) + { + echo ""; + + if ( (strlen($menu_id) < 1) or ($CoNfIrM != 'YES') or ($LOGdelete_dids < 1) ) + { + echo "
MENU NÃO REMOVIDO - Por favor, volte e verifique os dados digitados\n"; + echo "
menu_id be at least 1 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_call_menu where menu_id='$menu_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + $stmtA="DELETE from vicidial_call_menu_options where menu_id='$menu_id' limit 17;"; + $rslt=mysql_query($stmtA, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|$stmtA"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CALLMENUS', event_type='DELETE', record_id='$menu_id', event_code='ADMIN DELETE CALL MENU', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
REMOÇÃO DE MENU COMPLETADA: $menu_id\n"; + echo "

\n"; + } + + $ADD='1500'; # go to call menu list + } + +###################### +# ADD=61111 delete remote agent record +###################### + +if ($ADD==61111) + { + echo ""; + + if ( (strlen($remote_agent_id) < 1) or ($CoNfIrM != 'YES') or ($LOGdelete_remote_agents < 1) ) + { + echo "
AGENTE REMOTO NÃO APAGADO - Por favor, volte e verifique os dados digitados\n"; + echo "
Remote_agent_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_remote_agents where remote_agent_id='$remote_agent_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='REMOTEAGENTS', event_type='DELETE', record_id='$remote_agent_id', event_code='ADMIN DELETE REMOTE AGENT', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
REMOÇÃO DE AGENTE REMOTO CONCLUÍDA: $remote_agent_id\n"; + echo "

\n"; + } + + $ADD='10000'; # go to remote agents list + } + +###################### +# ADD=611111 delete user group record +###################### + +if ($ADD==611111) + { + echo ""; + + if ( (strlen($user_group) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_user_groups < 1) ) + { + echo "
GRUPO DE USUÁRIOS NÃO APAGADO - Por favor, volte e verifique os dados digitados\n"; + echo "
Usuário_group be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_user_groups where user_group='$user_group' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='USERGROUPS', event_type='DELETE', record_id='$user_group', event_code='ADMIN DELETE GRUPO DE USUÁRIOS', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
REMOÇÃO DE GRUPO DE USUÁRIOS CONCLUÍDA: $user_group\n"; + echo "

\n"; + } + + $ADD='100000'; # go to user group list + } + +###################### +# ADD=6111111 delete script record +###################### + +if ($ADD==6111111) + { + echo ""; + + if ( (strlen($script_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_scripts < 1) ) + { + echo "
SCRIPT NÃO APAGADO - Por favor, volte e verifique os dados digitados\n"; + echo "
Script_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_scripts where script_id='$script_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='SCRIPTS', event_type='DELETE', record_id='$script_id', event_code='ADMIN DELETE SCRIPT', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
REMOÇÃO DE SCRIPT CONCLUÍDA: $script_id\n"; + echo "

\n"; + } + + $ADD='1000000'; # go to script list + } + + +###################### +# ADD=61111111 delete filter record +###################### + +if ($ADD==61111111) + { + echo ""; + + if ( (strlen($lead_filter_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_filters < 1) ) + { + echo "
FILTRO NÃO REMOVIDO - Por favor, volte e verifique os dados digitados\n"; + echo "
ID do filtro deve ter pelo menos 2 caracteres de comprimento\n"; + } + else + { + $stmt="DELETE from vicidial_lead_filters where lead_filter_id='$lead_filter_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='FILTROS', event_type='DELETE', record_id='$lead_filter_id', event_code='ADMIN DELETE FILTROS', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
REMOÇÃO DO FILTRO COMPLETADA $lead_filter_id\n"; + echo "

\n"; + } + + $ADD='10000000'; # go to filter list + } + + +###################### +# ADD=611111111 delete call times record +###################### + +if ($ADD==611111111) + { + echo ""; + + if ( (strlen($call_time_id) < 2) or ($LOGdelete_call_times < 1) ) + { + echo "
HORÁRIO DE CHAMADA NÃO REMOVIDO - Por favor, volte e verifique os dados digitados\n"; + echo "
ID do horário de cham. deve ter pelo menos 2 caracteres\n"; + } + else + { + $stmt="DELETE from vicidial_call_times where call_time_id='$call_time_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CALLTIMES', event_type='DELETE', record_id='$call_time_id', event_code='ADMIN DELETE CALL TIME', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
HORÁRIO DE CHAM. REMOVIDO: $call_time_id\n"; + echo "

\n"; + } + + $ADD='100000000'; # go to call times list + } + + +###################### +# ADD=6111111111 delete state call times record +###################### + +if ($ADD==6111111111) + { + echo ""; + + if ( (strlen($call_time_id) < 2) or ($LOGdelete_call_times < 1) ) + { + echo "
HORÁRIO DE CHAM. POR ESTADO NÃO REMOVIDO - Por favor, volte e verifique os dados digitados\n"; + echo "
ID do horário de cham. deve ter pelo menos 2 caracteres\n"; + } + else + { + $stmtA="DELETE from vicidial_state_call_times where state_call_time_id='$call_time_id' limit 1;"; + $rslt=mysql_query($stmtA, $link); + + $stmt="SELECT call_time_id,ct_state_call_times from vicidial_call_times where ct_state_call_times LIKE \"%|$call_time_id|%\" order by call_time_id;"; + $rslt=mysql_query($stmt, $link); + $sct_to_print = mysql_num_rows($rslt); + $sct_list=''; + + $o=0; + while ($sct_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $sct_ids[$o] = "$rowx[0]"; + $sct_states[$o] = "$rowx[1]"; + $o++; + } + $o=0; + while ($sct_to_print > $o) + { + $sct_states[$o] = eregi_replace("\|$call_time_id\|",'|',$sct_states[$o]); + $stmt="UPDATE vicidial_call_times set ct_state_call_times='$sct_states[$o]' where call_time_id='$sct_ids[$o]';"; + $rslt=mysql_query($stmt, $link); + echo "$stmt\n"; + echo "Regra de Estado Removida: $sct_ids[$o]
\n"; + $o++; + } + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmtA|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CALLTIMES', event_type='DELETE', record_id='$call_time_id', event_code='ADMIN DELETE STATE CALL TIME', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
REMOÇÃO DO HORÁRIO DE CHAM. POR ESTADO FINALIZADA: $call_time_id\n"; + echo "

\n"; + } + + $ADD='1000000000'; # go to call times list + } + + +###################### +# ADD=631111111 delete shift record +###################### + +if ($ADD==631111111) + { + echo ""; + + if ( (strlen($shift_id) < 2) or ($LOGdelete_call_times < 1) ) + { + echo "
TURNO NÃO REMOVIDO - Por favor, volte e verifique os dados digitados\n"; + echo "
Shift ID must be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_shifts where shift_id='$shift_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmtA|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='SHIFTS', event_type='DELETE', record_id='$shift_id', event_code='ADMIN DELETE SHIFT', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
REMOÇÃO DE TURNO FINALIZADA: $shift_id\n"; + echo "

\n"; + } + + $ADD='130000000'; # go to shifts list + } + + +###################### +# ADD=61111111111 delete phone record +###################### + +if ($ADD==61111111111) + { + echo ""; + + if ( (strlen($extension) < 2) or (strlen($server_ip) < 7) or ($CoNfIrM != 'YES') or ($LOGast_delete_phones < 1) ) + { + echo "
RAMAL NÃO APAGADO - Por favor, volte e verifique os dados digitados\n"; + echo "
Extension be at least 2 characters in length\n"; + echo "
IP do Servidor be at least 7 characters in length\n"; + } + else + { + $stmt="DELETE from phones where extension='$extension' and server_ip='$server_ip' limit 1;"; + $rslt=mysql_query($stmt, $link); + + $stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$server_ip';"; + $rslt=mysql_query($stmtA, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='PHONES', event_type='DELETE', record_id='$extension', event_code='ADMIN DELETE PHONE', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
REMOÇÃO DE RAMAL CONCLUÍDA: $extension - $server_ip\n"; + echo "

\n"; + } + $ADD='10000000000'; # go to phone list + } + + +###################### +# ADD=62111111111 delete phone alias record +###################### + +if ($ADD==62111111111) + { + echo ""; + + if ( (strlen($alias_id) < 2) or ($CoNfIrM != 'YES') or ($LOGast_delete_phones < 1) ) + { + echo "
ALIAS DE RAMAL NÃO REMOVIDO - Por favor, volte e verifique os dados digitados\n"; + echo "
Alias ID must be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from phones_alias where alias_id='$alias_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmtA|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='PHONEALIASES', event_type='DELETE', record_id='$alias_id', event_code='ADMIN REMOVER ALIAS DE RAMAL', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
REMOÇÃO DO ALIAS DE RAMAL CONCLUÍDA: $alias_id\n"; + echo "

\n"; + } + $ADD='12000000000'; # go to phone alias list + } + + +###################### +# ADD=63111111111 delete group alias record +###################### + +if ($ADD==63111111111) + { + echo ""; + + if ( (strlen($group_alias_id) < 2) or ($CoNfIrM != 'YES') or ($LOGast_delete_phones < 1) ) + { + echo "
ALIAS DE GRUPO NÃO REMOVIDO - Por favor, volte e verifique os dados digitados\n"; + echo "
ID do Alias must be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from groups_alias where group_alias_id='$group_alias_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmtA|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='GROUPALIASES', event_type='DELETE', record_id='$group_alias_id', event_code='ADMIN REMOVER ALIAS DE GRUPO', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
REMOÇÃO DO ALIAS DE GRUPO FINALIZADA: $group_alias_id\n"; + echo "

\n"; + } + $ADD='13000000000'; # go to group alias list + } + + +###################### +# ADD=611111111111 delete server record +###################### + +if ($ADD==611111111111) + { + echo ""; + + if ( (strlen($server_id) < 2) or (strlen($server_ip) < 7) or ($CoNfIrM != 'YES') or ($LOGast_delete_phones < 1) ) + { + echo "
SERVIDOR NOT DELETED - Por favor, volte e verifique os dados digitados\n"; + echo "
ID do Servidor be at least 2 characters in length\n"; + echo "
IP do Servidor be at least 7 characters in length\n"; + } + else + { + $stmt="DELETE from servers where server_id='$server_id' and server_ip='$server_ip' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmtA|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='SERVERS', event_type='DELETE', record_id='$server_id', event_code='ADMIN DELETE SERVER', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
SERVIDOR DELETION COMPLETED: $server_id - $server_ip\n"; + echo "

\n"; + } + $ADD='100000000000'; # go to server list + } + + +###################### +# ADD=621111111111 delete vicidial server trunk record in the system +###################### + +if ($ADD==621111111111) + { + if ($LOGmodify_servers==1) + { + echo ""; + + if ( (strlen($campaign_id) < 2) or (strlen($server_ip) < 7) ) + { + echo "
REGISTRO DE TRUNK VICIDIAL NAO REMOVIDO - Por favor, volte e verifique os dados digitados\n"; + echo "
campanha deve ter entre 3 e 8 caracteres de comprimento\n"; + echo "
delay do IP do servidor deve ser pelo menos 7 caracteres\n"; + } + else + { + echo "
REGISTRO DE TRUNK VICIDIAL REMOVIDO: $campaign_id - $server_ip\n"; + + $stmt="DELETE FROM vicidial_server_trunks where campaign_id='$campaign_id' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='SERVERTRUNKS', event_type='DELETE', record_id='$server_ip', event_code='ADMIN DELETE SERVIDOR TRUNK', event_sql=\"$SQL_log\", event_notes='Campanha: $campaign_id';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + $ADD=311111111111; # go to server modification form below + } + + +###################### +# ADD=631111111111 delete conf template record +###################### + +if ($ADD==631111111111) + { + echo ""; + + if ( (strlen($template_id) < 2) or ($CoNfIrM != 'YES') ) + { + echo "
TEMPLATE DE CONF NÃO REMOVIDO - Por favor, volte e verifique os dados digitados\n"; + echo "
ID do template deve ter pelo menos 2 caracteres\n"; + } + else + { + $stmt="UPDATE phones SET template_id='' where template_id='$template_id';"; + $rslt=mysql_query($stmt, $link); + + $stmt="UPDATE vicidial_server_carriers SET template_id='' where template_id='$template_id';"; + $rslt=mysql_query($stmt, $link); + + $stmt="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y';"; + $rslt=mysql_query($stmt, $link); + + $stmt="DELETE from vicidial_conf_templates where template_id='$template_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CONFTEMPLATES', event_type='DELETE', record_id='$template_id', event_code='ADMIN REMOVER TEMPLATE CONF', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
REMOÇÃO DO TEMPLATE DE CONF FINALIZADA: $server_id - $server_ip\n"; + echo "

\n"; + } + $ADD='130000000000'; # go to conf template list + } + + +###################### +# ADD=641111111111 delete carrier record +###################### + +if ($ADD==641111111111) + { + echo ""; + + if ( (strlen($carrier_id) < 2) or ($CoNfIrM != 'YES') ) + { + echo "
OPERADORA NÃO REMOVIDA - Por favor, volte e verifique os dados digitados\n"; + echo "
O ID da operadora precisa ter pelo menos 2 caracteres\n"; + } + else + { + $stmt="SELECT server_ip from vicidial_server_carriers where carrier_id='$carrier_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $CARRIERserver_ip = $row[0]; + + $stmt="DELETE from vicidial_server_carriers where carrier_id='$carrier_id';"; + $rslt=mysql_query($stmt, $link); + + $stmt="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$CARRIERserver_ip';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CARRIERS', event_type='DELETE', record_id='$carrier_id', event_code='ADMIN REMOVER OPERADORA', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
REMOÇÃO DA OPERADORA FINALIZADA: $carrier_id\n"; + echo "

\n"; + } + $ADD='140000000000'; # go to carrier list + } + + +###################### +# ADD=651111111111 delete tts record +###################### + +if ($ADD==651111111111) + { + echo ""; + + if ( (strlen($tts_id) < 2) or ($CoNfIrM != 'YES') ) + { + echo "
TTS entrada no DELETED - Por favor, volte e verifique os dados digitados\n"; + echo "
TTS ID be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_tts_prompts where tts_id='$tts_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='TTS', event_type='DELETE', record_id='$tts_id', event_code='ADMIN DELETE TTS', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
TTS DELETION COMPLETED: $tts_id\n"; + echo "

\n"; + } + $ADD='150000000000'; # go to tts entry list + } + + +###################### +# ADD=661111111111 delete music on hold record +###################### + +if ($ADD==661111111111) + { + echo ""; + + if ( (strlen($moh_id) < 2) or ($CoNfIrM != 'YES') ) + { + echo "
MÚSICA EN ESPERA DE ENTRADA no se eliminan - Por favor, volte e verifique os dados digitados\n"; + echo "
MOH ID be at least 2 characters in length\n"; + } + else + { + $stmt="UPDATE vicidial_music_on_hold SET remove='Y' where moh_id='$moh_id';"; + $rslt=mysql_query($stmt, $link); + + $stmtA="DELETE from vicidial_music_on_hold_files where moh_id='$moh_id';"; + $rslt=mysql_query($stmtA, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|$stmtA|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='MOH', event_type='DELETE', record_id='$moh_id', event_code='ADMIN DELETE MOH', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
MÚSICA EN ESPERA SUPRESIÓN COMPLETA: $moh_id\n"; + echo "

\n"; + } + $ADD='160000000000'; # go to music on hold entry list + } + + +###################### +# ADD=671111111111 delete voicemail record +###################### + +if ($ADD==671111111111) + { + echo ""; + + if ( (strlen($voicemail_id) < 2) or ($CoNfIrM != 'YES') ) + { + echo "
Contestador no se eliminan - Por favor, volte e verifique os dados digitados\n"; + echo "
ID de correo de voz be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_voicemail where voicemail_id='$voicemail_id';"; + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT active_voicemail_server from system_settings;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $active_voicemail_server = $row[0]; + + $stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$active_voicemail_server';"; + $rslt=mysql_query($stmtA, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='VOICEMAIL', event_type='DELETE', record_id='$voicemail_id', event_code='ADMIN DELETE VOICEMAIL', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
Contestador SUPRESIÓN COMPLETA: $voicemail_id\n"; + echo "

\n"; + } + $ADD='170000000000'; # go to voicemail entry list + } + + +###################### +# ADD=6111111111111 delete conference record +###################### + +if ($ADD==6111111111111) + { + echo ""; + + if ( (strlen($conf_exten) < 2) or (strlen($server_ip) < 7) or ($CoNfIrM != 'YES') or ($LOGast_delete_phones < 1) ) + { + echo "
CONFERENCE NOT DELETED - Por favor, volte e verifique os dados digitados\n"; + echo "
Conference be at least 2 characters in length\n"; + echo "
IP do Servidor be at least 7 characters in length\n"; + } + else + { + $stmt="DELETE from conferences where conf_exten='$conf_exten' and server_ip='$server_ip' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CONFERENCES', event_type='DELETE', record_id='$conf_exten', event_code='ADMIN DELETE CONFERENCE', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
CONFERENCE DELETION COMPLETED: $conf_exten - $server_ip\n"; + echo "

\n"; + } + $ADD='1000000000000'; # go to conference list + } + + +###################### +# ADD=61111111111111 delete vicidial conference record +###################### + +if ($ADD==61111111111111) + { + echo ""; + + if ( (strlen($conf_exten) < 2) or (strlen($server_ip) < 7) or ($CoNfIrM != 'YES') or ($LOGast_delete_phones < 1) ) + { + echo "
VICIDIAL CONFERENCE NOT DELETED - Por favor, volte e verifique os dados digitados\n"; + echo "
Conference be at least 2 characters in length\n"; + echo "
IP do Servidor be at least 7 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_conferences where conf_exten='$conf_exten' and server_ip='$server_ip' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CONFERENCES', event_type='DELETE', record_id='$conf_exten', event_code='ADMIN DELETE CONFERENCE', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
VICIDIAL CONFERENCE DELETION COMPLETED: $conf_exten - $server_ip\n"; + echo "

\n"; + } + $ADD='10000000000000'; # go to vicidial conference list + } + + + + + +###################################################################################################### +###################################################################################################### +####### 3 series, record modification forms +###################################################################################################### +###################################################################################################### + + + + +###################### +# ADD=3 modify user info in the system +###################### + +if ($ADD==3) + { + if ($LOGmodify_users==1) + { + echo "
\n"; + echo ""; + + $stmt="SELECT user_id,user,pass,full_name,user_level,user_group,phone_login,phone_pass,delete_users,delete_user_groups,delete_lists,delete_campaigns,delete_ingroups,delete_remote_agents,load_leads,campaign_detail,ast_admin_access,ast_delete_phones,delete_scripts,modify_leads,hotkeys_active,change_agent_campaign,agent_choose_ingroups,closer_campaigns,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,delete_filters,alter_agent_interface_options,closer_default_blended,delete_call_times,modify_call_times,modify_users,modify_campaigns,modify_lists,modify_scripts,modify_filters,modify_ingroups,modify_usergroups,modify_remoteagents,modify_servers,view_reports,vicidial_recording_override,alter_custdata_override,qc_enabled,qc_user_level,qc_pass,qc_finish,qc_commit,add_timeclock_log,modify_timeclock_log,delete_timeclock_log,alter_custphone_override,vdc_agent_api_access,modify_inbound_dids,delete_inbound_dids,active,alert_enabled,download_lists,agent_shift_enforcement_override,manager_shift_enforcement_override,shift_override_flag,export_reports,delete_from_dnc,email,user_code,territory,allow_alerts,agent_choose_territories,custom_one,custom_two,custom_three,custom_four,custom_five from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $user_id = $row[0]; + $user = $row[1]; + $pass = $row[2]; + $full_name = $row[3]; + $user_level = $row[4]; + $user_group = $row[5]; + $phone_login = $row[6]; + $phone_pass = $row[7]; + $delete_users = $row[8]; + $delete_user_groups = $row[9]; + $delete_lists = $row[10]; + $delete_campaigns = $row[11]; + $delete_ingroups = $row[12]; + $delete_remote_agents = $row[13]; + $load_leads = $row[14]; + $campaign_detail = $row[15]; + $ast_admin_access = $row[16]; + $ast_delete_phones = $row[17]; + $delete_scripts = $row[18]; + $modify_leads = $row[19]; + $hotkeys_active = $row[20]; + $change_agent_campaign =$row[21]; + $agent_choose_ingroups =$row[22]; + $scheduled_callbacks = $row[24]; + $agentonly_callbacks = $row[25]; + $agentcall_manual = $row[26]; + $vicidial_recording = $row[27]; + $vicidial_transfers = $row[28]; + $delete_filters = $row[29]; + $alter_agent_interface_options =$row[30]; + $closer_default_blended = $row[31]; + $delete_call_times = $row[32]; + $modify_call_times = $row[33]; + $modify_users = $row[34]; + $modify_campaigns = $row[35]; + $modify_lists = $row[36]; + $modify_scripts = $row[37]; + $modify_filters = $row[38]; + $modify_ingroups = $row[39]; + $modify_usergroups = $row[40]; + $modify_remoteagents = $row[41]; + $modify_servers = $row[42]; + $view_reports = $row[43]; + $vicidial_recording_override = $row[44]; + $alter_custdata_override = $row[45]; + $qc_enabled = $row[46]; + $qc_user_level = $row[47]; + $qc_pass = $row[48]; + $qc_finish = $row[49]; + $qc_commit = $row[50]; + $add_timeclock_log = $row[51]; + $modify_timeclock_log = $row[52]; + $delete_timeclock_log = $row[53]; + $alter_custphone_override = $row[54]; + $vdc_agent_api_access = $row[55]; + $modify_inbound_dids = $row[56]; + $delete_inbound_dids = $row[57]; + $active = $row[58]; + $alert_enabled = $row[59]; + $download_lists = $row[60]; + $agent_shift_enforcement_override = $row[61]; + $manager_shift_enforcement_override = $row[62]; + $export_reports = $row[64]; + $delete_from_dnc = $row[65]; + $email = $row[66]; + $user_code = $row[67]; + $territory = $row[68]; + $allow_alerts = $row[69]; + $agent_choose_territories = $row[70]; + $user_custom_one = $row[71]; + $user_custom_two = $row[72]; + $user_custom_three = $row[73]; + $user_custom_four = $row[74]; + $user_custom_five = $row[75]; + + if ( ($user_level >= $LOGuser_level) and ($LOGuser_level < 9) ) + { + echo "
Você não tem permissão de alterar este usuário: $user\n"; + } + else + { + echo "
ALTERAR REGISTRO DE USUÁRIO: $user\n"; + if ($LOGuser_level > 8) + {echo "\n";} + else + { + if ($LOGalter_agent_interface == "1") + {echo "\n";} + else + {echo "\n";} + } + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + if ($SSuser_territories_active > 0) + { + $stmt="SELECT vut.territory,vt.territory_description from vicidial_user_territories vut,vicidial_territories vt where user='$user' and vut.territory=vt.territory;"; + $rslt=mysql_query($stmt, $link); + $Uterrs_to_print = mysql_num_rows($rslt); + $Uterrs_list=''; + $o=0; + while ($Uterrs_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $Uterrs_list .= "$rowx[0] - $rowx[1]
\n"; + $o++; + } + echo "\n"; + } + + if ( ($LOGuser_level > 8) or ($LOGalter_agent_interface == "1") ) + { + echo "\n"; + echo "\n"; + if ($SSuser_territories_active > 0) + { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + if ($SSoutbound_autodial_active > 0) + { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + if ($SSqc_features_active > 0) + { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + } + if ($LOGuser_level > 8) + { + echo "\n"; + + #9BB9FB + #B9CBFD + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + + if ($SSoutbound_autodial_active > 0) + { + echo "\n"; + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + } + echo "\n"; + echo "
Número do usuário: $user$NWB#vicidial_users-user$NWE
Senha: $NWB#vicidial_users-pass$NWE
Nome Completo: $NWB#vicidial_users-full_name$NWE
Nível do Usuário: $NWB#vicidial_users-user_level$NWE
Grupo do Usuário: $NWB#vicidial_users-user_group$NWE
Login do Ramal: $NWB#vicidial_users-phone_login$NWE
Senha do Ramal: $NWB#vicidial_users-phone_pass$NWE
Ativo: $NWB#vicidial_users-active$NWE
Email:$NWB#vicidial_users-optional$NWE
Usuário Code: $NWB#vicidial_users-optional$NWE
Main Territorio: $NWB#vicidial_users-optional$NWE
Territorios de usuario: $Uterrs_list
OPÇÕES DA INTERFACE DO AGENTE:
Agente pode escolher Grupos de Entrada: $NWB#vicidial_users-agent_choose_ingroups$NWE
Agente Elija territorios: $NWB#vicidial_users-agent_choose_territories$NWE
Atalhos Ativos: $NWB#vicidial_users-hotkeys_active$NWE
Agendamento de Chamadas: $NWB#vicidial_users-scheduled_callbacks$NWE
Agendamento de Chamadas com Fidelização: $NWB#vicidial_users-agentonly_callbacks$NWE
Agente Manual: $NWB#vicidial_users-agentcall_manual$NWE
Gravação do Vicidial: $NWB#vicidial_users-vicidial_recording$NWE
Transferências do Vicidial: $NWB#vicidial_users-vicidial_transfers$NWE
Finalizador Padrão como Mesclado: $NWB#vicidial_users-closer_default_blended$NWE
Sobrepor Conf. de Gravação no VICIDIAL:$NWB#vicidial_users-vicidial_recording_override$NWE
Sobrepor Permissão de Alteração$NWB#vicidial_users-alter_custdata_override$NWE
Sobrepor Permissão de Alter. de Telefone:$NWB#vicidial_users-alter_custphone_override$NWE
Sobrepor Controle de Turno do Agente: $NWB#vicidial_users-agent_shift_enforcement_override$NWE
Alerta Ativo: $alert_enabled $NWB#vicidial_users-alert_enabled$NWE
Permitir Alertas: $NWB#vicidial_users-allow_alerts$NWE
Rankings da Campanha:$NWB#vicidial_users-campaign_ranks$NWE
\n"; + echo "\n"; + echo "$RANKcampaigns_list"; + echo "
\n"; + echo "
Grupos de Entrada: $NWB#vicidial_users-closer_campaigns$NWE
\n"; + echo "\n"; + echo "$RANKgroups_list"; + echo "
\n"; + echo "
Custom 1: $NWB#vicidial_users-custom_one$NWE
Custom 2: $NWB#vicidial_users-custom_two$NWE
Custom 3: $NWB#vicidial_users-custom_three$NWE
Custom 4: $NWB#vicidial_users-custom_four$NWE
Custom 5: $NWB#vicidial_users-custom_five$NWE
CQ Ativado:$NWB#vicidial_users-qc_enabled$NWE
Nível de Usuário CQ:$NWB#vicidial_users-qc_user_level$NWE
Passou no CQ:$NWB#vicidial_users-qc_pass$NWE
Fim do CQ:$NWB#vicidial_users-qc_finish$NWE
Confirmado CQ:$NWB#vicidial_users-qc_commit$NWE
OPÇÕES DA INTERFACE ADMIN:
Mostrar Relatórios: $NWB#vicidial_users-view_reports$NWE
Alterar opções da Interface do Agente:$NWB#vicidial_users-alter_agent_interface_options$NWE
Alterar Usuários: $NWB#vicidial_users-modify_sections$NWE
Alterar a Campanha do Agente: $NWB#vicidial_users-change_agent_campaign$NWE
Apagar Usuários: $NWB#vicidial_users-delete_users$NWE
Alterar Grupos de Usuário: $NWB#vicidial_users-modify_sections$NWE
Apagar Grupos de Usuários: $NWB#vicidial_users-delete_user_groups$NWE
Alterar Listas: $NWB#vicidial_users-modify_sections$NWE
Apagar Listas: $NWB#vicidial_users-delete_lists$NWE
Carregar Registros: $NWB#vicidial_users-load_leads$NWE
Alterar Registros: $NWB#vicidial_users-modify_leads$NWE
Download de Listas: $NWB#vicidial_users-modify_leads$NWE
Exportar Relatórios: $NWB#vicidial_users-export_reports$NWE
Remover da Lista de Bloqueio: $NWB#vicidial_users-delete_from_dnc$NWE
Alterar Campanhas: $NWB#vicidial_users-modify_sections$NWE
Detalhes da Campanha: $NWB#vicidial_users-campaign_detail$NWE
Apagar Campanhas: $NWB#vicidial_users-delete_campaigns$NWE
Alterar Grupos de Ent.: $NWB#vicidial_users-modify_sections$NWE
Apagar Grupos de Entrada: $NWB#vicidial_users-delete_ingroups$NWE
Alterar DDRs:$NWB#vicidial_users-modify_sections$NWE
Remover DDRs:$NWB#vicidial_users-delete_ingroups$NWE
Alterar Agentes Remotos: $NWB#vicidial_users-modify_sections$NWE
Apagar Usuários Remotos: $NWB#vicidial_users-delete_remote_agents$NWE
Alterar Scripts: $NWB#vicidial_users-modify_sections$NWE
Apagar Scriptss: $NWB#vicidial_users-delete_scripts$NWE
Alterar Filtros: $NWB#vicidial_users-modify_sections$NWE
Apagar Filtros: $NWB#vicidial_users-delete_filters$NWE
Acesso Admin ao AGC: $NWB#vicidial_users-ast_admin_access$NWE
Apagar Ramais do AGC: $NWB#vicidial_users-ast_delete_phones$NWE
Alterar um Hor. de Cham.s: $NWB#vicidial_users-modify_call_times$NWE
RemoverHorários de Cham.: $NWB#vicidial_users-delete_call_times$NWE
Alterar Servidor: $NWB#vicidial_users-modify_sections$NWE
Agente para Acesso ao API:$NWB#vicidial_users-vdc_agent_api_access$NWE
Incluir Registro de Ponto: $NWB#vicidial_users-add_timeclock_log$NWE
Alterar Registro de Log do Ponto: $NWB#vicidial_users-modify_timeclock_log$NWE
Remover Registro de Log do Ponto: $NWB#vicidial_users-delete_timeclock_log$NWE
Sobrepor Controle de Turno do Gerente: $NWB#vicidial_users-manager_shift_enforcement_override$NWE
\n"; + + if ($LOGdelete_users > 0) + { + echo "

APAGAR ESTE USUÁRIO\n"; + } + echo "

Clique aqui para a planilha de tempo do usuário\n"; + echo "

Clique aqui para o status do usuário\n"; + echo "

Clique aqui para ver o status do usuário\n"; + echo "

Clique aqui para um relatório de status de vários dias\n"; + echo "

Clique aqui para os registros de Chamada Agendada do usuário\n"; + if ($LOGuser_level >= 9) + { + echo "

Clique aqui para ver alterações Admin para este registro
\n"; + } + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=31 modify campaign info in the system - Detail view +###################### + +if ( ($LOGcampaign_detail < 1) and ($ADD==31) ) {$ADD=34;} # send to Básico if not allowed + +if ( ($ADD==31) and ( (!eregi("$campaign_id",$LOGallowed_campaigns)) and (!eregi("ALL-CAMPANHAS",$LOGallowed_campaigns)) ) ) + {$ADD=30;} # send to not allowed screen if not in vicidial_user_groups allowed_campaigns list + +if ($ADD==31) + { + if ($LOGmodify_campaigns==1) + { + if ($stage=='show_dialable') + { + $stmt="UPDATE vicidial_campaigns set display_dialable_count='Y' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + } + if ($stage=='hide_dialable') + { + $stmt="UPDATE vicidial_campaigns set display_dialable_count='N' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + } + + $stmt="SELECT enable_vtiger_integration,vtiger_url from system_settings;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $enable_vtiger_integration_LU = $row[0]; + $vtiger_url_LU = $row[1]; + + $stmt="SELECT campaign_id,campaign_name,active,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,park_ext,park_file_name,web_form_address,allow_closers,hopper_level,auto_dial_level,next_agent_call,local_call_time,voicemail_ext,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,amd_send_to_vmx,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,lead_filter_id,drop_call_seconds,drop_action,safe_harbor_exten,display_dialable_count,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc,allcalls_delay,omit_phone_code,dial_method,available_only_ratio_tally,adaptive_dropped_percentage,adaptive_maximum_level,adaptive_latest_server_time,adaptive_intensity,adaptive_dl_diff_target,concurrent_transfers,auto_alt_dial,auto_alt_dial_statuses,agent_pause_codes_active,campaign_description,campaign_changedate,campaign_stats_refresh,campaign_logindate,dial_statuses,disable_alter_custdata,no_hopper_leads_logins,list_order_mix,campaign_allow_inbound,manual_dial_list_id,default_xfer_group,xfer_groups,queue_priority,drop_inbound_group,qc_enabled,qc_statuses,qc_lists,qc_shift_id,qc_get_record_launch,qc_show_recording,qc_web_form_address,qc_script,survey_first_audio_file,survey_dtmf_digits,survey_ni_digit,survey_opt_in_audio_file,survey_ni_audio_file,survey_method,survey_no_response_action,survey_ni_status,survey_response_digit_map,survey_xfer_exten,survey_camp_record_dir,disable_alter_custphone,display_queue_count,manual_dial_filter,agent_clipboard_copy,agent_extended_alt_dial,use_campaign_dnc,three_way_call_cid,three_way_dial_prefix,web_form_target,vtiger_search_category,vtiger_create_call_record,vtiger_create_lead_record,vtiger_screen_login,cpd_amd_action,agent_allow_group_alias,default_group_alias,vtiger_search_dead,vtiger_status_call,survey_third_digit,survey_third_audio_file,survey_third_status,survey_third_exten,survey_fourth_digit,survey_fourth_audio_file,survey_fourth_status,survey_fourth_exten,drop_lockout_time,quick_transfer_button,prepopulate_transfer_preset,drop_rate_group,view_calls_in_queue,view_calls_in_queue_launch,grab_calls_in_queue,call_requeue_button,pause_after_each_call,no_hopper_dialing,agent_dial_owner_only,agent_display_dialable_leads,web_form_address_two,waitforsilence_options,agent_select_territories,campaign_calldate,crm_popup_login,crm_login_address,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number from vicidial_campaigns where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $campaign_name = $row[1]; + $dial_status_a = $row[3]; + $dial_status_b = $row[4]; + $dial_status_c = $row[5]; + $dial_status_d = $row[6]; + $dial_status_e = $row[7]; + $lead_order = $row[8]; + $web_form_address = stripslashes($row[11]); + $allow_closers = $row[12]; + $hopper_level = $row[13]; + $auto_dial_level = $row[14]; + $next_agent_call = $row[15]; + $local_call_time = $row[16]; + $voicemail_ext = $row[17]; + $dial_timeout = $row[18]; + $dial_prefix = $row[19]; + $campaign_cid = $row[20]; + $campaign_vdad_exten = $row[21]; + $campaign_rec_exten = $row[22]; + $campaign_recording = $row[23]; + $campaign_rec_filename = $row[24]; + $script_id = $row[25]; + $get_call_launch = $row[26]; + $am_message_exten = $row[27]; + $amd_send_to_vmx = $row[28]; + $xferconf_a_dtmf = $row[29]; + $xferconf_a_number = $row[30]; + $xferconf_b_dtmf = $row[31]; + $xferconf_b_number = $row[32]; + $alt_number_dialing = $row[33]; + $scheduled_callbacks = $row[34]; + $lead_filter_id = $row[35]; + if ($lead_filter_id=='') {$lead_filter_id='NONE';} + $drop_call_seconds = $row[36]; + $drop_action = $row[37]; + $safe_harbor_exten = $row[38]; + $display_dialable_count = $row[39]; + $wrapup_seconds = $row[40]; + $wrapup_message = $row[41]; + # $closer_campaigns = $row[42]; + $use_internal_dnc = $row[43]; + $allcalls_delay = $row[44]; + $omit_phone_code = $row[45]; + $dial_method = $row[46]; + $available_only_ratio_tally = $row[47]; + $adaptive_dropped_percentage = $row[48]; + $adaptive_maximum_level = $row[49]; + $adaptive_latest_server_time = $row[50]; + $adaptive_intensity = $row[51]; + $adaptive_dl_diff_target = $row[52]; + $concurrent_transfers = $row[53]; + $auto_alt_dial = $row[54]; + $auto_alt_dial_statuses = $row[55]; + $agent_pause_codes_active = $row[56]; + $campaign_description = $row[57]; + $campaign_changedate = $row[58]; + $campaign_stats_refresh = $row[59]; + $campaign_logindate = $row[60]; + $dial_statuses = $row[61]; + $disable_alter_custdata = $row[62]; + $no_hopper_leads_logins = $row[63]; + $list_order_mix = $row[64]; + $campaign_allow_inbound = $row[65]; + $manual_dial_list_id = $row[66]; + $default_xfer_group = $row[67]; + $queue_priority = $row[69]; + $drop_inbound_group = $row[70]; + $qc_enabled = $row[71]; + $qc_statuses = $row[72]; + $qc_lists = $row[73]; + $qc_shift_id = $row[74]; + $qc_get_record_launch = $row[75]; + $qc_show_recording = $row[76]; + $qc_web_form_address = stripslashes($row[77]); + $qc_script = $row[78]; + $survey_first_audio_file = $row[79]; + $survey_dtmf_digits = $row[80]; + $survey_ni_digit = $row[81]; + $survey_opt_in_audio_file = $row[82]; + $survey_ni_audio_file = $row[83]; + $survey_method = $row[84]; + $survey_no_response_action = $row[85]; + $survey_ni_status = $row[86]; + $survey_response_digit_map = $row[87]; + $survey_xfer_exten = $row[88]; + $survey_camp_record_dir = $row[89]; + $disable_alter_custphone = $row[90]; + $display_queue_count = $row[91]; + $manual_dial_filter = $row[92]; + $agent_clipboard_copy = $row[93]; + $agent_extended_alt_dial = $row[94]; + $use_campaign_dnc = $row[95]; + $three_way_call_cid = $row[96]; + $three_way_dial_prefix = $row[97]; + $web_form_target = $row[98]; + $vtiger_search_category = $row[99]; + $vtiger_create_call_record = $row[100]; + $vtiger_create_lead_record = $row[101]; + $vtiger_screen_login = $row[102]; + $cpd_amd_action = $row[103]; + $agent_allow_group_alias = $row[104]; + $default_group_alias = $row[105]; + $vtiger_search_dead = $row[106]; + $vtiger_status_call = $row[107]; + $survey_third_digit = $row[108]; + $survey_third_audio_file = $row[109]; + $survey_third_status = $row[110]; + $survey_third_exten = $row[111]; + $survey_fourth_digit = $row[112]; + $survey_fourth_audio_file = $row[113]; + $survey_fourth_status = $row[114]; + $survey_fourth_exten = $row[115]; + $drop_lockout_time = $row[116]; + $quick_transfer_button = $row[117]; + $prepopulate_transfer_preset = $row[118]; + $drop_rate_group = $row[119]; + $view_calls_in_queue = $row[120]; + $view_calls_in_queue_launch = $row[121]; + $grab_calls_in_queue = $row[122]; + $call_requeue_button = $row[123]; + $pause_after_each_call = $row[124]; + $no_hopper_dialing = $row[125]; + $agent_dial_owner_only = $row[126]; + $agent_display_dialable_leads = $row[127]; + $web_form_address_two = $row[128]; + $waitforsilence_options = $row[129]; + $agent_select_territories = $row[130]; + $campaign_calldate = $row[131]; + $crm_popup_login = $row[132]; + $crm_login_address = $row[133]; + $timer_action = $row[134]; + $timer_action_message = $row[135]; + $timer_action_seconds = $row[136]; + $start_call_url = $row[137]; + $dispo_call_url = $row[138]; + $xferconf_c_number = $row[139]; + $xferconf_d_number = $row[140]; + $xferconf_e_number = $row[141]; + + if (ereg("DISABLED",$list_order_mix)) + {$DEFlistDISABLE = ''; $DEFstatusDISABLED=0;} + else + {$DEFlistDISABLE = 'disabled'; $DEFstatusDISABLED=1;} + + $stmt="SELECT count(*) from vicidial_campaigns_list_mix where campaign_id='$campaign_id' and status='ACTIVE'"; + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0] < 1) + { + $mixes_list="\n"; + $mixname_list["DISABLED"] = "DISABLED"; + } + else + { + ##### get list_mix listings for dynamic pulldown + $stmt="SELECT vcl_id,vcl_name from vicidial_campaigns_list_mix where campaign_id='$campaign_id' and status='ACTIVE' limit 1"; + $rslt=mysql_query($stmt, $link); + $mixes_to_print = mysql_num_rows($rslt); + $mixes_list="\n"; + + $o=0; + while ($mixes_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $mixes_list .= "\n"; + $mixname_list["ACTIVE"] = "$rowx[0] - $rowx[1]"; + $o++; + } + } + + $dial_statuses = preg_replace("/ -$/","",$dial_statuses); + $Dstatuses = explode(" ", $dial_statuses); + $Ds_to_print = (count($Dstatuses) -1); + + $qc_statuses = preg_replace("/^ | -$/","",$qc_statuses); + $QCstatuses = explode(" ", $qc_statuses); + $QCs_to_print = (count($QCstatuses) -0); + + $qc_lists = preg_replace("/^ | -$/","",$qc_lists); + $QClists = explode(" ", $qc_lists); + $QCL_to_print = (count($QClists) -0); + + ##### get status listings for dynamic pulldown + $stmt="SELECT status,status_name,selectable,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable from vicidial_statuses order by status"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + $statuses_list=''; + $dial_statuses_list=''; + $qc_statuses_list=''; + $survey_ni_status_list=''; + $o=0; + while ($statuses_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $statuses_list .= "\n"; + if ($rowx[0] != 'CBHOLD') + { + $dial_statuses_list .= "\n"; + if ($survey_ni_status == $rowx[0]) + { + $survey_ni_status_list .= "\n"; + } + else + { + $survey_ni_status_list .= "\n"; + } + } + $statname_list["$rowx[0]"] = "$rowx[1]"; + $LRstatuses_list .= "\n"; + if (eregi("Y",$rowx[2])) + {$HKstatuses_list .= "\n";} + + $qc_statuses_list .= " $o) + { + $rowx=mysql_fetch_row($rslt); + $statuses_list .= "\n"; + if ($rowx[0] != 'CBHOLD') {$dial_statuses_list .= "\n";} + $statname_list["$rowx[0]"] = "$rowx[1]"; + $LRstatuses_list .= "\n"; + if (eregi("Y",$rowx[2])) + {$HKstatuses_list .= "\n";} + + $qc_statuses_list .= " $o) + { + $rowx=mysql_fetch_row($rslt); + $Dgroups_menu .= "\n"; + $o++; + } + if ($Dgroups_selected < 1) + {$Dgroups_menu .= "\n";} + else + {$Dgroups_menu .= "\n";} + + + ##### get in-groups listings for dynamic transfer group pulldown list menu + $stmt="SELECT group_id,group_name from vicidial_inbound_groups $xfer_groupsSQL order by group_id"; + $rslt=mysql_query($stmt, $link); + $Xgroups_to_print = mysql_num_rows($rslt); + $Xgroups_menu=''; + $Xgroups_selected=0; + $o=0; + while ($Xgroups_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $Xgroups_menu .= "\n"; + $o++; + } + if ($Xgroups_selected < 1) + {$Xgroups_menu .= "\n";} + else + {$Xgroups_menu .= "\n";} + + + if ($SUB<1) {$camp_detail_color=$subcamp_color;} + else {$camp_detail_color=$campaigns_color;} + if ($SUB==22) {$camp_statuses_color=$subcamp_color;} + else {$camp_statuses_color=$campaigns_color;} + if ($SUB==23) {$camp_hotkeys_color=$subcamp_color;} + else {$camp_hotkeys_color=$campaigns_color;} + if ($SUB==25) {$camp_recycle_color=$subcamp_color;} + else {$camp_recycle_color=$campaigns_color;} + if ($SUB==26) {$camp_autoalt_color=$subcamp_color;} + else {$camp_autoalt_color=$campaigns_color;} + if ($SUB==27) {$camp_pause_color=$subcamp_color;} + else {$camp_pause_color=$campaigns_color;} + if ($SUB==28) {$camp_qc_color=$subcamp_color;} + else {$camp_qc_color=$campaigns_color;} + if ($SUB==29) {$camp_listmix_color=$subcamp_color;} + else {$camp_listmix_color=$campaigns_color;} + if ($SUB=='20A') {$camp_survey_color=$subcamp_color;} + else {$camp_survey_color=$campaigns_color;} + echo "\n"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + if ($SSoutbound_autodial_active > 0) + { + echo ""; + echo ""; + echo ""; + echo ""; + } + echo ""; + if ($SSqc_features_active > 0) + { + echo ""; + } + if ($SSoutbound_autodial_active < 1) + { + echo "\n"; + } + echo "\n"; + echo "
$row[0]: Básico Detalhes StatusAtalhosLead RecyclingDiscar Num. Alt.Mesclagem de ListaPesquisaCódigos de PausaQC Tempo Real
\n"; + + echo "
\n"; + echo ""; + + echo "
\n"; + + if ($SUB < 1) + { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + if ($SSenable_second_webform > 0) + { + echo "\n"; + } + echo "\n"; + echo "\n"; + + if ($SSoutbound_autodial_active > 0) + { + echo "\n"; + + $o=0; + while ($Ds_to_print > $o) + { + $o++; + $Dstatus = $Dstatuses[$o]; + + echo "\n"; + } + else + { + echo "$Dstatus - $statname_list[$Dstatus]         \n"; + echo "REMOVER\n"; + } + } + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + + + echo "\n"; + + echo "\n"; + + echo "\n"; + + + + echo "\n"; + + + + echo "\n"; + } + + echo "\n"; + + echo "\n"; + + if ($SSoutbound_autodial_active > 0) + { + echo "\n"; + } + echo "\n"; + + echo "\n"; + + echo "\n"; + + if ($SSoutbound_autodial_active > 0) + { + echo "\n"; + } + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + $eswHTML=''; + if ($SSenable_second_webform > 0) + {$eswHTML = '';} + echo "\n"; + + echo "\n"; + + echo "\n"; + + if ($SSoutbound_autodial_active > 0) + { + echo "\n"; + + echo "\n"; + } + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + if ($SSoutbound_autodial_active > 0) + { + echo "\n"; + } + echo "\n"; + + if ($SSoutbound_autodial_active > 0) + { + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + } + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + echo "\n"; + + if ($SSoutbound_autodial_active > 0) + { + echo "\n"; + + echo "\n"; + + echo "\n"; + + if ($SSuser_territories_active > 0) + { + echo "\n"; + } + echo "\n"; + } + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + if ($SSoutbound_autodial_active > 0) + { + echo "\n"; + } + echo "\n"; + + echo "\n"; + + echo "\n"; + + if ($agent_allow_group_alias == 'Y') + { + ##### get groups_alias listings for dynamic default group alias pulldown list menu + $stmt="SELECT group_alias_id,group_alias_name from groups_alias where active='Y' order by group_alias_id"; + $rslt=mysql_query($stmt, $link); + $group_alias_to_print = mysql_num_rows($rslt); + $group_alias_menu=''; + $group_alias_selected=0; + $o=0; + while ($group_alias_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $group_alias_menu .= "\n"; + $o++; + } + + echo "\n"; + } + + if ($SSenable_vtiger_integration > 0) + { + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + } + else + { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + if ($campaign_allow_inbound == 'Y') + { + echo "\n"; + } + + echo "\n"; + + if ($allow_closers == 'Y') + { + echo "\n"; + } + + echo "\n"; + echo "
ID da Campanha: $row[0]$NWB#vicidial_campaigns-campaign_id$NWE
Nome da Campanha: $NWB#vicidial_campaigns-campaign_name$NWE
Descrição da Campanha: $NWB#vicidial_campaigns-campaign_description$NWE
Campanha Data da Alter.: $campaign_changedate   $NWB#vicidial_campaigns-campaign_changedate$NWE
Campanha Data do Login: $campaign_logindate   $NWB#vicidial_campaigns-campaign_logindate$NWE
Campanha Call Date: $campaign_calldate   $NWB#vicidial_campaigns-campaign_calldate$NWE
Ativo: $NWB#vicidial_campaigns-active$NWE
Extensão de Estacionamento: - Filename: $NWB#vicidial_campaigns-park_ext$NWE
Formulário Web: $NWB#vicidial_campaigns-web_form_address$NWE
Formulário Web Two: $NWB#vicidial_campaigns-web_form_address$NWE
Target do Form. Web: $NWB#vicidial_campaigns-web_form_target$NWE
Permitir Finalizadores (Closers): $NWB#vicidial_campaigns-allow_closers$NWE
Permitir Entrantes e Blended:$NWB#vicidial_campaigns-campaign_allow_inbound$NWE
Status de Discagem$o: \n"; + + if ($DEFstatusDISABLED > 0) + { + echo "$Dstatus - $statname_list[$Dstatus]         \n"; + echo "REMOVE
Add A Dial Status:   \n"; + echo "     $NWB#vicidial_campaigns-dial_status$NWE
Ordem da Lista: $NWB#vicidial_campaigns-lead_order$NWE
Mesclagem de Lista: $NWB#vicidial_campaigns-list_order_mix$NWE
Filtro de registros: $NWB#vicidial_campaigns-lead_filter_id$NWE
Tiempo de caída de bloqueo: $NWB#vicidial_campaigns-drop_lockout_time$NWE
Nível do Hopper: $NWB#vicidial_campaigns-hopper_level$NWE
Forçar Reset do Hopper: $NWB#vicidial_campaigns-force_reset_hopper$NWE
Método de Discagem: $NWB#vicidial_campaigns-dial_method$NWE
Nível de Discagem Automática: (0 = off)$NWB#vicidial_campaigns-auto_dial_level$NWE       SOBREPOR ADAPT
Somente Lista Autom.: $NWB#vicidial_campaigns-available_only_ratio_tally$NWE
Limite de Derrubadas (drop): % $NWB#vicidial_campaigns-adaptive_dropped_percentage$NWE
Nível Máximo de Discagem: number only $NWB#vicidial_campaigns-adaptive_maximum_level$NWE
Horário Final do Servidor: 4 somente dígitos $NWB#vicidial_campaigns-adaptive_latest_server_time$NWE
Modificador de Intensidade : $NWB#vicidial_campaigns-adaptive_intensity$NWE
Alvo de Diferença de Nível: $NWB#vicidial_campaigns-adaptive_dl_diff_target$NWE
Transferências Simultâneas: $NWB#vicidial_campaigns-concurrent_transfers$NWE
Prioridade da Fila: $NWB#vicidial_campaigns-queue_priority$NWE
Varias campañas Drop Rate Grupo: $NWB#vicidial_campaigns-drop_rate_group$NWE
Auto Discar Alternativo: $NWB#vicidial_campaigns-auto_alt_dial$NWE
Próximo Agente a chamar: $NWB#vicidial_campaigns-next_agent_call$NWE
Horário Local da Chamada: $NWB#vicidial_campaigns-local_call_time$NWE
Tempo de Espera da Discagem: in seconds$NWB#vicidial_campaigns-dial_timeout$NWE
Prefixo de Discagem: for 91NXXNXXXXXX value would be 9, for no dial prefix use X$NWB#vicidial_campaigns-dial_prefix$NWE
Omitir Código de Telefone: $NWB#vicidial_campaigns-omit_phone_code$NWE
CallerID da Campanha: $NWB#vicidial_campaigns-campaign_cid$NWE\n"; + $stmt="SELECT count(*) from vicidial_lists where campaign_id='$campaign_id' and campaign_cid_override != '' and active='Y';"; + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0] > 0) + {echo " LIST OVERRIDE ACTIVE";} + echo "
Extensão VDAD da Campanha: $NWB#vicidial_campaigns-campaign_vdad_exten$NWE
Extensão de Gravação da Campanha: $NWB#vicidial_campaigns-campaign_rec_exten$NWE
Gravação da Campanha: $NWB#vicidial_campaigns-campaign_recording$NWE
Nome do Arquivo de Gravação da Campanha: $NWB#vicidial_campaigns-campaign_rec_filename$NWE
Atraso de Gravação: in seconds$NWB#vicidial_campaigns-allcalls_delay$NWE
Script: $NWB#vicidial_campaigns-campaign_script$NWE\n"; + $stmt="SELECT count(*) from vicidial_lists where campaign_id='$campaign_id' and agent_script_override != '' and active='Y';"; + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0] > 0) + {echo " LIST OVERRIDE ACTIVE";} + echo "
Pegar lançamento da chamada: $NWB#vicidial_campaigns-get_call_launch$NWE
Mensagem na Secretária Eletrônica: audio chooser $NWB#vicidial_campaigns-am_message_exten$NWE\n"; + $stmt="SELECT count(*) from vicidial_lists where campaign_id='$campaign_id' and am_message_exten_override != '' and active='Y';"; + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0] > 0) + {echo " LIST OVERRIDE ACTIVE";} + echo "
Opciones WaitForSilence: $NWB#vicidial_campaigns-waitforsilence_options$NWE
Extensão para enviar AMD: $NWB#vicidial_campaigns-amd_send_to_vmx$NWE
Ação CPD AMD: $NWB#vicidial_campaigns-cpd_amd_action$NWE
Transfer-Conf DTMF 1: $NWB#vicidial_campaigns-xferconf_a_dtmf$NWE
Número Transfer-Conf 1: $NWB#vicidial_campaigns-xferconf_a_dtmf$NWE
Transfer-Conf DTMF 2: $NWB#vicidial_campaigns-xferconf_a_dtmf$NWE
Número Transfer-Conf 2: $NWB#vicidial_campaigns-xferconf_a_dtmf$NWE
Número Transfer-Conf 3: $NWB#vicidial_campaigns-xferconf_a_dtmf$NWE
Número Transfer-Conf 4: $NWB#vicidial_campaigns-xferconf_a_dtmf$NWE
Número Transfer-Conf 5: $NWB#vicidial_campaigns-xferconf_a_dtmf$NWE
Rápida transferencia Button: $NWB#vicidial_campaigns-quick_transfer_button$NWE
Transferencia de rellenar previamente Preset: $NWB#vicidial_campaigns-prepopulate_transfer_preset$NWE
Temporizador de Acción de: $NWB#vicidial_campaigns-timer_action$NWE
Temporizador de mensaje de acción: $NWB#vicidial_campaigns-timer_action_message$NWE
Temporizador Segundos Acción: $NWB#vicidial_campaigns-timer_action_seconds$NWE
Discagem para número alternativo: $NWB#vicidial_campaigns-alt_number_dialing$NWE
Agendamento de Chamadas: $NWB#vicidial_campaigns-scheduled_callbacks$NWE
Tempo até derrubar(DROP): $NWB#vicidial_campaigns-drop_call_seconds$NWE
Ação de Drop:$NWB#vicidial_campaigns-drop_action$NWE
Extensão do Porto Seguro: $NWB#vicidial_campaigns-safe_harbor_exten$NWE
Correio de Voz: voicemail chooser$NWB#vicidial_campaigns-voicemail_ext$NWE
Grupo de Transferência de Drop:$NWB#vicidial_campaigns-drop_inbound_group$NWE\n"; + $stmt="SELECT count(*) from vicidial_lists where campaign_id='$campaign_id' and drop_inbound_group_override != '' and active='Y';"; + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0] > 0) + {echo " LIST OVERRIDE ACTIVE";} + echo "
Tempo de pós atendimento: $NWB#vicidial_campaigns-wrapup_seconds$NWE
Mensagem de pós atendimento: $NWB#vicidial_campaigns-wrapup_message$NWE
Usar lista de bloqueio interna: $NWB#vicidial_campaigns-use_internal_dnc$NWE
Usar Lista de Bloqueio: $NWB#vicidial_campaigns-use_campaign_dnc$NWE
AgentCódigos de PausaAtivo: $NWB#vicidial_campaigns-agent_pause_codes_active$NWE
Campanha Stats Refresh: $NWB#vicidial_campaigns-campaign_stats_refresh$NWE
Desabilitar Alteração de Dados do Cliente:$NWB#vicidial_campaigns-disable_alter_custdata$NWE
Desab. Alterar Telefone do Cliente :$NWB#vicidial_campaigns-disable_alter_custphone$NWE
Permitir Logar Sem Registros no Hopper: $NWB#vicidial_campaigns-no_hopper_leads_logins$NWE
N marcado Hopper: $NWB#vicidial_campaigns-no_hopper_dialing$NWE
Único propietario de marcado: $NWB#vicidial_campaigns-agent_dial_owner_only$NWE
Agente Seleccione territorios: $NWB#vicidial_campaigns-agent_select_territories$NWE
Agente de pantalla Dialable Leads: $NWB#vicidial_campaigns-agent_display_dialable_leads$NWE
Mostrar Clientes em Espera ao Agente:$NWB#vicidial_campaigns-display_queue_count$NWE
Agente Pide Ver en cola: $NWB#vicidial_campaigns-view_calls_in_queue$NWE
Ver las llamadas en cola de lanzamiento: $NWB#vicidial_campaigns-view_calls_in_queue_launch$NWE
Agente Pide Agarre en cola: $NWB#vicidial_campaigns-grab_calls_in_queue$NWE
Agente de Call Re-Cola Button: $NWB#vicidial_campaigns-call_requeue_button$NWE
Agente de pausa después de cada llamada: $NWB#vicidial_campaigns-pause_after_each_call$NWE
ID da Lista Manual :$NWB#vicidial_campaigns-manual_dial_list_id$NWE
Filtro de Discagem Manual:$NWB#vicidial_campaigns-manual_dial_filter$NWE
Cópia p/ Área de Transf. do Agente: $NWB#vicidial_campaigns-agent_clipboard_copy$NWE
Discagem Extendida na tela do Agente : $NWB#vicidial_campaigns-agent_extended_alt_dial$NWE
CallerID de Chamada a 3: $NWB#vicidial_campaigns-three_way_call_cid$NWE
Prefixo para chamadas a 3: $NWB#vicidial_campaigns-three_way_dial_prefix$NWE
Alias de Grupo Permitido: $NWB#vicidial_campaigns-agent_allow_group_alias$NWE
Alias de Grupo Padrão: $NWB#vicidial_campaigns-default_group_alias$NWE
Categoria de Pesquisa Vtiger: $NWB#vicidial_campaigns-vtiger_search_category$NWE
Pesquisar contas Mortas no Vtiger: $NWB#vicidial_campaigns-vtiger_search_dead$NWE
Criar Registro de Chamada no Vtiger: $NWB#vicidial_campaigns-vtiger_create_call_record$NWE
Criar Registro de Tel. no Vtiger: $NWB#vicidial_campaigns-vtiger_create_lead_record$NWE
Status da Chamada no Vtiger: $NWB#vicidial_campaigns-vtiger_status_call$NWE
Tela de Login do Vtiger: $NWB#vicidial_campaigns-vtiger_screen_login$NWE
CRM Popup Login: $NWB#vicidial_campaigns-crm_popup_login$NWE
CRM Dirección Popup: $NWB#vicidial_campaigns-crm_login_address$NWE
Iniciar llamada URL: $NWB#vicidial_campaigns-start_call_url$NWE
Dispo Call URL: $NWB#vicidial_campaigns-dispo_call_url$NWE
Grupos De entrada Permitidos:
"; + echo " $NWB#vicidial_campaigns-closer_campaigns$NWE
\n"; + echo "$groups_list"; + echo "
Grupo de Transferência Padrão:$NWB#vicidial_campaigns-default_xfer_group$NWE
Grupos de Transferência Permitidos:
"; + echo " $NWB#vicidial_campaigns-xfer_groups$NWE
\n"; + echo "$XFERgroups_list"; + echo "
\n"; + + echo "
\n"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + if ($SSoutbound_autodial_active > 0) + { + echo "
LISTAS DESTA CAMPANHA:   $NWB#vicidial_campaign_lists$NWE\n"; + + echo "
\n"; + echo ""; + + $LISTlink='stage=LISTIDDOWN'; + $TALLYlink='stage=TALLYDOWN'; + $ACTIVElink='stage=ACTIVEDOWN'; + $CAMPANHAlink='stage=CAMPANHADOWN'; + $CALLDATElink='stage=CALLDATEDOWN'; + $SQLorder='order by list_id'; + if (eregi("LISTIDUP",$stage)) {$SQLorder='order by list_id asc'; $LISTlink='stage=LISTIDDOWN';} + if (eregi("LISTIDDOWN",$stage)) {$SQLorder='order by list_id desc'; $LISTlink='stage=LISTIDUP';} + if (eregi("TALLYUP",$stage)) {$SQLorder='order by tally asc'; $TALLYlink='stage=TALLYDOWN';} + if (eregi("TALLYDOWN",$stage)) {$SQLorder='order by tally desc'; $TALLYlink='stage=TALLYUP';} + if (eregi("ACTIVEUP",$stage)) {$SQLorder='order by active asc'; $ACTIVElink='stage=ACTIVEDOWN';} + if (eregi("ACTIVEDOWN",$stage)) {$SQLorder='order by active desc'; $ACTIVElink='stage=ACTIVEUP';} + if (eregi("CAMPANHAUP",$stage)) {$SQLorder='order by campaign_id asc'; $CAMPANHAlink='stage=CAMPANHADOWN';} + if (eregi("CAMPANHADOWN",$stage)) {$SQLorder='order by campaign_id desc'; $CAMPANHAlink='stage=CAMPANHAUP';} + if (eregi("CALLDATEUP",$stage)) {$SQLorder='order by list_lastcalldate asc'; $CALLDATElink='stage=CALLDATEDOWN';} + if (eregi("CALLDATEDOWN",$stage)) {$SQLorder='order by list_lastcalldate desc'; $CALLDATElink='stage=CALLDATEUP';} + $stmt="SELECT vls.list_id,list_name,list_description,count(*) as tally,active,list_lastcalldate,campaign_id from vicidial_lists vls,vicidial_list vl where vls.list_id=vl.list_id and campaign_id='$campaign_id' group by list_id $SQLorder"; + $rslt=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rslt); + + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + + $o=0; + while ($lists_to_print > $o) + { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + + $o++; + } + + echo "\n"; + echo "
ID DA LISTANOME DA LISTADESCRIÇÃOTOTAL DE REG.ATIVOÚLTIMA CHAMADAALTERAR
$row[0] $row[1] $row[2] $row[3] $row[4]"; + + if (ereg('Y',$row[4])) + { + $active_lists++; + $camp_lists .= "'$row[0]',"; + echo ""; + } + else + { + $inactive_lists++; + echo ""; + echo " $row[5]ALTERAR

\n"; + + echo "
\n"; + + $filterSQL = $filtersql_list[$lead_filter_id]; + $filterSQL = preg_replace("/\\\\/","",$filterSQL); + $filterSQL = eregi_replace("^and|and$|^or|or$","",$filterSQL); + if (strlen($filterSQL)>4) + {$fSQL = "and $filterSQL";} + else + {$fSQL = '';} + + $camp_lists = eregi_replace(".$","",$camp_lists); + echo "Esta campanha tem$active_lists listas ativas e$inactive_lists listas inativas

\n"; + + if ($display_dialable_count == 'Y') + { + ### call function to calculate and print dialable leads + dialable_leads($DB,$link,$local_call_time,$dial_statuses,$camp_lists,$drop_lockout_time,$fSQL); + echo " - ESCONDER

"; + } + else + { + echo "Popup Dialable Leads Count"; + echo " - MOSTRAR

"; + } + + $stmt="SELECT count(*) FROM vicidial_hopper where campaign_id='$campaign_id' and status IN('READY')"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $hopper_leads = "$rowx[0]"; + + echo "Esta campanha tem$hopper_leads registros no hopper

\n"; + echo "Clique aqui para ver quais registros estão no hopper agora

\n"; + echo "Clique aqui para ver um relatório VDAD para esta campanha

\n"; + } + echo "Clique aqui para visualizar todos os registros de Chamada Agendada para esta campanha

\n"; + if ($LOGuser_level >= 9) + { + echo "

Clique aqui para ver alterações Admin para esta campanha
\n"; + } + echo "
\n"; + } + + + ##### CAMPANHA CUSTOM STATUS ##### + if ($SUB==22) + { + + ##### get status category listings for dynamic pulldown + $stmt="SELECT vsc_id,vsc_name from vicidial_status_categories order by vsc_id desc"; + $rslt=mysql_query($stmt, $link); + $cats_to_print = mysql_num_rows($rslt); + $cats_list=""; + + $o=0; + while ($cats_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $cats_list .= "\n"; + $catsname_list["$rowx[0]"] = substr($rowx[1],0,20); + $o++; + } + + + echo "
\n"; + echo "
STATUS CUSTOMIZADOS PARA ESSA CAMPANHA:   $NWB#vicidial_campaign_statuses$NWE
\n"; + echo "\n"; + echo "\n"; + + $stmt="SELECT status,status_name,selectable,campaign_id,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable from vicidial_campaign_statuses where campaign_id='$campaign_id'"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + $o=0; + while ($statuses_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $AScategory = $rowx[5]; + $o++; + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + + echo "
STATUSDESCRIÇÃOSELECIONÁVELRESPOSTA HUMANOACATEGORIAMODIFY-DELETE
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "$rowx[0]
\n"; + echo "\n"; + echo "         \n"; + echo "   \n"; + echo "APAGAR\n"; + echo "
\n"; + + echo "  Sale:   \n"; + echo "  DNC:   \n"; + echo "  Customer Contact:   \n"; + echo "  Not Interested:   \n"; + echo "  Unworkable:   \n"; + + echo "
\n"; + + echo "
INCLUIR NOVO STATUS DE CAMPANHA
\n"; + echo "\n"; + echo "\n"; + echo "Status:   \n"; + echo "Descrição:   \n"; + echo "Selecionável:  
\n"; + echo "Resposta Humana:   \n"; + echo "Sale:   \n"; + echo "DNC:   \n"; + echo "Customer Contact:  
\n"; + echo "Not Interested:   \n"; + echo "Unworkable:   \n"; + echo "Categoria:\n"; + echo "  
\n"; + echo "
\n"; + + echo "

\n"; + } + + ##### CAMPANHA HOTKEYS ##### + if ($SUB==23) + { + echo "
ATALHOS DE TECLADO DESTA CAMPANHA:   $NWB#vicidial_campaign_hotkeys$NWE
\n"; + echo "\n"; + echo "\n"; + + $stmt="SELECT status,hotkey,status_name,selectable,campaign_id from vicidial_campaign_hotkeys where campaign_id='$campaign_id' order by hotkey"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + $o=0; + while ($statuses_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $o++; + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + + echo "
ATALHOSTATUSDESCRIÇÃOAPAGAR
$rowx[1]$rowx[0]$rowx[2]APAGAR
\n"; + + echo "
INCLUIR NOVO ATALHO DE TECLADO DA CAMPANHA
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "Hotkey:   \n"; + echo "Status:   \n"; + echo "
\n"; + echo "

\n"; + } + + ##### CAMPANHA LEAD RECYCLING ##### + if ($SUB==25) + { + ### display counts on leads that have hit the limit in this campaign + $stmt="SELECT list_id,active,list_name from vicidial_lists where campaign_id='$campaign_id'"; + $rslt=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rslt); + $camp_lists=''; + $o=0; + while ($lists_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + if (ereg("Y", $rowx[1])) {$camp_lists .= "'$rowx[0]',";} + $o++; + } + $camp_lists = eregi_replace(".$","",$camp_lists); + + $stmt="SELECT recycle_id,campaign_id,status,attempt_delay,attempt_maximum,active from vicidial_lead_recycle where campaign_id='$campaign_id' order by status"; + $rslt=mysql_query($stmt, $link); + $recycle_to_print = mysql_num_rows($rslt); + $o=0; + while ($recycle_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $RECYCLE_status[$o] = $rowx[2]; + $RECYCLE_delay[$o] = $rowx[3]; + $RECYCLE_attempt[$o] = $rowx[4]; + $RECYCLE_active[$o] = $rowx[5]; + $RECYCLE_count[$o] = "'Y','Y1','Y2','Y3','Y4','Y5','Y6','Y7','Y8','Y9','Y10'"; + if ($RECYCLE_attempt[$o]==1) {$RECYCLE_count[$o] = "'Y1','Y2','Y3','Y4','Y5','Y6','Y7','Y8','Y9','Y10'";} + if ($RECYCLE_attempt[$o]==2) {$RECYCLE_count[$o] = "'Y2','Y3','Y4','Y5','Y6','Y7','Y8','Y9','Y10'";} + if ($RECYCLE_attempt[$o]==3) {$RECYCLE_count[$o] = "'Y3','Y4','Y5','Y6','Y7','Y8','Y9','Y10'";} + if ($RECYCLE_attempt[$o]==4) {$RECYCLE_count[$o] = "'Y4','Y5','Y6','Y7','Y8','Y9','Y10'";} + if ($RECYCLE_attempt[$o]==5) {$RECYCLE_count[$o] = "'Y5','Y6','Y7','Y8','Y9','Y10'";} + if ($RECYCLE_attempt[$o]==6) {$RECYCLE_count[$o] = "'Y6','Y7','Y8','Y9','Y10'";} + if ($RECYCLE_attempt[$o]==7) {$RECYCLE_count[$o] = "'Y7','Y8','Y9','Y10'";} + if ($RECYCLE_attempt[$o]==8) {$RECYCLE_count[$o] = "'Y8','Y9','Y10'";} + if ($RECYCLE_attempt[$o]==9) {$RECYCLE_count[$o] = "'Y9','Y10'";} + if ($RECYCLE_attempt[$o]>9) {$RECYCLE_count[$o] = "'Y10'";} + $o++; + } + $o=0; + + echo "

RECICLAGEM DE REGISTROS DESTA CAMPANHA:   $NWB#vicidial_lead_recycle$NWE
\n"; + echo "\n"; + echo "\n"; + + while ($recycle_to_print > $o) + { + $recycle_limit=0; + if (strlen($camp_lists) > 2) + { + $stmt="SELECT count(*) from vicidial_list where status='$RECYCLE_status[$o]' and list_id IN($camp_lists) and called_since_last_reset IN($RECYCLE_count[$o]);"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $counts_to_print = mysql_num_rows($rslt); + if ($counts_to_print > 0) + { + $rowx=mysql_fetch_row($rslt); + $recycle_limit = $rowx[0]; + } + } + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $o++; + } + + echo "
STATUSTEMPO DE TENTATIVAQUANTIDADE MÁXIMA DE TENTATIVASREGISTROS NO LIMITEATIVO APAGAR
  $RECYCLE_status[$o]
\n"; + echo "\n"; + echo "\n"; + echo "
$recycle_limit   APAGAR
\n"; + + echo "
INCLUIR RECICLAGEM DE REGISTROS DA CAMPANHA
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "Status:   \n"; + echo "Tempo de Tentativa: \n"; + echo "Quantidade Máxima de Tentativas: \n"; + echo "
\n"; + + echo "

\n"; + echo "
\n"; + echo "* Contagem de registros tirada das listas ativas nesta campanha.\n"; + } + + ##### CAMPANHA AUTO-ALT-NUMBER DIALING ##### + if ($SUB==26) + { + echo "

DISCAR NÚMERO ALT. NESTA CAMPANHA:   $NWB#vicidial_auto_alt_dial_statuses$NWE
\n"; + echo "\n"; + echo "\n"; + + $auto_alt_dial_statuses = preg_replace("/ -$/","",$auto_alt_dial_statuses); + $AADstatuses = explode(" ", $auto_alt_dial_statuses); + $AADs_to_print = (count($AADstatuses) -1); + + $o=0; + while ($AADs_to_print > $o) + { + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + $o++; + + echo "\n"; + echo "\n"; + } + + echo "
STATUSAPAGAR
$AADstatuses[$o]APAGAR
\n"; + + echo "
INCLUIR NOVO STATUS PARA DISCAGEM DE NÚM. ALT.
\n"; + echo "\n"; + echo "\n"; + echo "Status:   \n"; + echo "
\n"; + + echo "

\n"; + } + + ##### CAMPANHA CÓDIGOS DE PAUSA ##### + if ($SUB==27) + { + echo "

CÓDIGOS DE PAUSA PARA CAMPANHA:   $NWB#vicidial_pause_codes$NWE
\n"; + echo "\n"; + echo "\n"; + + $stmt="SELECT pause_code,pause_code_name,billable,campaign_id from vicidial_pause_codes where campaign_id='$campaign_id' order by pause_code"; + $rslt=mysql_query($stmt, $link); + $pause_codes_to_print = mysql_num_rows($rslt); + $o=0; + while ($pause_codes_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $o++; + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + + echo "
CÓDIGOS DE PAUSACOBRÁVELALTERARAPAGAR
$rowx[0]\n"; + echo "\n"; + echo "\n"; + echo "  \n"; + echo "
APAGAR
\n"; + + echo "
NOVO CÓDIGO DE PAUSA
\n"; + echo "\n"; + echo "\n"; + echo "Código de Pausa: \n"; + echo "Nome do Código de Pausa: \n"; + echo "   Cobrável: \n"; + echo "
\n"; + + echo "

\n"; + } + + ##### CAMPANHA QC SETTINGS ##### + if ( ($SUB==28) and ($SSqc_features_active > 0) ) + { + $stmt="SELECT list_id,list_name,active from vicidial_lists where campaign_id='$campaign_id'"; + $rslt=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rslt); + $qc_lists_list=''; + + $p=0; + while ($lists_to_print > $p) + { + $rowx=mysql_fetch_row($rslt); + $qc_lists_list .= " $o) + { + $rowx=mysql_fetch_row($rslt); + $QCscripts_list .= "\n"; + $scriptname_list["$rowx[0]"] = "$rowx[1]"; + $o++; + } + ##### get shifts listings for pulldown + $stmt="SELECT shift_id,shift_name from vicidial_shifts order by shift_id"; + $rslt=mysql_query($stmt, $link); + $shifts_to_print = mysql_num_rows($rslt); + $QCshifts_list=""; + $o=0; + while ($shifts_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $QCshifts_list .= "\n"; + $shiftname_list["$rowx[0]"] = "$rowx[1]"; + $o++; + } + + echo "

CONFIGURAÇÕES DE CQ PARA CAMPANHA:
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; +# echo "\n"; + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + echo "\n"; + + echo "\n"; + echo "
\n"; + echo "\n"; + echo "CQ Ativado: $NWB#vicidial_campaigns-qc_enabled$NWE
Status de CQ:
$NWB#vicidial_campaigns-qc_statuses$NWE
$qc_statuses_list
QC Lists:
$NWB#vicidial_campaigns-qc_lists$NWE
$qc_lists_list
WebForm de CQ:$NWB#vicidial_campaigns-qc_web_form_address$NWE
Script de CQ: $NWB#vicidial_campaigns-qc_script$NWE
Turno de CQ: $NWB#vicidial_campaigns-qc_shift_id$NWE
Entrada de registro CQ: $NWB#vicidial_campaigns-qc_get_record_launch$NWE
Mostrar Gravações CQ: $NWB#vicidial_campaigns-qc_show_recording$NWE
\n"; + echo "

\n"; + } + + ##### CAMPANHA SURVEY SETTINGS ##### + if ($SUB=='20A') + { + + echo "

CONFIG. DE PESQUISA PARA ESTA CAMPANHA:
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "
\n"; + echo "\n"; + + echo "
Primeiro Arquivo de Audio: audio chooser $NWB#vicidial_campaigns-survey_first_audio_file$NWE
Dígitos DTMF: $NWB#vicidial_campaigns-survey_dtmf_digits$NWE
Dígito p/ Não Interessado: $NWB#vicidial_campaigns-survey_ni_digit$NWE
Arquivo de Audio para Interessado: audio chooser $NWB#vicidial_campaigns-survey_opt_in_audio_file$NWE
Arquivo de Audio para não Interessado: audio chooser $NWB#vicidial_campaigns-survey_ni_audio_file$NWE
Método de Pesquisa: $NWB#vicidial_campaigns-survey_method$NWE
Ação p/ sem Resposta: $NWB#vicidial_campaigns-survey_no_response_action$NWE
Status p/ Não Interessado: $NWB#vicidial_campaigns-survey_ni_status$NWE
Terceiro Dígito: $NWB#vicidial_campaigns-survey_third_digit$NWE
Terceiro Arquivo de Audio: audio chooser $NWB#vicidial_campaigns-survey_third_audio_file$NWE
Terceiro Status: $NWB#vicidial_campaigns-survey_third_status$NWE
Terceira Extensão: $NWB#vicidial_campaigns-survey_third_exten$NWE
Quarto Dígito: $NWB#vicidial_campaigns-survey_fourth_digit$NWE
Quarto Arquivo de Audio: audio chooser $NWB#vicidial_campaigns-survey_fourth_audio_file$NWE
Quarto Status: $NWB#vicidial_campaigns-survey_fourth_status$NWE
Quarta Extensão: $NWB#vicidial_campaigns-survey_fourth_exten$NWE
Mapa de Digitos: $NWB#vicidial_campaigns-survey_response_digit_map$NWE
Pesquisa Extensão de Transfer.: $NWB#vicidial_campaigns-survey_xfer_exten$NWE
Diretório de Gravações da Pesquisa: $NWB#vicidial_campaigns-survey_camp_record_dir$NWE
Correio de Voz: voicemail chooser $NWB#vicidial_campaigns-voicemail_ext$NWE
\n"; + echo "

\n"; + } + + + if ($SUB < 1) + { + echo "

\n"; + echo "DESCONECTAR TODOS OS AGENTES DESTA CAMPANHA

\n"; + echo "EMERGENCY VDAC CLEAR FOR THIS CAMPANHA

\n"; + + if ($LOGdelete_campaigns > 0) + { + echo "

APAGAR ESTA CAMPANHA\n"; + } + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } +} + + +###################### +# ADD=34 modify campaign info in the system - Basic View +###################### + +if ( ($ADD==34) and ( (!eregi("$campaign_id",$LOGallowed_campaigns)) and (!eregi("ALL-CAMPANHAS",$LOGallowed_campaigns)) ) ) + {$ADD=30;} # send to not allowed screen if not in vicidial_user_groups allowed_campaigns list + +if ($ADD==34) + { + if ($LOGmodify_campaigns==1) + { + if ($stage=='show_dialable') + { + $stmt="UPDATE vicidial_campaigns set display_dialable_count='Y' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + } + if ($stage=='hide_dialable') + { + $stmt="UPDATE vicidial_campaigns set display_dialable_count='N' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + } + + $stmt="SELECT campaign_id,campaign_name,active,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,park_ext,park_file_name,web_form_address,allow_closers,hopper_level,auto_dial_level,next_agent_call,local_call_time,voicemail_ext,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,amd_send_to_vmx,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,lead_filter_id,drop_call_seconds,drop_action,safe_harbor_exten,display_dialable_count,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc,allcalls_delay,omit_phone_code,dial_method,available_only_ratio_tally,adaptive_dropped_percentage,adaptive_maximum_level,adaptive_latest_server_time,adaptive_intensity,adaptive_dl_diff_target,concurrent_transfers,auto_alt_dial,auto_alt_dial_statuses,agent_pause_codes_active,campaign_description,campaign_changedate,campaign_stats_refresh,campaign_logindate,dial_statuses,disable_alter_custdata,no_hopper_leads_logins,list_order_mix,campaign_allow_inbound,manual_dial_list_id,default_xfer_group,xfer_groups,queue_priority,drop_inbound_group,qc_enabled,qc_statuses,qc_lists,qc_shift_id,qc_get_record_launch,qc_show_recording,qc_web_form_address,qc_script,survey_first_audio_file,survey_dtmf_digits,survey_ni_digit,survey_opt_in_audio_file,survey_ni_audio_file,survey_method,survey_no_response_action,survey_ni_status,survey_response_digit_map,survey_xfer_exten,survey_camp_record_dir,disable_alter_custphone,display_queue_count,manual_dial_filter,agent_clipboard_copy,agent_extended_alt_dial,use_campaign_dnc,three_way_call_cid,three_way_dial_prefix,web_form_target,vtiger_search_category,vtiger_create_call_record,vtiger_create_lead_record,vtiger_screen_login,cpd_amd_action,agent_allow_group_alias,default_group_alias,vtiger_search_dead,vtiger_status_call,survey_third_digit,survey_third_audio_file,survey_third_status,survey_third_exten,survey_fourth_digit,survey_fourth_audio_file,survey_fourth_status,survey_fourth_exten,drop_lockout_time,quick_transfer_button,prepopulate_transfer_preset,drop_rate_group,view_calls_in_queue,view_calls_in_queue_launch,grab_calls_in_queue,call_requeue_button,pause_after_each_call,no_hopper_dialing,agent_dial_owner_only,agent_display_dialable_leads,web_form_address_two,waitforsilence_options from vicidial_campaigns where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $dial_status_a = $row[3]; + $dial_status_b = $row[4]; + $dial_status_c = $row[5]; + $dial_status_d = $row[6]; + $dial_status_e = $row[7]; + $lead_order = $row[8]; + $hopper_level = $row[13]; + $auto_dial_level = $row[14]; + $next_agent_call = $row[15]; + $local_call_time = $row[16]; + $voicemail_ext = $row[17]; + $dial_timeout = $row[18]; + $dial_prefix = $row[19]; + $campaign_cid = $row[20]; + $campaign_vdad_exten = $row[21]; + $script_id = $row[25]; + $get_call_launch = $row[26]; + $lead_filter_id = $row[35]; + if ($lead_filter_id=='') {$lead_filter_id='NONE';} + $display_dialable_count = $row[39]; + $dial_method = $row[46]; + $adaptive_intensity = $row[51]; + $campaign_description = $row[57]; + $campaign_changedate = $row[58]; + $campaign_stats_refresh = $row[59]; + $campaign_logindate = $row[60]; + $dial_statuses = $row[61]; + $list_order_mix = $row[64]; + $default_xfer_group = $row[67]; + $campaign_allow_inbound = $row[65]; + $default_xfer_group = $row[67]; + $drop_lockout_time = $row[116]; + + if (ereg("DISABLED",$list_order_mix)) + {$DEFlistDISABLE = ''; $DEFstatusDISABLED=0;} + else + {$DEFlistDISABLE = 'disabled'; $DEFstatusDISABLED=1;} + + $stmt="SELECT status,status_name,selectable,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable from vicidial_statuses order by status"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + $statuses_list=''; + $dial_statuses_list=''; + $o=0; + while ($statuses_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $statuses_list .= "\n"; + if ($rowx[0] != 'CBHOLD') {$dial_statuses_list .= "\n";} + $statname_list["$rowx[0]"] = "$rowx[1]"; + $LRstatuses_list .= "\n"; + if (eregi("Y",$rowx[2])) + {$HKstatuses_list .= "\n";} + $o++; + } + + $stmt="SELECT status,status_name,selectable,campaign_id,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable from vicidial_campaign_statuses where campaign_id='$campaign_id' order by status"; + $rslt=mysql_query($stmt, $link); + $Cstatuses_to_print = mysql_num_rows($rslt); + + $o=0; + while ($Cstatuses_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $statuses_list .= "\n"; + if ($rowx[0] != 'CBHOLD') {$dial_statuses_list .= "\n";} + $statname_list["$rowx[0]"] = "$rowx[1]"; + $LRstatuses_list .= "\n"; + if (eregi("Y",$rowx[2])) + {$HKstatuses_list .= "\n";} + $o++; + } + + $dial_statuses = preg_replace("/ -$/","",$dial_statuses); + $Dstatuses = explode(" ", $dial_statuses); + $Ds_to_print = (count($Dstatuses) -1); + + $stmt="SELECT count(*) from vicidial_campaigns_list_mix where campaign_id='$campaign_id' and status='ACTIVE'"; + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0] < 1) + { + $mixes_list="\n"; + $mixname_list["DISABLED"] = "DISABLED"; + } + else + { + ##### get list_mix listings for dynamic pulldown + $stmt="SELECT vcl_id,vcl_name from vicidial_campaigns_list_mix where campaign_id='$campaign_id' and status='ACTIVE' limit 1"; + $rslt=mysql_query($stmt, $link); + $mixes_to_print = mysql_num_rows($rslt); + $mixes_list="\n"; + + $o=0; + while ($mixes_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $mixes_list .= "\n"; + $mixname_list["ACTIVE"] = "$rowx[0] - $rowx[1]"; + $o++; + } + } + + if ($SUB<1) {$camp_detail_color=$subcamp_color;} + else {$camp_detail_color=$campaigns_color;} + if ($SUB==22) {$camp_statuses_color=$subcamp_color;} + else {$camp_statuses_color=$campaigns_color;} + if ($SUB==23) {$camp_hotkeys_color=$subcamp_color;} + else {$camp_hotkeys_color=$campaigns_color;} + if ($SUB==25) {$camp_recycle_color=$subcamp_color;} + else {$camp_recycle_color=$campaigns_color;} + if ($SUB==26) {$camp_autoalt_color=$subcamp_color;} + else {$camp_autoalt_color=$campaigns_color;} + if ($SUB==27) {$camp_pause_color=$subcamp_color;} + else {$camp_pause_color=$campaigns_color;} + if ($SUB==29) {$camp_listmix_color=$subcamp_color;} + else {$camp_listmix_color=$campaigns_color;} + echo "\n"; + echo ""; + echo ""; + echo ""; + if ($SSoutbound_autodial_active > 0) + { + echo ""; + } + echo "\n"; + echo "\n"; + if ($SSoutbound_autodial_active < 1) + { + echo ""; + } + echo "
$row[0]: Visão Básica Visão Detalhada Mesclagem de Lista Tela de Tempo Real  
\n"; + + if ($SUB < 1) + { + echo "
\n"; + echo ""; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + if ($SSoutbound_autodial_active > 0) + { + echo "\n"; + + $o=0; + while ($Ds_to_print > $o) + { + $o++; + $Dstatus = $Dstatuses[$o]; + + echo "\n"; + } + else + { + echo "$Dstatus - $statname_list[$Dstatus]         \n"; + echo "REMOVER\n"; + } + } + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + } + echo "\n"; + + echo "\n"; + + echo "\n"; + echo "
ID da Campanha: $row[0]$NWB#vicidial_campaigns-campaign_id$NWE
Nome da Campanha: $NWB#vicidial_campaigns-campaign_name$NWE
Descrição da Campanha: $row[57]$NWB#vicidial_campaigns-campaign_description$NWE
Campanha Data da Alter.: $campaign_changedate   $NWB#vicidial_campaigns-campaign_changedate$NWE
Campanha Data do Login: $campaign_logindate   $NWB#vicidial_campaigns-campaign_logindate$NWE
Ativo: $NWB#vicidial_campaigns-active$NWE
Extensão de Estacionamento: $row[9] - $row[10]$NWB#vicidial_campaigns-park_ext$NWE
Formulário Web: $row[11]$NWB#vicidial_campaigns-web_form_address$NWE
Permitir Finalizadores (Closers): $row[12] $NWB#vicidial_campaigns-allow_closers$NWE
Grupo de Transferência Padrão:$default_xfer_group $NWB#vicidial_campaigns-default_xfer_group$NWE
Permitir Entrantes e Blended:$campaign_allow_inbound $NWB#vicidial_campaigns-campaign_allow_inbound$NWE
Status de Discagem$o: \n"; + if ($DEFstatusDISABLED > 0) + { + echo "$Dstatus - $statname_list[$Dstatus]         \n"; + echo "REMOVE
Add A Dial Status:   \n"; + echo "     $NWB#vicidial_campaigns-dial_status$NWE
Ordem da Lista: $NWB#vicidial_campaigns-lead_order$NWE
Mesclagem de Lista: $NWB#vicidial_campaigns-list_order_mix$NWE
Filtro de registros: $NWB#vicidial_campaigns-lead_filter_id$NWE
Nível do Hopper: $NWB#vicidial_campaigns-hopper_level$NWE
Forçar Reset do Hopper: $NWB#vicidial_campaigns-force_reset_hopper$NWE
Método de Discagem: $NWB#vicidial_campaigns-dial_method$NWE
Nível de Discagem Automática: (0 = off)$NWB#vicidial_campaigns-auto_dial_level$NWE
Modificador de Intensidade : $NWB#vicidial_campaigns-adaptive_intensity$NWE
Script: $script_id
Pegar lançamento da chamada: $get_call_launch
\n"; + + echo "
\n"; + + if ($SSoutbound_autodial_active > 0) + { + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
LISTAS DESTA CAMPANHA:   $NWB#vicidial_campaign_lists$NWE\n"; + + echo "
\n"; + echo ""; + + $LISTlink='stage=LISTIDDOWN'; + $TALLYlink='stage=TALLYDOWN'; + $ACTIVElink='stage=ACTIVEDOWN'; + $CAMPANHAlink='stage=CAMPANHADOWN'; + $CALLDATElink='stage=CALLDATEDOWN'; + $SQLorder='order by list_id'; + if (eregi("LISTIDUP",$stage)) {$SQLorder='order by list_id asc'; $LISTlink='stage=LISTIDDOWN';} + if (eregi("LISTIDDOWN",$stage)) {$SQLorder='order by list_id desc'; $LISTlink='stage=LISTIDUP';} + if (eregi("TALLYUP",$stage)) {$SQLorder='order by tally asc'; $TALLYlink='stage=TALLYDOWN';} + if (eregi("TALLYDOWN",$stage)) {$SQLorder='order by tally desc'; $TALLYlink='stage=TALLYUP';} + if (eregi("ACTIVEUP",$stage)) {$SQLorder='order by active asc'; $ACTIVElink='stage=ACTIVEDOWN';} + if (eregi("ACTIVEDOWN",$stage)) {$SQLorder='order by active desc'; $ACTIVElink='stage=ACTIVEUP';} + if (eregi("CAMPANHAUP",$stage)) {$SQLorder='order by campaign_id asc'; $CAMPANHAlink='stage=CAMPANHADOWN';} + if (eregi("CAMPANHADOWN",$stage)) {$SQLorder='order by campaign_id desc'; $CAMPANHAlink='stage=CAMPANHAUP';} + if (eregi("CALLDATEUP",$stage)) {$SQLorder='order by list_lastcalldate asc'; $CALLDATElink='stage=CALLDATEDOWN';} + if (eregi("CALLDATEDOWN",$stage)) {$SQLorder='order by list_lastcalldate desc'; $CALLDATElink='stage=CALLDATEUP';} + $stmt="SELECT vls.list_id,list_name,list_description,count(*) as tally,active,list_lastcalldate,campaign_id from vicidial_lists vls,vicidial_list vl where vls.list_id=vl.list_id and campaign_id='$campaign_id' group by list_id $SQLorder"; + $rslt=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rslt); + + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + + $o=0; + while ($lists_to_print > $o) + { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + + $o++; + } + + echo "\n"; + echo "
ID DA LISTANOME DA LISTADESCRIÇÃOTOTAL DE REG.ATIVOÚLTIMA CHAMADAALTERAR
$row[0] $row[1] $row[2] $row[3] $row[4]"; + + if (ereg('Y',$row[4])) + { + $active_lists++; + $camp_lists .= "'$row[0]',"; + echo ""; + } + else + { + $inactive_lists++; + echo ""; + echo " $row[5]ALTERAR

\n"; + echo "
\n"; + + $filterSQL = $filtersql_list[$lead_filter_id]; + $filterSQL = preg_replace("/\\\\/","",$filterSQL); + $filterSQL = eregi_replace("^and|and$|^or|or$","",$filterSQL); + if (strlen($filterSQL)>4) + {$fSQL = "and $filterSQL";} + else + {$fSQL = '';} + + $camp_lists = eregi_replace(".$","",$camp_lists); + echo "Esta campanha tem$active_lists listas ativas e$inactive_lists listas inativas

\n"; + + + if ($display_dialable_count == 'Y') + { + ### call function to calculate and print dialable leads + dialable_leads($DB,$link,$local_call_time,$dial_statuses,$camp_lists,$drop_lockout_time,$fSQL); + echo " - ESCONDER

"; + } + else + { + echo "Popup Dialable Leads Count"; + echo " - MOSTRAR

"; + } + + + + $stmt="SELECT count(*) FROM vicidial_hopper where campaign_id='$campaign_id' and status IN('READY')"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $hopper_leads = "$rowx[0]"; + + echo "Esta campanha tem$hopper_leads registros no hopper

\n"; + echo "Clique aqui para ver quais registros estão no hopper agora

\n"; + echo "Clique aqui para ver um relatório VDAD para esta campanha

\n"; + } + echo "Clique aqui para visualizar todos os registros de Chamada Agendada para esta campanha

\n"; + if ($LOGuser_level >= 9) + { + echo "

Clique aqui para ver alterações Admin para esta campanha
\n"; + } + + echo "
\n"; + + echo "
\n"; + + ### list of agent rank or skill-level for this campaign + echo "
\n"; + echo "
RANKING DO AGENTE NA CAMPANHA:
\n"; + echo "\n"; + echo "\n"; + + $stmt="SELECT vu.user,vca.campaign_rank,vca.calls_today,full_name from vicidial_campaign_agents vca, vicidial_users vu where campaign_id='$campaign_id' and active='Y' and vu.user=vca.user;"; + $rsltx=mysql_query($stmt, $link); + $users_to_print = mysql_num_rows($rsltx); + + $o=0; + while ($users_to_print > $o) { + $rowx=mysql_fetch_row($rsltx); + $o++; + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + } + + echo "
USER     RANK     CALLS TODAY
$rowx[0] - $rowx[3]$rowx[1]$rowx[2]

\n"; + + + echo "DESCONECTAR TODOS OS AGENTES DESTA CAMPANHA

\n"; + + + if ($LOGdelete_campaigns > 0) + { + echo "

APAGAR ESTA CAMPANHA\n"; + } + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } +} + + +###################### +# ADD=31 or 34 and SUB=29 for list mixes +###################### +if ( ( ($ADD==34) or ($ADD==31) ) and ( (!eregi("$campaign_id",$LOGallowed_campaigns)) and (!eregi("ALL-CAMPANHAS",$LOGallowed_campaigns)) ) ) + {$ADD=30;} # send to not allowed screen if not in vicidial_user_groups allowed_campaigns list + +if ( ($ADD==34) or ($ADD==31) ) +{ + if ($LOGmodify_campaigns==1) + { + ##### CAMPANHA LIST MIX SETTINGS ##### + if ($SUB==29) + { + ##### get list_id listings for dynamic pulldown + $stmt="SELECT list_id,list_name from vicidial_lists where campaign_id='$campaign_id' order by list_id"; + $rslt=mysql_query($stmt, $link); + $mixlists_to_print = mysql_num_rows($rslt); + $mixlists_list=""; + + $o=0; + while ($mixlists_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $mixlists_list .= "\n"; + $mixlistsname_list["$rowx[0]"] = "$rowx[1]"; + $o++; + } + + + echo "

MESCLAGEM DE LISTAS PARA ESTA CAMPANHA:  $NWB#vicidial_campaigns-list_order_mix$NWE
\n"; + + echo "
ATENÇÃO, só recomendamos Mesclagem de Listas para usuários avançados, Por favor leia o Manual de Gerente do Vicidial
\n"; + + $stmt="SELECT dial_statuses from vicidial_campaigns where campaign_id='$campaign_id'"; + $rslt=mysql_query($stmt, $link); + $statuses = mysql_num_rows($rslt); + if ($statuses > 0) + { + $rowy=mysql_fetch_row($rslt); + $LMdial_statuses=$rowy[0]; + } + + $stmt="SELECT vcl_id,vcl_name,campaign_id,list_mix_container,mix_method,status from vicidial_campaigns_list_mix where campaign_id='$campaign_id' order by status, vcl_id"; + $rslt=mysql_query($stmt, $link); + $listmixes = mysql_num_rows($rslt); + $o=0; + while ($listmixes > $o) + { + $rowx=mysql_fetch_row($rslt); + $vcl_id=$rowx[0]; + $o++; + + if ($o < 2) + {$tablecolor='bgcolor="#99FF99"'; $bgcolor='bgcolor="#CCFFCC"';} + else + { + if (eregi("1$|3$|5$|7$|9$", $o)) + {$tablecolor='bgcolor="#B9CBFD"'; $bgcolor='bgcolor="#9BB9FB"';} + else + {$tablecolor='bgcolor="#9BB9FB"'; $bgcolor='bgcolor="#B9CBFD"';} + } + echo "
\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + } + else + {echo "$rowx[5]\n";} + echo "\n"; + echo "\n"; + +# list_id|order|percent|statuses|:list_id|order|percent|statuses|:... +# 101|1|40| A B NA -|:102|2|25| NEW -|:103|3|30| DROP CALLBK -|:101|4|5| DROP -| +# INSERT INTO vicidial_campaigns_list_mix values('TESTMIX','TESTCAMP List Mix','TESTCAMP','101|1|40| A B NA -|:102|2|25| NEW -|:103|3|30| DROP CALLBK -|:101|4|5| DROP -|','IN_ORDER','ACTIVE'); +# INSERT INTO vicidial_campaigns_list_mix values('TESTMIX2','TESTCAMP List Mix2','TESTCAMP','101|1|20| A B -|:102|2|45| NEW -|:103|3|30| DROP CALLBK -|:101|4|5| DROP -|','IN_ORDER','ACTIVE'); +# INSERT INTO vicidial_campaigns_list_mix values('TESTMIX3','TESTCAMP List Mix3','TESTCAMP','101|1|30| A NA -|:102|2|35| NEW -|:103|3|30| DROP CALLBK -|:101|4|5| DROP -|','IN_ORDER','ACTIVE'); + + $MIXentries = $MT; + $MIXentries = explode(":", $rowx[3]); + $Ms_to_print = (count($MIXentries) - 0); + $q=0; + while ($Ms_to_print > $q) + { + $MIXdetails = explode('|', $MIXentries[$q]); + $MIXdetailsLIST = $MIXdetails[0]; + + $dial_statuses = preg_replace("/ -$/","",$dial_statuses); + $Dstatuses = explode(" ", $dial_statuses); + $Ds_to_print = (count($Dstatuses) - 0); + $Dsql = ''; + $r=0; + while ($Ds_to_print > $r) + { + $r++; + $Dsql .= "'$Dstatuses[$r]',"; + } + $Dsql = preg_replace("/,$/","",$Dsql); + + echo "\n"; + + echo "\n"; + + echo "\n"; + + + echo "\n"; + echo "\n"; + + + echo "\n"; + + + $q++; + + } + + + + + echo "\n"; + + echo "\n"; + + + echo "\n"; + + $X='X'; + echo "\n"; + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "$vcl_id:\n"; + echo "\n"; + echo "     DELETE LIST MIX
Status: \n"; + if ($rowx[5]=='INACTIVE') + { + echo "$rowx[5]\n"; + echo "ATIVARMethod:\n"; + echo "
ID DA LISTAPRIORIDADE% MIXSTATUS
\n"; + echo "\n"; + echo "List: $MIXdetailsLIST   REMOVER\n"; + + + + echo " \n"; + echo "ADD   \n"; + echo "REMOVER\n"; + echo "
\n"; + echo "Difference %: \n"; + echo "   \n"; + echo "\n"; + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "List: \n"; + + if ($q > 39) {$AE_disabled = 'DISABLED';} + else {$AE_disabled = '';} + echo "\n"; + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "
CHANGE: \n"; + echo "ALL   \n"; + echo "EMPTY\n"; + echo "
\n"; + echo " \n"; + echo "ADD   \n"; + echo "REMOVER\n"; + echo "
\n"; + } + + + echo "

NOVA LISTA MIX
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "Mix ID: Mix Name: Mix Method: "; + echo "
List: Dial Status:  
\n"; + + echo "
\n"; + + } + } + echo "
\n"; +} + + +###################### +# ADD=30 campaign not allowed +###################### + +if ($ADD==30) +{ +echo "
\n"; + echo ""; +echo "You do not have permission to view campaign $campaign_id\n"; +} + + +###################### +# ADD=32 display all campaign statuses +###################### +if ($ADD==32) +{ +echo "
\n"; + echo ""; + +echo "
LISTA DE STATUS CUSTOMIZADOS:\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $campaigns_to_print = mysql_num_rows($rslt); + + $o=0; + while ($campaigns_to_print > $o) + { + $row=mysql_fetch_row($rslt); + $campaigns_id_list[$o] = $row[0]; + $campaigns_name_list[$o] = $row[1]; + $o++; + } + + $o=0; + while ($campaigns_to_print > $o) + { + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
CAMPANHANOMESTATUSALTERAR
$campaigns_id_list[$o] $campaigns_name_list[$o] "; + + $stmt="SELECT status from vicidial_campaign_statuses where campaign_id='$campaigns_id_list[$o]' order by status"; + $rslt=mysql_query($stmt, $link); + $campstatus_to_print = mysql_num_rows($rslt); + $p=0; + while ( ($campstatus_to_print > $p) and ($p < 10) ) + { + $row=mysql_fetch_row($rslt); + echo "$row[0] "; + $p++; + } + if ($p<1) + {echo "NONE";} + echo "MODIFY STATUS
\n"; +} + + +###################### +# ADD=33 display all campaign hotkeys +###################### +if ($ADD==33) +{ +echo "
\n"; + echo ""; + +echo "
LISTA DE ATALHOS DA CAMPANHA:\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $campaigns_to_print = mysql_num_rows($rslt); + + $o=0; + while ($campaigns_to_print > $o) + { + $row=mysql_fetch_row($rslt); + $campaigns_id_list[$o] = $row[0]; + $campaigns_name_list[$o] = $row[1]; + $o++; + } + + $o=0; + while ($campaigns_to_print > $o) + { + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
CAMPANHANOMEHOTKEYSALTERAR
$campaigns_id_list[$o] $campaigns_name_list[$o] "; + + $stmt="SELECT status from vicidial_campaign_hotkeys where campaign_id='$campaigns_id_list[$o]' order by status"; + $rslt=mysql_query($stmt, $link); + $campstatus_to_print = mysql_num_rows($rslt); + $p=0; + while ( ($campstatus_to_print > $p) and ($p < 10) ) + { + $row=mysql_fetch_row($rslt); + echo "$row[0] "; + $p++; + } + if ($p<1) + {echo "NONE";} + echo "MODIFY HOTKEYS
\n"; +} + + +###################### +# ADD=35 display all campaign lead recycle entries +###################### +if ($ADD==35) +{ +echo "
\n"; + echo ""; + +echo "
LISTA DE RECICLAGEM DE REGISTROS:\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $campaigns_to_print = mysql_num_rows($rslt); + + $o=0; + while ($campaigns_to_print > $o) + { + $row=mysql_fetch_row($rslt); + $campaigns_id_list[$o] = $row[0]; + $campaigns_name_list[$o] = $row[1]; + $o++; + } + + $o=0; + while ($campaigns_to_print > $o) + { + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
CAMPANHANOMERECICLAGEM DE REGISTROSALTERAR
$campaigns_id_list[$o] $campaigns_name_list[$o] "; + + $stmt="SELECT status from vicidial_lead_recycle where campaign_id='$campaigns_id_list[$o]' order by status"; + $rslt=mysql_query($stmt, $link); + $campstatus_to_print = mysql_num_rows($rslt); + $p=0; + while ( ($campstatus_to_print > $p) and ($p < 10) ) + { + $row=mysql_fetch_row($rslt); + echo "$row[0] "; + $p++; + } + if ($p<1) + {echo "NONE";} + echo "MODIFY RECICLAGEM DE REGISTROS
\n"; +} + + +###################### +# ADD=36 display all campaign auto-alt dial entries +###################### +if ($ADD==36) +{ +echo "
\n"; + echo ""; + +echo "
LISTA DE DISC. ALTERN. DE REG.:\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $campaigns_to_print = mysql_num_rows($rslt); + + $o=0; + while ($campaigns_to_print > $o) + { + $row=mysql_fetch_row($rslt); + $campaigns_id_list[$o] = $row[0]; + $campaigns_name_list[$o] = $row[1]; + $o++; + } + + $o=0; + while ($campaigns_to_print > $o) + { + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
CAMPANHANOMEAUTO-ALT DIALALTERAR
$campaigns_id_list[$o] $campaigns_name_list[$o] "; + + $stmt="SELECT auto_alt_dial_statuses from vicidial_campaigns where campaign_id='$campaigns_id_list[$o]';"; + $rslt=mysql_query($stmt, $link); + $campstatus_to_print = mysql_num_rows($rslt); + $p=0; + while ( ($campstatus_to_print > $p) and ($p < 10) ) + { + $row=mysql_fetch_row($rslt); + echo "$row[0] "; + $p++; + } + if (strlen($row[0])<3) + {echo "NONE";} + echo "MODIFY AUTO-ALT DIAL
\n"; +} + + +###################### +# ADD=37 display all campaign agent pause codes +###################### +if ($ADD==37) +{ +echo "
\n"; + echo ""; + +echo "
LISTA DE CÓDIGOS DE PAUSA DE AGENTE:\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $campaigns_to_print = mysql_num_rows($rslt); + + $o=0; + while ($campaigns_to_print > $o) + { + $row=mysql_fetch_row($rslt); + $campaigns_id_list[$o] = $row[0]; + $campaigns_name_list[$o] = $row[1]; + $o++; + } + + $o=0; + while ($campaigns_to_print > $o) + { + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
CAMPANHANOMECÓDIGOS DE PAUSAALTERAR
$campaigns_id_list[$o] $campaigns_name_list[$o] "; + + $stmt="SELECT pause_code from vicidial_pause_codes where campaign_id='$campaigns_id_list[$o]' order by pause_code;"; + $rslt=mysql_query($stmt, $link); + $campstatus_to_print = mysql_num_rows($rslt); + $p=0; + while ( ($campstatus_to_print > $p) and ($p < 10) ) + { + $row=mysql_fetch_row($rslt); + echo "$row[0] "; + $p++; + } + if ($p<1) + {echo "NONE";} + echo "MODIFY CÓDIGOS DE PAUSA
\n"; +} + + +###################### +# ADD=39 display all campaign list mixes +###################### +if ($ADD==39) +{ +echo "
\n"; + echo ""; + +echo "
LISTA DE MESCLAGEM DE LISTA DE REGISTROS:\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $campaigns_to_print = mysql_num_rows($rslt); + + $o=0; + while ($campaigns_to_print > $o) + { + $row=mysql_fetch_row($rslt); + $campaigns_id_list[$o] = $row[0]; + $campaigns_name_list[$o] = $row[1]; + $o++; + } + + $o=0; + while ($campaigns_to_print > $o) + { + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
CAMPANHANOMELIST MIXALTERAR
$campaigns_id_list[$o] $campaigns_name_list[$o] "; + + $stmt="SELECT vcl_id from vicidial_campaigns_list_mix where campaign_id='$campaigns_id_list[$o]' order by status,vcl_id;"; + $rslt=mysql_query($stmt, $link); + $campstatus_to_print = mysql_num_rows($rslt); + $p=0; + while ( ($campstatus_to_print > $p) and ($p < 10) ) + { + $row=mysql_fetch_row($rslt); + echo "$row[0] "; + $p++; + } + if ($p<1) + {echo "NONE";} + echo "MODIFY LIST MIX
\n"; +} + + + + + +###################### +# ADD=311 modify list info in the system +###################### + +if ($ADD==311) + { + if ($LOGmodify_lists==1) + { + echo "
\n"; + echo ""; + + $stmt="SELECT list_id,list_name,campaign_id,active,list_description,list_changedate,list_lastcalldate,reset_time,agent_script_override,campaign_cid_override,am_message_exten_override,drop_inbound_group_override,xferconf_a_number,xferconf_b_number,xferconf_c_number,xferconf_d_number,xferconf_e_number from vicidial_lists where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $list_name = $row[1]; + $campaign_id = $row[2]; + $active = $row[3]; + $list_description = $row[4]; + $list_changedate = $row[5]; + $list_lastcalldate = $row[6]; + $reset_time = $row[7]; + $agent_script_override = $row[8]; + $campaign_cid_override = $row[9]; + $am_message_exten_override = $row[10]; + $drop_inbound_group_override = $row[11]; + $xferconf_a_number = $row[12]; + $xferconf_b_number = $row[13]; + $xferconf_c_number = $row[14]; + $xferconf_d_number = $row[15]; + $xferconf_e_number = $row[16]; + + # grab names of global statuses and statuses in the selected campaign + $stmt="SELECT status,status_name,selectable,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable from vicidial_statuses order by status"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + + $o=0; + while ($statuses_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $statuses_list["$rowx[0]"] = "$rowx[1]"; + $o++; + } + + $stmt="SELECT status,status_name,selectable,campaign_id,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable from vicidial_campaign_statuses where campaign_id='$campaign_id' order by status"; + $rslt=mysql_query($stmt, $link); + $Cstatuses_to_print = mysql_num_rows($rslt); + + $o=0; + while ($Cstatuses_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $statuses_list["$rowx[0]"] = "$rowx[1]"; + $o++; + } + # end grab status names + + ##### get scripts listings for pulldown + $Lscripts_list = "\n"; + $stmt="SELECT script_id,script_name from vicidial_scripts order by script_id"; + $rslt=mysql_query($stmt, $link); + $scripts_to_print = mysql_num_rows($rslt); + $o=0; + while ($scripts_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $Lscripts_list .= "\n"; + $scriptname_list["$rowx[0]"] = "$rowx[1]"; + $o++; + } + + ##### get in-groups listings for dynamic drop in-group pulldown + $stmt="SELECT group_id,group_name from vicidial_inbound_groups order by group_id"; + $rslt=mysql_query($stmt, $link); + $Dgroups_to_print = mysql_num_rows($rslt); + $Dgroups_menu=''; + $Dgroups_selected=0; + $o=0; + while ($Dgroups_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $Dgroups_menu .= "\n"; + $o++; + } + if ($Dgroups_selected < 1) + {$Dgroups_menu .= "\n";} + else + {$Dgroups_menu .= "\n";} + + + echo "
ALTERAR REGISTRO DA LISTA: $list_id
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + + echo "\n"; + echo "
ID da Lista: $list_id$NWB#vicidial_lists-list_id$NWE
Nome da Lista: $NWB#vicidial_lists-list_name$NWE
Descrição da Lista: $NWB#vicidial_lists-list_description$NWE
Campanha: $NWB#vicidial_lists-campaign_id$NWE
Ativo: $NWB#vicidial_lists-active$NWE
Reiniciar Status dos registros de chamada para esta Lista: $NWB#vicidial_lists-reset_list$NWE
Perdí Times: $NWB#vicidial_lists-reset_time$NWE
Data da Alteração: $list_changedate   $NWB#vicidial_lists-list_changedate$NWE
Data da última chamada da lista: $list_lastcalldate   $NWB#vicidial_lists-list_lastcalldate$NWE
Agente de secuencias de comandos Reemplazar: $NWB#vicidial_lists-agent_script_override$NWE
Campaña CID Override: $NWB#vicidial_lists-campaign_cid_override$NWE
Contestador automático de mensajes Override: audio chooser $NWB#vicidial_lists-am_message_exten_override$NWE
Drop de entrada Grupo de Override: $NWB#vicidial_lists-drop_inbound_group_override$NWE
Número Transfer-Conf 1 Override: $NWB#vicidial_lists-xferconf_a_dtmf$NWE
Número Transfer-Conf 2 Override: $NWB#vicidial_lists-xferconf_a_dtmf$NWE
Número Transfer-Conf 3 Override: $NWB#vicidial_lists-xferconf_a_dtmf$NWE
Número Transfer-Conf 4 Override: $NWB#vicidial_lists-xferconf_a_dtmf$NWE
Número Transfer-Conf 5 Override: $NWB#vicidial_lists-xferconf_a_dtmf$NWE
\n"; + + echo "
\n"; + echo "
STATUS DESTA LISTA:
\n"; + echo "\n"; + echo "\n"; + + $leads_in_list = 0; + $leads_in_list_N = 0; + $leads_in_list_Y = 0; + $stmt="SELECT status,called_since_last_reset,count(*) from vicidial_list where list_id='$list_id' group by status,called_since_last_reset order by status,called_since_last_reset"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + + $o=0; + $lead_list['count'] = 0; + $lead_list['Y_count'] = 0; + $lead_list['N_count'] = 0; + while ($statuses_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + + $lead_list['count'] = ($lead_list['count'] + $rowx[2]); + if ($rowx[1] == 'N') + { + $since_reset = 'N'; + $since_resetX = 'Y'; + } + else + { + $since_reset = 'Y'; + $since_resetX = 'N'; + } + $lead_list[$since_reset][$rowx[0]] = ($lead_list[$since_reset][$rowx[0]] + $rowx[2]); + $lead_list[$since_reset.'_count'] = ($lead_list[$since_reset.'_count'] + $rowx[2]); + #If opposite side is not set, it may not in the future so give it a value of zero + if (!isset($lead_list[$since_resetX][$rowx[0]])) + { + $lead_list[$since_resetX][$rowx[0]]=0; + } + $o++; + } + + $o=0; + if ($lead_list['count'] > 0) + { + while (list($dispo,) = each($lead_list[$since_reset])) + { + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + if ($dispo == 'CBHOLD') + { + $CLB=""; + $CLE=""; + } + else + { + $CLB=''; + $CLE=''; + } + + echo "\n"; + $o++; + } + } + + echo "\n"; + echo "\n"; + + echo "
STATUSNOME DO STATUSCHAMADONÃO CHAMADO
$CLB$dispo$CLE$statuses_list[$dispo]".$lead_list['Y'][$dispo]."".$lead_list['N'][$dispo]."
SUBTOTAIS$lead_list[Y_count]$lead_list[N_count]
TOTAL$lead_list[count]

\n"; + unset($lead_list); + + + echo "
\n"; + echo "
FUSOS HORÁRIOS DESTA CAMPANHA:
\n"; + echo "\n"; + echo "\n"; + + $stmt="SELECT gmt_offset_now,called_since_last_reset,count(*) from vicidial_list where list_id='$list_id' group by gmt_offset_now,called_since_last_reset order by gmt_offset_now,called_since_last_reset"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + + $o=0; + $plus='+'; + $lead_list['count'] = 0; + $lead_list['Y_count'] = 0; + $lead_list['N_count'] = 0; + while ($statuses_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + + $lead_list['count'] = ($lead_list['count'] + $rowx[2]); + if ($rowx[1] == 'N') + { + $since_reset = 'N'; + $since_resetX = 'Y'; + } + else + { + $since_reset = 'Y'; + $since_resetX = 'N'; + } + $lead_list[$since_reset][$rowx[0]] = ($lead_list[$since_reset][$rowx[0]] + $rowx[2]); + $lead_list[$since_reset.'_count'] = ($lead_list[$since_reset.'_count'] + $rowx[2]); + #If opposite side is not set, it may not in the future so give it a value of zero + if (!isset($lead_list[$since_resetX][$rowx[0]])) + { + $lead_list[$since_resetX][$rowx[0]]=0; + } + $o++; + } + + if ($lead_list['count'] > 0) + { + while (list($tzone,) = each($lead_list[$since_reset])) + { + $LOCALzone=3600 * $tzone; + $LOCALdate=gmdate("D M Y H:i", time() + $LOCALzone); + + if ($tzone >= 0) {$DISPtzone = "$plus$tzone";} + else {$DISPtzone = "$tzone";} + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + } + } + + echo "\n"; + echo "\n"; + + echo "
DIFERENÇA PARA GMT AGORA (horário local)CHAMADONÃO CHAMADO
".$DISPtzone."     ($LOCALdate)".$lead_list['Y'][$tzone]."".$lead_list['N'][$tzone]."
SUBTOTAIS$lead_list[Y_count]$lead_list[N_count]
TOTAL$lead_list[count]

\n"; + unset($lead_list); + + + echo "
\n"; + echo "
PROPIETARIOS dentro de esta lista:
\n"; + echo "\n"; + echo "\n"; + + $leads_in_list = 0; + $leads_in_list_N = 0; + $leads_in_list_Y = 0; + $stmt="SELECT owner,called_since_last_reset,count(*) from vicidial_list where list_id='$list_id' group by owner,called_since_last_reset order by owner,called_since_last_reset"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $owners_to_print = mysql_num_rows($rslt); + + $o=0; + $lead_list['count'] = 0; + $lead_list['Y_count'] = 0; + $lead_list['N_count'] = 0; + while ($owners_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + + $lead_list['count'] = ($lead_list['count'] + $rowx[2]); + if ($rowx[1] == 'N') + { + $since_reset = 'N'; + $since_resetX = 'Y'; + } + else + { + $since_reset = 'Y'; + $since_resetX = 'N'; + } + $lead_list[$since_reset][$rowx[0]] = ($lead_list[$since_reset][$rowx[0]] + $rowx[2]); + $lead_list[$since_reset.'_count'] = ($lead_list[$since_reset.'_count'] + $rowx[2]); + #If opposite side is not set, it may not in the future so give it a value of zero + if (!isset($lead_list[$since_resetX][$rowx[0]])) + { + $lead_list[$since_resetX][$rowx[0]]=0; + } + $o++; + } + + $o=0; + if ($lead_list['count'] > 0) + { + while (list($owner,) = each($lead_list[$since_reset])) + { + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $CLB=''; + $CLE=''; + + echo "\n"; + $o++; + } + } + + echo "\n"; + echo "\n"; + + echo "
OWNERCHAMADONÃO CHAMADO
$CLB$owner$CLE".$lead_list['Y'][$owner]."".$lead_list['N'][$owner]."
SUBTOTAIS$lead_list[Y_count]$lead_list[N_count]
TOTAL$lead_list[count]

\n"; + unset($lead_list); + + + echo "
\n"; + echo "
RANKS dentro de esta lista:
\n"; + echo "\n"; + echo "\n"; + + $leads_in_list = 0; + $leads_in_list_N = 0; + $leads_in_list_Y = 0; + $stmt="SELECT rank,called_since_last_reset,count(*) from vicidial_list where list_id='$list_id' group by rank,called_since_last_reset order by rank,called_since_last_reset"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $ranks_to_print = mysql_num_rows($rslt); + + $o=0; + $lead_list['count'] = 0; + $lead_list['Y_count'] = 0; + $lead_list['N_count'] = 0; + while ($ranks_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + + $lead_list['count'] = ($lead_list['count'] + $rowx[2]); + if ($rowx[1] == 'N') + { + $since_reset = 'N'; + $since_resetX = 'Y'; + } + else + { + $since_reset = 'Y'; + $since_resetX = 'N'; + } + $lead_list[$since_reset][$rowx[0]] = ($lead_list[$since_reset][$rowx[0]] + $rowx[2]); + $lead_list[$since_reset.'_count'] = ($lead_list[$since_reset.'_count'] + $rowx[2]); + #If opposite side is not set, it may not in the future so give it a value of zero + if (!isset($lead_list[$since_resetX][$rowx[0]])) + { + $lead_list[$since_resetX][$rowx[0]]=0; + } + $o++; + } + + $o=0; + if ($lead_list['count'] > 0) + { + while (list($rank,) = each($lead_list[$since_reset])) + { + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $CLB=''; + $CLE=''; + + echo "\n"; + $o++; + } + } + + echo "\n"; + echo "\n"; + + echo "
RANKCHAMADONÃO CHAMADO
$CLB$rank$CLE".$lead_list['Y'][$rank]."".$lead_list['N'][$rank]."
SUBTOTAIS$lead_list[Y_count]$lead_list[N_count]
TOTAL$lead_list[count]

\n"; + unset($lead_list); + + + $leads_in_list = 0; + $leads_in_list_N = 0; + $leads_in_list_Y = 0; + $stmt="SELECT status, if(called_count >= 100, 100, called_count), count(*) from vicidial_list where list_id='$list_id' group by status, if(called_count >= 100, 100, called_count) order by status,called_count"; + $rslt=mysql_query($stmt, $link); + $status_called_to_print = mysql_num_rows($rslt); + + $o=0; + $sts=0; + $first_row=1; + $all_called_first=1000; + $all_called_last=0; + while ($status_called_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $leads_in_list = ($leads_in_list + $rowx[2]); + $count_statuses[$o] = $rowx[0]; + $count_called[$o] = $rowx[1]; + $count_count[$o] = $rowx[2]; + $all_called_count[$rowx[1]] = ($all_called_count[$rowx[1]] + $rowx[2]); + + if ( (strlen($status[$sts]) < 1) or ($status[$sts] != "$rowx[0]") ) + { + if ($first_row) {$first_row=0;} + else {$sts++;} + $status[$sts] = "$rowx[0]"; + $status_called_first[$sts] = "$rowx[1]"; + if ($status_called_first[$sts] < $all_called_first) {$all_called_first = $status_called_first[$sts];} + } + $leads_in_sts[$sts] = ($leads_in_sts[$sts] + $rowx[2]); + $status_called_last[$sts] = "$rowx[1]"; + if ($status_called_last[$sts] > $all_called_last) {$all_called_last = $status_called_last[$sts];} + + $o++; + } + + + echo "
\n"; + echo "
CHAMADAS EFETUADAS DESTA LISTA:
\n"; + echo "\n"; + echo ""; + $first = $all_called_first; + while ($first <= $all_called_last) + { + if (eregi("1$|3$|5$|7$|9$", $first)) {$AB='bgcolor="#AFEEEE"';} + else{$AB='bgcolor="#E0FFFF"';} + if ($first >= 100) {$Fplus='+';} + else {$Fplus='';} + echo ""; + $first++; + } + echo "\n"; + + $sts=0; + $statuses_called_to_print = count($status); + while ($statuses_called_to_print > $sts) + { + $Pstatus = $status[$sts]; + if (eregi("1$|3$|5$|7$|9$", $sts)) + {$bgcolor='bgcolor="#B9CBFD"'; $AB='bgcolor="#9BB9FB"';} + else + {$bgcolor='bgcolor="#9BB9FB"'; $AB='bgcolor="#B9CBFD"';} + # echo "$status[$sts]|$status_called_first[$sts]|$status_called_last[$sts]|$leads_in_sts[$sts]|\n"; + # echo "$status[$sts]|"; + echo ""; + + $first = $all_called_first; + while ($first <= $all_called_last) + { + if (eregi("1$|3$|5$|7$|9$", $sts)) + { + if (eregi("1$|3$|5$|7$|9$", $first)) {$AB='bgcolor="#9BB9FB"';} + else{$AB='bgcolor="#B9CBFD"';} + } + else + { + if (eregi("0$|2$|4$|6$|8$", $first)) {$AB='bgcolor="#9BB9FB"';} + else{$AB='bgcolor="#B9CBFD"';} + } + + $called_printed=0; + $o=0; + while ($status_called_to_print > $o) + { + if ( ($count_statuses[$o] == "$Pstatus") and ($count_called[$o] == "$first") ) + { + $called_printed++; + echo ""; + } + + $o++; + } + if (!$called_printed) + {echo "";} + $first++; + } + echo "\n\n"; + + $sts++; + } + + echo ""; + $first = $all_called_first; + while ($first <= $all_called_last) + { + if (eregi("1$|3$|5$|7$|9$", $first)) {$AB='bgcolor="#AFEEEE"';} + else{$AB='bgcolor="#E0FFFF"';} + echo ""; + $first++; + } + echo "\n"; + + echo "
STATUSNOME DO STATUS$first$FplusSUBTOTAL
$Pstatus$statuses_list[$Pstatus] $count_count[$o]  $leads_in_sts[$sts]
TOTAL$all_called_count[$first]$leads_in_list

\n"; + + + + + + echo "
\n"; + + echo "

Clique aqui para ver todos os registros de Callback para esta lista

\n"; + echo "

Clique aqui para fazer download desta lista

\n"; + + if ($LOGdelete_lists > 0) + { + echo "

APAGAR ESTA LISTA\n"; + } + if ($LOGuser_level >= 9) + { + echo "

Clique aqui para ver alterações Admin para esta lista
\n"; + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + + +###################### +# ADD=3111 modify in-group info in the system +###################### + +if ($ADD==3111) + { + if ($LOGmodify_ingroups==1) + { + echo "
\n"; + echo ""; + + $stmt="SELECT group_id,group_name,group_color,active,web_form_address,voicemail_ext,next_agent_call,fronter_display,ingroup_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,drop_call_seconds,drop_action,drop_exten,call_time_id,after_hours_action,after_hours_message_filename,after_hours_exten,after_hours_voicemail,welcome_message_filename,moh_context,onhold_prompt_filename,prompt_interval,agent_alert_exten,agent_alert_delay,default_xfer_group,queue_priority,drop_inbound_group,ingroup_recording_override,ingroup_rec_filename,afterhours_xfer_group,qc_enabled,qc_statuses,qc_shift_id,qc_get_record_launch,qc_show_recording,qc_web_form_address,qc_script,play_place_in_line,play_estimate_hold_time,hold_time_option,hold_time_option_seconds,hold_time_option_exten,hold_time_option_voicemail,hold_time_option_xfer_group,hold_time_option_callback_filename,hold_time_option_callback_list_id,hold_recall_xfer_group,no_delay_call_route,play_welcome_message,answer_sec_pct_rt_stat_one,answer_sec_pct_rt_stat_two,default_group_alias,no_agent_no_queue,no_agent_action,no_agent_action_value,web_form_address_two,timer_action,timer_action_message,timer_action_seconds,start_call_url,dispo_call_url,xferconf_c_number,xferconf_d_number,xferconf_e_number from vicidial_inbound_groups where group_id='$group_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $group_name = $row[1]; + $group_color = $row[2]; + $active = $row[3]; + $web_form_address = stripslashes($row[4]); + $voicemail_ext = $row[5]; + $next_agent_call = $row[6]; + $fronter_display = $row[7]; + $script_id = $row[8]; + $get_call_launch = $row[9]; + $xferconf_a_dtmf = $row[10]; + $xferconf_a_number = $row[11]; + $xferconf_b_dtmf = $row[12]; + $xferconf_b_number = $row[13]; + $drop_call_seconds = $row[14]; + $drop_action = $row[15]; + $drop_exten = $row[16]; + $call_time_id = $row[17]; + $after_hours_action = $row[18]; + $after_hours_message_filename = $row[19]; + $after_hours_exten = $row[20]; + $after_hours_voicemail = $row[21]; + $welcome_message_filename = $row[22]; + $moh_context = $row[23]; + $onhold_prompt_filename = $row[24]; + $prompt_interval = $row[25]; + $agent_alert_exten = $row[26]; + $agent_alert_delay = $row[27]; + $default_xfer_group = $row[28]; + $queue_priority = $row[29]; + $drop_inbound_group = $row[30]; + $ingroup_recording_override = $row[31]; + $ingroup_rec_filename = $row[32]; + $afterhours_xfer_group = $row[33]; + $qc_enabled = $row[34]; + $qc_statuses = $row[35]; + $qc_shift_id = $row[36]; + $qc_get_record_launch = $row[37]; + $qc_show_recording = $row[38]; + $qc_web_form_address = stripslashes($row[39]); + $qc_script = $row[40]; + $play_place_in_line = $row[41]; + $play_estimate_hold_time = $row[42]; + $hold_time_option = $row[43]; + $hold_time_option_seconds = $row[44]; + $hold_time_option_exten = $row[45]; + $hold_time_option_voicemail = $row[46]; + $hold_time_option_xfer_group = $row[47]; + $hold_time_option_callback_filename = $row[48]; + $hold_time_option_callback_list_id = $row[49]; + $hold_recall_xfer_group = $row[50]; + $no_delay_call_route = $row[51]; + $play_welcome_message = $row[52]; + $answer_sec_pct_rt_stat_one = $row[53]; + $answer_sec_pct_rt_stat_two = $row[54]; + $default_group_alias = $row[55]; + $no_agent_no_queue = $row[56]; + $no_agent_action = $row[57]; + $no_agent_action_value = $row[58]; + $web_form_address_two = stripslashes($row[59]); + $timer_action = $row[60]; + $timer_action_message = $row[61]; + $timer_action_seconds = $row[62]; + $start_call_url = $row[63]; + $dispo_call_url = $row[64]; + $xferconf_c_number = $row[65]; + $xferconf_d_number = $row[66]; + $xferconf_e_number = $row[67]; + + ##### get in-groups listings for dynamic pulldown + $stmt="SELECT group_id,group_name from vicidial_inbound_groups where group_id NOT IN('AGENTDIRECT') order by group_id"; + $rslt=mysql_query($stmt, $link); + $Xgroups_to_print = mysql_num_rows($rslt); + $Xgroups_menu=''; + $Xgroups_selected=0; + $Dgroups_menu=''; + $Dgroups_selected=0; + $Agroups_menu=''; + $Agroups_selected=0; + $Hgroups_menu=''; + $Hgroups_selected=0; + $Tgroups_menu=''; + $Tgroups_selected=0; + $o=0; + while ($Xgroups_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $Xgroups_menu .= "\n"; + $Dgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]\n"; + if ($group_id!=$rowx[0]) + { + $Agroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]\n"; + $Tgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]\n"; + $Hgroups_menu .= "value=\"$rowx[0]\">$rowx[0] - $rowx[1]\n"; + } + $o++; + } + if ($Xgroups_selected < 1) + {$Xgroups_menu .= "\n";} + else + {$Xgroups_menu .= "\n";} + if ($Dgroups_selected < 1) + {$Dgroups_menu .= "\n";} + else + {$Dgroups_menu .= "\n";} + if ($Agroups_selected < 1) + {$Agroups_menu .= "\n";} + else + {$Agroups_menu .= "\n";} + if ($Tgroups_selected < 1) + {$Tgroups_menu .= "\n";} + else + {$Tgroups_menu .= "\n";} + if ($Hgroups_selected < 1) + {$Hgroups_menu .= "\n";} + else + {$Hgroups_menu .= "\n";} + + + echo "
ALTERAR REGISTRO DE GRUPOS: $row[0]\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + if ($SSenable_second_webform > 0) + { + echo "\n"; + } + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + $eswHTML=''; + if ($SSenable_second_webform > 0) + {$eswHTML = '';} + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + ##### get groups_alias listings for dynamic default group alias pulldown list menu + $stmt="SELECT group_alias_id,group_alias_name from groups_alias where active='Y' order by group_alias_id"; + $rslt=mysql_query($stmt, $link); + $group_alias_to_print = mysql_num_rows($rslt); + $group_alias_menu=''; + $group_alias_selected=0; + $o=0; + while ($group_alias_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $group_alias_menu .= "\n"; + $o++; + } + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + + echo "\n"; + + if ($SSqc_features_active > 0) + { + echo "\n"; + echo "\n"; + + ##### get status listings for dynamic pulldown + $qc_statuses = preg_replace("/^ | -$/","",$qc_statuses); + $QCstatuses = explode(" ", $qc_statuses); + $QCs_to_print = (count($QCstatuses) -0); + $stmt="SELECT status,status_name,selectable,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable from vicidial_statuses where status NOT IN('QUEUE','INCALL') order by status"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + $qc_statuses_list=''; + + $o=0; + while ($statuses_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $qc_statuses_list .= " $o) + { + $rowx=mysql_fetch_row($rslt); + if (!ereg("\"$rowx[0]\"",$qc_statuses_list)) + { + $qc_statuses_list .= " $o) + { + $rowx=mysql_fetch_row($rslt); + $QCscripts_list .= "\n"; + $scriptname_list["$rowx[0]"] = "$rowx[1]"; + $o++; + } + ##### get shifts listings for pulldown + $stmt="SELECT shift_id,shift_name from vicidial_shifts order by shift_id"; + $rslt=mysql_query($stmt, $link); + $shifts_to_print = mysql_num_rows($rslt); + $QCshifts_list=""; + $o=0; + while ($shifts_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $QCshifts_list .= "\n"; + $shiftname_list["$rowx[0]"] = "$rowx[1]"; + $o++; + } + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + } + + echo "
ID do Grupo: $row[0]$NWB#vicidial_inbound_groups-group_id$NWE
Nome do Grupo: $NWB#vicidial_inbound_groups-group_name$NWE
Cor do Grupo: $NWB#vicidial_inbound_groups-group_color$NWE
Ativo: $NWB#vicidial_inbound_groups-active$NWE
Formulário Web: $NWB#vicidial_inbound_groups-web_form_address$NWE
Formulário Web Two: $NWB#vicidial_inbound_groups-web_form_address$NWE
Próximo Agente a chamar: $NWB#vicidial_inbound_groups-next_agent_call$NWE
Prioridade da Fila: $NWB#vicidial_inbound_groups-queue_priority$NWE
Mostrar Fronter: $NWB#vicidial_inbound_groups-fronter_display$NWE
Script: $NWB#vicidial_inbound_groups-ingroup_script$NWE
Pegar lançamento da chamada: $NWB#vicidial_inbound_groups-get_call_launch$NWE
Transfer-Conf DTMF 1: $NWB#vicidial_inbound_groups-xferconf_a_dtmf$NWE
Número Transfer-Conf 1: $NWB#vicidial_inbound_groups-xferconf_a_dtmf$NWE
Transfer-Conf DTMF 2: $NWB#vicidial_inbound_groups-xferconf_a_dtmf$NWE
Número Transfer-Conf 2: $NWB#vicidial_inbound_groups-xferconf_a_dtmf$NWE
Número Transfer-Conf 3: $NWB#vicidial_inbound_groups-xferconf_a_dtmf$NWE
Número Transfer-Conf 4: $NWB#vicidial_inbound_groups-xferconf_a_dtmf$NWE
Número Transfer-Conf 5: $NWB#vicidial_inbound_groups-xferconf_a_dtmf$NWE
Temporizador de Acción de: $NWB#vicidial_inbound_groups-timer_action$NWE
Temporizador de mensaje de acción: $NWB#vicidial_inbound_groups-timer_action_message$NWE
Temporizador Segundos Acción: $NWB#vicidial_inbound_groups-timer_action_seconds$NWE
Tempo até derrubar(DROP): $NWB#vicidial_inbound_groups-drop_call_seconds$NWE
Ação de Drop:$NWB#vicidial_inbound_groups-drop_action$NWE
Exten de Drop: $NWB#vicidial_inbound_groups-drop_exten$NWE
Correio de Voz: voicemail chooser$NWB#vicidial_inbound_groups-voicemail_ext$NWE
Grupo de Transferência de Drop:$NWB#vicidial_inbound_groups-drop_inbound_group$NWE
Horário de Chamada:$NWB#vicidial_inbound_groups-call_time_id$NWE
Ação Fora do Expediente:$NWB#vicidial_inbound_groups-after_hours_action$NWE
Arquivo Fora do Expediente: audio chooser $NWB#vicidial_inbound_groups-after_hours_message_filename$NWE
Extensão Fora do Expediente:$NWB#vicidial_inbound_groups-after_hours_exten$NWE
Correio de Voz Fora do Expediente: voicemail chooser$NWB#vicidial_inbound_groups-after_hours_voicemail$NWE
Grupo de Transferência Fora do Exped.:$NWB#vicidial_inbound_groups-afterhours_xfer_group$NWE
N de colas n Agentes: $NWB#vicidial_inbound_groups-no_agent_no_queue$NWE
No No Acción cola de agente: $NWB#vicidial_inbound_groups-no_agent_no_queue$NWE\n"; + + echo "
"; + echo "\n"; + + if ($no_agent_action=='CALLMENU') + { + echo ""; + echo "Menu:"; + echo ""; + echo " \n"; + } + if ($no_agent_action=='INGROUP') + { + if (strlen($no_agent_action_value) < 10) + {$no_agent_action_value = 'SALESLINE,CID,LB,998,TESTCAMP,1';} + $IGno_agent_action_value = explode(",",$no_agent_action_value); + $IGgroup_id = $IGno_agent_action_value[0]; + $IGhandle_method = $IGno_agent_action_value[1]; + $IGsearch_method = $IGno_agent_action_value[2]; + $IGlist_id = $IGno_agent_action_value[3]; + $IGcampaign_id = $IGno_agent_action_value[4]; + $IGphone_code = $IGno_agent_action_value[5]; + echo ""; + echo "In-Group:"; + echo ""; + echo " "; + echo "   Handle Method: \n"; + echo "
Search Method: \n"; + echo "   ID da Lista: "; + echo "
ID da Campanha: \n"; + echo "   Phone Code: "; + } + if ($no_agent_action=='DID') + { + $stmt="SELECT did_id from vicidial_inbound_dids where did_pattern='$no_agent_action_value';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $did_id = $row[0]; + + echo ""; + echo "DID:"; + echo ""; + echo " \n"; + } + if ($no_agent_action=='MESSAGE') + { + if (strlen($no_agent_action_value) < 3) + {$no_agent_action_value = 'nbdy-avail-to-take-call|vm-goodbye';} + echo "Audio File: audio chooser\n"; + } + if ($no_agent_action=='EXTENSION') + { + if (strlen($no_agent_action_value) < 3) + {$no_agent_action_value = '8304,default';} + $EXno_agent_action_value = explode(",",$no_agent_action_value); + $EXextension = $EXno_agent_action_value[0]; + $EXcontext = $EXno_agent_action_value[1]; + echo "Extensão:   Context: \n"; + } + if ($no_agent_action=='VOICEMAIL') + { + echo "Caixa do Correio de Voz: voicemail chooser\n"; + } + + echo "
+
 
Arquivo de Boas Vindas: audio chooser $NWB#vicidial_inbound_groups-welcome_message_filename$NWE
Tocar Mens. de Boas Vindas:$NWB#vicidial_inbound_groups-play_welcome_message$NWE
Contexto da Música de Espera: moh chooser $NWB#vicidial_inbound_groups-moh_context$NWE
Arquivo de Aviso de Espera audio chooser $NWB#vicidial_inbound_groups-onhold_prompt_filename$NWE
Intervalo de Aviso de Espera:$NWB#vicidial_inbound_groups-prompt_interval$NWE
Tocar Lugar na Fila:$NWB#vicidial_inbound_groups-play_place_in_line$NWE
Tocar Tempo Estimado:$NWB#vicidial_inbound_groups-play_estimate_hold_time$NWE
Opção de Espera:$NWB#vicidial_inbound_groups-hold_time_option$NWE
Tempo de Opção de Espera:$NWB#vicidial_inbound_groups-hold_time_option_seconds$NWE
Extensão de Opção de Espera:$NWB#vicidial_inbound_groups-hold_time_option_exten$NWE
Correio de Voz da Opção de Espera: voicemail chooser $NWB#vicidial_inbound_groups-hold_time_option_voicemail$NWE
Grupo de Entrada da Opção de Espera:$NWB#vicidial_inbound_groups-hold_time_option_xfer_group$NWE
Arq. de Agend. da Opção de Espera: audio chooser $NWB#vicidial_inbound_groups-hold_time_option_callback_filename$NWE
Lista de Agend. da Opção de Espera:$NWB#vicidial_inbound_groups-hold_time_option_callback_list_id$NWE
Agente de Alerta Nombre de archivo: audio chooser $NWB#vicidial_inbound_groups-agent_alert_exten$NWE
Atraso de Alerta ao Agente:$NWB#vicidial_inbound_groups-agent_alert_delay$NWE
Grupo de Transferência Padrão:$NWB#vicidial_inbound_groups-default_xfer_group$NWE
Alias de Grupo Padrão: $NWB#vicidial_inbound_groups-default_group_alias$NWE
Grupo de Transferência de Rechamada:$NWB#vicidial_inbound_groups-hold_recall_xfer_group$NWE
Rotear sem Atrasos:$NWB#vicidial_inbound_groups-no_delay_call_route$NWE
Sobrepor Config. de Grav. de Entr.:$NWB#vicidial_inbound_groups-ingroup_recording_override$NWE
Arquivo de Gravação de Entrada:$NWB#vicidial_inbound_groups-ingroup_rec_filename$NWE
Percentual Estatístico de Chamadas Atendidas em X seg 1: $NWB#vicidial_inbound_groups-answer_sec_pct_rt_stat_one$NWE
Percentual Estatístico de Chamadas Atendidas em X seg 2: $NWB#vicidial_inbound_groups-answer_sec_pct_rt_stat_one$NWE
Iniciar llamada URL: $NWB#vicidial_inbound_groups-start_call_url$NWE
Dispo Call URL: $NWB#vicidial_inbound_groups-dispo_call_url$NWE
 
Config. de CQ para Entrantes:
CQ Ativado: $NWB#vicidial_inbound_groups-qc_enabled$NWE
Status de CQ:
$NWB#vicidial_inbound_groups-qc_statuses$NWE
$qc_statuses_list
WebForm de CQ:$NWB#vicidial_inbound_groups-qc_web_form_address$NWE
Script de CQ: $NWB#vicidial_inbound_groups-qc_script$NWE
Turno de CQ: $NWB#vicidial_inbound_groups-qc_shift_id$NWE
Entrada de registro CQ: $NWB#vicidial_inbound_groups-qc_get_record_launch$NWE
Mostrar Gravações CQ: $NWB#vicidial_inbound_groups-qc_show_recording$NWE
\n"; + echo "

\n"; + + + ### list of agent rank or skill-level for this inbound group + echo "
\n"; + echo "
AGENTE RANKS FOR THIS ENTRANTE GROUP:
\n"; + echo "\n"; + echo "\n"; + + $stmt="SELECT vu.user,viga.group_rank,calls_today,full_name from vicidial_inbound_group_agents viga, vicidial_users vu where group_id='$group_id' and active='Y' and vu.user=viga.user;"; + $rsltx=mysql_query($stmt, $link); + $users_to_print = mysql_num_rows($rsltx); + + $o=0; + while ($users_to_print > $o) + { + $rowx=mysql_fetch_row($rsltx); + $o++; + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + } + + echo "
USER     RANK     CALLS TODAY
$rowx[0] - $rowx[3]$rowx[1]$rowx[2]

\n"; + + echo "

\n"; + + echo "
Clique aqui para ver um relatório deste grupo de entrada

\n"; + + echo "
\n"; + + echo "DIDS USING THIS IN-GROUP:
\n"; + echo "\n"; + + $stmt="SELECT did_id,did_pattern,did_description from vicidial_inbound_dids where group_id='$group_id' and did_route='IN_GROUP';"; + $rslt=mysql_query($stmt, $link); + $dids_to_print = mysql_num_rows($rslt); + $o=0; + while ($dids_to_print > $o) + { + $row=mysql_fetch_row($rslt); + echo "\n"; + $o++; + } + + echo "
$row[1] $row[2]

\n"; + echo "CALL MENUS USING THIS IN-GROUP:
\n"; + echo "\n"; + + $stmt="SELECT distinct vm.menu_id,menu_name from vicidial_call_menu vm,vicidial_call_menu_options vmo where vm.menu_id=vmo.menu_id and option_route='INGROUP' and option_route_value='$group_id';"; + $rslt=mysql_query($stmt, $link); + $cms_to_print = mysql_num_rows($rslt); + $o=0; + while ($cms_to_print > $o) + { + $row=mysql_fetch_row($rslt); + echo "\n"; + $o++; + } + + echo "
$row[0] $row[1]

\n"; + echo "CAMPAÑAS QUE PERMITA EN ESTE GRUPO:
\n"; + echo "\n"; + + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns where closer_campaigns LIKE \"% $group_id %\";"; + $rslt=mysql_query($stmt, $link); + $campin_to_print = mysql_num_rows($rslt); + $o=0; + while ($campin_to_print > $o) + { + $row=mysql_fetch_row($rslt); + echo "\n"; + $o++; + } + + echo "
$row[0] $row[1]
\n"; + + if ($LOGdelete_ingroups > 0) + { + echo "

EMERGENCY VDAC CLEAR FOR THIS IN-GROUP

\n"; + echo "

APAGAR ESTE GRUPO DE ENTRADA\n"; + } + if ($LOGuser_level >= 9) + { + echo "

Clique aqui para ver alterações Admin para este grupo de entrada\n"; + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + + +###################### +# ADD=3311 modify did info in the system +###################### + +if ($ADD==3311) + { + if ($LOGmodify_dids==1) + { + echo "
\n"; + echo ""; + + $didSQL = "did_id='$did_id'"; + if ( (strlen($did_id)<1) and (strlen($did_pattern)>0) ) + {$didSQL = "did_pattern='$did_pattern'";} + $stmt="SELECT did_id,did_pattern,did_description,did_active,did_route,extension,exten_context,voicemail_ext,phone,server_ip,user,user_unavailable_action,user_route_settings_ingroup,group_id,call_handle_method,agent_search_method,list_id,campaign_id,phone_code,menu_id from vicidial_inbound_dids where $didSQL;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $did_id = $row[0]; + $did_pattern = $row[1]; + $did_description = $row[2]; + $did_active = $row[3]; + $did_route = $row[4]; + $extension = $row[5]; + $exten_context = $row[6]; + $voicemail_ext = $row[7]; + $phone = $row[8]; + $server_ip = $row[9]; + $user = $row[10]; + $user_unavailable_action = $row[11]; + $user_route_settings_ingroup = $row[12]; + $group_id = $row[13]; + $call_handle_method = $row[14]; + $agent_search_method = $row[15]; + $list_id = $row[16]; + $campaign_id = $row[17]; + $phone_code = $row[18]; + $menu_id = $row[19]; + + + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $campaigns_to_print = mysql_num_rows($rslt); + $campaigns_list=''; + $o=0; + while ($campaigns_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $campaigns_list .= "\n"; + $o++; + } + + ##### get in-groups listings for dynamic pulldown + $stmt="SELECT group_id,group_name from vicidial_inbound_groups order by group_id"; + $rslt=mysql_query($stmt, $link); + $Xgroups_to_print = mysql_num_rows($rslt); + $Xgroups_menu=''; + $Xgroups_selected=0; + $o=0; + while ($Xgroups_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $Xgroups_menu .= "\n"; + $o++; + } + if ($Xgroups_selected < 1) + {$Xgroups_menu .= "\n";} + else + {$Xgroups_menu .= "\n";} + + + ##### get in-groups listings for dynamic pulldown + $stmt="SELECT group_id,group_name from vicidial_inbound_groups where group_id NOT IN('AGENTDIRECT') order by group_id"; + $rslt=mysql_query($stmt, $link); + $Dgroups_to_print = mysql_num_rows($rslt); + $Dgroups_menu=''; + $Dgroups_selected=0; + $o=0; + while ($Dgroups_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $Dgroups_menu .= "\n"; + $o++; + } + if ($Dgroups_selected < 1) + {$Dgroups_menu .= "\n";} + else + {$Dgroups_menu .= "\n";} + + + echo "
ALTERAR UM REGISTRO DDR:$row[0]
\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + $stmt="select menu_id,menu_name,menu_prompt from vicidial_call_menu;"; + $rslt=mysql_query($stmt, $link); + $menus_to_print = mysql_num_rows($rslt); + $menu_list=''; + $i=0; + while ($i < $menus_to_print) + { + $row=mysql_fetch_row($rslt); + $menu_list .= ""; + $i++; + } + + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "
Extensão DDR:$NWB#vicidial_inbound_dids-did_pattern$NWE
Descrição DDR:$NWB#vicidial_inbound_dids-did_description$NWE
Ativo: $NWB#vicidial_inbound_dids-did_active$NWE
Rota DDR:$NWB#vicidial_inbound_dids-did_route$NWE
Extensão:$NWB#vicidial_inbound_dids-extension$NWE
Contexto da Extensão:$NWB#vicidial_inbound_dids-exten_context$NWE
Caixa do Correio de Voz: voicemail chooser$NWB#vicidial_inbound_dids-voicemail_ext$NWE
Extensão do Ramal:$NWB#vicidial_inbound_dids-phone$NWE
IP do Servidor: $NWB#vicidial_inbound_dids-server_ip$NWE
Menu: $NWB#vicidial_inbound_dids-menu_id$NWE
Agente:$NWB#vicidial_inbound_dids-user$NWE
Ação p/ Agente não Disponível:$NWB#vicidial_inbound_dids-user_unavailable_action$NWE
Config. de Rota de Entrada do Agente:$NWB#vicidial_inbound_dids-user_route_settings_ingroup$NWE
In-ID do Grupo: $NWB#vicidial_inbound_dids-group_id$NWE
Método de Manuseio de Chamada Entrante:$NWB#vicidial_inbound_dids-call_handle_method$NWE
Método de Busca de Agente p/ Ch. Entr.:$NWB#vicidial_inbound_dids-agent_search_method$NWE
ID da Lista de Entrada:$NWB#vicidial_inbound_dids-list_id$NWE
ID da Campanha de Entrada:$NWB#vicidial_inbound_dids-campaign_id$NWE
Código do Ramal de Entrada:$NWB#vicidial_inbound_dids-phone_code$NWE
\n"; + echo "

\n"; + + echo "
Haga clic aquí para ver un informe de tráfico para este DID

\n"; + + if ($LOGdelete_dids > 0) + { + echo "

REMOVER DDR\n"; + } + if ($LOGuser_level >= 9) + { + echo "

Clique aqui para ver alterações Admin para este DDR\n"; + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + + +###################### +# ADD=3511 modify call menu info in the system +###################### + +if ($ADD==3511) + { + if ($LOGmodify_dids==1) + { + echo "
\n"; + echo ""; + + $stmt="SELECT menu_name,menu_prompt,menu_timeout,menu_timeout_prompt,menu_invalid_prompt,menu_repeat,menu_time_check,call_time_id,track_in_vdac,custom_dialplan_entry,tracking_group from vicidial_call_menu where menu_id='$menu_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $menu_name = $row[0]; + $menu_prompt = $row[1]; + $menu_timeout = $row[2]; + $menu_timeout_prompt = $row[3]; + $menu_invalid_prompt = $row[4]; + $menu_repeat = $row[5]; + $menu_time_check = $row[6]; + $call_time_id = $row[7]; + $track_in_vdac = $row[8]; + $custom_dialplan_entry= $row[9]; + $tracking_group = $row[10]; + + + echo "
ALTERAR O REGISTRO DE MENU: $menu_id
\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + + echo "\n"; + echo "\n"; + + $j=0; + $stmtA="SELECT option_value,option_description,option_route,option_route_value,option_route_value_context from vicidial_call_menu_options where menu_id='$menu_id' order by option_value;"; + $rslt=mysql_query($stmtA, $link); + $menus_to_print = mysql_num_rows($rslt); + + while ($menus_to_print > $j) + { + $row=mysql_fetch_row($rslt); + $Aoption_value[$j] = $row[0]; + $Aoption_description[$j] = $row[1]; + $Aoption_route[$j] = $row[2]; + $Aoption_route_value[$j] = $row[3]; + $Aoption_route_value_context[$j] = $row[4]; + $j++; + } + + $j=0; + while ($menus_to_print > $j) + { + $choose_height = (($j * 40) + 400); + $option_value = $Aoption_value[$j]; + $option_description = $Aoption_description[$j]; + $option_route = $Aoption_route[$j]; + $option_route_value = $Aoption_route_value[$j]; + $option_route_value_context = $Aoption_route_value_context[$j]; + + $dtmf_list = ""; + + if (eregi("1$|3$|5$|7$|9$", $j)) + {$bgcolor='bgcolor="#CCFFFF"';} + else + {$bgcolor='bgcolor="#99FFCC"';} + + echo "\n"; + $j++; + } + + while ($j <= 18) + { + $choose_height = (($j * 40) + 400); + $dtmf_list = ""; + + if (eregi("1$|3$|5$|7$|9$", $j)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + $j++; + } + + if ($SSallow_custom_dialplan > 0) + { + echo "\n"; + } + else + { + echo "\n"; + } + + echo "\n"; + echo "
ID do Menu: $menu_id $NWB#vicidial_call_menu-menu_id$NWE
Nome do Menu: $NWB#vicidial_call_menu-menu_name$NWE
Audio do Menu: audio chooser $NWB#vicidial_call_menu-menu_prompt$NWE
Tempo max do menu: $NWB#vicidial_call_menu-menu_timeout$NWE
Audio de tempo excedido do menu: audio chooser $NWB#vicidial_call_menu-menu_timeout_prompt$NWE
Audio de Opção Inválida do menu: audio chooser $NWB#vicidial_call_menu-menu_invalid_prompt$NWE
Repetir Menu: $NWB#vicidial_call_menu-menu_repeat$NWE
Verif. Horário de Menu: $NWB#vicidial_call_menu-menu_time_check$NWE
Horário de Chamada:$NWB#vicidial_call_menu-call_time_id$NWE
Rastrear Chamadas no Relat. Tempo-Real: $NWB#vicidial_call_menu-track_in_vdac$NWE
Grupo de seguimiento de: $NWB#vicidial_call_menu-tracking_group$NWE
Opções do Menu:
+ Opção: $dtmf_list   + Descrição: + Route: $NWB#vicidial_call_menu-option_value$NWE
+ + \n"; + + if ($option_route=='CALLMENU') + { + echo ""; + echo "Menu:"; + echo ""; + echo " \n"; + } + if ($option_route=='INGROUP') + { + if (strlen($option_route_value_context) < 10) + {$option_route_value_context = 'CID,LB,998,TESTCAMP,1';} + $IGoption_route_value_context = explode(",",$option_route_value_context); + $IGhandle_method = $IGoption_route_value_context[0]; + $IGsearch_method = $IGoption_route_value_context[1]; + $IGlist_id = $IGoption_route_value_context[2]; + $IGcampaign_id = $IGoption_route_value_context[3]; + $IGphone_code = $IGoption_route_value_context[4]; + echo ""; + echo "In-Group:"; + echo ""; + echo " "; + echo " "; + echo "   Handle Method: \n"; + echo "
Search Method: \n"; + echo "   ID da Lista: "; + echo "
ID da Campanha: \n"; + echo "   Phone Code: "; + } + if ($option_route=='DID') + { + $stmt="SELECT did_id from vicidial_inbound_dids where did_pattern='$option_route_value';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $did_id = $row[0]; + + echo ""; + echo "DID:"; + echo ""; + echo " \n"; + } + if ($option_route=='HANGUP') + { + echo "Audio File: audio chooser\n"; + } + if ($option_route=='EXTENSION') + { + echo "Extensão:   Context: \n"; + } + if ($option_route=='PHONE') + { + echo "Phone: \n"; + } + if ($option_route=='VOICEMAIL') + { + echo "Caixa do Correio de Voz: voicemail chooser\n"; + } + if ($option_route=='AGI') + { + echo "AGI: \n"; + } + + echo "
+
 
+ Opção: $dtmf_list   + Descrição: + Route: + $NWB#vicidial_call_menu-option_value$NWE
+ + \n"; + echo " +
 
Custom Plano de Discagem:
$NWB#vicidial_call_menu-custom_dialplan_entry$NWE
Custom Plano de Discagem: Disabled $NWB#vicidial_call_menu-custom_dialplan_entry$NWE
\n"; + echo "

\n"; + + echo "DIDS USING THIS CALL MENU:
\n"; + echo "\n"; + + $stmt="SELECT did_id,did_pattern,did_description from vicidial_inbound_dids where menu_id='$menu_id' and did_route='CALLMENU';"; + $rslt=mysql_query($stmt, $link); + $dids_to_print = mysql_num_rows($rslt); + $o=0; + while ($dids_to_print > $o) + { + $row=mysql_fetch_row($rslt); + echo "\n"; + $o++; + } + + echo "
$row[1] $row[2]

\n"; + + echo "CALL MENUS USING THIS CALL MENU:
\n"; + echo "\n"; + + $stmt="SELECT distinct vm.menu_id,menu_name from vicidial_call_menu vm,vicidial_call_menu_options vmo where vm.menu_id=vmo.menu_id and option_route='CALLMENU' and option_route_value='$menu_id';"; + $rslt=mysql_query($stmt, $link); + $cms_to_print = mysql_num_rows($rslt); + $o=0; + while ($cms_to_print > $o) + { + $row=mysql_fetch_row($rslt); + echo "\n"; + $o++; + } + + echo "
$row[0] $row[1]
\n"; + + + if ($LOGdelete_dids > 0) + { + echo "

REMOVER ESTE MENU\n"; + } + if ($LOGuser_level >= 9) + { + echo "

Clique aqui para ver as alterações deste MENU
\n"; + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + + +###################### +# ADD=31111 modify remote agents info in the system +###################### + +if ($ADD==31111) + { + if ($LOGmodify_remoteagents==1) + { + echo "
\n"; + echo ""; + + $stmt="SELECT remote_agent_id,user_start,number_of_lines,server_ip,conf_exten,status,campaign_id,closer_campaigns from vicidial_remote_agents where remote_agent_id='$remote_agent_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $remote_agent_id = $row[0]; + $user_start = $row[1]; + $number_of_lines = $row[2]; + $server_ip = $row[3]; + $conf_exten = $row[4]; + $status = $row[5]; + $campaign_id = $row[6]; + + echo "
ALTERAR AGENTES REMOTOS: $row[0]
\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Início do ID do Usuário: (somente números, incremented)$NWB#vicidial_remote_agents-user_start$NWE
Número de linhas: (somente números)$NWB#vicidial_remote_agents-number_of_lines$NWE
IP do Servidor: $NWB#vicidial_remote_agents-server_ip$NWE
Extensão Externa: (número do plano de discagem para ligar para agentes)$NWB#vicidial_remote_agents-conf_exten$NWE
Status: $NWB#vicidial_remote_agents-status$NWE
Campanha: $NWB#vicidial_remote_agents-campaign_id$NWE
Grupos de Entrada: \n"; + echo "$groups_list"; + echo "$NWB#vicidial_remote_agents-closer_campaigns$NWE
\n"; + echo "AVISO: Pode demorar até 30 segundos para que as alterações enviadas por essa tela se tornem ativas\n"; + + + if ($LOGdelete_remote_agents > 0) + { + echo "

APAGAR ESTE USUÁRIO REMOTO\n"; + } + if ($LOGuser_level >= 9) + { + echo "

Clique aqui para ver alterações Admin para este Agente Remoto
\n"; + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=311111 modify user group info in the system +###################### + +if ($ADD==311111) + { + if ($LOGmodify_usergroups==1) + { + echo "
\n"; + echo ""; + + $stmt="SELECT user_group,group_name,allowed_campaigns,qc_allowed_campaigns,qc_allowed_inbound_groups,group_shifts,forced_timeclock_login,shift_enforcement,agent_status_viewable_groups,agent_status_view_time from vicidial_user_groups where user_group='$user_group';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $user_group = $row[0]; + $group_name = $row[1]; + $GROUP_shifts = $row[5]; + $forced_timeclock_login = $row[6]; + $shift_enforcement = $row[7]; + $VGROUP_vgroups = $row[8]; + $agent_status_view_time = $row[9]; + + echo ""; + + echo "
ALTERAR O REGISTRO DE GRUPO DE USUÁRIOS\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + + echo "\n"; + + + echo "\n"; + + echo "\n"; + + if ($SSqc_features_active > 0) + { + echo "\n"; + echo "\n"; + } + + echo "\n"; + echo "
Grupo: (sem espaços ou pontos)$NWB#vicidial_user_groups-user_group$NWE
Descrição: (descrição do grupo)$NWB#vicidial_user_groups-group_name$NWE
Forçar Login no Ponto: $NWB#vicidial_user_groups-forced_timeclock_login$NWE
Controle de Turno: $NWB#vicidial_user_groups-shift_enforcement$NWE
Campanhas Permitidas:
$NWB#vicidial_user_groups-allowed_campaigns$NWE
\n"; + echo "$campaigns_list
 "; + echo "
Turnos do Grupo:
$NWB#vicidial_user_groups-group_shifts$NWE
\n"; + $stmt="SELECT shift_id,shift_name from vicidial_shifts order by shift_id"; + $rslt=mysql_query($stmt, $link); + $shifts_to_print = mysql_num_rows($rslt); + $o=0; + while ($shifts_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $shift_id_value = $rowx[0]; + $shift_name_value = $rowx[1]; + echo " $shift_id_value - $shift_name_value
\n"; + $o++; + } + echo "
 
Estado del agente visible Grupos:
$NWB#vicidial_user_groups-agent_status_viewable_groups$NWE
\n"; + echo "ALL-GROUPS - All user groups in the system
\n"; + echo "CAMPANHA-AGENTS - All users logged into the same campaign as the agent
\n"; + + $stmt="SELECT user_group,group_name from vicidial_user_groups order by user_group"; + $rslt=mysql_query($stmt, $link); + $view_groups_to_print = mysql_num_rows($rslt); + $o=0; + while ($view_groups_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $vgroups_id_value = $rowx[0]; + $vgroups_name_value = $rowx[1]; + echo " $vgroups_id_value - $vgroups_name_value
\n"; + $o++; + } + echo "
 
Ver estado del agente de turno: $NWB#vicidial_user_groups-agent_status_view_time$NWE
Campanhas Permitidas no CQ:
$NWB#vicidial_user_groups-qc_allowed_campaigns$NWE
\n"; + echo "$qc_campaigns_list"; + echo "
 
Grupos de Entrada para CQ:
$NWB#vicidial_user_groups-qc_allowed_inbound_groups$NWE
\n"; + echo "$qc_groups_list"; + echo "
 
\n"; + + + ### list of users in this user group + + $active_confs = 0; + $stmt="SELECT user,full_name,user_level,active from vicidial_users where user_group='$user_group'"; + $rsltx=mysql_query($stmt, $link); + $users_to_print = mysql_num_rows($rsltx); + + echo "
\n"; + echo "
USUÁRIOS DESTE GRUPO: $users_to_print
\n"; + echo "\n"; + echo "\n"; + + $o=0; + while ($users_to_print > $o) + { + $rowx=mysql_fetch_row($rsltx); + $o++; + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + + echo "
USERNOME COMPLETONÍVELATIVO
$rowx[0]$rowx[1]$rowx[2]$rowx[3]

\n"; + + + echo "

Clique aqui para ver todos os registros de CallBack para este grupo de usuários

\n"; + echo "

Clique aqui para ver o Status de Relógio de ponto para este usuário

\n"; + + if ($LOGdelete_user_groups > 0) + { + echo "

APAGAR ESTE GRUPO DE USUÁRIOS\n"; + } + if ($LOGuser_level >= 9) + { + echo "

Clique aqui para ver as alterações Admin para este Grupo de usuários
\n"; + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=3111111 modify script info in the system +###################### + +if ($ADD==3111111) + { + if ($LOGmodify_scripts==1) + { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo ""; + + $stmt="SELECT script_id,script_name,script_comments,script_text,active from vicidial_scripts where script_id='$script_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $script_name = $row[1]; + $script_comments = $row[2]; + $script_text = stripslashes($row[3]); + $active = $row[4]; + echo ""; + + echo "
ALTERAR SCRIPT\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
ID do Script: $script_id$NWB#vicidial_scripts-script_name$NWE
Nome do Script: (título do script)$NWB#vicidial_scripts-script_name$NWE
Comentários do Script: $NWB#vicidial_scripts-script_comments$NWE
Ativo: $NWB#vicidial_scripts-active$NWE
Texto do Script:

Pré-Visualizar Script
"; + # BEGIN Insert Field + echo ""; + echo "
"; + # END Insert Field + echo " $NWB#vicidial_scripts-script_text$NWE
\n"; + + + + echo "


\n"; + echo " CAMPANHAS USING THIS SCRIPT:
\n"; + echo "\n"; + + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns where campaign_script='$script_id';"; + $rslt=mysql_query($stmt, $link); + $camps_to_print = mysql_num_rows($rslt); + $o=0; + while ($camps_to_print > $o) + { + $row=mysql_fetch_row($rslt); + echo "\n"; + $o++; + } + + echo "
$row[0] $row[1]


\n"; + echo " GRUPOS DE ENTR. USING THIS SCRIPT:
\n"; + echo "\n"; + + $stmt="SELECT group_id,group_name from vicidial_inbound_groups where ingroup_script='$script_id';"; + $rslt=mysql_query($stmt, $link); + $camps_to_print = mysql_num_rows($rslt); + $o=0; + while ($camps_to_print > $o) + { + $row=mysql_fetch_row($rslt); + echo "\n"; + $o++; + } + + echo "
$row[0] $row[1]


\n"; + echo " LIST OVERRIDES USING THIS SCRIPT:
\n"; + echo "\n"; + + $stmt="SELECT list_id,list_name from vicidial_lists where agent_script_override='$script_id';"; + $rslt=mysql_query($stmt, $link); + $camps_to_print = mysql_num_rows($rslt); + $o=0; + while ($camps_to_print > $o) + { + $row=mysql_fetch_row($rslt); + echo "\n"; + $o++; + } + + echo "
$row[0] $row[1]
\n"; + + + if ($LOGdelete_scripts > 0) + { + echo "

APAGAR ESTE SCRIPT\n"; + } + if ($LOGuser_level >= 9) + { + echo "

Clique aqui para ver as alterações Admin para este script\n"; + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=31111111 modify filter info in the system +###################### + +if ($ADD==31111111) + { + if ($LOGmodify_filters==1) + { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo ""; + + $stmt="SELECT lead_filter_id,lead_filter_name,lead_filter_comments,lead_filter_sql from vicidial_lead_filters where lead_filter_id='$lead_filter_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $lead_filter_name = $row[1]; + $lead_filter_comments = $row[2]; + $lead_filter_sql = stripslashes($row[3]); + echo ""; + + echo "
ALTERAR FILTRO\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
ID do Filtro:$lead_filter_id$NWB#vicidial_lead_filters-lead_filter_id$NWE
Nome do Filtro: (descrição simples do filtro)$NWB#vicidial_lead_filters-lead_filter_name$NWE
Comentários do filtro: $NWB#vicidial_lead_filters-lead_filter_comments$NWE
Filtro SQL: $NWB#vicidial_lead_filters-lead_filter_sql$NWE
\n"; + + ##### get campaigns listing for dynamic pulldown + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $campaigns_to_print = mysql_num_rows($rslt); + $campaigns_list=''; + + $o=0; + while ($campaigns_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $campaigns_list .= "\n"; + $o++; + } + + echo "

"; + echo "
TESTAR A CAMPANHA:
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + + if ($LOGdelete_filters > 0) + { + echo "

APAGAR ESTE FILTRO\n"; + } + if ($LOGuser_level >= 9) + { + echo "

Clique aqui para ver as alterações Admin para este Filtro\n"; + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=321111111 modify call time definition info in the system +###################### + +if ($ADD==321111111) + { + if ($LOGmodify_call_times==1) + { + if ( ($stage=="ADD") and (strlen($state_rule)>0) ) + { + $stmt="SELECT ct_state_call_times from vicidial_call_times where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $ct_state_call_times = $row[0]; + + if (eregi("\|$",$ct_state_call_times)) + {$ct_state_call_times = "$ct_state_call_times$state_rule\|";} + else + {$ct_state_call_times = "$ct_state_call_times\|$state_rule\|";} + $stmt="UPDATE vicidial_call_times set ct_state_call_times='$ct_state_call_times' where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + echo "Regra de Estado Adicionada: $state_rule
\n"; + } + if ( ($stage=="REMOVE") and (strlen($state_rule)>0) ) + { + $stmt="SELECT ct_state_call_times from vicidial_call_times where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $ct_state_call_times = $row[0]; + + $ct_state_call_times = eregi_replace("\|$state_rule\|",'|',$ct_state_call_times); + $stmt="UPDATE vicidial_call_times set ct_state_call_times='$ct_state_call_times' where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + echo "Regra de Estado Removida: $state_rule
\n"; + } + + $ADD=311111111; + } + else + { + echo "Você não esta autorizado a visualizar esta página. Por favor retorne."; + } + } + + +###################### +# ADD=311111111 modify call time definition info in the system +###################### + +if ($ADD==311111111) + { + if ($LOGmodify_call_times==1) + { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + $ct_srs=1; + $b=0; + $srs_SQL =''; + if (strlen($ct_state_call_times)>2) + { + $state_rules = explode('|',$ct_state_call_times); + $ct_srs = ((count($state_rules)) - 1); + } + echo "\n"; + echo "\n"; + while($ct_srs >= $b) + { + if (strlen($state_rules[$b])>0) + { + $stmt="SELECT state_call_time_state,state_call_time_name from vicidial_state_call_times where state_call_time_id='$state_rules[$b]';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + echo "\n"; + $srs_SQL .= "'$state_rules[$b]',"; + $srs_state_SQL .= "'$row[0]',"; + } + $b++; + } + if (strlen($srs_SQL)>2) + { + $srs_SQL = "$srs_SQL''"; + $srs_state_SQL = "$srs_state_SQL''"; + $srs_SQL = "where state_call_time_id NOT IN($srs_SQL) and state_call_time_state NOT IN($srs_state_SQL)"; + } + else + {$srs_SQL='';} + $stmt="SELECT state_call_time_id,state_call_time_name from vicidial_state_call_times $srs_SQL order by state_call_time_id;"; + $rslt=mysql_query($stmt, $link); + $sct_to_print = mysql_num_rows($rslt); + $sct_list=''; + + $o=0; + while ($sct_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $sct_list .= "\n"; + $o++; + } + echo "\n"; + echo "\n"; + + echo "
\n"; + echo ""; + + $stmt="SELECT call_time_id,call_time_name,call_time_comments,ct_default_start,ct_default_stop,ct_sunday_start,ct_sunday_stop,ct_monday_start,ct_monday_stop,ct_tuesday_start,ct_tuesday_stop,ct_wednesday_start,ct_wednesday_stop,ct_thursday_start,ct_thursday_stop,ct_friday_start,ct_friday_stop,ct_saturday_start,ct_saturday_stop,ct_state_call_times from vicidial_call_times where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $call_time_name = $row[1]; + $call_time_comments = $row[2]; + $ct_default_start = $row[3]; + $ct_default_stop = $row[4]; + $ct_sunday_start = $row[5]; + $ct_sunday_stop = $row[6]; + $ct_monday_start = $row[7]; + $ct_monday_stop = $row[8]; + $ct_tuesday_start = $row[9]; + $ct_tuesday_stop = $row[10]; + $ct_wednesday_start = $row[11]; + $ct_wednesday_stop = $row[12]; + $ct_thursday_start = $row[13]; + $ct_thursday_stop = $row[14]; + $ct_friday_start = $row[15]; + $ct_friday_stop = $row[16]; + $ct_saturday_start = $row[17]; + $ct_saturday_stop = $row[18]; + $ct_state_call_times = $row[19]; + + echo ""; + + echo "
ALTERAR UM HOR. DE CHAM.\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
ID do Horário de Cham.: $call_time_id$NWB#vicidial_call_times-call_time_id$NWE
Nome do Horário de Cham.: (descrição curta do horário de chamada)$NWB#vicidial_call_times-call_time_name$NWE
Comentários do Horário de cham.: $NWB#vicidial_call_times-call_time_comments$NWE
Padrão de Início: Padrão de Fim: $NWB#vicidial_call_times-ct_default_start$NWE
Início no Domingo: Fim no Domingo: $NWB#vicidial_call_times-ct_sunday_start$NWE
Início na Segunda: Fim na Segunda: $NWB#vicidial_call_times-ct_sunday_start$NWE
Início na Terça: Fim na Terça: $NWB#vicidial_call_times-ct_sunday_start$NWE
Início na Quarta: Fim na Quarta: $NWB#vicidial_call_times-ct_sunday_start$NWE
Início na Quinta: Fim na Quinta: $NWB#vicidial_call_times-ct_sunday_start$NWE
Início na Sexta: Fim na Sexta: $NWB#vicidial_call_times-ct_sunday_start$NWE
Início no Sábado: Fim no Sábado: $NWB#vicidial_call_times-ct_sunday_start$NWE
Configuração de Horário de Chamada por estado para este Registro:  
$state_rules[$b] - REMOVE $row[0] - $row[1]
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "Add state call time rule:


\n"; + echo "CAMPANHAS QUE USAM ESTE HORÁRIO DE CHAMADA:
\n"; + echo "\n"; + + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns where local_call_time='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $camps_to_print = mysql_num_rows($rslt); + $o=0; + while ($camps_to_print > $o) + { + $row=mysql_fetch_row($rslt); + echo "\n"; + $o++; + } + + echo "
$row[0] $row[1]
\n"; + echo "ENTRANTE GROUPS USING THIS CALL TIME:
\n"; + echo "\n"; + + $stmt="SELECT group_id,group_name from vicidial_inbound_groups where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $camps_to_print = mysql_num_rows($rslt); + $o=0; + while ($camps_to_print > $o) + { + $row=mysql_fetch_row($rslt); + echo "\n"; + $o++; + } + + echo "
$row[0] $row[1]
\n"; + echo "

\n"; + + if ($LOGdelete_call_times > 0) + { + echo "

APAGAR ESTA CONFIGURAÇÃO DE HORÁRIO DE CHAMADA\n"; + } + if ($LOGuser_level >= 9) + { + echo "

Clique aqui para ver as alterações Admin para este Horário de Chamada\n"; + } + } + else + { + echo "Você não esta autorizado a visualizar esta página. Por favor retorne."; + } + + } + + +###################### +# ADD=3111111111 modify state call time definition info in the system +###################### + +if ($ADD==3111111111) + { + if ($LOGmodify_call_times==1) + { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "
\n"; + echo ""; + + $stmt="SELECT state_call_time_id,state_call_time_state,state_call_time_name,state_call_time_comments,sct_default_start,sct_default_stop,sct_sunday_start,sct_sunday_stop,sct_monday_start,sct_monday_stop,sct_tuesday_start,sct_tuesday_stop,sct_wednesday_start,sct_wednesday_stop,sct_thursday_start,sct_thursday_stop,sct_friday_start,sct_friday_stop,sct_saturday_start,sct_saturday_stop from vicidial_state_call_times where state_call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $state_call_time_state =$row[1]; + $call_time_name = $row[2]; + $call_time_comments = $row[3]; + $ct_default_start = $row[4]; + $ct_default_stop = $row[5]; + $ct_sunday_start = $row[6]; + $ct_sunday_stop = $row[7]; + $ct_monday_start = $row[8]; + $ct_monday_stop = $row[9]; + $ct_tuesday_start = $row[10]; + $ct_tuesday_stop = $row[11]; + $ct_wednesday_start = $row[12]; + $ct_wednesday_stop = $row[13]; + $ct_thursday_start = $row[14]; + $ct_thursday_stop = $row[15]; + $ct_friday_start = $row[16]; + $ct_friday_stop = $row[17]; + $ct_saturday_start = $row[18]; + $ct_saturday_stop = $row[19]; + + echo ""; + + echo "
ALTERAR HOR. CHAM. P/ ESTADO
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
ID do Horário de Cham.: $call_time_id$NWB#vicidial_call_times-call_time_id$NWE
State Call Time State: $NWB#vicidial_call_times-state_call_time_state$NWE
Nome do horário de chamada por estado: (descrição curta do horário de chamada)$NWB#vicidial_call_times-call_time_name$NWE
Comentários do horário de chamada por estado: $NWB#vicidial_call_times-call_time_comments$NWE
Padrão de Início: Padrão de Fim: $NWB#vicidial_call_times-ct_default_start$NWE
Início no Domingo: Fim no Domingo: $NWB#vicidial_call_times-ct_sunday_start$NWE
Início na Segunda: Fim na Segunda: $NWB#vicidial_call_times-ct_sunday_start$NWE
Início na Terça: Fim na Terça: $NWB#vicidial_call_times-ct_sunday_start$NWE
Início na Quarta: Fim na Quarta: $NWB#vicidial_call_times-ct_sunday_start$NWE
Início na Quinta: Fim na Quinta: $NWB#vicidial_call_times-ct_sunday_start$NWE
Início na Sexta: Fim na Sexta: $NWB#vicidial_call_times-ct_sunday_start$NWE
Início no Sábado: Fim no Sábado: $NWB#vicidial_call_times-ct_sunday_start$NWE


\n"; + echo "TEMPOS DE CHAMADA USANDO HORÁRIOS DE CHAMADA POR ESTADO:
\n"; + echo "\n"; + + $stmt="SELECT call_time_id,call_time_name from vicidial_call_times where ct_state_call_times LIKE \"%|$call_time_id|%\";"; + $rslt=mysql_query($stmt, $link); + $camps_to_print = mysql_num_rows($rslt); + $o=0; + while ($camps_to_print > $o) + { + $row=mysql_fetch_row($rslt); + echo "\n"; + $o++; + } + + echo "
$row[0] $row[1]
\n"; + echo "

\n"; + + if ($LOGdelete_call_times > 0) + { + echo "

APAGAR ESTE HORÁRIO DE CHAMADA POR ESTADO\n"; + } + } + else + { + echo "Você não esta autorizado a visualizar esta página. Por favor retorne."; + } + } + + +###################### +# ADD=331111111 modify shift definition info in the system +###################### + +if ($ADD==331111111) + { + if ($LOGmodify_call_times==1) + { + echo "
\n"; + echo ""; + + $stmt="SELECT shift_id,shift_name,shift_start_time,shift_length,shift_weekdays from vicidial_shifts where shift_id='$shift_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $shift_name = $row[1]; + $shift_start_time = $row[2]; + $shift_length = $row[3]; + $shift_weekdays = $row[4]; + + $shift_start_hour = substr($shift_start_time,0,2); + $shift_start_min = substr($shift_start_time,2,2); + $shift_length_hour = substr($shift_length,0,2); + $shift_length_min = substr($shift_length,3,2); + $shift_end_hour = ($shift_start_hour + $shift_length_hour); + $shift_end_min = ($shift_start_min + $shift_length_min); + if ($shift_end_min >=60) + { + $shift_end_min = ($shift_end_min - 60); + $shift_end_hour++; + } + if ($shift_end_hour >=24) + { + $shift_end_hour = ($shift_end_hour - 24); + } + $shift_end_hour = sprintf("%02s", $shift_end_hour); + $shift_end_min = sprintf("%02s", $shift_end_min); + $shift_end = "$shift_end_hour$shift_end_min"; + + echo ""; + + echo "
ALTERAR TURNO\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
ID do Turno:$shift_id
Nome do Turno: (descrição curta do turno)$NWB#vicidial_shifts-shift_name$NWE
Início do Turno:\n"; + echo "   Final do Turno:\n"; + echo " $NWB#vicidial_shifts-shift_start_time$NWE
Duração do Turno: $NWB#vicidial_shifts-shift_length$NWE
Dias do Turno:
$NWB#vicidial_shifts-shift_weekdays$NWE
\n"; + echo "Domingo
\n"; + echo "Segunda
\n"; + echo "Terça
\n"; + echo "Quarta
\n"; + echo "Quinta
\n"; + echo "Sexta
\n"; + echo "Sábado
\n"; + echo "
\n"; + + echo "


\n"; + echo "GRUPOS DE USUÁRIO USANDO ESTE TURNO:
\n"; + echo "\n"; + + $stmt="SELECT user_group,group_name from vicidial_user_groups where group_shifts LIKE\"% $shift_id %\";"; + $rslt=mysql_query($stmt, $link); + $camps_to_print = mysql_num_rows($rslt); + $o=0; + while ($camps_to_print > $o) + { + $row=mysql_fetch_row($rslt); + echo "\n"; + $o++; + } + + echo "
$row[0] $row[1]
\n"; + echo "

\n"; + + if ($LOGdelete_call_times > 0) + { + echo "

REMOVER ESTE TURNO\n"; + } + if ($LOGuser_level >= 9) + { + echo "

Clique aqui para ver as alterações Admin para este Turno\n"; + } + } + else + { + echo "Você não esta autorizado a visualizar esta página. Por favor retorne."; + } + + } + + +###################### +# ADD=31111111111 modify phone record in the system +###################### + +if ($ADD==31111111111) + { + if ($LOGast_admin_access==1) + { + echo "
\n"; + echo ""; + + $stmt="SELECT extension,dialplan_number,voicemail_id,phone_ip,computer_ip,server_ip,login,pass,status,active,phone_type,fullname,company,picture,messages,old_messages,protocol,local_gmt,ASTmgrUSERNAME,ASTmgrSECRET,login_user,login_pass,login_campaign,park_on_extension,conf_on_extension,VICIDIAL_park_on_extension,VICIDIAL_park_on_filename,monitor_prefix,recording_exten,voicemail_exten,voicemail_dump_exten,ext_context,dtmf_send_extension,call_out_number_group,client_browser,install_directory,local_web_callerID_URL,VICIDIAL_web_URL,AGI_call_logging_enabled,user_switching_enabled,conferencing_enabled,admin_hangup_enabled,admin_hijack_enabled,admin_monitor_enabled,call_parking_enabled,updater_check_enabled,AFLogging_enabled,QUEUE_ACTION_enabled,CallerID_popup_enabled,voicemail_button_enabled,enable_fast_refresh,fast_refresh_rate,enable_persistant_mysql,auto_dial_next_number,VDstop_rec_after_each_call,DBX_server,DBX_database,DBX_user,DBX_pass,DBX_port,DBY_server,DBY_database,DBY_user,DBY_pass,DBY_port,outbound_cid,enable_sipsak_messages,email,template_id,conf_override,phone_context,phone_ring_timeout,conf_secret,delete_vm_after_email from phones where extension='$extension' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + + echo "
ALTERAR UM REGISTRO DE RAMAL: $row[1]\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + echo "
Extensão do Ramal: $NWB#phones-extension$NWE (Agent Screen Login do Ramal)
Número no Plano de Discagem: (somente dígitos)$NWB#phones-dialplan_number$NWE
Caixa do Correio de Voz: (somente dígitos)$NWB#phones-voicemail_id$NWE
CallerID de Saída: (somente dígitos)$NWB#phones-outbound_cid$NWE
Endereço IP do Ramal: (optional)$NWB#phones-phone_ip$NWE
Endereço IP do Computador: (optional)$NWB#phones-computer_ip$NWE
IP do Servidor: $NWB#phones-server_ip$NWE
Login: $NWB#phones-login$NWE
Senha: $NWB#phones-pass$NWE
Status: $NWB#phones-status$NWE
Conta Ativa: $NWB#phones-active$NWE
Tipo de Ramal: $NWB#phones-phone_type$NWE
Nome Completo: $NWB#phones-fullname$NWE
Email: $NWB#phones-email$NWE
Eliminar correo de voz después del email: $NWB#phones-delete_vm_after_email$NWE
Empresa: $NWB#phones-company$NWE
Foto: $NWB#phones-picture$NWE
Mensagens Novas: $row[14]$NWB#phones-messages$NWE
Mensagens Antigas: $row[15]$NWB#phones-old_messages$NWE
Protocolo do Cliente: $NWB#phones-protocol$NWE
GMT Local: (NÃO ajuste para o horário de verão)$NWB#phones-local_gmt$NWE
Teléfono Anillo de tiempo de espera: $NWB#phones-phone_ring_timeout$NWE
Login do Gerente: $NWB#phones-ASTmgrUSERNAME$NWE
Senha do Gerente: $NWB#phones-ASTmgrSECRET$NWE
Usuário padrão do VICIDIAL: $NWB#phones-login_user$NWE
Senha padrão do VICIDIAL: $NWB#phones-login_pass$NWE
Campanha padrão do VICIDIAL: $NWB#phones-login_campaign$NWE
Exten de Estacionamento: $NWB#phones-park_on_extension$NWE
Exten de Conferência: $NWB#phones-conf_on_extension$NWE
Extensão de estacionamento do VICIDIAL: $NWB#phones-VICIDIAL_park_on_extension$NWE
Arquivo de estacionamento do VICIDIAL: $NWB#phones-VICIDIAL_park_on_filename$NWE
Prefixo de Monitoramento: $NWB#phones-monitor_prefix$NWE
Exten de Gravação: $NWB#phones-recording_exten$NWE
Exten de Correio de Voz Principal: $NWB#phones-voicemail_exten$NWE
Exten de Correio de Voz: $NWB#phones-voicemail_dump_exten$NWE
Contexto do Exten: $NWB#phones-ext_context$NWE
Teléfono Contexto: $NWB#phones-phone_context$NWE
Conf. Archivo Secreto: $NWB#phones-conf_secret$NWE
Canal de envio do DTMF: $NWB#phones-dtmf_send_extension$NWE
Grupo de Saída de Chamadas: $NWB#phones-call_out_number_group$NWE
Localização do Navegador: $NWB#phones-client_browser$NWE
Caminho de Instalação: $NWB#phones-install_directory$NWE
URL do CallerID: $NWB#phones-local_web_callerID_URL$NWE
URL Padrão do VICIDIAL: $NWB#phones-VICIDIAL_web_URL$NWE
Call Logging: $NWB#phones-AGI_call_logging_enabled$NWE
Troca de Usuário: $NWB#phones-user_switching_enabled$NWE
Conferências: $NWB#phones-conferencing_enabled$NWE
Hang Up do Admin: $NWB#phones-admin_hangup_enabled$NWE
Captura do Admin: $NWB#phones-admin_hijack_enabled$NWE
Monitoramento do Admin: $NWB#phones-admin_monitor_enabled$NWE
Estacionamento de Chamada: $NWB#phones-call_parking_enabled$NWE
Verificar Atualizador: $NWB#phones-updater_check_enabled$NWE
AF Logging: $NWB#phones-AFLogging_enabled$NWE
Permitir Filas: $NWB#phones-QUEUE_ACTION_enabled$NWE
Popup do CallerID: $NWB#phones-CallerID_popup_enabled$NWE
Botão CxPostal : $NWB#phones-voicemail_button_enabled$NWE
Atualizar Rápido: $NWB#phones-enable_fast_refresh$NWE
Taxa da Atualização Rápida: (in ms)$NWB#phones-fast_refresh_rate$NWE
Persistant MySQL: $NWB#phones-enable_persistant_mysql$NWE
Auto Discar próximo número: $NWB#phones-auto_dial_next_number$NWE
Parar de gravar após cada chamada: $NWB#phones-VDstop_rec_after_each_call$NWE
Habilitar Mensagens SIPSAK: $NWB#phones-enable_sipsak_messages$NWE
Servidor do DBX: (Primário DB Server)$NWB#phones-DBX_server$NWE
Base de dados do DBX: (Primário Server Database)$NWB#phones-DBX_database$NWE
Usuário do DBX: (Primário DB Login)$NWB#phones-DBX_user$NWE
Senha do DBX: (Primário DB Secret)$NWB#phones-DBX_pass$NWE
Porta do DBX: (Primário DB Port)$NWB#phones-DBX_port$NWE
Servidor do DBY: (Secundário DB Server)$NWB#phones-DBY_server$NWE
Base de dados do DBY: (Secundário Server Database)$NWB#phones-DBY_database$NWE
Usuário do DBY: (Secundário DB Login)$NWB#phones-DBY_user$NWE
Senha do DBY: (Secundário DB Secret)$NWB#phones-DBY_pass$NWE
Porta do DBY: (Secundário DB Port)$NWB#phones-DBY_port$NWE
ID do Template: $NWB#phones-template_id$NWE
Sobrepor Conf: $NWB#phones-conf_override$NWE
\n"; + + echo "

Clique aqui para statísticas do ramal\n"; + + if ($LOGast_delete_phones > 0) + { + echo "

APAGAR ESTE RAMAL\n"; + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=32111111111 modify phone alias record in the system +###################### + +if ($ADD==32111111111) + { + if ($LOGast_admin_access==1) + { + echo "
\n"; + echo ""; + + $stmt="SELECT alias_id,alias_name,logins_list from phones_alias where alias_id='$alias_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + + echo "
ALTERAR UM ALIAS DE RAMAL: $row[0]\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
ID do Alias:$row[0] $NWB#phones-alias_id$NWE
Nome do Alias: $NWB#phones-alias_name$NWE
Phones Logins List: (comma separated)$NWB#phones-logins_list$NWE
\n"; + + + ### list of phones in this phones alias + $phone_alias_SQL = ereg_replace(',',"','",$row[2]); + + echo "
\n"; + echo "
RAMAIS DESTE ALIAS:
\n"; + echo "\n"; + echo "\n"; + + $stmt="SELECT login,extension,server_ip,protocol,phone_ip from phones where login IN ('$phone_alias_SQL');"; + if ($DB) {echo "|$stmt|";} + $rsltx=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rsltx); + + $o=0; + while ($lists_to_print > $o) { + $rowx=mysql_fetch_row($rsltx); + $o++; + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + } + + echo "
LOGINEXTENSÃOSERVERPROTOCOLIP
$rowx[0]$rowx[1]$rowx[2]$rowx[3]$rowx[4]

\n"; + + if ($LOGast_delete_phones > 0) + { + echo "

REMOVER ESTE ALIAS DE RAMAL\n"; + } + if ($LOGuser_level >= 9) + { + echo "

Clique aqui para ver as alterações Admin para este Alias de Ramal
\n"; + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=33111111111 modify group alias record in the system +###################### + +if ($ADD==33111111111) + { + if ($LOGast_admin_access==1) + { + echo "
\n"; + echo ""; + + $stmt="SELECT group_alias_id,group_alias_name,caller_id_number,caller_id_name,active from groups_alias where group_alias_id='$group_alias_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + + echo "
ALTERAR ALIAS DE GRUPO: $row[0]\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
ID do Alias: $row[0] $NWB#phones-group_alias_id$NWE
Nome do Alias: $NWB#phones-group_alias_name$NWE
Número CallerID: $NWB#phones-caller_id_number$NWE
Nome CallerID: $NWB#phones-caller_id_name$NWE
Ativo:
\n"; + + + if ($LOGast_delete_phones > 0) + { + echo "

REMOVER ESTE ALIAS DE GRUPO\n"; + } + if ($LOGuser_level >= 9) + { + echo "

Clique aqui para ver as alterações Admin para este Alias de Grupo
\n"; + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=311111111111 modify server record in the system +###################### + +if ($ADD==311111111111) + { + if ($LOGmodify_servers==1) + { + echo "
\n"; + echo ""; + + $stmt="SELECT server_id,server_description,server_ip,active,asterisk_version,max_vicidial_trunks,telnet_host,telnet_port,ASTmgrUSERNAME,ASTmgrSECRET,ASTmgrUSERNAMEupdate,ASTmgrUSERNAMElisten,ASTmgrUSERNAMEsend,local_gmt,voicemail_dump_exten,answer_transfer_agent,ext_context,sys_perf_log,vd_server_logs,agi_output,vicidial_balance_active,balance_trunks_offlimits,recording_web_link,alt_server_ip,active_asterisk_server,generate_vicidial_conf,rebuild_conf_files,outbound_calls_per_second,sysload,channels_total,cpu_idle_percent,disk_usage,sounds_update,vicidial_recording_limit,carrier_logging_active,vicidial_balance_rank,rebuild_music_on_hold,active_agent_login_server,conf_secret from servers where server_id='$server_id' or server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $server_id = $row[0]; + $server_description = $row[1]; + $server_ip = $row[2]; + $active = $row[3]; + $asterisk_version = $row[4]; + $max_vicidial_trunks = $row[5]; + $telnet_host = $row[6]; + $telnet_port = $row[7]; + $ASTmgrUSERNAME = $row[8]; + $ASTmgrSECRET = $row[9]; + $ASTmgrUSERNAMEupdate = $row[10]; + $ASTmgrUSERNAMElisten = $row[11]; + $ASTmgrUSERNAMEsend = $row[12]; + $local_gmt = $row[13]; + $voicemail_dump_exten = $row[14]; + $answer_transfer_agent = $row[15]; + $ext_context = $row[16]; + $sys_perf_log = $row[17]; + $vd_server_logs = $row[18]; + $agi_output = $row[19]; + $vicidial_balance_active = $row[20]; + $balance_trunks_offlimits = $row[21]; + $recording_web_link = $row[22]; + $alt_server_ip = $row[23]; + $active_asterisk_server = $row[24]; + $generate_vicidial_conf = $row[25]; + $rebuild_conf_files = $row[26]; + $outbound_calls_per_second = $row[27]; + $sysload = $row[28]; + $channels_total = $row[29]; + $cpu_idle_percent = $row[30]; + $disk_usage = $row[31]; + $sounds_update = $row[32]; + $vicidial_recording_limit = $row[33]; + $carrier_logging_active = $row[34]; + $vicidial_balance_rank = $row[35]; + $rebuild_music_on_hold = $row[36]; + $active_agent_login_server = $row[37]; + $conf_secret = $row[38]; + + $cpu = (100 - $cpu_idle_percent); + $disk_usage = preg_replace("/ /"," - ",$disk_usage); + $disk_usage = preg_replace("/\|/","%     ",$disk_usage); + + echo "
ALTERAR O REGISTRO DO SERVIDOR: $row[0]\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + + echo "\n"; + echo "
ID do Servidor: $NWB#servers-server_id$NWE
Descrição do Servidor: $NWB#servers-server_description$NWE
Endereço IP do Servidor: $NWB#servers-server_ip$NWE
Ativo: $NWB#servers-active$NWE
Carga do Sistema: $sysload - $cpu%   $NWB#servers-sysload$NWE
Canais Falando: $channels_total   $NWB#servers-channels_total$NWE
Uso do HD: $disk_usage   $NWB#servers-disk_usage$NWE
Versão do Asterisk: $NWB#servers-asterisk_version$NWE
Máx. Trunks no VICIDIAL: $NWB#servers-max_vicidial_trunks$NWE
Máx. de Chamadas por Segundo: $NWB#servers-outbound_calls_per_second$NWE
Discagem Balanceada do VICIDIAL: $NWB#servers-vicidial_balance_active$NWE
Balance Vicidial Rango:$NWB#servers-vicidial_balance_rank$NWE
Limite de Balanceamento do VICIDIAL: $NWB#servers-balance_trunks_offlimits$NWE
Host Telnet: $NWB#servers-telnet_host$NWE
Porta Telnet: $NWB#servers-telnet_port$NWE
Usuário do Manager (AMI): $NWB#servers-ASTmgrUSERNAME$NWE
Senha do Gerente: $NWB#servers-ASTmgrSECRET$NWE
Usuário do Atualizador do Manager: $NWB#servers-ASTmgrUSERNAMEupdate$NWE
Usuário de Listen do Manager: $NWB#servers-ASTmgrUSERNAMElisten$NWE
Usuário de Send do Manager: $NWB#servers-ASTmgrUSERNAMEsend$NWE
Conf. Archivo Secreto: $NWB#servers-conf_secret$NWE
GMT Local: (NÃO ajuste para o horário de verão)$NWB#servers-local_gmt$NWE
Extensão para descarregar Correio de Voz : $NWB#servers-voicemail_dump_exten$NWE
Extensão do AD do VICIDIAL: $NWB#servers-answer_transfer_agent$NWE
Contexto Padrão: $NWB#servers-ext_context$NWE
Performance do Sistema: $NWB#servers-sys_perf_log$NWE
Logs do Servidor: $NWB#servers-vd_server_logs$NWE
Saída do AGI: $NWB#servers-agi_output$NWE
Portador de registro activo: $NWB#servers-carrier_logging_active$NWE
Link Web de Gravação: $NWB#servers-recording_web_link$NWE
Alternate Recording IP do Servidor: $NWB#servers-alt_server_ip$NWE
Servidor Asterisk Ativo: $NWB#servers-active_asterisk_server$NWE
Ativo Server Agent: $NWB#servers-active_agent_login_server$NWE
Gerar Arquivos Conf: $NWB#servers-generate_vicidial_conf$NWE
Reconstruir Arquivos Conf: $NWB#servers-rebuild_conf_files$NWE
Volver a generar música en espera: $NWB#servers-rebuild_music_on_hold$NWE
Actualización de los sonidos: $NWB#servers-sounds_update$NWE
Grabación Vicidial Límite: $NWB#servers-vicidial_recording_limit$NWE
\n"; + + + ### vicidial server trunk records for this server + echo "

TRUNKS DO VICIDIAL PARA ESTE SERVIDOR:   $NWB#vicidial_server_trunks$NWE
\n"; + echo "\n"; + echo "\n"; + + $stmt="SELECT server_ip,campaign_id,dedicated_trunks,trunk_restriction from vicidial_server_trunks where server_ip='$server_ip' order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $recycle_to_print = mysql_num_rows($rslt); + $o=0; + while ($recycle_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $o++; + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + + echo "
CAMPANHA TRUNKS RESTRIÇÃO DELETE
$rowx[1]
\n"; + echo "\n"; + echo "\n"; + echo "
APAGAR
\n"; + + echo "
INCLUIR TRUNK DO SERVIDOR VICIDIAL
\n"; + echo "\n"; + echo "\n"; + echo "TRUNKS:
\n"; + echo "CAMPANHA:
\n"; + echo "RESTRICTION:
\n"; + echo "
\n"; + + echo "

\n"; + + + ### list of carriers on this server + echo "
\n"; + echo "
OPERADORAS NESTE SERVIDOR:
\n"; + echo "\n"; + echo "\n"; + + $active_carriers = 0; + $inactive_carriers = 0; + $stmt="SELECT carrier_id,carrier_name,registration_string,active from vicidial_server_carriers where server_ip='$row[2]'"; + $rsltx=mysql_query($stmt, $link); + $carriers_to_print = mysql_num_rows($rsltx); + $camp_lists=''; + + $o=0; + while ($carriers_to_print > $o) + { + $rowx=mysql_fetch_row($rsltx); + $o++; + if (ereg("Y", $rowx[3])) {$active_carriers++;} + if (ereg("N", $rowx[3])) {$inactive_carriers++;} + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + } + + echo "
CARRIER IDNOMEREGISTRATIONATIVO
$rowx[0]$rowx[1]$rowx[2]$rowx[3]

\n"; + + + ### list of phones on this server + echo "
\n"; + echo "
RAMAIS DESTE SERVIDOR:
\n"; + echo "\n"; + echo "\n"; + + $active_phones = 0; + $inactive_phones = 0; + $stmt="SELECT extension,active,fullname from phones where server_ip='$row[2]'"; + $rsltx=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rsltx); + $camp_lists=''; + + $o=0; + while ($lists_to_print > $o) + { + $rowx=mysql_fetch_row($rsltx); + $o++; + if (ereg("Y", $rowx[1])) {$active_phones++; $camp_lists .= "'$rowx[0]',";} + if (ereg("N", $rowx[1])) {$inactive_phones++;} + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + } + + echo "
EXTENSÃONOMEATIVO
$rowx[0]$rowx[2]$rowx[1]

\n"; + + + ### list of conferences on this server + echo "
\n"; + echo "
CONFERENCES WITHIN THIS SERVER:
\n"; + echo "\n"; + echo "\n"; + + $active_confs = 0; + $stmt="SELECT conf_exten,extension from conferences where server_ip='$row[2]'"; + $rsltx=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rsltx); + $camp_lists=''; + + $o=0; + while ($lists_to_print > $o) + { + $rowx=mysql_fetch_row($rsltx); + $o++; + $active_confs++; + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + } + + echo "
CONFERENCEEXTENSÃO
$rowx[0]$rowx[2]

\n"; + + + ### list of vicidial conferences on this server + echo "
\n"; + echo "
VICIDIAL CONFERENCES WITHIN THIS SERVER:
\n"; + echo "\n"; + echo "\n"; + + $active_vdconfs = 0; + $stmt="SELECT conf_exten,extension from vicidial_conferences where server_ip='$row[2]'"; + $rsltx=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rsltx); + $camp_lists=''; + + $o=0; + while ($lists_to_print > $o) + { + $rowx=mysql_fetch_row($rsltx); + $o++; + $active_vdconfs++; + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + } + + echo "
VD CONFERENCEEXTENSÃO
$rowx[0]$rowx[2]

\n"; + + + echo "
\n"; + + $camp_lists = eregi_replace(".$","",$camp_lists); + echo "Este servidor tem $active_carriers active carriers and $inactive_carriers inactive carriers

\n"; + echo "Este servidor tem $active_phones ramais ativos e $inactive_phones ramais inativos

\n"; + echo "Este servidor tem $active_confs active conferences

\n"; + echo "Este servidor tem $active_vdconfs active vicidial conferences

\n"; + echo "
\n"; + if ($LOGast_delete_phones > 0) + { + echo "

REMOVER ESTE SERVIDOR\n"; + } + if ($LOGuser_level >= 9) + { + echo "

Clique aqui para ver as alterações Admin para este Servidor
\n"; + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=331111111111 modify conf template record in the system +###################### + +if ($ADD==331111111111) + { + if ($LOGast_admin_access==1) + { + echo "
\n"; + echo ""; + + $stmt="SELECT template_id,template_name,template_contents from vicidial_conf_templates where template_id='$template_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $template_id = $row[0]; + $template_name = $row[1]; + $template_contents = $row[2]; + + echo "
ALTERAR UM REGISTRO DE TEMPLATE DE CONF: $row[0]
\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
ID do Template: $template_id
Nome do Template: $NWB#vicidial_conf_templates-template_name$NWE
Conteúdo do Template: $NWB#vicidial_conf_templates-template_contents$NWE
\n"; + + echo "
\n"; + + ### list of phones using this conf template + echo "
\n"; + echo "
RAMAIS USANDO ESTA TEMPLATE DE CONF:
\n"; + echo "\n"; + echo "\n"; + + $active_phones = 0; + $inactive_phones = 0; + $stmt="SELECT extension,active,fullname,server_ip from phones where template_id='$template_id'"; + $rsltx=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rsltx); + $camp_lists=''; + + $o=0; + while ($lists_to_print > $o) + { + $rowx=mysql_fetch_row($rsltx); + $o++; + if (ereg("Y", $rowx[1])) {$active_phones++; $camp_lists .= "'$rowx[0]',";} + if (ereg("N", $rowx[1])) {$inactive_phones++;} + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + } + + echo "
EXTENSÃONOMESERVERATIVO
$rowx[0]$rowx[2]$rowx[3]$rowx[1]

\n"; + + ### list of carriers using this conf template + echo "
\n"; + echo "
OPERADORAS USANDO ESTA TEMPLATE DE CONF:
\n"; + echo "\n"; + echo "\n"; + + $active_phones = 0; + $inactive_phones = 0; + $stmt="SELECT carrier_id,active,carrier_name,server_ip from vicidial_server_carriers where template_id='$template_id'"; + $rsltx=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rsltx); + $camp_lists=''; + + $o=0; + while ($lists_to_print > $o) + { + $rowx=mysql_fetch_row($rsltx); + $o++; + if (ereg("Y", $rowx[1])) {$active_phones++; $camp_lists .= "'$rowx[0]',";} + if (ereg("N", $rowx[1])) {$inactive_phones++;} + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + } + + echo "
CARRIERNOMESERVERATIVO
$rowx[0]$rowx[2]$rowx[3]$rowx[1]

\n"; + + + + if ($LOGast_delete_phones > 0) + { + echo "

REMOVER TEMPLATE DE CONF\n"; + } + if ($LOGuser_level >= 9) + { + echo "

Clique aqui para ver as alterações Admin para este template de conf
\n"; + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=341111111111 modify carrier record in the system +###################### + +if ($ADD==341111111111) + { + if ($LOGast_admin_access==1) + { + echo "
\n"; + echo ""; + + $stmt="SELECT carrier_id,carrier_name,registration_string,template_id,account_entry,protocol,globals_string,dialplan_entry,server_ip,active,carrier_description from vicidial_server_carriers where carrier_id='$carrier_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $carrier_id = $row[0]; + $carrier_name = $row[1]; + $registration_string = $row[2]; + $template_id = $row[3]; + $account_entry = $row[4]; + $protocol = $row[5]; + $globals_string = $row[6]; + $dialplan_entry = $row[7]; + $server_ip = $row[8]; + $active = $row[9]; + $carrier_description = $row[10]; + + echo "
ALTERAR OPERADORA: $row[0]\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
ID da Operadora: $carrier_id
Nome da Operadora: $NWB#vicidial_server_carriers-carrier_name$NWE
Descripción Carrier: $NWB#vicidial_server_carriers-carrier_description$NWE
String de Registro: $NWB#vicidial_server_carriers-registration_string$NWE
ID do Template: $NWB#vicidial_server_carriers-template_id$NWE
Dados da Conta: $NWB#vicidial_server_carriers-account_entry$NWE
Protocolo: $NWB#vicidial_server_carriers-protocol$NWE
String Global: $NWB#vicidial_server_carriers-globals_string$NWE
Plano de Discagem: $NWB#vicidial_server_carriers-dialplan_entry$NWE
IP do Servidor: $NWB#vicidial_server_carriers-server_ip$NWE
Ativo: $NWB#vicidial_server_carriers-active$NWE
\n"; + + echo "
\n"; + if ($LOGast_delete_phones > 0) + { + echo "

REMOVER OPERADORA\n"; + } + if ($LOGuser_level >= 9) + { + echo "

Clique aqui para ver as alterações Admin para esta Operadora
\n"; + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=351111111111 modify tts record in the system +###################### + +if ($ADD==351111111111) + { + if ($LOGast_admin_access==1) + { + echo "
\n"; + echo ""; + + $stmt="SELECT tts_id,tts_name,active,tts_text from vicidial_tts_prompts where tts_id='$tts_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $tts_id = $row[0]; + $tts_name = $row[1]; + $active = $row[2]; + $tts_text = $row[3]; + + echo "
TTS MODIFICAR UN RECORD: $tts_id\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + + echo "\n"; + echo "
TTS ID: $tts_id
Nombre TTS: $NWB#vicidial_tts_prompts-tts_name$NWE
Ativo: $NWB#vicidial_tts_prompts-active$NWE
TTS Texto: $NWB#vicidial_tts_prompts-tts_text$NWE
\n"; + + echo "
\n"; + if ($LOGast_delete_phones > 0) + { + echo "

ELIMINAR ESTA ENTRADA TTS\n"; + } + if ($LOGuser_level >= 9) + { + echo "

Haga clic aquí para ver chages Admin a esta entrada a TTS
\n"; + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=361111111111 modify music on hold record in the system +###################### + +if ($ADD==361111111111) + { + if ($LOGast_admin_access==1) + { + echo "
\n"; + echo ""; + + $stmt="SELECT moh_id,moh_name,active,random from vicidial_music_on_hold where moh_id='$moh_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $moh_id = $row[0]; + $moh_name = $row[1]; + $active = $row[2]; + $random = $row[3]; + + echo "
MODIFY A MUSIC ON HOLD RECORD: $moh_id\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + echo "
Música en espera de identificación: $moh_id
Música en espera Nombre: $NWB#vicidial_music_on_hold-moh_name$NWE
Ativo: $NWB#vicidial_music_on_hold-active$NWE
Orden aleatorio: $NWB#vicidial_music_on_hold-random$NWE
Archivos de Audio: \n"; + ##### get files listing for rank/delete options + $stmt="SELECT filename,rank from vicidial_music_on_hold_files where moh_id='$moh_id' order by rank;"; + $rsltx=mysql_query($stmt, $link); + $mohfiles_to_print = mysql_num_rows($rsltx); + $ranks = ($mohfiles_to_print + 2); + $o=0; + while ($mohfiles_to_print > $o) + { + $rowx=mysql_fetch_row($rsltx); + echo "Rango:\n"; + + echo "   $rowx[0] - APAGAR
\n"; + $o++; + } + + echo "
Añadir un archivo de audio: audio chooser $NWB#vicidial_music_on_hold-filename$NWE
\n"; + + echo "
\n"; + if ($LOGast_delete_phones > 0) + { + echo "

DELETE MÚSICA EN ESPERA DE ENTRADA\n"; + } + if ($LOGuser_level >= 9) + { + echo "

Haga clic aquí para ver chages de administración para esta música en espera de entrada
\n"; + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=371111111111 modify voicemail box in the system +###################### + +if ($ADD==371111111111) + { + if ($LOGast_admin_access==1) + { + echo "
\n"; + echo ""; + + $stmt="SELECT voicemail_id,pass,fullname,active,email,messages,old_messages,delete_vm_after_email from vicidial_voicemail where voicemail_id='$voicemail_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $voicemail_id = $row[0]; + $pass = $row[1]; + $fullname = $row[2]; + $active = $row[3]; + $email = $row[4]; + $messages = $row[5]; + $old_messages = $row[6]; + $delete_vm_after_email = $row[7]; + + echo "
MODIFICAR UN contestador: $tts_id\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "
ID de correo de voz: $voicemail_id
Senha: $NWB#vicidial_voicemail-pass$NWE
Name: $NWB#vicidial_voicemail-fullname$NWE
Email:$NWB#vicidial_voicemail-email$NWE
Ativo: $NWB#vicidial_voicemail-active$NWE
Eliminar correo de voz después del email: $NWB#vicidial_voicemail-delete_vm_after_email$NWE
Mensagens Novas: $messages
Mensagens Antigas: $old_messages
\n"; + + echo "
\n"; + if ($LOGast_delete_phones > 0) + { + echo "

Este mensaje de voz DELETE BOX\n"; + } + if ($LOGuser_level >= 9) + { + echo "

Haga clic aquí para ver chages de administración para esta casilla de correo de voz
\n"; + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=3111111111111 modify conference record in the system +###################### + +if ($ADD==3111111111111) + { + if ($LOGast_admin_access==1) + { + echo "
\n"; + echo ""; + + $stmt="SELECT conf_exten,server_ip,extension from conferences where conf_exten='$conf_exten' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $conf_exten = $row[0]; + $server_ip = $row[1]; + + echo "
ALTERAR O REGISTRO DA CONFERÊNCIA: $row[0]\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Conferência: $NWB#conferences-conf_exten$NWE
IP do Servidor: $NWB#conferences-server_ip$NWE
Extensão Atual:
\n"; + + echo "
\n"; + if ($LOGast_delete_phones > 0) + { + echo "

REMOVER ESTA CONFERÊNCIA\n"; + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=31111111111111 modify vicidial conference record in the system +###################### + +if ($ADD==31111111111111) + { + if ($LOGast_admin_access==1) + { + echo "
\n"; + echo ""; + + $stmt="SELECT conf_exten,server_ip,extension,leave_3way,leave_3way_datetime from vicidial_conferences where conf_exten='$conf_exten' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $conf_exten = $row[0]; + $server_ip = $row[1]; + + echo "
MODIFY A VICIDIAL CONFERENCE RECORD: $row[0]\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Conferência: $NWB#conferences-conf_exten$NWE
IP do Servidor: $NWB#conferences-server_ip$NWE
Extensão Atual:
\n"; + + echo "
\n"; + if ($LOGast_delete_phones > 0) + { + echo "

REMOVER ESTA CONFERÊNCIA VICIDIAL\n"; + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + + +###################### +# ADD=311111111111111 modify vicidial system settings +###################### + +if ($ADD==311111111111111) + { + if ($LOGmodify_servers==1) + { + echo "
\n"; + echo ""; + + $stmt="SELECT version,install_date,use_non_latin,webroot_writable,enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_url,queuemetrics_log_id,queuemetrics_eq_prepend,vicidial_agent_disable,allow_sipsak_messages,admin_home_url,enable_agc_xfer_log,db_schema_version,auto_user_add_value,timeclock_end_of_day,timeclock_last_reset_date,vdc_header_date_format,vdc_customer_date_format,vdc_header_phone_format,vdc_agent_api_active,qc_last_pull_time,enable_vtiger_integration,vtiger_server_ip,vtiger_dbname,vtiger_login,vtiger_pass,vtiger_url,qc_features_active,outbound_autodial_active,outbound_calls_per_second,enable_tts_integration,agentonly_callback_campaign_lock,sounds_central_control_active,sounds_web_server,sounds_web_directory,active_voicemail_server,auto_dial_limit,user_territories_active,allow_custom_dialplan,db_schema_update_date,enable_second_webform from system_settings;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $version = $row[0]; + $install_date = $row[1]; + $use_non_latin = $row[2]; + $webroot_writable = $row[3]; + $enable_queuemetrics_logging = $row[4]; + $queuemetrics_server_ip = $row[5]; + $queuemetrics_dbname = $row[6]; + $queuemetrics_login = $row[7]; + $queuemetrics_pass = $row[8]; + $queuemetrics_url = $row[9]; + $queuemetrics_log_id = $row[10]; + $queuemetrics_eq_prepend = $row[11]; + $vicidial_agent_disable = $row[12]; + $allow_sipsak_messages = $row[13]; + $admin_home_url = $row[14]; + $enable_agc_xfer_log = $row[15]; + $db_schema_version = $row[16]; + $auto_user_add_value = $row[17]; + $timeclock_end_of_day = $row[18]; + $timeclock_last_reset_date = $row[19]; + $vdc_header_date_format = $row[20]; + $vdc_customer_date_format = $row[21]; + $vdc_header_phone_format = $row[22]; + $vdc_agent_api_active = $row[23]; + $qc_last_pull_time = $row[24]; + $enable_vtiger_integration = $row[25]; + $vtiger_server_ip = $row[26]; + $vtiger_dbname = $row[27]; + $vtiger_login = $row[28]; + $vtiger_pass = $row[29]; + $vtiger_url = $row[30]; + $qc_features_active = $row[31]; + $outbound_autodial_active = $row[32]; + $outbound_calls_per_second = $row[33]; + $enable_tts_integration = $row[34]; + $agentonly_callback_campaign_lock = $row[35]; + $sounds_central_control_active = $row[36]; + $sounds_web_server = $row[37]; + $sounds_web_directory = $row[38]; + $active_voicemail_server = $row[39]; + $auto_dial_limit = $row[40]; + $user_territories_active = $row[41]; + $allow_custom_dialplan = $row[42]; + $db_schema_update_date = $row[43]; + $enable_second_webform = $row[44]; + + echo "
ALTERAR CONFIG. DE SISTEMA DO VICIDIAL\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "
Versão: $version
DB Schema Versão: $db_schema_version
DB Schema Update Date: $db_schema_update_date
Auto Usuário-add Value: $auto_user_add_value
Data da Instalação: $install_date
Uso Não-Latino: $NWB#settings-use_non_latin$NWE
Raiz Web Gravável: $NWB#settings-webroot_writable$NWE
Mostrar Bloqueio ao Agente VICIDIAL:$NWB#settings-vicidial_agent_disable$NWE
Permitir Mensagens SIPSAK$NWB#settings-allow_sipsak_messages$NWE
URL Home do Admin: $NWB#settings-admin_home_url$NWE
Habilitar Log de Transferências: $NWB#settings-enable_agc_xfer_log$NWE
Relógio Ponto Final do Dia:$NWB#settings-timeclock_end_of_day$NWE
Último Sair Automático do Ponto: $timeclock_last_reset_date
Formato da Data no Cabeçalho da tela do Agente: $NWB#settings-vdc_header_date_format$NWE
Formato da Data do Cliente na tela do Agente: $NWB#settings-vdc_customer_date_format$NWE
Formato do Número do Telefone na tela do Agente: $NWB#settings-vdc_header_phone_format$NWE
API do Agente Ativa:$NWB#settings-vdc_agent_api_active$NWE
Trava para Agendamento Vinculado: $NWB#settings-agentonly_callback_campaign_lock$NWE
Controle Central de Audio Ativado: $NWB#settings-sounds_central_control_active$NWE
Servidor Web de Sons: $NWB#settings-sounds_web_server$NWE
Diretório Web de Sons: $sounds_web_directory $NWB#settings-sounds_web_directory$NWE
Servidor de correo de voz activo: $NWB#settings-active_voicemail_server$NWE
Marcado automático de límite de: $NWB#settings-auto_dial_limit$NWE
Discagem Automática Ativa: $NWB#settings-outbound_autodial_active$NWE
Máx. de Cham. Trasnf. por Segundo: $NWB#settings-outbound_calls_per_second$NWE
Permitir Custom Dialplan entradas: $NWB#settings-allow_custom_dialplan$NWE
Territorios de usuario de Ativo: $NWB#settings-user_territories_active$NWE
Formulario de Asistencia Segunda Habilitar: $NWB#settings-enable_second_webform$NWE
Habilitar TTS Integración: $NWB#settings-enable_tts_integration$NWE
Recursos de CQ Ativos: $NWB#settings-qc_features_active$NWE
Última Hora de Retirada do CQ: $qc_last_pull_time
Habilitar Log para o QueueMetrics: $NWB#settings-enable_queuemetrics_logging$NWE
IP do Servidor QueueMetrics: $NWB#settings-queuemetrics_server_ip$NWE
Nome do BD do QueueMetrics: $NWB#settings-queuemetrics_dbname$NWE
Login do BD do QueueMetrics: $NWB#settings-queuemetrics_login$NWE
Senha do BD do QueueMetrics: $NWB#settings-queuemetrics_pass$NWE
QueueMetrics URL: $NWB#settings-queuemetrics_url$NWE
ID do Log do QueueMetrics: $NWB#settings-queuemetrics_log_id$NWE
Prefixo QueueMetrics EnterQueue: $NWB#settings-queuemetrics_eq_prepend$NWE
Habilitar Integração com Vtiger: $NWB#settings-enable_vtiger_integration$NWE\n"; + echo "   Clique aqui para sincronizar usuários com o Vtiger\n"; + echo "
IP do Servidor Vtiger: $NWB#settings-vtiger_server_ip$NWE
Vtiger DB Name: $NWB#settings-vtiger_dbname$NWE
Vtiger DB Login: $NWB#settings-vtiger_login$NWE
Vtiger DB Senha: $NWB#settings-vtiger_pass$NWE
URL do Vtiger: $NWB#settings-vtiger_url$NWE
\n"; + echo "\n"; + if ($LOGuser_level >= 9) + { + echo "

Clique aqui para ver as alterações Admin para esta Configuração de sistema
\n"; + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + + + + + +###################### +# ADD=321111111111111 modify vicidial system statuses +###################### + +if ($ADD==321111111111111) + { + if ($LOGmodify_servers==1) + { + echo "
\n"; + echo ""; + + echo "
\n"; + echo "ESTADOS DE VICIDIAL DENTRO DE ESTE SISTEMA:  $NWB#vicidial_statuses$NWE
\n"; + echo "\n"; + echo "\n"; + + ##### get status category listings for dynamic pulldown + $stmt="SELECT vsc_id,vsc_name from vicidial_status_categories order by vsc_id desc"; + $rslt=mysql_query($stmt, $link); + $cats_to_print = mysql_num_rows($rslt); + $cats_list=""; + + $o=0; + while ($cats_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $cats_list .= "\n"; + $catsname_list["$rowx[0]"] = substr($rowx[1],0,20); + $o++; + } + + + $stmt="SELECT status,status_name,selectable,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable from vicidial_statuses order by status;"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + $o=0; + while ($statuses_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $AScategory = $rowx[4]; + $o++; + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + + echo "
STATUSDESCRIÇÃOSELECT-
ABLE
HUMANO
RESPOSTA
CATEGORIAMODIFY/DELETE
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "$rowx[0]
\n"; + echo "\n"; + echo "         \n"; + echo "   \n"; + + if (preg_match("/^B$|^NA$|^DNC$|^NA$|^DROP$|^INCALL$|^QUEUE$|^NEW$/i",$rowx[0])) + { + echo "APAGAR\n"; + } + else + { + echo "APAGAR\n"; + } + + echo "
\n"; + + echo "  Sale:   \n"; + echo "  DNC:   \n"; + echo "  Customer Contact:   \n"; + echo "  Not Interested:   \n"; + echo "  Unworkable:   \n"; + + echo "
\n"; + + echo "
INCLUIR STATUS DE SISTEMA
\n"; + echo "\n"; + echo "Status:   \n"; + echo "Descrição:
\n"; + echo "Selecionável:   \n"; + echo "Resposta Humana:   \n"; + echo "Sale:   \n"; + echo "DNC:   \n"; + echo "Customer Contact:  
\n"; + echo "Not Interested:   \n"; + echo "Unworkable:   \n"; + echo "Categoria:\n"; + echo "  
\n"; + echo "
\n"; + + echo "

\n"; + + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + + + + +###################### +# ADD=331111111111111 modify vicidial status categories +###################### + +if ($ADD==331111111111111) + { + if ($LOGmodify_servers==1) + { + echo "
\n"; + echo ""; + + echo "
\n"; + echo "VICIDIAL CATEGORIA DE STATUS:   $NWB#vicidial_status_categories$NWE
\n"; + echo "\n"; + echo "\n"; + + $stmt="SELECT vsc_id,vsc_name,vsc_description,tovdad_display,sale_category,dead_lead_category from vicidial_status_categories order by vsc_id;"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + $o=0; + while ($statuses_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $Avsc_id[$o] = $rowx[0]; + $Avsc_name[$o] = $rowx[1]; + $Avsc_description[$o] = $rowx[2]; + $Atovdad_display[$o] = $rowx[3]; + $Asale_category[$o] = $rowx[4]; + $Adead_lead_category[$o] = $rowx[5]; + $o++; + } + $p=0; + while ($o > $p) + { + if (eregi("1$|3$|5$|7$|9$", $p)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $CATstatuses=''; + $stmt="SELECT status from vicidial_statuses where category='$Avsc_id[$p]' order by status;"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + $q=0; + while ($statuses_to_print > $q) + { + $rowx=mysql_fetch_row($rslt); + $CATstatuses.=" $rowx[0]"; + $q++; + } + $stmt="SELECT status from vicidial_campaign_statuses where category='$Avsc_id[$p]' order by status;"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + $q=0; + while ($statuses_to_print > $q) + { + $rowx=mysql_fetch_row($rslt); + $CATstatuses.=" $rowx[0]"; + $q++; + } + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + $p++; + } + + echo "
CATEGORIANOMESTATUS NESTA CATEGORIA
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "$Avsc_id[$p]
\n"; + echo "$CATstatuses"; + echo "
TO VDAD Mostrar:     Categoria de Venda:     Categoria de Registro Ruim:  
Descrição:
        \n"; + echo "   APAGAR
 
\n"; + + echo "
INCLUIR CATEG. DE STATUS
\n"; + echo "\n"; + echo "Category ID:   \n"; + echo "Name:  
\n"; + echo "TimeOnVDAD Mostrar:   \n"; + echo "Categoria de Venda:   \n"; + echo "Categoria de Registro Ruim:  
\n"; + echo "Descrição:   \n"; + echo "
\n"; + + echo "

\n"; + + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + + + + +###################### +# ADD=341111111111111 modify vicidial QC status code +###################### + +if ($ADD==341111111111111) + { + if ( ($LOGmodify_servers==1) and ($SSqc_features_active > 0) ) + { + echo "
\n"; + echo ""; + + echo "
\n"; + echo "CÓDIGOS DE STATUS DE CQ NESTE SISTEMA VICIDIAL:  $NWB#vicidial_qc_status_codes$NWE
\n"; + echo "\n"; + echo "\n"; + + ##### go through each QC status code + $stmt="SELECT count(*) from vicidial_qc_codes;"; + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0] > 0) + { + $stmt="SELECT code,code_name from vicidial_qc_codes order by code;"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + $o=0; + while ($statuses_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $o++; + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + echo "\n"; + echo "\n"; + } + } + echo "
STATUS CODEDESCRIÇÃOMODIFY/DELETE
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "$rowx[0]
        \n"; + echo "   \n"; + + if (preg_match("/^B$|^NA$|^DNC$|^NA$|^DROP$|^INCALL$|^QUEUE$|^NEW$/i",$rowx[0])) + { + echo "APAGAR\n"; + } + else + { + echo "APAGAR\n"; + } + echo "
\n"; + + echo "
INCLUIR CÓDIGO DE CQ
\n"; + echo "\n"; + echo "Status:   \n"; + echo "Descrição:
\n"; + echo "
\n"; + + echo "

\n"; + + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + + + + + +###################### +# ADD=550 user search form +###################### + +if ($ADD==550) + { + echo "
\n"; + echo ""; + + echo "
PESQUISAR USUÁRIO
\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "
Número do usuário:
Nome Completo:
Nível do Usuário:
Grupo do Usuário:
\n"; + } + +###################### +# ADD=660 user search results +###################### + +if ($ADD==660) + { + echo "
\n"; + echo ""; + + $SQL = ''; + if ($user) {$SQL .= " user LIKE \"%$user%\" and";} + if ($full_name) {$SQL .= " full_name LIKE \"%$full_name%\" and";} + if ($user_level > 0) {$SQL .= " user_level LIKE \"%$user_level%\" and";} + if ($user_group) {$SQL .= " user_group = '$user_group' and";} + $SQL = eregi_replace(" and$", "", $SQL); + if (strlen($SQL)>5) {$SQL = "and $SQL";} + + $stmt="SELECT user_id,user,pass,full_name,user_level,user_group,phone_login,phone_pass,delete_users,delete_user_groups,delete_lists,delete_campaigns,delete_ingroups,delete_remote_agents,load_leads,campaign_detail,ast_admin_access,ast_delete_phones,delete_scripts,modify_leads,hotkeys_active,change_agent_campaign,agent_choose_ingroups,closer_campaigns,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,delete_filters,alter_agent_interface_options,closer_default_blended,delete_call_times,modify_call_times,modify_users,modify_campaigns,modify_lists,modify_scripts,modify_filters,modify_ingroups,modify_usergroups,modify_remoteagents,modify_servers,view_reports,vicidial_recording_override,alter_custdata_override,qc_enabled,qc_user_level,qc_pass,qc_finish,qc_commit,add_timeclock_log,modify_timeclock_log,delete_timeclock_log,alter_custphone_override,vdc_agent_api_access,modify_inbound_dids,delete_inbound_dids,active,alert_enabled,download_lists,agent_shift_enforcement_override,manager_shift_enforcement_override,shift_override_flag,export_reports,delete_from_dnc,email,user_code,territory,allow_alerts from vicidial_users where user_level <= $LOGuser_level $SQL order by full_name desc;"; +# echo "\n|$stmt|\n"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + + echo "
RESULTADOS DA PESQUISA:\n"; + echo "
\n"; + + $o=0; + while ($people_to_print > $o) + { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + $o++; + } + + echo "
$row[1]$row[3]$row[4]$row[5]ALTERAR | ESTATÍSTICAS | STATUS | TIME
\n"; + + } + + +###################################################################################################### +###################################################################################################### +####### 8 series, Callback lists +###################################################################################################### +###################################################################################################### + +###################### +# ADD=8 find all callbacks on hold by a User +###################### +if ($ADD==8) + { + if ($LOGmodify_users==1) + { + if ($SUB==89) + { + $stmt="UPDATE vicidial_callbacks SET status='INACTIVE' where user='$user' and status IN('LIVE','ACTIVE') and callback_time < '$past_month_date';"; + $rslt=mysql_query($stmt, $link); + echo "
Usuário($user) callback listings LIVE for more than one month have been made INACTIVE\n"; + } + if ($SUB==899) + { + $stmt="UPDATE vicidial_callbacks SET status='INACTIVE' where user='$user' and status IN('LIVE','ACTIVE') and callback_time < '$past_week_date';"; + $rslt=mysql_query($stmt, $link); + echo "
Usuário($user) callback listings LIVE for more than one week have been made INACTIVE\n"; + } + } + $CBinactiveLINK = "
Remove LIVE Callbacks older than one month for this user
Remove LIVE Callbacks older than one week for this user
"; + + echo ""; + + $CBquerySQLwhere = "and user='$user'"; + + echo "
USER CALLBACK HOLD LISTINGS: $user\n"; + $oldADD = "ADD=8&user=$user"; + $ADD='82'; + } + +###################### +# ADD=81 find all callbacks on hold within a Campaign +###################### +if ($ADD==81) + { + if ($LOGmodify_campaigns==1) + { + if ($SUB==89) + { + $stmt="UPDATE vicidial_callbacks SET status='INACTIVE' where campaign_id='$campaign_id' and status IN('LIVE','ACTIVE') and callback_time < '$past_month_date';"; + $rslt=mysql_query($stmt, $link); + echo "
campaign($campaign_id) callback listings LIVE for more than one month have been made INACTIVE\n"; + } + if ($SUB==899) + { + $stmt="UPDATE vicidial_callbacks SET status='INACTIVE' where campaign_id='$campaign_id' and status IN('LIVE','ACTIVE') and callback_time < '$past_week_date';"; + $rslt=mysql_query($stmt, $link); + echo "
campaign($campaign_id) callback listings LIVE for more than one week have been made INACTIVE\n"; + } + } + $CBinactiveLINK = "
Remove LIVE Callbacks older than one month for this campaign
Remove LIVE Callbacks older than one week for this campaign
"; + + echo ""; + + $CBquerySQLwhere = "and campaign_id='$campaign_id'"; + + echo "
CAMPANHA CALLBACK HOLD LISTINGS: $campaign_id\n"; + $oldADD = "ADD=81&campaign_id=$campaign_id"; + $ADD='82'; + } + +###################### +# ADD=811 find all callbacks on hold within a List +###################### +if ($ADD==811) + { + if ($LOGmodify_lists==1) + { + if ($SUB==89) + { + $stmt="UPDATE vicidial_callbacks SET status='INACTIVE' where list_id='$list_id' and status IN('LIVE','ACTIVE') and callback_time < '$past_month_date';"; + $rslt=mysql_query($stmt, $link); + echo "
list($list_id) callback listings LIVE for more than one month have been made INACTIVE\n"; + } + if ($SUB==899) + { + $stmt="UPDATE vicidial_callbacks SET status='INACTIVE' where list_id='$list_id' and status IN('LIVE','ACTIVE') and callback_time < '$past_week_date';"; + $rslt=mysql_query($stmt, $link); + echo "
list($list_id) callback listings LIVE for more than one week have been made INACTIVE\n"; + } + } + $CBinactiveLINK = "
Remove LIVE Callbacks older than one month for this list
Remove LIVE Callbacks older than one week for this list
"; + + echo ""; + + $CBquerySQLwhere = "and list_id='$list_id'"; + + echo "
LIST CALLBACK HOLD LISTINGS: $list_id\n"; + $oldADD = "ADD=811&list_id=$list_id"; + $ADD='82'; + } + +###################### +# ADD=8111 find all callbacks on hold within a user group +###################### +if ($ADD==8111) + { + if ($LOGmodify_usergroups==1) + { + if ($SUB==89) + { + $stmt="UPDATE vicidial_callbacks SET status='INACTIVE' where user_group='$user_group' and status IN('LIVE','ACTIVE') and callback_time < '$past_month_date';"; + $rslt=mysql_query($stmt, $link); + echo "
user group($user_group) callback listings LIVE for more than one month have been made INACTIVE\n"; + } + if ($SUB==899) + { + $stmt="UPDATE vicidial_callbacks SET status='INACTIVE' where user_group='$user_group' and status IN('LIVE','ACTIVE') and callback_time < '$past_week_date';"; + $rslt=mysql_query($stmt, $link); + echo "
user group($user_group) callback listings LIVE for more than one week have been made INACTIVE\n"; + } + } + $CBinactiveLINK = "
Remove LIVE Callbacks older than one month for this user group
Remove LIVE Callbacks older than one week for this user group
"; + + echo ""; + + $CBquerySQLwhere = "and user_group='$user_group'"; + + echo "
GRUPO DE USUÁRIOS CALLBACK HOLD LISTINGS: $list_id\n"; + $oldADD = "ADD=8111&user_group=$user_group"; + $ADD='82'; + } + +###################### +# ADD=82 display all callbacks on hold +###################### +if ($ADD==82) + { + $USERlink='stage=USERIDDOWN'; + $GROUPlink='stage=GROUPDOWN'; + $ENDATElink='stage=ENDATEDOWN'; + $SQLorder='order by '; + if (eregi("USERIDDOWN",$stage)) {$SQLorder='order by user desc,'; $USERlink='stage=USERIDUP';} + if (eregi("GROUPDOWN",$stage)) {$SQLorder='order by user_group desc,'; $NAMElink='stage=NAMEUP';} + if (eregi("ENDATEDOWN",$stage)) {$SQLorder='order by entry_time desc,'; $NÍVELlink='stage=NÍVELUP';} + + $stmt="SELECT callback_id,lead_id,list_id,campaign_id,status,entry_time,callback_time,modify_date,user,recipient,comments,user_group from vicidial_callbacks where status IN('ACTIVE','LIVE') $CBquerySQLwhere $SQLorder recipient,status desc,callback_time"; + $rslt=mysql_query($stmt, $link); + $cb_to_print = mysql_num_rows($rslt); + + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + $o=0; + while ($cb_to_print > $o) + { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + + echo "
LEADLIST CAMPANHAENTRY DATACALLBACK DATAUSERRECIPIENTSTATUSGROUP
$row[1]$row[2]$row[3]$row[5]$row[6]$row[8]$row[9]$row[4]$row[11]
\n"; + + echo "$CBinactiveLINK"; + } + + + +###################################################################################################### +###################################################################################################### +####### 0 series, displays and searches +###################################################################################################### +###################################################################################################### + +###################### +# ADD=0 display all active users +###################### +if ($ADD==0) + { + echo "
\n"; + echo ""; + echo "
LISTA DE USUÁRIOS: "; + if (ereg('display_all',$status)) + { + $SQLstatus = ''; + echo "   mostrar somente usuários ativos\n"; + } + else + { + $SQLstatus = "and active='Y'"; + echo "   mostrar todos usuários\n"; + } + + $USERlink='stage=USERIDDOWN'; + $NAMElink='stage=NAMEDOWN'; + $NÍVELlink='stage=NÍVELDOWN'; + $GROUPlink='stage=GROUPDOWN'; + $SQLorder='order by full_name'; + if (eregi("USERIDUP",$stage)) {$SQLorder='order by user asc'; $USERlink='stage=USERIDDOWN';} + if (eregi("USERIDDOWN",$stage)) {$SQLorder='order by user desc'; $USERlink='stage=USERIDUP';} + if (eregi("NAMEUP",$stage)) {$SQLorder='order by full_name asc'; $NAMElink='stage=NAMEDOWN';} + if (eregi("NAMEDOWN",$stage)) {$SQLorder='order by full_name desc'; $NAMElink='stage=NAMEUP';} + if (eregi("NÍVELUP",$stage)) {$SQLorder='order by user_level asc'; $NÍVELlink='stage=NÍVELDOWN';} + if (eregi("NÍVELDOWN",$stage)) {$SQLorder='order by user_level desc'; $NÍVELlink='stage=NÍVELUP';} + if (eregi("GROUPUP",$stage)) {$SQLorder='order by user_group asc'; $GROUPlink='stage=GROUPDOWN';} + if (eregi("GROUPDOWN",$stage)) {$SQLorder='order by user_group desc'; $GROUPlink='stage=GROUPUP';} + $stmt="SELECT user,full_name,user_level,user_group,active from vicidial_users where user_level <= $LOGuser_level $SQLstatus $SQLorder"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + + $o=0; + while ($people_to_print > $o) + { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + + echo "
ID DO USUÁRIONOME COMPLETONÍVELGROUPATIVOLINKS
$row[0]$row[1]$row[2]$row[3]$row[4]
ALTERAR | ESTATÍSTICAS | STATUS | TIME
\n"; + } + +###################### +# ADD=10 display all campaigns +###################### +if ($ADD==10) + { + echo "
\n"; + echo ""; + + $stmt="SELECT campaign_id,campaign_name,active,dial_method,auto_dial_level,lead_order,dial_statuses from vicidial_campaigns order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $campaigns_to_print = mysql_num_rows($rslt); + + echo "
LISTA DE CAMPANHAS:\n"; + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo ""; + if ($SSoutbound_autodial_active > 0) + { + echo ""; + echo ""; + echo ""; + echo ""; + } + echo "\n"; + + $o=0; + while ($campaigns_to_print > $o) + { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + if ($SSoutbound_autodial_active > 0) + { + echo ""; + echo ""; + echo ""; + echo ""; + } + echo "\n"; + $o++; + } + + echo "
ID
NOME
ACTIVE   MÉTODO DE DISC.   NÍVEL   ORDEM DOS REG.   STATUS DE DISC.   ALTERAR
$row[0]   $row[1]   $row[2]   $row[3]   $row[4]   $row[5]   $row[6]ALTERAR
\n"; + } + + +###################### +# ADD=100 display all lists +###################### +if ($ADD==100) + { + echo "
\n"; + echo ""; + + $LISTlink='stage=LISTIDDOWN'; + $TALLYlink='stage=TALLYDOWN'; + $ACTIVElink='stage=ACTIVEDOWN'; + $CAMPANHAlink='stage=CAMPANHADOWN'; + $CALLDATElink='stage=CALLDATEDOWN'; + $SQLorder='order by list_id'; + if (eregi("LISTIDUP",$stage)) {$SQLorder='order by list_id asc'; $LISTlink='stage=LISTIDDOWN';} + if (eregi("LISTIDDOWN",$stage)) {$SQLorder='order by list_id desc'; $LISTlink='stage=LISTIDUP';} + if (eregi("TALLYUP",$stage)) {$SQLorder='order by tally asc'; $TALLYlink='stage=TALLYDOWN';} + if (eregi("TALLYDOWN",$stage)) {$SQLorder='order by tally desc'; $TALLYlink='stage=TALLYUP';} + if (eregi("ACTIVEUP",$stage)) {$SQLorder='order by active asc'; $ACTIVElink='stage=ACTIVEDOWN';} + if (eregi("ACTIVEDOWN",$stage)) {$SQLorder='order by active desc'; $ACTIVElink='stage=ACTIVEUP';} + if (eregi("CAMPANHAUP",$stage)) {$SQLorder='order by campaign_id asc'; $CAMPANHAlink='stage=CAMPANHADOWN';} + if (eregi("CAMPANHADOWN",$stage)) {$SQLorder='order by campaign_id desc'; $CAMPANHAlink='stage=CAMPANHAUP';} + if (eregi("CALLDATEUP",$stage)) {$SQLorder='order by list_lastcalldate asc'; $CALLDATElink='stage=CALLDATEDOWN';} + if (eregi("CALLDATEDOWN",$stage)) {$SQLorder='order by list_lastcalldate desc'; $CALLDATElink='stage=CALLDATEUP';} + $stmt="SELECT vls.list_id,list_name,list_description,count(*) as tally,active,list_lastcalldate,campaign_id,reset_time from vicidial_lists vls,vicidial_list vl where vls.list_id=vl.list_id group by list_id $SQLorder"; + $rslt=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rslt); + + echo "
LISTAS:\n"; + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + + $lists_printed = ''; + $o=0; + while ($lists_to_print > $o) + { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $lists_printed .= "'$row[0]',"; + $o++; + } + + $stmt="SELECT list_id,list_name,list_description,0,active,list_lastcalldate,campaign_id,reset_time from vicidial_lists where list_id NOT IN($lists_printed'');"; + $rslt=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rslt); + $o=0; + while ($lists_to_print > $o) + { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + + echo "
ID DA LISTANOME DA LISTADESCRIÇÃORTIMETOTAL DE REG.ATIVOÚLTIMA CHAMADACAMPANHAALTERAR
$row[0] $row[1] $row[2] $row[7] $row[3] $row[4] $row[5] $row[6]ALTERAR
$row[0] $row[1] $row[2] $row[7] $row[3] $row[4] $row[5] $row[6]ALTERAR
\n"; + } + + + +###################### +# ADD=1000 display all inbound groups +###################### +if ($ADD==1000) + { + echo "
\n"; + echo ""; + + $stmt="SELECT group_id,group_name,queue_priority,active,call_time_id,group_color from vicidial_inbound_groups order by group_id"; + $rslt=mysql_query($stmt, $link); + $ingroups_to_print = mysql_num_rows($rslt); + + echo "
LISTA DE GRUPOS DE ENTRADA:\n"; + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + + $o=0; + while ($ingroups_to_print > $o) + { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + + echo "
IN-GROUPNOMEPRIORIDADEATIVOTIMECOLORALTERAR
$row[0] $row[1] $row[2] $row[3] $row[4]  ALTERAR
\n"; + } + + +###################### +# ADD=1300 display all inbound dids +###################### +if ($ADD==1300) + { + echo "
\n"; + echo ""; + + $stmt="SELECT did_id,did_pattern,did_description,did_active,did_route from vicidial_inbound_dids order by did_pattern"; + $rslt=mysql_query($stmt, $link); + $dids_to_print = mysql_num_rows($rslt); + + echo "
ENTRANTE DID LISTINGS:\n"; + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + + $o=0; + while ($dids_to_print > $o) + { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + + echo "
#DIDDESCRIÇÃOATIVOROUTEALTERAR
$row[0] $row[1] $row[2] $row[3] $row[4]ALTERAR
\n"; + } + + +###################### +# ADD=1500 display all call menus +###################### +if ($ADD==1500) + { + echo "
\n"; + echo ""; + + $stmt="SELECT menu_id,menu_name,menu_prompt,menu_timeout from vicidial_call_menu order by menu_id"; + $rslt=mysql_query($stmt, $link); + $menus_to_print = mysql_num_rows($rslt); + + echo "
LISTA DE MENUS:\n"; + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + + $o=0; + $menu_id = $MT; + + while ($menus_to_print > $o) + { + $row=mysql_fetch_row($rslt); + $menu_id[$o] = $row[0]; + $menu_name[$o] = $row[1]; + $menu_prompt[$o] = $row[2]; + $menu_timeout[$o] = $row[3]; + $o++; + } + + $o=0; + while ($menus_to_print > $o) + { + $stmt="SELECT count(*) from vicidial_call_menu_options where menu_id=\"$menu_id[$o]\";"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + + echo "
MENU IDNOMEPROMPTTIMEOUTOPTIONSALTERAR
$menu_id[$o] $menu_name[$o] $menu_prompt[$o] $menu_timeout[$o] $row[0]ALTERAR
\n"; + } + + +###################### +# ADD=10000 display all remote agents +###################### +if ($ADD==10000) + { + echo "
\n"; + echo ""; + + $stmt="SELECT remote_agent_id,user_start,number_of_lines,server_ip,conf_exten,status,campaign_id from vicidial_remote_agents order by server_ip,campaign_id,user_start"; + $rslt=mysql_query($stmt, $link); + $remoteagents_to_print = mysql_num_rows($rslt); + + echo "
LISTA DE AGENTES REMOTOS:\n"; + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + + $o=0; + while ($remoteagents_to_print > $o) + { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + + echo "
USERLINESSERVIDOR   CONF-EXTEN   STATUS   CAMPANHA   ALTERAR
$row[1] $row[2] $row[3] $row[4] $row[5] $row[6]ALTERAR
\n"; + } + + +###################### +# ADD=100000 display all user groups +###################### +if ($ADD==100000) + { + echo "
\n"; + echo ""; + + $stmt="SELECT user_group,group_name,forced_timeclock_login from vicidial_user_groups order by user_group"; + $rslt=mysql_query($stmt, $link); + $usergroups_to_print = mysql_num_rows($rslt); + + echo "
GRUPOS DE USUÁRIOS:\n"; + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + + $o=0; + while ($usergroups_to_print > $o) + { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + + echo "
GRUPO DE USUÁRIOSNOME DO GRUPOFORÇAR PONTO   ALTERAR
$row[0] $row[1] $row[2]ALTERAR
\n"; + } + + +###################### +# ADD=1000000 display all scripts +###################### +if ($ADD==1000000) + { + echo "
\n"; + echo ""; + + $stmt="SELECT script_id,script_name,active from vicidial_scripts order by script_id"; + $rslt=mysql_query($stmt, $link); + $scripts_to_print = mysql_num_rows($rslt); + + echo "
LISTA DE SCRIPTS:\n"; + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + + $o=0; + while ($scripts_to_print > $o) + { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + + echo "
ID DO SCRIPTNOME DO SCRIPTACTIVE   ALTERAR
$row[0] $row[1] $row[2]ALTERAR
\n"; + } + + +###################### +# ADD=10000000 display all filters +###################### +if ($ADD==10000000) + { + echo "
\n"; + echo ""; + + $stmt="SELECT lead_filter_id,lead_filter_name from vicidial_lead_filters order by lead_filter_id"; + $rslt=mysql_query($stmt, $link); + $filters_to_print = mysql_num_rows($rslt); + + echo "
Listagem de Filtros de Registro:\n"; + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo "\n"; + + $o=0; + while ($filters_to_print > $o) + { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo "\n"; + $o++; + } + + echo "
FILTER IDFILTER NAMEALTERAR
$row[0] $row[1]ALTERAR
\n"; + } + + +###################### +# ADD=100000000 display all call times +###################### +if ($ADD==100000000) + { + echo "
\n"; + echo ""; + + $stmt="SELECT call_time_id,call_time_name,ct_default_start,ct_default_stop from vicidial_call_times order by call_time_id"; + $rslt=mysql_query($stmt, $link); + $calltimes_to_print = mysql_num_rows($rslt); + + echo "
LISTAGEM DE HORÁRIOS DE CHAMADA:\n"; + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + + $o=0; + while ($calltimes_to_print > $o) + { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + + echo "
ID DO HORÁRIONOME DO HORÁRIOINÍCIO PADRÃOFIM PADRÃOALTERAR
$row[0] $row[1] $row[2] $row[3] ALTERAR
\n"; + } + +###################### +# ADD=1000000000 display all state call times +###################### +if ($ADD==1000000000) + { + echo "
\n"; + echo ""; + + $stmt="SELECT state_call_time_id,state_call_time_state,state_call_time_name,sct_default_start,sct_default_stop from vicidial_state_call_times order by state_call_time_id"; + $rslt=mysql_query($stmt, $link); + $statecalltimes_to_print = mysql_num_rows($rslt); + + echo "
LISTAGEM DE HORÁRIOS DE CHAMADA POR ESTADO:\n"; + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + + $o=0; + while ($statecalltimes_to_print > $o) + { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + + echo "
ID DO HORÁRIOCALLTIME STATENOME DO HORÁRIOINÍCIO PADRÃOFIM PADRÃOALTERAR
$row[0] $row[1] $row[2] $row[3] $row[4] ALTERAR
\n"; + } + +###################### +# ADD=130000000 display all shifts +###################### +if ($ADD==130000000) + { + echo "
\n"; + echo ""; + + $stmt="SELECT shift_id,shift_name,shift_start_time,shift_length,shift_weekdays from vicidial_shifts order by shift_id"; + $rslt=mysql_query($stmt, $link); + $shifts_to_print = mysql_num_rows($rslt); + + echo "
LISTA DE TURNOS:\n"; + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + + $o=0; + while ($shifts_to_print > $o) + { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + + echo "
ID DO TURNONOME DO TURNOINÍCIO DO TURNOFIM DO TURNOSEMANALALTERAR
$row[0] $row[1] $row[2] $row[3] $row[4] ALTERAR
\n"; + } + +###################### +# ADD=10000000000 display all phones +###################### +if ($ADD==10000000000) + { + echo "
\n"; + echo ""; + + $EXTENlink='stage=EXTENDOWN'; + $PROTOlink='stage=PROTODOWN'; + $SERVERlink='stage=SERVERDOWN'; + $STATUSlink='stage=STATUSDOWN'; + $SQLorder='order by extension,server_ip'; + if (eregi("EXTENUP",$stage)) {$SQLorder='order by extension asc'; $EXTENlink='stage=EXTENDOWN';} + if (eregi("EXTENDOWN",$stage)) {$SQLorder='order by extension desc'; $EXTENlink='stage=EXTENUP';} + if (eregi("PROTOUP",$stage)) {$SQLorder='order by protocol asc'; $PROTOlink='stage=PROTODOWN';} + if (eregi("PROTODOWN",$stage)) {$SQLorder='order by protocol desc'; $PROTOlink='stage=PROTOUP';} + if (eregi("SERVERUP",$stage)) {$SQLorder='order by server_ip asc'; $SERVERlink='stage=SERVERDOWN';} + if (eregi("SERVERDOWN",$stage)) {$SQLorder='order by server_ip desc'; $SERVERlink='stage=SERVERUP';} + if (eregi("STATUSUP",$stage)) {$SQLorder='order by status asc'; $STATUSlink='stage=STATUSDOWN';} + if (eregi("STATUSDOWN",$stage)) {$SQLorder='order by status desc'; $STATUSlink='stage=STATUSUP';} + $stmt="SELECT extension,protocol,server_ip,dialplan_number,voicemail_id,status,fullname,messages,old_messages from phones $SQLorder"; + $rslt=mysql_query($stmt, $link); + $phones_to_print = mysql_num_rows($rslt); + + echo "
LISTA DE RAMAIS:\n"; + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + + $o=0; + while ($phones_to_print > $o) + { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo " + + + + + + + + "; + echo "\n"; + $o++; + } + + echo "
EXTENPROTOSERVERPLANO DE DISC.STATUSNOMEVMAILLINKS
$row[0]$row[1]$row[2]$row[3]$row[4]$row[5]$row[6]$row[7]$row[8]ALTERAR | ESTATÍSTICAS
\n"; + } + +###################### +# ADD=12000000000 display all phones alias +###################### +if ($ADD==12000000000) + { + echo "
\n"; + echo ""; + + $stmt="SELECT alias_id,alias_name,logins_list from phones_alias order by alias_id;"; + $rslt=mysql_query($stmt, $link); + $phonealias_to_print = mysql_num_rows($rslt); + + echo "
LISTAGEM DE ALIAS DE RAMAL:\n"; + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + + $o=0; + while ($phonealias_to_print > $o) + { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + + echo "
ID DO ALIASNOME DO ALIASLISTA DE LOGINS DE RAMALALTERAR
$row[0]$row[1]$row[2]ALTERAR
\n"; + } + +###################### +# ADD=13000000000 display all group alias +###################### +if ($ADD==13000000000) + { + echo "
\n"; + echo ""; + + $stmt="SELECT group_alias_id,group_alias_name,caller_id_number,caller_id_name,active from groups_alias order by group_alias_id;"; + $rslt=mysql_query($stmt, $link); + $phonealias_to_print = mysql_num_rows($rslt); + + echo "
LISTAS DE ALIAS DE GRUPO:\n"; + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + + $o=0; + while ($phonealias_to_print > $o) + { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + + echo "
ID DO ALIAS DE GRUPONOME DO ALIAS DE GRUPONÚMERO CIDNOME CIDATIVOALTERAR
$row[0]$row[1]$row[2]$row[3]$row[4]ALTERAR
\n"; + } + +###################### +# ADD=100000000000 display all servers +###################### +if ($ADD==100000000000) + { + echo "
\n"; + echo ""; + + $stmt="SELECT server_id,server_description,server_ip,active,asterisk_version,max_vicidial_trunks,local_gmt from servers order by server_id"; + $rslt=mysql_query($stmt, $link); + $servers_to_print = mysql_num_rows($rslt); + + echo "
LISTA DE SERVIDORES:\n"; + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + + $o=0; + while ($servers_to_print > $o) + { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + + echo "
SERVIDOR IDNOMESERVIDOR IPATIVOASTERISKTRUNKSGMTALTERAR
$row[0]$row[1]$row[2]$row[3]$row[4]$row[5]$row[6]ALTERAR
\n"; + } + +###################### +# ADD=130000000000 display all conf templates +###################### +if ($ADD==130000000000) + { + echo "
\n"; + echo ""; + + $stmt="SELECT template_id,template_name from vicidial_conf_templates order by template_id"; + $rslt=mysql_query($stmt, $link); + $templates_to_print = mysql_num_rows($rslt); + + echo "
LISTA DAS TEMPLATES DE CONF:\n"; + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo "\n"; + + $o=0; + while ($templates_to_print > $o) + { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo "\n"; + $o++; + } + + echo "
ID do TemplateNome do TemplateALTERAR
$row[0]$row[1]ALTERAR
\n"; + } + +###################### +# ADD=140000000000 display all carriers +###################### +if ($ADD==140000000000) + { + echo "
\n"; + echo ""; + + $stmt="SELECT carrier_id,carrier_name,server_ip,protocol,registration_string,active from vicidial_server_carriers order by carrier_id"; + $rslt=mysql_query($stmt, $link); + $carriers_to_print = mysql_num_rows($rslt); + + echo "
LISTAS DAS OPERADORAS:\n"; + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + + $o=0; + while ($carriers_to_print > $o) + { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + + echo "
ID da OperadoraNome da OperadoraIP do ServidorProtocolRegistroAtivoALTERAR
$row[0]$row[1]$row[2]$row[3]$row[4]$row[5]ALTERAR
\n"; + } + + +###################### +# ADD=150000000000 display all tts entries +###################### +if ($ADD==150000000000) + { + echo "
\n"; + echo ""; + + $stmt="SELECT tts_id,tts_name,active,tts_text from vicidial_tts_prompts order by tts_id"; + $rslt=mysql_query($stmt, $link); + $tts_to_print = mysql_num_rows($rslt); + + echo "
TEXT-TO-SPEECH(TTS) LISTINGS:\n"; + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + + $o=0; + while ($tts_to_print > $o) + { + $row=mysql_fetch_row($rslt); + $row[3]=ereg_replace(";|<|>","",$row[3]); + while(strlen($row[3]) > 50) {$row[3] = substr("$row[3]", 0, -1);} + if(strlen($row[3]) > 47) {$row[3] = "$row[3]...";} + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + + echo "
TTS IDNombre TTSAtivoTTS TextoALTERAR
$row[0]$row[1]$row[2]$row[3]ALTERAR
\n"; + } + + +###################### +# ADD=160000000000 display all music on hold entries +###################### +if ($ADD==160000000000) + { + echo "
\n"; + echo ""; + + $stmt="SELECT moh_id,moh_name,active,random from vicidial_music_on_hold where remove='N' order by moh_id"; + $rslt=mysql_query($stmt, $link); + $moh_to_print = mysql_num_rows($rslt); + + echo "
MUSIC-ON-HOLD(MOH) LISTINGS:\n"; + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + + $o=0; + while ($moh_to_print > $o) + { + $row=mysql_fetch_row($rslt); + $row[3]=ereg_replace(";|<|>","",$row[3]); + while(strlen($row[3]) > 50) {$row[3] = substr("$row[3]", 0, -1);} + if(strlen($row[3]) > 47) {$row[3] = "$row[3]...";} + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + + echo "
MOH IDMOH NameAtivoOrden aleatorioALTERAR
$row[0]$row[1]$row[2]$row[3]ALTERAR
\n"; + } + + +###################### +# ADD=170000000000 display all voicemail entries +###################### +if ($ADD==170000000000) + { + echo "
\n"; + echo ""; + + $stmt="SELECT voicemail_id,fullname,active,messages,old_messages,delete_vm_after_email from vicidial_voicemail order by voicemail_id"; + $rslt=mysql_query($stmt, $link); + $vm_to_print = mysql_num_rows($rslt); + + echo "
CAJAS DE CORREO DE VOZ:\n"; + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + + $o=0; + while ($vm_to_print > $o) + { + $row=mysql_fetch_row($rslt); + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + + echo "
VOICEMAIL IDNameAtivoMensagens NovasMensagens AntigasDeleteALTERAR
$row[0]$row[1]$row[2]$row[3]$row[4]$row[5]ALTERAR
\n"; + } + + +###################### +# ADD=1000000000000 display all conferences +###################### +if ($ADD==1000000000000) + { + echo "
\n"; + echo ""; + + $stmt="SELECT conf_exten,server_ip,extension from conferences order by conf_exten"; + $rslt=mysql_query($stmt, $link); + $conferences_to_print = mysql_num_rows($rslt); + + echo "
LISTA DE CONFERÊNCIAS:\n"; + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + + $o=0; + while ($conferences_to_print > $o) + { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + + echo "
CONFERENCESERVIDOR IPEXTENSÃOALTERAR
$row[0]$row[1]$row[2]ALTERAR
\n"; + } + +###################### +# ADD=10000000000000 display all vicidial conferences +###################### +if ($ADD==10000000000000) + { + echo "
\n"; + echo ""; + + $stmt="SELECT conf_exten,server_ip,extension from vicidial_conferences order by conf_exten"; + $rslt=mysql_query($stmt, $link); + $vicidialconf_to_print = mysql_num_rows($rslt); + + echo "
VICIDIAL LISTA DE CONFERÊNCIAS:\n"; + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + + $o=0; + while ($vicidialconf_to_print > $o) + { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + + echo "
CONFERENCESERVIDOR IPEXTENSÃOALTERAR
$row[0] $row[1] $row[2]ALTERAR
\n"; + } + + + + + +###################### +# ADD=700000000000000 view all activity in the admin log +###################### + +if ($ADD==700000000000000) + { + echo "
\n"; + echo ""; + + if ($stage > 9999) + { + $next_limit = ($stage + 10000); + $limitSQL = "10000 offset $stage"; + } + else + { + $next_limit = "10000"; + $limitSQL = "10000"; + } + + $stmt="SELECT admin_log_id,event_date,user,ip_address,event_section,event_type,record_id,event_code from vicidial_admin_log order by event_date desc limit $limitSQL;"; + $rslt=mysql_query($stmt, $link); + $logs_to_print = mysql_num_rows($rslt); + + echo "
LOG DE ALT. ADMIN: (Últimos 10000 registros)\n"; + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + $logs_printed = ''; + $o=0; + while ($logs_to_print > $o) + { + $row=mysql_fetch_row($rslt); + if (eregi("USER|AGENT",$row[4])) {$record_link = "ADD=3&user=$row[6]";} + if (eregi('CAMPANHA',$row[4])) {$record_link = "ADD=31&campaign_id=$row[6]";} + if (eregi('LIST',$row[4])) {$record_link = "ADD=311&list_id=$row[6]";} + if (eregi('SCRIPT',$row[4])) {$record_link = "ADD=3111111&script_id=$row[6]";} + if (eregi('FILTER',$row[4])) {$record_link = "ADD=31111111&lead_filter_id=$row[6]";} + if (eregi('INGROUP',$row[4])) {$record_link = "ADD=3111&group_id=$row[6]";} + if (eregi('DID',$row[4])) {$record_link = "ADD=3311&did_id=$row[6]";} + if (eregi('USERGROUP',$row[4])) {$record_link = "ADD=311111&user_group=$row[6]";} + if (eregi('REMOTEAGENT',$row[4])) {$record_link = "ADD=31111&remote_agent_id=$row[6]";} + if (eregi('PHONE',$row[4])) {$record_link = "ADD=10000000000";} + if (eregi('CALLTIME',$row[4])) {$record_link = "ADD=311111111&call_time_id=$row[6]";} + if (eregi('SHIFT',$row[4])) {$record_link = "ADD=331111111&shift_id=$row[6]";} + if (eregi('CONFTEMPLATE',$row[4])) {$record_link = "ADD=331111111111&template_id=$row[6]";} + if (eregi('CARRIER',$row[4])) {$record_link = "ADD=341111111111&carrier_id=$row[6]";} + if (eregi('SERVER',$row[4])) {$record_link = "ADD=311111111111&server_id=$row[6]";} + if (eregi('CONFERENCE',$row[4])) {$record_link = "ADD=1000000000000";} + if (eregi('SYSTEM',$row[4])) {$record_link = "ADD=311111111111111";} + if (eregi('CATEGOR',$row[4])) {$record_link = "ADD=331111111111111";} + if (eregi('GROUPALIAS',$row[4])) {$record_link = "ADD=33111111111&group_alias_id=$row[6]";} + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $logs_printed .= "'$row[0]',"; + $o++; + } + echo "
IDDATE TIMEUSERIPSECTIONTYPERECORD IDDESCRIÇÃOGOTO
$row[0] $row[1] $row[2] $row[3] $row[4] $row[5] $row[6] $row[7] GOTO


\n"; + echo "NEXT\n"; + echo "
\n"; + } + + +###################### +# ADD=710000000000000 view all activity in the admin log made by one user +###################### + +if ($ADD==710000000000000) + { + echo "\n";echo "\n"; +$stmt="SELECT admin_home_url,enable_tts_integration from system_settings;"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$admin_home_url_LU = $row[0]; +$SSenable_tts_integration = $row[1]; + +?> +
+ +
\n"; + echo ""; + + $stmt="SELECT full_name from vicidial_users where user='$stage';"; + $rslt=mysql_query($stmt, $link); + $names_to_print = mysql_num_rows($rslt); + if ($names_to_print > 0) + { + $row=mysql_fetch_row($rslt); + $user_name = $row[0]; + } + + $stmt="SELECT admin_log_id,event_date,user,ip_address,event_section,event_type,record_id,event_code from vicidial_admin_log where user='$stage' order by event_date desc limit 10000;"; + $rslt=mysql_query($stmt, $link); + $logs_to_print = mysql_num_rows($rslt); + + echo "
LOG DE ALT. ADMIN: Alterado por $stage - $user_name\n"; + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + $logs_printed = ''; + $o=0; + while ($logs_to_print > $o) + { + $row=mysql_fetch_row($rslt); + + if (eregi("USER|AGENT",$row[4])) {$record_link = "ADD=3&user=$row[6]";} + if (eregi('CAMPANHA',$row[4])) {$record_link = "ADD=31&campaign_id=$row[6]";} + if (eregi('LIST',$row[4])) {$record_link = "ADD=311&list_id=$row[6]";} + if (eregi('SCRIPT',$row[4])) {$record_link = "ADD=3111111&script_id=$row[6]";} + if (eregi('FILTER',$row[4])) {$record_link = "ADD=31111111&lead_filter_id=$row[6]";} + if (eregi('INGROUP',$row[4])) {$record_link = "ADD=3111&group_id=$row[6]";} + if (eregi('DID',$row[4])) {$record_link = "ADD=3311&did_id=$row[6]";} + if (eregi('USERGROUP',$row[4])) {$record_link = "ADD=311111&user_group=$row[6]";} + if (eregi('REMOTEAGENT',$row[4])) {$record_link = "ADD=31111&remote_agent_id=$row[6]";} + if (eregi('PHONE',$row[4])) {$record_link = "ADD=10000000000";} + if (eregi('CALLTIME',$row[4])) {$record_link = "ADD=311111111&call_time_id=$row[6]";} + if (eregi('SHIFT',$row[4])) {$record_link = "ADD=331111111&shift_id=$row[6]";} + if (eregi('CONFTEMPLATE',$row[4])) {$record_link = "ADD=331111111111&template_id=$row[6]";} + if (eregi('CARRIER',$row[4])) {$record_link = "ADD=341111111111&carrier_id=$row[6]";} + if (eregi('SERVER',$row[4])) {$record_link = "ADD=311111111111&server_id=$row[6]";} + if (eregi('CONFERENCE',$row[4])) {$record_link = "ADD=1000000000000";} + if (eregi('SYSTEM',$row[4])) {$record_link = "ADD=311111111111111";} + if (eregi('CATEGOR',$row[4])) {$record_link = "ADD=331111111111111";} + if (eregi('GROUPALIAS',$row[4])) {$record_link = "ADD=33111111111&group_alias_id=$row[6]";} + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $logs_printed .= "'$row[0]',"; + $o++; + } + echo "
IDDATE TIMEUSERIPSECTIONTYPERECORD IDDESCRIÇÃOGOTO
$row[0] $row[1] $row[2] $row[3] $row[4] $row[5] $row[6] $row[7] GOTO


\n"; + echo "\n"; + echo "
\n"; + } + + +###################### +# ADD=720000000000000 view all activity in the admin log made to one section/value +###################### + +if ($ADD==720000000000000) + { + if ($LOGuser_level >= 9) + { + echo "\n"; +echo "
\n"; + echo ""; + + $stmt="SELECT admin_log_id,event_date,user,ip_address,event_section,event_type,record_id,event_code from vicidial_admin_log where event_section='$category' and record_id='$stage' order by event_date desc limit 10000;"; + $rslt=mysql_query($stmt, $link); + $logs_to_print = mysql_num_rows($rslt); + + echo "
LOG DE ALT. ADMIN: Registros de Seção - $category - $stage\n"; + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + $logs_printed = ''; + $o=0; + while ($logs_to_print > $o) + { + $row=mysql_fetch_row($rslt); + + if (eregi("USER|AGENT",$row[4])) {$record_link = "ADD=3&user=$row[6]";} + if (eregi('CAMPANHA',$row[4])) {$record_link = "ADD=31&campaign_id=$row[6]";} + if (eregi('LIST',$row[4])) {$record_link = "ADD=311&list_id=$row[6]";} + if (eregi('SCRIPT',$row[4])) {$record_link = "ADD=3111111&script_id=$row[6]";} + if (eregi('FILTER',$row[4])) {$record_link = "ADD=31111111&lead_filter_id=$row[6]";} + if (eregi('INGROUP',$row[4])) {$record_link = "ADD=3111&group_id=$row[6]";} + if (eregi('DID',$row[4])) {$record_link = "ADD=3311&did_id=$row[6]";} + if (eregi('USERGROUP',$row[4])) {$record_link = "ADD=311111&user_group=$row[6]";} + if (eregi('REMOTEAGENT',$row[4])) {$record_link = "ADD=31111&remote_agent_id=$row[6]";} + if (eregi('PHONE',$row[4])) {$record_link = "ADD=10000000000";} + if (eregi('CALLTIME',$row[4])) {$record_link = "ADD=311111111&call_time_id=$row[6]";} + if (eregi('SHIFT',$row[4])) {$record_link = "ADD=331111111&shift_id=$row[6]";} + if (eregi('CONFTEMPLATE',$row[4])) {$record_link = "ADD=331111111111&template_id=$row[6]";} + if (eregi('CARRIER',$row[4])) {$record_link = "ADD=341111111111&carrier_id=$row[6]";} + if (eregi('SERVER',$row[4])) {$record_link = "ADD=311111111111&server_id=$row[6]";} + if (eregi('CONFERENCE',$row[4])) {$record_link = "ADD=1000000000000";} + if (eregi('SYSTEM',$row[4])) {$record_link = "ADD=311111111111111";} + if (eregi('CATEGOR',$row[4])) {$record_link = "ADD=331111111111111";} + if (eregi('GROUPALIAS',$row[4])) {$record_link = "ADD=33111111111&group_alias_id=$row[6]";} + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $logs_printed .= "'$row[0]',"; + $o++; + } + echo "
IDDATE TIMEUSERIPSECTIONTYPERECORD IDDESCRIÇÃOGOTO
$row[0] $row[1] $row[2] $row[3] $row[4] $row[5] $row[6] $row[7] GOTO


\n"; + echo "\n"; + echo "
\n"; + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=730000000000000 detail view of one admin log entry +###################### + +if ($ADD==730000000000000) + { + if ($LOGuser_level >= 9) + { + echo "
\n"; + echo ""; + + $stmt="SELECT admin_log_id,event_date,val.user,ip_address,event_section,event_type,record_id,event_code,event_notes,event_sql,full_name from vicidial_admin_log val, vicidial_users vu where admin_log_id='$stage' and val.user=vu.user;"; + $rslt=mysql_query($stmt, $link); + $logs_to_print = mysql_num_rows($rslt); + + if ($logs_to_print > 0) + { + $row=mysql_fetch_row($rslt); + echo "
LOG DE ALT. ADMIN: Detalhes do Reg. - $stage

\n"; + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo ""; + echo ""; + echo "\n"; + echo ""; + echo ""; + echo "\n"; + echo ""; + echo ""; + echo "\n"; + echo ""; + echo ""; + echo "\n"; + echo ""; + echo ""; + echo "\n"; + echo ""; + echo ""; + echo "\n"; + echo ""; + echo ""; + echo "\n"; + echo ""; + echo ""; + echo "\n"; + $row[9] = eregi_replace("',","' ,",$row[9]); + $row[9] = preg_replace("/\|/","
",$row[9]); + echo ""; + echo ""; + echo "\n"; + echo "
ID: $row[0]
DATE TIME: $row[1]
USER: $row[2] - $row[10]
IP: $row[3]
SECTION: $row[4]
TYPE: $row[5]
RECORD ID: $row[6]
DESCRIPTION: $row[7]
NOTES: $row[8]
SQL:

$row[9]



\n"; + echo "\n"; + echo "
\n"; + } + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +###################### +# ADD=999999 display reports section +###################### +if ($ADD==999999) + { + if ($LOGview_reports==1) + { + echo "
\n"; + echo ""; + + $stmt="select server_id,server_description,server_ip,active,sysload,channels_total,cpu_idle_percent,disk_usage from servers order by server_id;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $servers_to_print = mysql_num_rows($rslt); + $i=0; + while ($i < $servers_to_print) + { + $row=mysql_fetch_row($rslt); + $server_id[$i] = $row[0]; + $server_description[$i] = $row[1]; + $server_ip[$i] = $row[2]; + $active[$i] = $row[3]; + $sysload[$i] = $row[4]; + $channels_total[$i] = $row[5]; + $cpu_idle_percent[$i] = $row[6]; + $disk_usage[$i] = $row[7]; + $i++; + } + + $stmt="SELECT queuemetrics_url,vtiger_url from system_settings;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $queuemetrics_url_LU = $row[0]; + $vtiger_url_LU = $row[1]; + + $stmt="SELECT count(*) from vicidial_list_update_log;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $list_update_count = $row[0]; + ?> + + + + + + Estatísticas do Servidor e Relatórios + Estatísticas do Servidor e Relatórios

+
+       + + Tempo Real Relatórios
+
+ Inbound and Outbound Calling Relatórios
+ + +
+       + + Agent Relatórios
+
+ Time Clock Relatórios
+
+ Other Relatórios and Links
+ +
+ + +

+		
+		 $o)
+			{
+			$cpu = (100 - $cpu_idle_percent[$o]);
+			$disk = '';
+			$disk_ary = explode('|',$disk_usage[$o]);
+			$disk_ary_ct = count($disk_ary);
+			$k=0;
+			while ($k < $disk_ary_ct)
+				{
+				$disk_ary[$k] = preg_replace("/^\d* /","",$disk_ary[$k]);
+				if ($k<1) {$disk = "$disk_ary[$k]";}
+				else
+					{
+					if ($disk_ary[$k] > $disk) {$disk = "$disk_ary[$k]";}
+					}
+				$k++;
+				}
+			$disk = "$disk%";
+			echo "\n";
+			echo "\n";
+			echo "\n";
+			echo "\n";
+			echo "\n";
+			echo "\n";
+			echo "\n";
+			echo "\n";
+			echo "\n";
+			echo "\n";
+			echo "\n";
+			$o++;
+			}
+
+		echo "
SERVERDESCRIÇÃOIPACTLOADCHANDISKSAINTEENTRANTE
$server_id[$o]$server_description[$o]$server_ip[$o]$active[$o]$sysload[$o] - $cpu%$channels_total[$o]$diskLINKLINK
\n"; + } + else + { + echo "Você não tem permissão para ver esta página\n"; + exit; + } + } + + +echo "
\n"; +echo "
\n"; + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "
\n"; +echo "

"; +echo "VERSÃO: $admin_version
"; +echo "BUILD: $build
\n"; + +?> + +
+
+ + + +1) + { + if (strlen($dial_statuses)>2) + { + $g=0; + $p='13'; + $GMT_gmt[0] = ''; + $GMT_hour[0] = ''; + $GMT_day[0] = ''; + while ($p > -13) + { + $pzone=3600 * $p; + $pmin=(gmdate("i", time() + $pzone)); + $phour=( (gmdate("G", time() + $pzone)) * 100); + $pday=gmdate("w", time() + $pzone); + $tz = sprintf("%.2f", $p); + $GMT_gmt[$g] = "$tz"; + $GMT_day[$g] = "$pday"; + $GMT_hour[$g] = ($phour + $pmin); + $p = ($p - 0.25); + $g++; + } + + $stmt="SELECT call_time_id,call_time_name,call_time_comments,ct_default_start,ct_default_stop,ct_sunday_start,ct_sunday_stop,ct_monday_start,ct_monday_stop,ct_tuesday_start,ct_tuesday_stop,ct_wednesday_start,ct_wednesday_stop,ct_thursday_start,ct_thursday_stop,ct_friday_start,ct_friday_stop,ct_saturday_start,ct_saturday_stop,ct_state_call_times FROM vicidial_call_times where call_time_id='$local_call_time';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $Gct_default_start = "$rowx[3]"; + $Gct_default_stop = "$rowx[4]"; + $Gct_sunday_start = "$rowx[5]"; + $Gct_sunday_stop = "$rowx[6]"; + $Gct_monday_start = "$rowx[7]"; + $Gct_monday_stop = "$rowx[8]"; + $Gct_tuesday_start = "$rowx[9]"; + $Gct_tuesday_stop = "$rowx[10]"; + $Gct_wednesday_start = "$rowx[11]"; + $Gct_wednesday_stop = "$rowx[12]"; + $Gct_thursday_start = "$rowx[13]"; + $Gct_thursday_stop = "$rowx[14]"; + $Gct_friday_start = "$rowx[15]"; + $Gct_friday_stop = "$rowx[16]"; + $Gct_saturday_start = "$rowx[17]"; + $Gct_saturday_stop = "$rowx[18]"; + $Gct_state_call_times = "$rowx[19]"; + + $ct_states = ''; + $ct_state_gmt_SQL = ''; + $ct_srs=0; + $b=0; + if (strlen($Gct_state_call_times)>2) + { + $state_rules = explode('|',$Gct_state_call_times); + $ct_srs = ((count($state_rules)) - 2); + } + while($ct_srs >= $b) + { + if (strlen($state_rules[$b])>1) + { + $stmt="SELECT state_call_time_id,state_call_time_state,state_call_time_name,state_call_time_comments,sct_default_start,sct_default_stop,sct_sunday_start,sct_sunday_stop,sct_monday_start,sct_monday_stop,sct_tuesday_start,sct_tuesday_stop,sct_wednesday_start,sct_wednesday_stop,sct_thursday_start,sct_thursday_stop,sct_friday_start,sct_friday_stop,sct_saturday_start,sct_saturday_stop from vicidial_state_call_times where state_call_time_id='$state_rules[$b]';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $Gstate_call_time_id = "$row[0]"; + $Gstate_call_time_state = "$row[1]"; + $Gsct_default_start = "$row[4]"; + $Gsct_default_stop = "$row[5]"; + $Gsct_sunday_start = "$row[6]"; + $Gsct_sunday_stop = "$row[7]"; + $Gsct_monday_start = "$row[8]"; + $Gsct_monday_stop = "$row[9]"; + $Gsct_tuesday_start = "$row[10]"; + $Gsct_tuesday_stop = "$row[11]"; + $Gsct_wednesday_start = "$row[12]"; + $Gsct_wednesday_stop = "$row[13]"; + $Gsct_thursday_start = "$row[14]"; + $Gsct_thursday_stop = "$row[15]"; + $Gsct_friday_start = "$row[16]"; + $Gsct_friday_stop = "$row[17]"; + $Gsct_saturday_start = "$row[18]"; + $Gsct_saturday_stop = "$row[19]"; + + $ct_states .="'$Gstate_call_time_state',"; + + $r=0; + $state_gmt=''; + while($r < $g) + { + if ($GMT_day[$r]==0) #### Domingo horário local + { + if (($Gsct_sunday_start==0) and ($Gsct_sunday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_sunday_start) and ($GMT_hour[$r]<$Gsct_sunday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==1) #### Segunda horário local + { + if (($Gsct_monday_start==0) and ($Gsct_monday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_monday_start) and ($GMT_hour[$r]<$Gsct_monday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==2) #### Terça horário local + { + if (($Gsct_tuesday_start==0) and ($Gsct_tuesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_tuesday_start) and ($GMT_hour[$r]<$Gsct_tuesday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==3) #### Quarta horário local + { + if (($Gsct_wednesday_start==0) and ($Gsct_wednesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_wednesday_start) and ($GMT_hour[$r]<$Gsct_wednesday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==4) #### Quinta horário local + { + if (($Gsct_thursday_start==0) and ($Gsct_thursday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_thursday_start) and ($GMT_hour[$r]<$Gsct_thursday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==5) #### Sexta horário local + { + if (($Gsct_friday_start==0) and ($Gsct_friday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_friday_start) and ($GMT_hour[$r]<$Gsct_friday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==6) #### Sábado horário local + { + if (($Gsct_saturday_start==0) and ($Gsct_saturday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_saturday_start) and ($GMT_hour[$r]<$Gsct_saturday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + $r++; + } + $state_gmt = "$state_gmt'99'"; + $ct_state_gmt_SQL .= "or (state='$Gstate_call_time_state' and gmt_offset_now IN($state_gmt)) "; + } + + $b++; + } + if (strlen($ct_states)>2) + { + $ct_states = eregi_replace(",$",'',$ct_states); + $ct_statesSQL = "and state NOT IN($ct_states)"; + } + else + { + $ct_statesSQL = ""; + } + + $r=0; + $default_gmt=''; + while($r < $g) + { + if ($GMT_day[$r]==0) #### Domingo horário local + { + if (($Gct_sunday_start==0) and ($Gct_sunday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_sunday_start) and ($GMT_hour[$r]<$Gct_sunday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==1) #### Segunda horário local + { + if (($Gct_monday_start==0) and ($Gct_monday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_monday_start) and ($GMT_hour[$r]<$Gct_monday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==2) #### Terça horário local + { + if (($Gct_tuesday_start==0) and ($Gct_tuesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_tuesday_start) and ($GMT_hour[$r]<$Gct_tuesday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==3) #### Quarta horário local + { + if (($Gct_wednesday_start==0) and ($Gct_wednesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_wednesday_start) and ($GMT_hour[$r]<$Gct_wednesday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==4) #### Quinta horário local + { + if (($Gct_thursday_start==0) and ($Gct_thursday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_thursday_start) and ($GMT_hour[$r]<$Gct_thursday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==5) #### Sexta horário local + { + if (($Gct_friday_start==0) and ($Gct_friday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_friday_start) and ($GMT_hour[$r]<$Gct_friday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==6) #### Sábado horário local + { + if (($Gct_saturday_start==0) and ($Gct_saturday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_saturday_start) and ($GMT_hour[$r]<$Gct_saturday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + $r++; + } + + $default_gmt = "$default_gmt'99'"; + $all_gmtSQL = "(gmt_offset_now IN($default_gmt) $ct_statesSQL) $ct_state_gmt_SQL"; + + $dial_statuses = preg_replace("/ -$/","",$dial_statuses); + $Dstatuses = explode(" ", $dial_statuses); + $Ds_to_print = (count($Dstatuses) - 0); + $Dsql = ''; + $o=0; + while ($Ds_to_print > $o) + { + $o++; + $Dsql .= "'$Dstatuses[$o]',"; + } + $Dsql = preg_replace("/,$/","",$Dsql); + if (strlen($Dsql) < 2) {$Dsql = "''";} + + $DLTsql=''; + if ($drop_lockout_time > 0) + { + $DLseconds = ($drop_lockout_time * 3600); + $DLseconds = floor($DLseconds); + $DLseconds = intval("$DLseconds"); + $DLTsql = "and ( ( (status IN('DROP','XDROP')) and (last_local_call_time < CONCAT(DATE_ADD(NOW(), INTERVAL -$DLseconds SECOND),' ',CURTIME()) ) ) or (status NOT IN('DROP','XDROP')) )"; + } + + $stmt="SELECT count(*) FROM vicidial_list where called_since_last_reset='N' and status IN($Dsql) and list_id IN($camp_lists) and ($all_gmtSQL) $DLTsql $fSQL"; + #$DB=1; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $rslt_rows = mysql_num_rows($rslt); + if ($rslt_rows) + { + $rowx=mysql_fetch_row($rslt); + $active_leads = "$rowx[0]"; + } + else {$active_leads = '0';} + + echo "|$DB|\n"; + echo "Esta campanha tem$active_leads registros para serem discados nessas listas\n"; + } + else + { + echo "nenhum status de discagem selecionado para essa campanha\n"; + } + } + else + { + echo "nenhuma lista ativa para esta campanha\n"; + } + } +else + { + echo "nenhuma lista ativa para esta campanha\n"; + } +##### END calculate what gmt_offset_now values are within the allowed local_call_time setting ### +} +?> diff --git a/LANG_www/vicidial_br/admin_header.php b/LANG_www/vicidial_br/admin_header.php new file mode 100644 index 00000000..72403543 --- /dev/null +++ b/LANG_www/vicidial_br/admin_header.php @@ -0,0 +1,1287 @@ + LICENSE: AGPLv2 +# + +# CHANGES +# 90310-0709 - First Build +# 90508-0542 - Added Call Menu option, changed script to use long PHP tags +# 90514-0605 - Added audio prompt selection functions +# 90530-1206 - Changed List Mix to allow for 40 mixes and a default populate option +# 90531-2339 - Added Dynamic options for Call Menu +# 90612-0852 - Changed relative links +# 90635-0943 - Added javascript for dynamic menus in In-Groups +# 90627-0548 - Added no-agent-no-queue options +# 90628-1016 - Added Text-to-speech options +# 90830-2213 - Added Music On Hold options +# 90904-1534 - Added launch_moh_chooser +# 90916-2334 - Added Voicemail options +# 91223-1030 - Added VIDPROMPT options for in-group routing in Call Menus +# + + +######################### SMALL HTML HEADER BEGIN ####################################### +if($short_header) + { + ?> +
+ + + + + + + + + + + + +
    Usuários     Campanhas     Listas     Scripts     Filtros     Groupos de Entrada     Grupos de Usuário     Agentes Remotos     Admin     Relatórios  
+ 0) + { + if ($hh=='lists') + {$lists_hh="bgcolor=\"$lists_color\""; $lists_fc="$lists_font"; $lists_bold="$header_selected_bold";} + else {$lists_hh=''; $lists_fc='WHITE'; $lists_bold="$header_nonselected_bold";} + } +if ($hh=='ingroups') + {$ingroups_hh="bgcolor=\"$ingroups_color\""; $ingroups_fc="$ingroups_font"; $ingroups_bold="$header_selected_bold";} + else {$ingroups_hh=''; $ingroups_fc='WHITE'; $ingroups_bold="$header_nonselected_bold";} +if ($hh=='remoteagent') + {$remoteagent_hh="bgcolor=\"$remoteagent_color\""; $remoteagent_fc="$remoteagent_font"; $remoteagent_bold="$header_selected_bold";} + else {$remoteagent_hh=''; $remoteagent_fc='WHITE'; $remoteagent_bold="$header_nonselected_bold";} +if ($hh=='usergroups') + {$usergroups_hh="bgcolor=\"$usergroups_color\""; $usergroups_fc="$usergroups_font"; $usergroups_bold="$header_selected_bold";} + else {$usergroups_hh=''; $usergroups_fc='WHITE'; $usergroups_bold="$header_nonselected_bold";} +if ($hh=='scripts') + {$scripts_hh="bgcolor=\"$scripts_color\""; $scripts_fc="$scripts_font"; $scripts_bold="$header_selected_bold";} + else {$scripts_hh=''; $scripts_fc='WHITE'; $scripts_bold="$header_nonselected_bold";} +if ($SSoutbound_autodial_active > 0) + { + if ($hh=='filters') + {$filters_hh="bgcolor=\"$filters_color\""; $filters_fc="$filters_font"; $filters_bold="$header_selected_bold";} + else {$filters_hh=''; $filters_fc='WHITE'; $filters_bold="$header_nonselected_bold";} + } +if ($hh=='admin') + {$admin_hh="bgcolor=\"$admin_color\""; $admin_fc="$admin_font"; $admin_bold="$header_selected_bold";} + else {$admin_hh=''; $admin_fc='WHITE'; $admin_bold="$header_nonselected_bold";} +if ($hh=='reports') + {$reports_hh="bgcolor=\"$reports_color\""; $reports_fc="$reports_font"; $reports_bold="$header_selected_bold";} + else {$reports_hh=''; $reports_fc='WHITE'; $reports_bold="$header_nonselected_bold";} + +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
English Brazilian
+ +\r\n"; + print " \r\n"; + } + $rec_count++; + } +$sthA->finish(); + +exit; diff --git a/LANG_www/vicidial_br/listloader_super.pl b/LANG_www/vicidial_br/listloader_super.pl new file mode 100644 index 00000000..93bfa20e --- /dev/null +++ b/LANG_www/vicidial_br/listloader_super.pl @@ -0,0 +1,1313 @@ +#!/usr/bin/perl +# +# listloader_super.pl version 2.2.0 +# +# Copyright (C) 2010 Matt Florell,Joe Johnson LICENSE: AGPLv2 +# +# +# CHANGES +# 60616-1548 - Added listID override feature to force all leads into same list +# - Added gmt_offset_now lookup for each lead +# 60811-1232 - Changed to DBI +# 60811-1329 - changed to use /etc/astguiclient.conf for configs +# 60906-1056 - added filter of non-digits in alt_phone field +# 61110-1229 - added new USA-Canada DST scheme and Brazil DST scheme +# 61128-1207 - added postal code GMT lookup and duplicate check options +# 70205-1703 - Defaulted phone_code to 1 if not populated +# 70417-1059 - Fixed default phone_code bug +# 70510-1518 - Added campaign and system duplicate check and phonecode override +# 80428-0144 - UTF8 cleanup +# 80713-0023 - added last_local_call_time field default of 2008-01-01 +# 90721-1341 - Added rank and owner as vicidial_list fields +# 91112-0616 - Added title/alt-phone duplicate checking +# 100118-0539 - Added new Australian and New Zealand DST schemes (FSO-FSA and LSS-FSA) +# + +### begin parsing run-time options ### +if (length($ARGV[0])>1) + { + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + $i++; + } + + if ($args =~ /--help|-h/i) + { + print "allowed run time options:\n [-forcelistid=1234] = overrides the listID given in the file with the 1234\n [-h] = this help screen\n\n"; + + exit; + } + else + { + if ($args =~ /-duplicate-check/i) + {$dupcheck=1;} + if ($args =~ /-duplicate-campaign-check/i) + {$dupcheckcamp=1;} + if ($args =~ /-duplicate-system-check/i) + {$dupchecksys=1;} + if ($args =~ /-duplicate-tap-list-check/i) + {$duptapchecklist=1;} + if ($args =~ /-duplicate-tap-system-check/i) + {$duptapchecksys=1;} + if ($args =~ /-postal-code-gmt/i) + {$postalgmt=1;} + if ($args =~ /--forcelistid=/i) + { + @data_in = split(/--forcelistid=/,$args); + $forcelistid = $data_in[1]; + $forcelistid =~ s/ .*//gi; + print "\n----- FORCE LISTID OVERRIDE: $forcelistid -----\n\n"; + } + else + {$forcelistid = '';} + + if ($args =~ /--forcephonecode=/i) + { + @data_in = split(/--forcephonecode=/,$args); + $forcephonecode = $data_in[1]; + $forcephonecode =~ s/ .*//gi; + print "\n----- FORCE PHONECODE OVERRIDE: $forcephonecode -----\n\n"; + } + else + {$forcephonecode = '';} + + if ($args =~ /--lead-file=/i) + { + @data_in = split(/--lead-file=/,$args); + $lead_file = $data_in[1]; + $lead_file =~ s/ .*//gi; + # print "\n----- LEAD FILE: $lead_file -----\n\n"; + } + else + {$lead_file = './vicidial_temp_file.xls';} + } + } +### end parsing run-time options ### + +use Spreadsheet::ParseExcel; +use Time::Local; +use DBI; + + +# default path to astguiclient configuration file: +$PATHconf = '/etc/astguiclient.conf'; + +open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n"; +@conf = ; +close(conf); +$i=0; +foreach(@conf) + { + $line = $conf[$i]; + $line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi; + if ( ($line =~ /^PATHhome/) && ($CLIhome < 1) ) + {$PATHhome = $line; $PATHhome =~ s/.*=//gi;} + if ( ($line =~ /^PATHlogs/) && ($CLIlogs < 1) ) + {$PATHlogs = $line; $PATHlogs =~ s/.*=//gi;} + if ( ($line =~ /^PATHagi/) && ($CLIagi < 1) ) + {$PATHagi = $line; $PATHagi =~ s/.*=//gi;} + if ( ($line =~ /^PATHweb/) && ($CLIweb < 1) ) + {$PATHweb = $line; $PATHweb =~ s/.*=//gi;} + if ( ($line =~ /^PATHsounds/) && ($CLIsounds < 1) ) + {$PATHsounds = $line; $PATHsounds =~ s/.*=//gi;} + if ( ($line =~ /^PATHmonitor/) && ($CLImonitor < 1) ) + {$PATHmonitor = $line; $PATHmonitor =~ s/.*=//gi;} + if ( ($line =~ /^VARserver_ip/) && ($CLIserver_ip < 1) ) + {$VARserver_ip = $line; $VARserver_ip =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_server/) && ($CLIDB_server < 1) ) + {$VARDB_server = $line; $VARDB_server =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_database/) && ($CLIDB_database < 1) ) + {$VARDB_database = $line; $VARDB_database =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_user/) && ($CLIDB_user < 1) ) + {$VARDB_user = $line; $VARDB_user =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_pass/) && ($CLIDB_pass < 1) ) + {$VARDB_pass = $line; $VARDB_pass =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_port/) && ($CLIDB_port < 1) ) + {$VARDB_port = $line; $VARDB_port =~ s/.*=//gi;} + $i++; + } + +# Customized Variables +$server_ip = $VARserver_ip; # Asterisk server IP + +if (!$VARDB_port) {$VARDB_port='3306';} + +$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass") + or die "Couldn't connect to database: " . DBI->errstr; + + +$vars=$ARGV[0]; +@xls_fields=split(/\,/, $vars); + +$|=0; +$secX = time(); + +($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); +$year = ($year + 1900); +$mon++; +if ($hour < 10) {$hour = "0$hour";} +if ($min < 10) {$min = "0$min";} +if ($sec < 10) {$sec = "0$sec";} +if ($mon < 10) {$mon = "0$mon";} +if ($mday < 10) {$mday = "0$mday";} +$pulldate0 = "$year-$mon-$mday $hour:$min:$sec"; +$pulldate="$year-$mon-$mday $hour:$min:$sec"; +$inSD = $pulldate0; +$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmtA = "SELECT use_non_latin FROM system_settings;"; +$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; +$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; +$sthArows=$sthA->rows; +if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $non_latin = "$aryA[0]"; + } +$sthA->finish(); +##### END SETTINGS LOOKUP ##### +########################################### + + +if ($non_latin > 0) {$affected_rows = $dbhA->do("SET NAMES 'UTF8'");} + +### Grab Server values from the database +$stmtA = "SELECT local_gmt FROM servers where server_ip = '$server_ip';"; +$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; +$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; +$sthArows=$sthA->rows; +$rec_count=0; +while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $DBSERVER_GMT = "$aryA[0]"; + if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;} + $rec_count++; + } +$sthA->finish(); + + $LOCAL_GMT_OFF = $SERVER_GMT; + $LOCAL_GMT_OFF_STD = $SERVER_GMT; + +if ($isdst) {$LOCAL_GMT_OFF++;} +if ($DB) {print "SEED TIME $secX : $year-$mon-$mday $hour:$min:$sec LOCAL GMT OFFSET NOW: $LOCAL_GMT_OFF\n";} + + + +$total=0; $good=0; $bad=0; +open(STMT_FILE, "> $PATHlogs/listloader_stmts.txt"); + +$oBook = Spreadsheet::ParseExcel::Workbook->Parse("$lead_file"); +my($iR, $iC, $oWkS, $oWkC); + +foreach $oWkS (@{$oBook->{Worksheet}}) { + for($iR = 0 ; defined $oWkS->{MaxRow} && $iR <= $oWkS->{MaxRow} ; $iR++) { + + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user = ""; + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[0]]; + if ($oWkC) {$vendor_lead_code=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[1]]; + if ($oWkC) {$source_code=$oWkC->Value; } + $source_id=$source_code; + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[2]]; + if ($oWkC) {$list_id=$oWkC->Value; } + $gmt_offset = '0'; + $called_since_last_reset='N'; + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[3]]; + if ($oWkC) {$phone_code=$oWkC->Value; } + $phone_code=~s/[^0-9]//g; + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[4]]; + if ($oWkC) {$phone_number=$oWkC->Value; } + $phone_number=~s/[^0-9]//g; + $USarea = substr($phone_number, 0, 3); + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[5]]; + if ($oWkC) {$title=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[6]]; + if ($oWkC) {$first_name=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[7]]; + if ($oWkC) {$middle_initial=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[8]]; + if ($oWkC) {$last_name=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[9]]; + if ($oWkC) {$address1=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[10]]; + if ($oWkC) {$address2=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[11]]; + if ($oWkC) {$address3=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[12]]; + if ($oWkC) {$city=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[13]]; + if ($oWkC) {$state=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[14]]; + if ($oWkC) {$province=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[15]]; + if ($oWkC) {$postal_code=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[16]]; + if ($oWkC) {$country_code=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[17]]; + if ($oWkC) {$gender=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[18]]; + if ($oWkC) {$date_of_birth=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[19]]; + if ($oWkC) {$alt_phone=$oWkC->Value; } + $alt_phone=~s/[^0-9]//g; + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[20]]; + if ($oWkC) {$email=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[21]]; + if ($oWkC) {$security_phrase=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[22]]; + if ($oWkC) {$comments=$oWkC->Value; } + $comments=~s/^\s*(.*?)\s*$/$1/; + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[23]]; + if ($oWkC) {$rank=$oWkC->Value; } + if (length($rank)<1) {$rank='0';} + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[24]]; + if ($oWkC) {$owner=$oWkC->Value; } + + + + if (length($forcelistid) > 0) + { + $list_id = $forcelistid; # set list_id to override value + } + if (length($forcephonecode) > 0) + { + $phone_code = $forcephonecode; # set phone_code to override value + } + + ##### Check for duplicate phone numbers in vicidial_list table entire database ##### + if ($dupchecksys > 0) + { + $dup_lead=0; + $stmtA = "select count(*) from vicidial_list where phone_number='$phone_number';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $dup_lead = $aryA[0]; + $dup_lead_list=$list_id; + } + $sthA->finish(); + if ($dup_lead < 1) + { + if ($phone_list =~ /\|$phone_number$US$list_id\|/) + {$dup_lead++;} + } + } + ##### Check for duplicate phone numbers in vicidial_list table for one list_id ##### + if ($dupcheck > 0) + { + $dup_lead=0; + $stmtA = "select list_id from vicidial_list where phone_number='$phone_number' and list_id='$list_id' limit 1;"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $dup_lead_list = $aryA[0]; + $dup_lead++; + } + $sthA->finish(); + if ($dup_lead < 1) + { + if ($phone_list =~ /\|$phone_number$US$list_id\|/) + {$dup_lead++;} + } + } + ##### Check for duplicate phone numbers in vicidial_list table for all lists in a campaign ##### + if ($dupcheckcamp > 0) + { + $dup_lead=0; + $dup_lists=''; + + $stmtA = "select count(*) from vicidial_lists where list_id='$list_id';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + @aryA = $sthA->fetchrow_array; + $ci_recs = $aryA[0]; + $sthA->finish(); + if ($ci_recs > 0) + { + $stmtA = "select campaign_id from vicidial_lists where list_id='$list_id';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + @aryA = $sthA->fetchrow_array; + $dup_camp = $aryA[0]; + $sthA->finish(); + + $stmtA = "select list_id from vicidial_lists where campaign_id='$dup_camp';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $dup_lists .= "'$aryA[0]',"; + $rec_count++; + } + $sthA->finish(); + + chop($dup_lists); + $stmtA = "select list_id from vicidial_list where phone_number='$phone_number' and list_id IN($dup_lists) limit 1;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $dup_lead_list = "'$aryA[0]',"; + $rec_count++; + $dup_lead=1; + } + $sthA->finish(); + } + if ($dup_lead < 1) + { + if ($phone_list =~ /\|$phone_number$US$list_id\|/) + {$dup_lead++;} + } + } + ##### Check for duplicate title/alt-phone in vicidial_list table entire database ##### + if ($duptapchecksys > 0) + { + $dup_lead=0; + $stmtA = "select count(*) from vicidial_list where title='$title' and alt_phone='$alt_phone';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $dup_lead = $aryA[0]; + $dup_lead_list=$list_id; + } + $sthA->finish(); + if ($dup_lead < 1) + { + if ($phone_list =~ /\|$alt_phone$title$US$list_id\|/) + {$dup_lead++;} + } + } + ##### Check for duplicate title/alt-phone in vicidial_list table for one list_id ##### + if ($duptapchecklist > 0) + { + $dup_lead=0; + $stmtA = "select list_id from vicidial_list where title='$title' and alt_phone='$alt_phone' and list_id='$list_id' limit 1;"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $dup_lead_list = $aryA[0]; + $dup_lead++; + } + $sthA->finish(); + if ($dup_lead < 1) + { + if ($phone_list =~ /\|$alt_phone$title$US$list_id\|/) + {$dup_lead++;} + } + } + + if ( (length($phone_number)>6) && ($dup_lead < 1) ) + { + if ( ($duptapchecklist > 0) || ($duptapchecksys > 0) ) + {$phone_list .= "$alt_phone$title$US$list_id|";} + else + {$phone_list .= "$phone_number$US$list_id|";} + $postalgmt_found=0; + if (length($phone_code)<1) {$phone_code = '1';} + + if ( ($postalgmt > 0) && (length($postal_code)>4) ) + { + if ($phone_code =~ /^1$/) + { + $stmtA = "select postal_code,state,GMT_offset,DST,DST_range,country,country_code from vicidial_postal_codes where country_code='$phone_code' and postal_code LIKE \"$postal_code%\";"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $gmt_offset = $aryA[2]; $gmt_offset =~ s/\+| //gi; + $dst = $aryA[3]; + $dst_range = $aryA[4]; + $PC_processed++; + $rec_count++; + $postalgmt_found++; + if ($DBX) {print " Postal GMT record found for $postal_code: |$gmt_offset|$dst|$dst_range|\n";} + } + $sthA->finish(); + } + } + if ($postalgmt_found < 1) + { + $PC_processed=0; + ### UNITED STATES ### + if ($phone_code =~ /^1$/) + { + $stmtA = "select country_code,country,areacode,state,GMT_offset,DST,DST_range,geographic_description from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $gmt_offset = $aryA[4]; $gmt_offset =~ s/\+| //gi; + $dst = $aryA[5]; + $dst_range = $aryA[6]; + $PC_processed++; + $rec_count++; + } + $sthA->finish(); + } + ### MEXICO ### + if ($phone_code =~ /^52$/) + { + $stmtA = "select country_code,country,areacode,state,GMT_offset,DST,DST_range,geographic_description from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $gmt_offset = $aryA[4]; $gmt_offset =~ s/\+| //gi; + $dst = $aryA[5]; + $dst_range = $aryA[6]; + $PC_processed++; + $rec_count++; + } + $sthA->finish(); + } + ### AUSTRALIA ### + if ($phone_code =~ /^61$/) + { + $stmtA = "select country_code,country,areacode,state,GMT_offset,DST,DST_range,geographic_description from vicidial_phone_codes where country_code='$phone_code' and state='$state';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $gmt_offset = $aryA[4]; $gmt_offset =~ s/\+| //gi; + $dst = $aryA[5]; + $dst_range = $aryA[6]; + $PC_processed++; + $rec_count++; + } + $sthA->finish(); + } + ### ALL OTHER COUNTRY CODES ### + if (!$PC_processed) + { + $stmtA = "select country_code,country,areacode,state,GMT_offset,DST,DST_range,geographic_description from vicidial_phone_codes where country_code='$phone_code';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $gmt_offset = $aryA[4]; $gmt_offset =~ s/\+| //gi; + $dst = $aryA[5]; + $dst_range = $aryA[6]; + $PC_processed++; + $rec_count++; + } + $sthA->finish(); + } + } + + ### Find out if DST to raise the gmt offset ### + $AC_GMT_diff = ($gmt_offset - $LOCAL_GMT_OFF_STD); + $AC_localtime = ($secX + (3600 * $AC_GMT_diff)); + ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($AC_localtime); + $year = ($year + 1900); + $mon++; + if ($mon < 10) {$mon = "0$mon";} + if ($mday < 10) {$mday = "0$mday";} + if ($hour < 10) {$hour = "0$hour";} + if ($min < 10) {$min = "0$min";} + if ($sec < 10) {$sec = "0$sec";} + $dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + + $AC_processed=0; + + if ( (!$AC_processed) && ($dst_range =~ /SSM-FSN/) ) + { + if ($DBX) {print " Second Sunday March to First Sunday November\n";} + &USACAN_dstcalc; + if ($DBX) {print " DST: $USACAN_DST\n";} + if ($USACAN_DST) {$area_GMT++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($dst_range =~ /FSA-LSO/) ) + { + if ($DBX) {print " First Sunday April to Last Sunday October\n";} + &NA_dstcalc; + if ($DBX) {print " DST: $NA_DST\n";} + if ($NA_DST) {$area_GMT++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($dst_range =~ /LSM-LSO/) ) + { + if ($DBX) {print " Last Sunday March to Last Sunday October\n";} + &GBR_dstcalc; + if ($DBX) {print " DST: $GBR_DST\n";} + if ($GBR_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($dst_range =~ /LSO-LSM/) ) + { + if ($DBX) {print " Last Sunday October to Last Sunday March\n";} + &AUS_dstcalc; + if ($DBX) {print " DST: $AUS_DST\n";} + if ($AUS_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($dst_range =~ /FSO-LSM/) ) + { + if ($DBX) {print " First Sunday October to Last Sunday March\n";} + &AUST_dstcalc; + if ($DBX) {print " DST: $AUST_DST\n";} + if ($AUST_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($area_GMT_method =~ /FSO-FSA/) ) + { + if ($DBX) {print " First Sunday October to First Sunday April\n";} + &AUSE_dstcalc; + if ($DBX) {print " DST: $AUSE_DST\n";} + if ($AUSE_DST) {$area_GMT++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($dst_range =~ /FSO-TSM/) ) + { + if ($DBX) {print " First Sunday October to Third Sunday March\n";} + &NZL_dstcalc; + if ($DBX) {print " DST: $NZL_DST\n";} + if ($NZL_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($area_GMT_method =~ /LSS-FSA/) ) + { + if ($DBX) {print " Last Sunday September to First Sunday April\n";} + &NZLN_dstcalc; + if ($DBX) {print " DST: $NZLN_DST\n";} + if ($NZLN_DST) {$area_GMT++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($dst_range =~ /TSO-LSF/) ) + { + if ($DBX) {print " Third Sunday October to Last Sunday February\n";} + &BZL_dstcalc; + if ($DBX) {print " DST: $BZL_DST\n";} + if ($BZL_DST) {$area_GMT++;} + $AC_processed++; + } + if (!$AC_processed) + { + if ($DBX) {print " No DST Method Found\n";} + if ($DBX) {print " DST: 0\n";} + $AC_processed++; + } + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list (lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner) values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0,'2008-01-01 00:00:00','$rank','$owner');"; + $affected_rows = $dbhA->do($stmtZ); + print STMT_FILE $stmtZ."\r\n"; + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0,'2008-01-01 00:00:00','$rank','$owner'),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 10000) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]| $dup_lead_list\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + sleep(1); +# flush(); + } + } +} + +if ($multi_insert_counter > 0) { + $stmtZ = "INSERT INTO vicidial_list (lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner) values ".substr($multistmt, 0, -1).";"; + $affected_rows = $dbhA->do($stmtZ); + print STMT_FILE $stmtZ."\r\n"; +} + +print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total"; + +exit; + + + + + + +sub USACAN_dstcalc { +#********************************************************************** +# SSM-FSN +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on Second Sunday March to First Sunday November at 2 am. +# INPUTS: +# mm INTEGER Month. +# dd INTEGER Day of the month. +# ns INTEGER Seconds into the day. +# dow INTEGER Day of week (0=Sunday, to 6=Saturday) +# OPTIONAL INPUT: +# timezone INTEGER hour difference UTC - local standard time +# (DEFAULT is blank) +# make calculations based on UTC time, +# which means shift at 10:00 UTC in April +# and 9:00 UTC in October +# OUTPUT: +# INTEGER 1 = DST, 0 = not DST +# +# S M T W T F S +# 1 2 3 4 5 6 7 +# 8 9 10 11 12 13 14 +#15 16 17 18 19 20 21 +#22 23 24 25 26 27 28 +#29 30 31 +# +# S M T W T F S +# 1 2 3 4 5 6 +# 7 8 9 10 11 12 13 +#14 15 16 17 18 19 20 +#21 22 23 24 25 26 27 +#28 29 30 31 +# +#********************************************************************** + + $USACAN_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 11) { + $USACAN_DST=0; return 0; + } elsif ($mm >= 4 && $mm <= 10) { + $USACAN_DST=1; return 1; + } elsif ($mm == 3) { + if ($dd > 13) { + $USACAN_DST=1; return 1; + } elsif ($dd >= ($dow+8)) { + if ($timezone) { + if ($dow == 0 && $ns < (7200+$timezone*3600)) { + $USACAN_DST=0; return 0; + } else { + $USACAN_DST=1; return 1; + } + } else { + if ($dow == 0 && $ns < 7200) { + $USACAN_DST=0; return 0; + } else { + $USACAN_DST=1; return 1; + } + } + } else { + $USACAN_DST=0; return 0; + } + } elsif ($mm == 11) { + if ($dd > 7) { + $USACAN_DST=0; return 0; + } elsif ($dd < ($dow+1)) { + $USACAN_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (7200+($timezone-1)*3600)) { + $USACAN_DST=1; return 1; + } else { + $USACAN_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 7200) { + $USACAN_DST=1; return 1; + } else { + $USACAN_DST=0; return 0; + } + } + } else { + $USACAN_DST=0; return 0; + } + } # end of month checks +} # end of subroutine dstcalc + + + + +sub NA_dstcalc { +#********************************************************************** +# FSA-LSO +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on first Sunday in April and last Sunday in October at 2 am. +#********************************************************************** + + $NA_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 4 || $mm > 10) { + $NA_DST=0; return 0; + } elsif ($mm >= 5 && $mm <= 9) { + $NA_DST=1; return 1; + } elsif ($mm == 4) { + if ($dd > 7) { + $NA_DST=1; return 1; + } elsif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 && $ns < (7200+$timezone*3600)) { + $NA_DST=0; return 0; + } else { + $NA_DST=1; return 1; + } + } else { + if ($dow == 0 && $ns < 7200) { + $NA_DST=0; return 0; + } else { + $NA_DST=1; return 1; + } + } + } else { + $NA_DST=0; return 0; + } + } elsif ($mm == 10) { + if ($dd < 25) { + $NA_DST=1; return 1; + } elsif ($dd < ($dow+25)) { + $NA_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (7200+($timezone-1)*3600)) { + $NA_DST=1; return 1; + } else { + $NA_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 7200) { + $NA_DST=1; return 1; + } else { + $NA_DST=0; return 0; + } + } + } else { + $NA_DST=0; return 0; + } + } # end of month checks +} # end of subroutine dstcalc + + + + +sub GBR_dstcalc { +#********************************************************************** +# LSM-LSO +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on last Sunday in March and last Sunday in October at 1 am. +#********************************************************************** + + $GBR_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $GBR_DST=0; return 0; + } elsif ($mm >= 4 && $mm <= 9) { + $GBR_DST=1; return 1; + } elsif ($mm == 3) { + if ($dd < 25) { + $GBR_DST=0; return 0; + } elsif ($dd < ($dow+25)) { + $GBR_DST=0; return 0; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=0; return 0; + } else { + $GBR_DST=1; return 1; + } + } else { # local time calculations + if ($ns < 3600) { + $GBR_DST=0; return 0; + } else { + $GBR_DST=1; return 1; + } + } + } else { + $GBR_DST=1; return 1; + } + } elsif ($mm == 10) { + if ($dd < 25) { + $GBR_DST=1; return 1; + } elsif ($dd < ($dow+25)) { + $GBR_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=1; return 1; + } else { + $GBR_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 3600) { + $GBR_DST=1; return 1; + } else { + $GBR_DST=0; return 0; + } + } + } else { + $GBR_DST=0; return 0; + } + } # end of month checks +} # end of subroutine dstcalc + + + + +sub AUS_dstcalc { +#********************************************************************** +# LSO-LSM +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on last Sunday in October and last Sunday in March at 1 am. +#********************************************************************** + + $AUS_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUS_DST=1; return 1; + } elsif ($mm >= 4 && $mm <= 9) { + $AUS_DST=0; return 0; + } elsif ($mm == 3) { + if ($dd < 25) { + $AUS_DST=1; return 1; + } elsif ($dd < ($dow+25)) { + $AUS_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=1; return 1; + } else { + $AUS_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 3600) { + $AUS_DST=1; return 1; + } else { + $AUS_DST=0; return 0; + } + } + } else { + $AUS_DST=0; return 0; + } + } elsif ($mm == 10) { + if ($dd < 25) { + $AUS_DST=0; return 0; + } elsif ($dd < ($dow+25)) { + $AUS_DST=0; return 0; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=0; return 0; + } else { + $AUS_DST=1; return 1; + } + } else { # local time calculations + if ($ns < 3600) { + $AUS_DST=0; return 0; + } else { + $AUS_DST=1; return 1; + } + } + } else { + $AUS_DST=1; return 1; + } + } # end of month checks +} # end of subroutine dstcalc + + + + + +sub AUST_dstcalc { +#********************************************************************** +# FSO-LSM +# TASMANIA ONLY +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on first Sunday in October and last Sunday in March at 1 am. +#********************************************************************** + + $AUST_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUST_DST=1; return 1; + } elsif ($mm >= 4 && $mm <= 9) { + $AUST_DST=0; return 0; + } elsif ($mm == 3) { + if ($dd < 25) { + $AUST_DST=1; return 1; + } elsif ($dd < ($dow+25)) { + $AUST_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUST_DST=1; return 1; + } else { + $AUST_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 3600) { + $AUST_DST=1; return 1; + } else { + $AUST_DST=0; return 0; + } + } + } else { + $AUST_DST=0; return 0; + } + } elsif ($mm == 10) { + if ($dd >= 8) { + $AUST_DST=1; return 1; + } elsif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 && $ns < (7200+$timezone*3600)) { + $AUST_DST=0; return 0; + } else { + $AUST_DST=1; return 1; + } + } else { + if ($dow == 0 && $ns < 3600) { + $AUST_DST=0; return 0; + } else { + $AUST_DST=1; return 1; + } + } + } else { + $AUST_DST=0; return 0; + } + } # end of month checks +} # end of subroutine dstcalc + + + + + +sub AUSE_dstcalc { +#********************************************************************** +# FSO-FSA +# 2008+ AUSTRALIA ONLY (country code 61) +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on first Sunday in October and first Sunday in April at 1 am. +#********************************************************************** + + $AUSE_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 4 || $mm > 10) { + $AUSE_DST=1; return 1; + } elsif ($mm >= 5 && $mm <= 9) { + $AUSE_DST=0; return 0; + } elsif ($mm == 4) { + if ($dd > 7) { + $AUSE_DST=0; return 1; + } elsif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 && $ns < (3600+$timezone*3600)) { + $AUSE_DST=1; return 0; + } else { + $AUSE_DST=0; return 1; + } + } else { + if ($dow == 0 && $ns < 7200) { + $AUSE_DST=1; return 0; + } else { + $AUSE_DST=0; return 1; + } + } + } else { + $AUSE_DST=1; return 0; + } + } elsif ($mm == 10) { + if ($dd >= 8) { + $AUSE_DST=1; return 1; + } elsif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 && $ns < (7200+$timezone*3600)) { + $AUSE_DST=0; return 0; + } else { + $AUSE_DST=1; return 1; + } + } else { + if ($dow == 0 && $ns < 3600) { + $AUSE_DST=0; return 0; + } else { + $AUSE_DST=1; return 1; + } + } + } else { + $AUSE_DST=0; return 0; + } + } # end of month checks +} # end of subroutine dstcalc + + + + + +sub NZL_dstcalc { +#********************************************************************** +# FSO-TSM +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on first Sunday in October and third Sunday in March at 1 am. +#********************************************************************** + + $NZL_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $NZL_DST=1; return 1; + } elsif ($mm >= 4 && $mm <= 9) { + $NZL_DST=0; return 0; + } elsif ($mm == 3) { + if ($dd < 14) { + $NZL_DST=1; return 1; + } elsif ($dd < ($dow+14)) { + $NZL_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $NZL_DST=1; return 1; + } else { + $NZL_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 3600) { + $NZL_DST=1; return 1; + } else { + $NZL_DST=0; return 0; + } + } + } else { + $NZL_DST=0; return 0; + } + } elsif ($mm == 10) { + if ($dd >= 8) { + $NZL_DST=1; return 1; + } elsif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 && $ns < (7200+$timezone*3600)) { + $NZL_DST=0; return 0; + } else { + $NZL_DST=1; return 1; + } + } else { + if ($dow == 0 && $ns < 3600) { + $NZL_DST=0; return 0; + } else { + $NZL_DST=1; return 1; + } + } + } else { + $NZL_DST=0; return 0; + } + } # end of month checks +} # end of subroutine dstcalc + + + + +sub NZLN_dstcalc { +#********************************************************************** +# LSS-FSA +# 2007+ NEW ZEALAND (country code 64) +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on last Sunday in September and first Sunday in April at 1 am. +#********************************************************************** + + $NZLN_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 4 || $mm > 9) { + $NZLN_DST=1; return 1; + } elsif ($mm >= 5 && $mm <= 9) { + $NZLN_DST=0; return 0; + } elsif ($mm == 4) { + if ($dd > 7) { + $NZLN_DST=0; return 1; + } elsif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 && $ns < (3600+$timezone*3600)) { + $NZLN_DST=1; return 0; + } else { + $NZLN_DST=0; return 1; + } + } else { + if ($dow == 0 && $ns < 7200) { + $NZLN_DST=1; return 0; + } else { + $NZLN_DST=0; return 1; + } + } + } else { + $NZLN_DST=1; return 0; + } + } elsif ($mm == 9) { + if ($dd < 25) { + $NZLN_DST=0; return 0; + } elsif ($dd < ($dow+25)) { + $NZLN_DST=0; return 0; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $NZLN_DST=0; return 0; + } else { + $NZLN_DST=1; return 1; + } + } else { # local time calculations + if ($ns < 3600) { + $NZLN_DST=0; return 0; + } else { + $NZLN_DST=1; return 1; + } + } + } else { + $NZLN_DST=1; return 1; + } + } # end of month checks +} # end of subroutine dstcalc + + + + + +sub BZL_dstcalc { +#********************************************************************** +# TSO-LSF +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. Brazil +# Based on Third Sunday October to Last Sunday February at 1 am. +#********************************************************************** + + $BZL_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 2 || $mm > 10) { + $BZL_DST=1; return 1; + } elsif ($mm >= 3 && $mm <= 9) { + $BZL_DST=0; return 0; + } elsif ($mm == 2) { + if ($dd < 22) { + $BZL_DST=1; return 1; + } elsif ($dd < ($dow+22)) { + $BZL_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $BZL_DST=1; return 1; + } else { + $BZL_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 3600) { + $BZL_DST=1; return 1; + } else { + $BZL_DST=0; return 0; + } + } + } else { + $BZL_DST=0; return 0; + } + } elsif ($mm == 10) { + if ($dd < 22) { + $BZL_DST=0; return 0; + } elsif ($dd < ($dow+22)) { + $BZL_DST=0; return 0; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $BZL_DST=0; return 0; + } else { + $BZL_DST=1; return 1; + } + } else { # local time calculations + if ($ns < 3600) { + $BZL_DST=0; return 0; + } else { + $BZL_DST=1; return 1; + } + } + } else { + $BZL_DST=1; return 1; + } + } # end of month checks +} # end of subroutine dstcalc diff --git a/LANG_www/vicidial_br/new_listloader_superL.php b/LANG_www/vicidial_br/new_listloader_superL.php new file mode 100644 index 00000000..2fb94bef --- /dev/null +++ b/LANG_www/vicidial_br/new_listloader_superL.php @@ -0,0 +1,2396 @@ + LICENSE: AGPLv2 +# +# AST GUI lead loader from formatted file +# +# CHANGES +# 50602-1640 - First version created by Joe Johnson +# 51128-1108 - Removed PHP global vars requirement +# 60113-1603 - Fixed a few bugs in Excel import +# 60421-1624 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60616-1240 - added listID override +# 60616-1604 - added gmt lookup for each lead +# 60619-1651 - Added variable filtering to eliminate SQL injection attack threat +# 60822-1121 - fixed for nonwritable directories +# 60906-1100 - added filter of non-digits in alt_phone field +# 61110-1222 - added new USA-Canada DST scheme and Brazil DST scheme +# 61128-1149 - added postal code GMT lookup and duplicate check options +# 70417-1059 - Fixed default phone_code bug +# 70510-1518 - Added campaign and system duplicate check and phonecode override +# 80428-0417 - UTF8 changes +# 80514-1030 - removed filesize limit and raised number of errors to be displayed +# 80713-0023 - added last_local_call_time field default of 2008-01-01 +# 81011-2009 - a few bug fixes +# 90309-1831 - Added admin_log logging +# 90310-2128 - Added admin header +# 90508-0644 - Changed to PHP long tags +# 90522-0506 - Security fix +# 90721-1339 - Added rank and owner as vicidial_list fields +# 91112-0616 - Added title/alt-phone duplicate checking +# 100118-0543 - Added new Australian and New Zealand DST schemes (FSO-FSA and LSS-FSA) +# +# make sure vicidial_list exists and that your file follows the formatting correctly. This page does not dedupe or do any other lead filtering actions yet at this time. + +$version = '2.2.0-34'; +$build = '100118-0543'; + + +require("dbconnect.php"); + +### links used for testing +#$link=mysql_connect("10.10.10.15", "cron", "1234"); +#mysql_select_db("asterisk"); +#$WeBServeRRooT = '/home/www/htdocs'; + +$US='_'; + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +$leadfile=$_FILES["leadfile"]; + $LF_orig = $_FILES['leadfile']['name']; + $LF_path = $_FILES['leadfile']['tmp_name']; +if (isset($_GET["submit_file"])) {$submit_file=$_GET["submit_file"];} + elseif (isset($_POST["submit_file"])) {$submit_file=$_POST["submit_file"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} +if (isset($_GET["leadfile_name"])) {$leadfile_name=$_GET["leadfile_name"];} + elseif (isset($_POST["leadfile_name"])) {$leadfile_name=$_POST["leadfile_name"];} +if (isset($_FILES["leadfile"])) {$leadfile_name=$_FILES["leadfile"]['name'];} +if (isset($_GET["file_layout"])) {$file_layout=$_GET["file_layout"];} + elseif (isset($_POST["file_layout"])) {$file_layout=$_POST["file_layout"];} +if (isset($_GET["OK_to_process"])) {$OK_to_process=$_GET["OK_to_process"];} + elseif (isset($_POST["OK_to_process"])) {$OK_to_process=$_POST["OK_to_process"];} +if (isset($_GET["vendor_lead_code_field"])) {$vendor_lead_code_field=$_GET["vendor_lead_code_field"];} + elseif (isset($_POST["vendor_lead_code_field"])) {$vendor_lead_code_field=$_POST["vendor_lead_code_field"];} +if (isset($_GET["source_id_field"])) {$source_id_field=$_GET["source_id_field"];} + elseif (isset($_POST["source_id_field"])) {$source_id_field=$_POST["source_id_field"];} +if (isset($_GET["list_id_field"])) {$list_id_field=$_GET["list_id_field"];} + elseif (isset($_POST["list_id_field"])) {$list_id_field=$_POST["list_id_field"];} +if (isset($_GET["phone_code_field"])) {$phone_code_field=$_GET["phone_code_field"];} + elseif (isset($_POST["phone_code_field"])) {$phone_code_field=$_POST["phone_code_field"];} +if (isset($_GET["phone_number_field"])) {$phone_number_field=$_GET["phone_number_field"];} + elseif (isset($_POST["phone_number_field"])) {$phone_number_field=$_POST["phone_number_field"];} +if (isset($_GET["title_field"])) {$title_field=$_GET["title_field"];} + elseif (isset($_POST["title_field"])) {$title_field=$_POST["title_field"];} +if (isset($_GET["first_name_field"])) {$first_name_field=$_GET["first_name_field"];} + elseif (isset($_POST["first_name_field"])) {$first_name_field=$_POST["first_name_field"];} +if (isset($_GET["middle_initial_field"])) {$middle_initial_field=$_GET["middle_initial_field"];} + elseif (isset($_POST["middle_initial_field"])) {$middle_initial_field=$_POST["middle_initial_field"];} +if (isset($_GET["last_name_field"])) {$last_name_field=$_GET["last_name_field"];} + elseif (isset($_POST["last_name_field"])) {$last_name_field=$_POST["last_name_field"];} +if (isset($_GET["address1_field"])) {$address1_field=$_GET["address1_field"];} + elseif (isset($_POST["address1_field"])) {$address1_field=$_POST["address1_field"];} +if (isset($_GET["address2_field"])) {$address2_field=$_GET["address2_field"];} + elseif (isset($_POST["address2_field"])) {$address2_field=$_POST["address2_field"];} +if (isset($_GET["address3_field"])) {$address3_field=$_GET["address3_field"];} + elseif (isset($_POST["address3_field"])) {$address3_field=$_POST["address3_field"];} +if (isset($_GET["city_field"])) {$city_field=$_GET["city_field"];} + elseif (isset($_POST["city_field"])) {$city_field=$_POST["city_field"];} +if (isset($_GET["state_field"])) {$state_field=$_GET["state_field"];} + elseif (isset($_POST["state_field"])) {$state_field=$_POST["state_field"];} +if (isset($_GET["province_field"])) {$province_field=$_GET["province_field"];} + elseif (isset($_POST["province_field"])) {$province_field=$_POST["province_field"];} +if (isset($_GET["postal_code_field"])) {$postal_code_field=$_GET["postal_code_field"];} + elseif (isset($_POST["postal_code_field"])) {$postal_code_field=$_POST["postal_code_field"];} +if (isset($_GET["country_code_field"])) {$country_code_field=$_GET["country_code_field"];} + elseif (isset($_POST["country_code_field"])) {$country_code_field=$_POST["country_code_field"];} +if (isset($_GET["gender_field"])) {$gender_field=$_GET["gender_field"];} + elseif (isset($_POST["gender_field"])) {$gender_field=$_POST["gender_field"];} +if (isset($_GET["date_of_birth_field"])) {$date_of_birth_field=$_GET["date_of_birth_field"];} + elseif (isset($_POST["date_of_birth_field"])) {$date_of_birth_field=$_POST["date_of_birth_field"];} +if (isset($_GET["alt_phone_field"])) {$alt_phone_field=$_GET["alt_phone_field"];} + elseif (isset($_POST["alt_phone_field"])) {$alt_phone_field=$_POST["alt_phone_field"];} +if (isset($_GET["email_field"])) {$email_field=$_GET["email_field"];} + elseif (isset($_POST["email_field"])) {$email_field=$_POST["email_field"];} +if (isset($_GET["security_phrase_field"])) {$security_phrase_field=$_GET["security_phrase_field"];} + elseif (isset($_POST["security_phrase_field"])) {$security_phrase_field=$_POST["security_phrase_field"];} +if (isset($_GET["comments_field"])) {$comments_field=$_GET["comments_field"];} + elseif (isset($_POST["comments_field"])) {$comments_field=$_POST["comments_field"];} +if (isset($_GET["rank_field"])) {$rank_field=$_GET["rank_field"];} + elseif (isset($_POST["rank_field"])) {$rank_field=$_POST["rank_field"];} +if (isset($_GET["owner_field"])) {$owner_field=$_GET["owner_field"];} + elseif (isset($_POST["owner_field"])) {$owner_field=$_POST["owner_field"];} +if (isset($_GET["list_id_override"])) {$list_id_override=$_GET["list_id_override"];} + elseif (isset($_POST["list_id_override"])) {$list_id_override=$_POST["list_id_override"];} + $list_id_override = (preg_replace("/\D/","",$list_id_override)); +if (isset($_GET["lead_file"])) {$lead_file=$_GET["lead_file"];} + elseif (isset($_POST["lead_file"])) {$lead_file=$_POST["lead_file"];} +if (isset($_GET["dupcheck"])) {$dupcheck=$_GET["dupcheck"];} + elseif (isset($_POST["dupcheck"])) {$dupcheck=$_POST["dupcheck"];} +if (isset($_GET["postalgmt"])) {$postalgmt=$_GET["postalgmt"];} + elseif (isset($_POST["postalgmt"])) {$postalgmt=$_POST["postalgmt"];} +if (isset($_GET["phone_code_override"])) {$phone_code_override=$_GET["phone_code_override"];} + elseif (isset($_POST["phone_code_override"])) {$phone_code_override=$_POST["phone_code_override"];} + $phone_code_override = (preg_replace("/\D/","",$phone_code_override)); + +# $country_field=$_GET["country_field"]; if (!$country_field) {$country_field=$_POST["country_field"];} + + +############################################# +##### 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 ##### +########################################### + +if ($non_latin < 1) + { + $PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); + $PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + $list_id_override = ereg_replace("[^0-9]","",$list_id_override); + } +else + { + $PHP_AUTH_PW = ereg_replace("'|\"|\\\\|;","",$PHP_AUTH_PW); + $PHP_AUTH_USER = ereg_replace("'|\"|\\\\|;","",$PHP_AUTH_USER); + } + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_datetime = $STARTtime; + +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; +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 ($WeBRooTWritablE > 0) {$fp = fopen ("./project_auth_entries.txt", "a");} +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICIDIAL-LEAD-LOADER\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Nome ou Senha inválidos: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + header ("Content-type: text/html; charset=utf-8"); + header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 + header ("Pragma: no-cache"); // HTTP/1.0 + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT load_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGload_leads =$row[0]; + + if ($LOGload_leads < 1) + { + echo "You do not have permissions to load leads\n"; + exit; + } + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "LIST_LOAD|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + } + else + { + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "LIST_LOAD|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + } + + +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +$admDIR = "$HTTPprotocol$server_name$script_name"; +$admDIR = eregi_replace('new_listloader_superL.php','',$admDIR); +$admSCR = 'admin.php'; +$NWB = "   \"AJUDA\""; + +$secX = date("U"); +$hour = date("H"); +$min = date("i"); +$sec = date("s"); +$mon = date("m"); +$mday = date("d"); +$year = date("Y"); +$isdst = date("I"); +$Shour = date("H"); +$Smin = date("i"); +$Ssec = date("s"); +$Smon = date("m"); +$Smday = date("d"); +$Syear = date("Y"); +$pulldate0 = "$year-$mon-$mday $hour:$min:$sec"; +$inSD = $pulldate0; +$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + + ### Grab Server GMT value from the database + $stmt="SELECT local_gmt FROM servers where server_ip = '$server_ip';"; + $rslt=mysql_query($stmt, $link); + $gmt_recs = mysql_num_rows($rslt); + if ($gmt_recs > 0) + { + $row=mysql_fetch_row($rslt); + $DBSERVER_GMT = "$row[0]"; + if (strlen($DBSERVER_GMT)>0) {$SERVER_GMT = $DBSERVER_GMT;} + if ($isdst) {$SERVER_GMT++;} + } + else + { + $SERVER_GMT = date("O"); + $SERVER_GMT = eregi_replace("\+","",$SERVER_GMT); + $SERVER_GMT = ($SERVER_GMT + 0); + $SERVER_GMT = ($SERVER_GMT / 100); + } + + $LOCAL_GMT_OFF = $SERVER_GMT; + $LOCAL_GMT_OFF_STD = $SERVER_GMT; + +#if ($DB) {print "SEED TIME $secX : $year-$mon-$mday $hour:$min:$sec LOCAL GMT OFFSET NOW: $LOCAL_GMT_OFF\n";} + + +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +function macfontfix($fontsize) { + + $browser = getenv("HTTP_USER_AGENT"); + $pctype = explode("(", $browser); + if (ereg("Mac",$pctype[1])) { + /* Browser is a Mac. If not Netscape 6, raise fonts */ + + $blownbrowser = explode('/', $browser); + $ver = explode(' ', $blownbrowser[1]); + $ver = $ver[0]; + if ($ver >= 5.0) return $fontsize; else return ($fontsize+2); + + } else return $fontsize; /* Browser is not a Mac - don't touch fonts */ +} + +echo "\n"; + +?> + + + +ADMINISTRATION: Lead Loader + + + +
+VICIDIAL logo +ADMINISTRATION
+ + + + 1) { + ?> + >>>>>>> + 0) or ($user_territories_active > 0) ) + { ?> + + > + + + + + 1) + { + if ($sh=='basic') {$sh='list';} + if ($sh=='detail') {$sh='list';} + if ($sh=='dialstat') {$sh='list';} + + if ($sh=='list') {$list_sh="bgcolor=\"$subcamp_color\""; $list_fc="$subcamp_font";} + else {$list_sh=''; $list_fc='BLACK';} + if ($sh=='status') {$status_sh="bgcolor=\"$subcamp_color\""; $status_fc="$subcamp_font";} + else {$status_sh=''; $status_fc='BLACK';} + if ($sh=='hotkey') {$hotkey_sh="bgcolor=\"$subcamp_color\""; $hotkey_fc="$subcamp_font";} + else {$hotkey_sh=''; $hotkey_fc='BLACK';} + if ($sh=='recycle') {$recycle_sh="bgcolor=\"$subcamp_color\""; $recycle_fc="$subcamp_font";} + else {$recycle_sh=''; $recycle_fc='BLACK';} + if ($sh=='autoalt') {$autoalt_sh="bgcolor=\"$subcamp_color\""; $autoalt_fc="$subcamp_font";} + else {$autoalt_sh=''; $autoalt_fc='BLACK';} + if ($sh=='pause') {$pause_sh="bgcolor=\"$subcamp_color\""; $pause_fc="$subcamp_font";} + else {$pause_sh=''; $pause_fc='BLACK';} + if ($sh=='listmix') {$listmix_sh="bgcolor=\"$subcamp_color\""; $listmix_fc="$subcamp_font";} + else {$listmix_sh=''; $listmix_fc='BLACK';} + + ?> + > + + > + + > + + 0) + { + ?> + > + + > + + > + + + > + + + + 0) + { + ?> + + 1) { + if ($LOGdelete_from_dnc > 0) {$DNClink = 'Incluir-Remover Número do Bloqueio';} + else {$DNClink = 'Add Number To DNC';} + ?> + >>>>> + + + + 1) + { + ?> + >> + + + 0) + { + ?> + + 1) + { + ?> + >> + + + + 1) + { + ?> + >>>>>>>>> + + + + 1) + { + ?> + >>>> + + + + 1) + { + ?> + >> + + + + 1) + { + if ($sh=='times') {$times_sh="bgcolor=\"$times_color\""; $times_fc="$times_font";} + else {$times_sh=''; $times_fc='BLACK';} + if ($sh=='shifts') {$shifts_sh="bgcolor=\"$shifts_color\""; $shifts_fc="$shifts_font";} + else {$shifts_sh=''; $shifts_fc='BLACK';} + if ($sh=='templates') {$templates_sh="bgcolor=\"$templates_color\""; $templates_fc="$templates_font";} + else {$templates_sh=''; $templates_fc='BLACK';} + if ($sh=='carriers') {$carriers_sh="bgcolor=\"$carriers_color\""; $carriers_fc="$carriers_font";} + else {$carriers_sh=''; $carriers_fc='BLACK';} + if ($sh=='phones') {$phones_sh="bgcolor=\"$server_color\""; $phones_fc="$phones_font";} + else {$phones_sh=''; $phones_fc='BLACK';} + if ($sh=='server') {$server_sh="bgcolor=\"$server_color\""; $server_fc="$server_font";} + else {$server_sh=''; $server_fc='BLACK';} + if ($sh=='conference') {$conference_sh="bgcolor=\"$server_color\""; $conference_fc="$server_font";} + else {$conference_sh=''; $conference_fc='BLACK';} + if ($sh=='settings') {$settings_sh="bgcolor=\"$settings_color\""; $settings_fc="$settings_font";} + else {$settings_sh=''; $settings_fc='BLACK';} + if ($sh=='status') {$status_sh="bgcolor=\"$status_color\""; $status_fc="$status_font";} + else {$status_sh=''; $status_fc='BLACK';} + if ($sh=='audio') {$audio_sh="bgcolor=\"$audio_color\""; $audio_fc="$audio_font";} + else {$audio_sh=''; $audio_fc='BLACK';} + if ($sh=='moh') {$moh_sh="bgcolor=\"$moh_color\""; $moh_fc="$moh_font";} + else {$moh_sh=''; $moh_fc='BLACK';} + if ($sh=='vm') {$vm_sh="bgcolor=\"$vm_color\""; $vm_fc="$vm_font";} + else {$vm_sh=''; $vm_fc='BLACK';} + if ($sh=='tts') {$tts_sh="bgcolor=\"$tts_color\""; $tts_fc="$tts_font";} + else {$tts_sh=''; $tts_fc='BLACK';} + + ?> + > + + > + > + > + > + > + > + > + > + > + + 0) or ($SSsounds_central_control_active > 0) ) + { ?> + > + + > + + + 0) + { ?> + > + + + + + + +
WIDTH=160> + SIZE=>Usuários +
+   >Mostrar Usuários +
+   >Incluir Usuário +
+   >Copiar Usuário +
+   >Pesquisar Usuário +
+   >Estatísticas de Usuário +
+   >Status do Usuário +
+   >Planilha de Tempo
+   >Territorios de usuario
> + SIZE=>Campanhas +
>   SIZE=>Campanhas
>   SIZE=>Status
>   SIZE=>Atalhos
>   SIZE=>Reciclar Registro
>   SIZE=>Auto-Alt Dial
>   SIZE=>Mesclagem de Lista
>   SIZE=>Códigos de Pausa
> SIZE=>Listas
  + > Mostrar Listas +
  + > Incluir Lista +
  + > Pesquisar Registro +
  + > +
  + > Carregar Registros +
> + SIZE=> Scripts +
  + > Mostrar Scripts +
  + > Incluir Script +
> SIZE=> Filtros
  + > Mostrar Filtros +
  + > Incluir Filtro +
> + SIZE=> Grupos Entr. +
  + > Mostrar Grupos Entr. +
  + > Incluir Grupo Entr. +
  + > Copiar Grupo de Entrada
+
  + > Mostrar DDRs +
  + > Incluir DDR +
  + > CopiarDID
+
  + > Mostrar Menus +
  + > Incluir um Menu +
  + > Copiar Menu de Chamada +
> + SIZE=> Grupos de Usuário +
  + > Mostrar Grp. de Usuário +
  + > Incluir Grp. de Usuário +
  + > Relat. de Grps por Hora +
  + > Troca de Grupo em lote +
> + SIZE=> Agentes Remotos +
  + > Mostrar Ag. Remotos +
  + > Incluir Ag. Remoto +
> + SIZE=> Admin +
COLSPAN=2>   + SIZE=> Horários de Cham.
>   + SIZE=> Turnos
>   + SIZE=> Ramais
>   + SIZE=> Templates
>   + SIZE=> Operadoras
>   + SIZE=> Servidores
>   + SIZE=> Conferências
>   + SIZE=> Config. de Sistema
>   + SIZE=>Status do Sistema
>   + SIZE=> Correio de Voz
>   + SIZE=> Audio de la tienda
>   + SIZE=> Música en espera
>   + SIZE=> Text To Speech
> + SIZE=> Relatórios +
 
+
BGCOLOR=#D9E6FE> + + + + + HEIGHT=15> + + + + + + + + + + + + 1) { + ?> + > + 1) { + ?> + > + 1) { + ?> + > + 1) { + ?> + > + 1) { + ?> + > + 1) and (strlen($admin_hh) > 1) ) { + ?> + > + 1) and (strlen($admin_hh) > 1) ) { + ?> + > + 1) and (strlen($admin_hh) > 1) ) { + ?> + > + 1) and (strlen($admin_hh) > 1) ) { + ?> + > + 1) and (strlen($admin_hh) > 1) ) { + ?> + > + 1) and (strlen($admin_hh) > 1) ) { + ?> + > + 1) { + ?> + > + 1) and (!eregi('campaign',$hh) ) ) { + ?> + > + + > + 1) { + ?> +> + + + + +"; + $alts_output .= ""; + $alts_output .= ""; + $alts_output .= "\n"; + $alts_output .= "\n"; + $alts_output .= "\n"; + } + + } + else + { + echo "procura de registro FALHOU para este lead_id $lead_id       $NOW_TIME\n

\n"; +# echo "Close this window\n

\n"; + } + + ##### grab vicidial_log records ##### + $stmt="select uniqueid,lead_id,list_id,campaign_id,call_date,start_epoch,end_epoch,length_in_sec,status,phone_code,phone_number,user,comments,processed,user_group,term_reason,alt_dial from vicidial_log where lead_id='" . mysql_real_escape_string($lead_id) . "' order by uniqueid desc limit 500;"; + $rslt=mysql_query($stmt, $link); + $logs_to_print = mysql_num_rows($rslt); + + $u=0; + $call_log = ''; + $log_campaign = ''; + while ($logs_to_print > $u) + { + $row=mysql_fetch_row($rslt); + if (strlen($log_campaign)<1) {$log_campaign = $row[3];} + if (eregi("1$|3$|5$|7$|9$", $u)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $u++; + $call_log .= ""; + $call_log .= ""; + $call_log .= ""; + $call_log .= "\n"; + $call_log .= "\n"; + $call_log .= "\n"; + $call_log .= "\n"; + $call_log .= "\n"; + $call_log .= "\n"; + $call_log .= "\n"; + $call_log .= "\n"; + + $campaign_id = $row[3]; + } + + ##### grab vicidial_agent_log records ##### + $stmt="select agent_log_id,user,server_ip,event_time,lead_id,campaign_id,pause_epoch,pause_sec,wait_epoch,wait_sec,talk_epoch,talk_sec,dispo_epoch,dispo_sec,status,user_group,comments,sub_status from vicidial_agent_log where lead_id='" . mysql_real_escape_string($lead_id) . "' order by agent_log_id desc limit 500;"; + $rslt=mysql_query($stmt, $link); + $Alogs_to_print = mysql_num_rows($rslt); + + $y=0; + $agent_log = ''; + $Alog_campaign = ''; + while ($Alogs_to_print > $y) + { + $row=mysql_fetch_row($rslt); + if (strlen($Alog_campaign)<1) {$Alog_campaign = $row[5];} + if (eregi("1$|3$|5$|7$|9$", $y)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $y++; + $agent_log .= ""; + $agent_log .= ""; + $agent_log .= ""; + $agent_log .= "\n"; + $agent_log .= "\n"; + $agent_log .= "\n"; + $agent_log .= "\n"; + $agent_log .= "\n"; + $agent_log .= "\n"; + $agent_log .= "\n"; + $agent_log .= "\n"; + $agent_log .= "\n"; + + $campaign_id = $row[5]; + } + + ##### grab vicidial_closer_log records ##### + $stmt="select closecallid,lead_id,list_id,campaign_id,call_date,start_epoch,end_epoch,length_in_sec,status,phone_code,phone_number,user,comments,processed,queue_seconds,user_group,xfercallid,term_reason,uniqueid,agent_only from vicidial_closer_log where lead_id='" . mysql_real_escape_string($lead_id) . "' order by closecallid desc limit 500;"; + $rslt=mysql_query($stmt, $link); + $Clogs_to_print = mysql_num_rows($rslt); + + $y=0; + $closer_log = ''; + $Clog_campaign = ''; + while ($Clogs_to_print > $y) + { + $row=mysql_fetch_row($rslt); + if (strlen($Clog_campaign)<1) {$Clog_campaign = $row[3];} + if (eregi("1$|3$|5$|7$|9$", $y)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $y++; + $closer_log .= ""; + $closer_log .= ""; + $closer_log .= ""; + $closer_log .= "\n"; + $closer_log .= "\n"; + $closer_log .= "\n"; + $closer_log .= "\n"; + $closer_log .= "\n"; + $closer_log .= "\n"; + $closer_log .= "\n"; + $closer_log .= "\n"; + + $campaign_id = $row[3]; + } + + ##### grab vicidial_list data for lead ##### + $stmt="SELECT lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + if (strlen($row[0]) > 0) + {$lead_id = $row[0];} + $dispo = $row[3]; + $tsr = $row[4]; + $vendor_id = $row[5]; + $list_id = $row[7]; + $gmt_offset_now = $row[8]; + $phone_code = $row[10]; + $phone_number = $row[11]; + $title = $row[12]; + $first_name = $row[13]; + $middle_initial = $row[14]; + $last_name = $row[15]; + $address1 = $row[16]; + $address2 = $row[17]; + $address3 = $row[18]; + $city = $row[19]; + $state = $row[20]; + $province = $row[21]; + $postal_code = $row[22]; + $country_code = $row[23]; + $gender = $row[24]; + $date_of_birth = $row[25]; + $alt_phone = $row[26]; + $email = $row[27]; + $security = $row[28]; + $comments = $row[29]; + $called_count = $row[30]; + $last_local_call_time = $row[31]; + $rank = $row[32]; + $owner = $row[33]; + + echo "
Informações da Chamada: $first_name $last_name - $phone_number

\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
HOME | Relógio Ponto | Sair  
>   > Mostrar Campanhas     |     > Incluir Campanha     |     > Copiar Campanha     |     > Resumo de Campanhas Tempos-real
  > Mostrar Horários de Cham.  | > Incluir Horário de Cham.  | > Mostrar Hor. de Cham. por Estado  | > Incluir Hor. de Cham. por Estado
  > Mostrar Turnos  | > Incluir Turno
  > Mostrar Ramais  | > Incluir Ramal  | > Lista de Alias de Ramal  | > Incluir Alias de Ramal  | > Lista de Alias de Grupo  | > Incluir Alias de Grupo
  > Mostrar Conferências   |   > Incluir Conferência   |   > Mostrar Conferências VICIDIAL   |   > Incluir Conferência VICIDIAL
  > Mostrar Servidores   |   > Incluir Servidor
  > Mostrar Templates   |   > Incluir Template
  > Show Operadoras   |   > Add A New Carrier
  > Mostrar las entradas TTS   |   > Agregar una nueva entrada TTS
  > Mostrar las entradas del Ministerio de Salud   |   > Agregar una nueva entrada del Ministerio de Salud
  > Show Correio de Voz Entries   |   > Add A New Correio de Voz Entry
  > Config. de Sistema
  >Status do Sistema   |   >Categoria de Status   |   >Cód. de Status CQ
  >Estatísticas de Usuário   |   >Status do Usuário   |   >Planilha de Tempo   |   >Status Diário
>  
+ LICENSE: AGPLv2 +# +# CHANGES +# +# 60419-1705 - Added ability to change lead callback record from USERONLY to ANYONE or USERONLY-user +# 60421-1459 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60609-1112 - Added DNC list addition if status changed to DNC +# 60619-1539 - Added variable filtering to eliminate SQL injection attack threat +# 61130-1639 - Added recording_log lookup and list for this lead_id +# 61201-1136 - Added recording_log user(TSR) display and link +# 70305-1133 - Changed to default CHECKED modify logs upon status change +# 70424-1128 - Added campaign-specific statuses, reformatted recordings list +# 70702-1259 - Added recording location link and truncation +# 70906-2132 - Added closer_log records display +# 80428-0144 - UTF8 cleanup +# 80501-0454 - Added Hangup Reason to logs display +# 80516-0936 - Cleanup of logging changes, added vicidial_agent_log display +# 80701-0832 - Changed to allow for altering of main phone number +# 80805-2106 - Changed comments to TEXTAREA +# 81210-1529 - Added server recording display options +# 90309-1829 - Added admin_log logging +# 90508-0644 - Changed to PHP long tags +# 90708-1549 - Added phone number dialed to outbound log +# 90721-1246 - Added rank and owner as vicidial_list fields +# 90917-2355 - Added extended alt phone entries +# 100405-1333 - Changed to show logs of non-found leads +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} + elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["old_phone"])) {$old_phone=$_GET["old_phone"];} + elseif (isset($_POST["old_phone"])) {$old_phone=$_POST["old_phone"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];} + elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];} + elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];} + elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];} +if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];} + elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];} +if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];} + elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];} +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["security"])) {$security=$_GET["security"];} + elseif (isset($_POST["security"])) {$security=$_POST["security"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["rank"])) {$rank=$_GET["rank"];} + elseif (isset($_POST["rank"])) {$rank=$_POST["rank"];} +if (isset($_GET["owner"])) {$owner=$_GET["owner"];} + elseif (isset($_POST["owner"])) {$owner=$_POST["owner"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} +if (isset($_GET["CBchangeUSERtoANY"])) {$CBchangeUSERtoANY=$_GET["CBchangeUSERtoANY"];} + elseif (isset($_POST["CBchangeUSERtoANY"])) {$CBchangeUSERtoANY=$_POST["CBchangeUSERtoANY"];} +if (isset($_GET["CBchangeUSERtoUSER"])) {$CBchangeUSERtoUSER=$_GET["CBchangeUSERtoUSER"];} + elseif (isset($_POST["CBchangeUSERtoUSER"])) {$CBchangeUSERtoUSER=$_POST["CBchangeUSERtoUSER"];} +if (isset($_GET["CBchangeANYtoUSER"])) {$CBchangeANYtoUSER=$_GET["CBchangeANYtoUSER"];} + elseif (isset($_POST["CBchangeANYtoUSER"])) {$CBchangeANYtoUSER=$_POST["CBchangeANYtoUSER"];} +if (isset($_GET["callback_id"])) {$callback_id=$_GET["callback_id"];} + elseif (isset($_POST["callback_id"])) {$callback_id=$_POST["callback_id"];} +if (isset($_GET["CBuser"])) {$CBuser=$_GET["CBuser"];} + elseif (isset($_POST["CBuser"])) {$CBuser=$_POST["CBuser"];} +if (isset($_GET["modify_logs"])) {$modify_logs=$_GET["modify_logs"];} + elseif (isset($_POST["modify_logs"])) {$modify_logs=$_POST["modify_logs"];} +if (isset($_GET["modify_closer_logs"])) {$modify_closer_logs=$_GET["modify_closer_logs"];} + elseif (isset($_POST["modify_closer_logs"])) {$modify_closer_logs=$_POST["modify_closer_logs"];} +if (isset($_GET["modify_agent_logs"])) {$modify_agent_logs=$_GET["modify_agent_logs"];} + elseif (isset($_POST["modify_agent_logs"])) {$modify_agent_logs=$_POST["modify_agent_logs"];} +if (isset($_GET["add_closer_record"])) {$add_closer_record=$_GET["add_closer_record"];} + elseif (isset($_POST["add_closer_record"])) {$add_closer_record=$_POST["add_closer_record"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); + +############################################# +##### 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 ##### +########################################### + +if ($non_latin < 1) + { + $old_phone = ereg_replace("[^0-9]","",$old_phone); + $phone_number = ereg_replace("[^0-9]","",$phone_number); + $alt_phone = ereg_replace("[^0-9]","",$alt_phone); + } +if (strlen($phone_number)<6) {$phone_number=$old_phone;} + +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7 and modify_leads='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 ($WeBRooTWritablE > 0) + {$fp = fopen ("./project_auth_entries.txt", "a");} + +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + +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 "Nome ou Senha inválidos: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } +else + { + + if($auth>0) + { + $stmt="SELECT full_name,modify_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname =$row[0]; + $LOGmodify_leads =$row[1]; + + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + } + else + { + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + } + +?> + + + +ADMINISTRATION: Registro Alterado + + +
+ADMINISTRATION: Registro Alterado
\n"; + +if ($end_call > 0) + { + ### update the lead record in the vicidial_list table + $stmt="UPDATE vicidial_list set status='" . mysql_real_escape_string($status) . "',first_name='" . mysql_real_escape_string($first_name) . "',last_name='" . mysql_real_escape_string($last_name) . "',address1='" . mysql_real_escape_string($address1) . "',address2='" . mysql_real_escape_string($address2) . "',address3='" . mysql_real_escape_string($address3) . "',city='" . mysql_real_escape_string($city) . "',state='" . mysql_real_escape_string($state) . "',province='" . mysql_real_escape_string($province) . "',postal_code='" . mysql_real_escape_string($postal_code) . "',country_code='" . mysql_real_escape_string($country_code) . "',alt_phone='" . mysql_real_escape_string($alt_phone) . "',phone_number='$phone_number',email='" . mysql_real_escape_string($email) . "',security_phrase='" . mysql_real_escape_string($security) . "',comments='" . mysql_real_escape_string($comments) . "',rank='" . mysql_real_escape_string($rank) . "',owner='" . mysql_real_escape_string($owner) . "' where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "Informação Alterada

\n"; + echo "\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$PHP_AUTH_USER', ip_address='$ip', event_section='LEADS', event_type='MODIFY', record_id='$lead_id', event_code='ADMIN MODIFY LEAD', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + if ( ($dispo != $status) and ($dispo == 'CBHOLD') ) + { + ### inactivate vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='" . mysql_real_escape_string($lead_id) . "' and status='ACTIVE';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
vicidial_callback record inactivated: $lead_id
\n"; + } + if ( ($dispo != $status) and ($dispo == 'CALLBK') ) + { + ### inactivate vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='" . mysql_real_escape_string($lead_id) . "' and status IN('ACTIVE','LIVE');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
vicidial_callback record inactivated: $lead_id
\n"; + } + + if ( ($dispo != $status) and ($status == 'DNC') ) + { + ### add lead to the internal DNC list + $stmt="INSERT INTO vicidial_dnc (phone_number) values('" . mysql_real_escape_string($phone_number) . "');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
Lead added to DNC List: $lead_id - $phone_number
\n"; + } + ### update last record in vicidial_log table + if (($dispo != $status) and ($modify_logs > 0)) + { + $stmt="UPDATE vicidial_log set status='" . mysql_real_escape_string($status) . "' where lead_id='" . mysql_real_escape_string($lead_id) . "' order by call_date desc limit 1"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + + ### update last record in vicidial_closer_log table + if (($dispo != $status) and ($modify_closer_logs > 0)) + { + $stmt="UPDATE vicidial_closer_log set status='" . mysql_real_escape_string($status) . "' where lead_id='" . mysql_real_escape_string($lead_id) . "' order by call_date desc limit 1"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + + ### update last record in vicidial_agent_log table + if (($dispo != $status) and ($modify_agent_logs > 0)) + { + $stmt="UPDATE vicidial_agent_log set status='" . mysql_real_escape_string($status) . "' where lead_id='" . mysql_real_escape_string($lead_id) . "' order by agent_log_id desc limit 1"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + + if ($add_closer_record > 0) + { + ### insert a NEW record to the vicidial_closer_log table + $stmt="INSERT INTO vicidial_closer_log (lead_id,list_id,campaign_id,call_date,start_epoch,end_epoch,length_in_sec,status,phone_code,phone_number,user,comments,processed) values('" . mysql_real_escape_string($lead_id) . "','" . mysql_real_escape_string($list_id) . "','" . mysql_real_escape_string($campaign_id) . "','" . mysql_real_escape_string($parked_time) . "','$NOW_TIME','$STARTtime','1','" . mysql_real_escape_string($status) . "','" . mysql_real_escape_string($phone_code) . "','" . mysql_real_escape_string($phone_number) . "','$PHP_AUTH_USER','" . mysql_real_escape_string($comments) . "','Y')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + + + } +else + { + + if ($CBchangeUSERtoANY == 'YES') + { + ### inactivate vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set recipient='ANYONE' where callback_id='" . mysql_real_escape_string($callback_id) . "';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
vicidial_callback record changed to ANYONE
\n"; + } + if ($CBchangeUSERtoUSER == 'YES') + { + ### inactivate vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set user='" . mysql_real_escape_string($CBuser) . "' where callback_id='" . mysql_real_escape_string($callback_id) . "';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
vicidial_callback record user changed to $CBuser
\n"; + } + if ($CBchangeANYtoUSER == 'YES') + { + ### inactivate vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set user='" . mysql_real_escape_string($CBuser) . "',recipient='USERONLY' where callback_id='" . mysql_real_escape_string($callback_id) . "';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
vicidial_callback record changed to USERONLY, user: $CBuser
\n"; + } + + + + $stmt="SELECT count(*) from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $lead_count = $row[0]; + + if ($lead_count > 0) + { + ##### grab vicidial_list_alt_phones records ##### + $stmt="select phone_code,phone_number,alt_phone_note,alt_phone_count,active from vicidial_list_alt_phones where lead_id='" . mysql_real_escape_string($lead_id) . "' order by alt_phone_count limit 500;"; + $rslt=mysql_query($stmt, $link); + $alts_to_print = mysql_num_rows($rslt); + + $c=0; + $alts_output = ''; + while ($alts_to_print > $c) + { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $c)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $c++; + $alts_output .= "
$c$row[0] $row[1] $row[2] $row[3] $row[4]
$u$row[4] $row[7] $row[8] $row[11] $row[3] $row[2] $row[1] $row[15]   $row[10]
$y$row[3] $row[5] $row[1] $row[7] $row[9] $row[11] $row[13]   $row[14]   $row[15]   $row[17]
$y$row[4] $row[7] $row[8] $row[11] $row[3] $row[2] $row[1]   $row[14]   $row[17]
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + + echo "\n"; + echo "
Vendor ID: $vendor_id     Lead ID: $lead_id
Fronter: $tsr     ID da Lista: $list_id
Nome:   \n"; + echo " Sobrenome:
Endereço 1 :
Endereço 2 :
Endereço 3 :
Cidade :
Estado:   \n"; + echo " CEP:
Província:
País :
Main Phone :
Tel. Alt. :
Email :
Segurança:
Rank :
Owner :
Comentários :
Finalização: (with $log_campaign statuses)
Alterarvicidial log
Alteraragent log
Alterarcloser log
Add closer log record
\n"; + echo "


\n"; + + if ( ($dispo == 'CALLBK') or ($dispo == 'CBHOLD') ) + { + ### find any vicidial_callback records for this lead + $stmt="select callback_id,lead_id,list_id,campaign_id,status,entry_time,callback_time,modify_date,user,recipient,comments,user_group from vicidial_callbacks where lead_id='" . mysql_real_escape_string($lead_id) . "' and status IN('ACTIVE','LIVE') order by callback_id desc LIMIT 1;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $CB_to_print = mysql_num_rows($rslt); + $rowx=mysql_fetch_row($rslt); + + if ($CB_to_print>0) + { + if ($rowx[9] == 'USERONLY') + { + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "

\n"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "New Callback Owner UsuárioID: \n"; + echo "

\n"; + } + else + { + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "New Callback Owner UsuárioID: \n"; + echo "

\n"; + } + } + else + { + echo "
No Callback records found
\n"; + } + } + + + echo "

\n"; + + echo "
\n"; + + if ($c > 0) + { + echo "EXTENDED SUPLENTE NÚMEROS DE TELÉFONO PARA ESTE DE PLOMO:\n"; + echo "\n"; + echo "\n"; + + echo "$alts_output\n"; + + echo "
# ALT PHONE ALT NOTE ALT COUNT ACTIVE
\n"; + echo "

\n"; + } + + echo "CHAMADAS PARA ESSE REGISTRO:\n"; + echo "\n"; + echo "\n"; + + echo "$call_log\n"; + + echo "
# DATE/TIME LENGTH STATUS TSR CAMPANHA LIST LEAD HANGUP REASON PHONE
\n"; + echo "

\n"; + + echo "CLOSER RECORDS FOR THIS LEAD:\n"; + echo "\n"; + echo "\n"; + + echo "$closer_log\n"; + + echo "
# DATE/TIME LENGTH STATUS TSR CAMPANHA LIST LEAD WAIT HANGUP REASON
\n"; + echo "

\n"; + + + echo "AGENTE LOG RECORDS FOR THIS LEAD:\n"; + echo "\n"; + echo "\n"; + + echo "$agent_log\n"; + + echo "
# DATE/TIME CAMPANHA TSR PAUSE WAIT TALK DISPO STATUS GROUP SUB
\n"; + echo "

\n"; + + + echo "RECORDINGS FOR THIS LEAD:\n"; + echo "\n"; + echo "\n"; + + $stmt="select recording_id,channel,server_ip,extension,start_time,start_epoch,end_time,end_epoch,length_in_sec,length_in_min,filename,location,lead_id,user,vicidial_id from recording_log where lead_id='" . mysql_real_escape_string($lead_id) . "' order by recording_id desc limit 500;"; + $rslt=mysql_query($stmt, $link); + $logs_to_print = mysql_num_rows($rslt); + if ($DB) {echo "$logs_to_print|$stmt|\n";} + + $u=0; + while ($logs_to_print > $u) + { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $u)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $location = $row[11]; + + if (strlen($location)>2) + { + $URLserver_ip = $location; + $URLserver_ip = eregi_replace('http://','',$URLserver_ip); + $URLserver_ip = eregi_replace('https://','',$URLserver_ip); + $URLserver_ip = eregi_replace("\/.*",'',$URLserver_ip); + $stmt="select count(*) from servers where server_ip='$URLserver_ip';"; + $rsltx=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rsltx); + + if ($rowx[0] > 0) + { + $stmt="select recording_web_link,alt_server_ip from servers where server_ip='$URLserver_ip';"; + $rsltx=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rsltx); + + if (eregi("ALT_IP",$rowx[0])) + { + $location = eregi_replace($URLserver_ip, $rowx[1], $location); + } + } + } + + if (strlen($location)>30) + {$locat = substr($location,0,27); $locat = "$locat...";} + else + {$locat = $location;} + if (eregi("http",$location)) + {$location = "$locat";} + else + {$location = $locat;} + $u++; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + + } + + + echo "
# LEADDATE/TIME SECONDS   RECIDFILENAMELOCATIONTSR
$u $row[12] $row[4] $row[8] $row[0]   $row[10] $location $row[13]
\n"; + } + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nScript runtime: $RUNtime seconds
"; + + +?> + + + + + + diff --git a/LANG_www/vicidial_br/admin_search_lead.php b/LANG_www/vicidial_br/admin_search_lead.php new file mode 100644 index 00000000..1bdc0cbc --- /dev/null +++ b/LANG_www/vicidial_br/admin_search_lead.php @@ -0,0 +1,598 @@ + LICENSE: AGPLv2 +# +# AST GUI database administration search for lead info +# admin_modify_lead.php +# +# this is the administration lead information search screen, the administrator +# just needs to enter the leadID and then they can view and modify the information +# in the record for that lead +# +# changes: +# 60620-1055 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# - Changed results to multi-record +# 80710-0023 - Added searching by list, user, status +# 90121-0500 - Added filter for phone to remove non-digits +# 90309-1828 - Added admin_log logging +# 90310-2146 - Added admin header +# 90508-0644 - Changed to PHP long tags +# 90917-2307 - Added alternate phone number searching option +# 90921-0713 - Removed SELECT STAR +# 100224-1621 - Added first/last name search and changed format of the page +# 100405-1331 - Added log search ability +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} + elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["log_phone"])) {$log_phone=$_GET["log_phone"];} + elseif (isset($_POST["log_phone"])) {$log_phone=$_POST["log_phone"];} +if (isset($_GET["log_lead_id"])) {$log_lead_id=$_GET["log_lead_id"];} + elseif (isset($_POST["log_lead_id"])) {$log_lead_id=$_POST["log_lead_id"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["alt_phone_search"])) {$alt_phone_search=$_GET["alt_phone_search"];} + elseif (isset($_POST["alt_phone_search"])) {$alt_phone_search=$_POST["alt_phone_search"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); +$phone = ereg_replace("[^0-9]","",$phone); +if (strlen($alt_phone_search) < 2) {$alt_phone_search='No';} + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); + +$vicidial_list_fields = 'lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner'; + +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7 and modify_leads='1';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$auth=$row[0]; + +if ($WeBRooTWritablE > 0) + {$fp = fopen ("./project_auth_entries.txt", "a");} + +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + +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 "Nome ou Senha inválidos: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } +else + { + if ($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name,modify_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname = $row[0]; + $LOGmodify_leads = $row[1]; + + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + } + else + { + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + } + +?> + + + +ADMINISTRATION: Pesquisar Registro +<?php + +##### BEGIN Set variables to make header show properly ##### +$ADD = '100'; +$hh = 'lists'; +$LOGast_admin_access = '1'; +$SSoutbound_autodial_active = '1'; +$ADMIN = 'admin.php'; +$page_width='770'; +$section_width='750'; +$header_font_size='3'; +$subheader_font_size='2'; +$subcamp_font_size='2'; +$header_selected_bold='<b>'; +$header_nonselected_bold=''; +$lists_color = '#FFFF99'; +$lists_font = 'BLACK'; +$lists_color = '#E6E6E6'; +$subcamp_color = '#C6C6C6'; +##### END Set variables to make header show properly ##### + +require("admin_header.php"); + + +echo " Lead search: $vendor_id $phone $lead_id $status $list_id $user\n"; +echo date("l F j, Y G:i:s A"); +echo "<BR>\n"; + +if ( (!$vendor_id) and (!$phone) and (!$lead_id) and (!$log_phone) and (!$log_lead_id) and ( (strlen($status)<1) and (strlen($list_id)<1) and (strlen($user)<1) ) and ( (strlen($first_name)<1) and (strlen($last_name)<1) )) + { + ### Lead search + echo "<br><center>\n"; + echo "<form method=post name=search action=\"$PHP_SELF\">\n"; + echo "<input type=hidden name=DB value=\"$DB\">\n"; + echo "<TABLE CELLPADDING=3 CELLSPACING=3>"; + echo "<TR>"; + echo "<TD colspan=3 align=center><b>Pesquisar Registro Opçãos:</TD>"; + echo "</TR><TR bgcolor=#B9CBFD>"; + + echo "<TD ALIGN=right>Vendor ID(código do fornecedor):   </TD><TD ALIGN=left><input type=text name=vendor_id size=10 maxlength=10></TD>"; + echo "<TD><input type=submit name=submit value=ENVIAR></TD>\n"; + echo "</TR><TR>"; + echo "<TD colspan=3 align=center>   </TD>"; + echo "</TR><TR bgcolor=#B9CBFD>"; + + echo "<TD ALIGN=right>Home Número do Telefone:   </TD><TD ALIGN=left><input type=text name=phone size=14 maxlength=18></TD>"; + echo "<TD rowspan=2><input type=submit name=submit value=ENVIAR></TD>\n"; + echo "</TR><TR bgcolor=#B9CBFD>"; + echo "<TD ALIGN=right>Alt phone search:   </TD><TD ALIGN=left><select size=1 name=alt_phone_search><option>No</option><option>Yes</option><option SELECTED>$alt_phone_search</option></select></TD>"; + echo "</TR><TR>"; + echo "<TD colspan=3 align=center>   </TD>"; + echo "</TR><TR bgcolor=#B9CBFD>"; + + echo "<TD ALIGN=right>Lead ID:   </TD><TD ALIGN=left><input type=text name=lead_id size=10 maxlength=10></TD>"; + echo "<TD><input type=submit name=submit value=ENVIAR></TD>\n"; + echo "</TR><TR>"; + echo "<TD colspan=3 align=center>   </TD>"; + echo "</TR><TR bgcolor=#B9CBFD>"; + + echo "<TD ALIGN=right>Status:   </TD><TD ALIGN=left><input type=text name=status size=7 maxlength=6></TD>"; + echo "<TD rowspan=3><input type=submit name=submit value=ENVIAR></TD>\n"; + echo "</TR><TR bgcolor=#B9CBFD>"; + echo "<TD ALIGN=right>ID da Lista:   </TD><TD ALIGN=left><input type=text name=list_id size=15 maxlength=14></TD>"; + echo "</TR><TR bgcolor=#B9CBFD>"; + echo "<TD ALIGN=right>Usuário:   </TD><TD ALIGN=left><input type=text name=user size=15 maxlength=20></TD>"; + echo "</TR><TR>"; + echo "<TD colspan=3 align=center>   </TD>"; + echo "</TR><TR bgcolor=#B9CBFD>"; + + echo "<TD ALIGN=right>Nome:   </TD><TD ALIGN=left><input type=text name=first_name size=15 maxlength=30></TD>"; + echo "<TD rowspan=2><input type=submit name=submit value=ENVIAR></TD>\n"; + echo "</TR><TR bgcolor=#B9CBFD>"; + echo "<TD ALIGN=right>Sobrenome:   </TD><TD ALIGN=left><input type=text name=last_name size=15 maxlength=30></TD>"; + echo "</TR>"; + + + ### Log search + echo "<br><center>\n"; + echo "<TD colspan=3 align=center>   </TD>"; + echo "</TR><TR>"; + echo "<TD colspan=3 align=center><b>Log Search Opçãos:</TD>"; + echo "</TR><TR bgcolor=#B9CBFD>"; + + echo "<TD ALIGN=right>Lead ID:   </TD><TD ALIGN=left><input type=text name=log_lead_id size=10 maxlength=10></TD>"; + echo "<TD><input type=submit name=submit value=ENVIAR></TD>\n"; + echo "</TR><TR>"; + echo "<TD colspan=3 align=center>   </TD>"; + echo "</TR><TR bgcolor=#B9CBFD>"; + + echo "<TD ALIGN=right>Número do Telefone Dialed:   </TD><TD ALIGN=left><input type=text name=log_phone size=18 maxlength=18></TD>"; + echo "<TD><input type=submit name=submit value=ENVIAR></TD>\n"; + echo "</TR><TR>"; + echo "<TD colspan=3 align=center>   </TD>"; + echo "</TR><TR bgcolor=#B9CBFD>"; + + + echo "</TABLE>\n"; + echo "</form>\n</center>\n"; + echo "</body></html>\n"; + exit; + } + +else + { + ##### BEGIN Log search ##### + if ( (strlen($log_lead_id)>0) or (strlen($log_phone)>0) ) + { + if (strlen($log_lead_id)>0) + { + $stmtA="SELECT lead_id,phone_number,campaign_id,call_date,status,user,list_id,length_in_sec,alt_dial from vicidial_log where lead_id='" . mysql_real_escape_string($log_lead_id) . "'"; + $stmtB="SELECT lead_id,phone_number,campaign_id,call_date,status,user,list_id,length_in_sec from vicidial_closer_log where lead_id='" . mysql_real_escape_string($log_lead_id) . "'"; + } + if (strlen($log_phone)>0) + { + $stmtA="SELECT lead_id,phone_number,campaign_id,call_date,status,user,list_id,length_in_sec,alt_dial from vicidial_log where phone_number='" . mysql_real_escape_string($log_phone) . "'"; + $stmtB="SELECT lead_id,phone_number,campaign_id,call_date,status,user,list_id,length_in_sec from vicidial_closer_log where phone_number='" . mysql_real_escape_string($log_phone) . "'"; + $stmtC="SELECT extension,caller_id_number,did_id,call_date from vicidial_did_log where caller_id_number='" . mysql_real_escape_string($log_phone) . "'"; + } + + $rslt=mysql_query("$stmtA", $link); + $results_to_print = mysql_num_rows($rslt); + if ( ($results_to_print < 1) and ($results_to_printX < 1) ) + { + echo "\n<br><br><center>\n"; + echo "<b>There are no outbound calls matching your search criteria</b><br><br>\n"; + echo "</center>\n"; + } + else + { + echo "<BR><b>SAINTE LOG RESULTS: $results_to_print</b><BR>\n"; + echo "<TABLE BGCOLOR=WHITE CELLPADDING=1 CELLSPACING=0 WIDTH=770>\n"; + echo "<TR BGCOLOR=BLACK>\n"; + echo "<TD ALIGN=LEFT VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>#</B></FONT></TD>\n"; + echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>LEAD ID</B>  </FONT></TD>\n"; + echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>PHONE</B>  </FONT></TD>\n"; + echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>CAMPANHA</B>  </FONT></TD>\n"; + echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>CALL DATA</B>  </FONT></TD>\n"; + echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>STATUS</B>  </FONT></TD>\n"; + echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>USER</B>  </FONT></TD>\n"; + echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>ID DA LISTA</B>  </FONT></TD>\n"; + echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>LENGTH</B>  </FONT></TD>\n"; + echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>DIAL</B></FONT></TD>\n"; + echo "</TR>\n"; + $o=0; + while ($results_to_print > $o) + { + $row=mysql_fetch_row($rslt); + $o++; + $search_lead = $row[0]; + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo "<TR $bgcolor>\n"; + echo "<TD ALIGN=LEFT><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$o</FONT></TD>\n"; + echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1><a href=\"admin_modify_lead.php?lead_id=$row[0]\" target=\"_blank\">$row[0]</a></FONT></TD>\n"; + echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[1]</FONT></TD>\n"; + echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[2]</FONT></TD>\n"; + echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[3]</FONT></TD>\n"; + echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[4]</FONT></TD>\n"; + echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[5]</FONT></TD>\n"; + echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[6]</FONT></TD>\n"; + echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[7]</FONT></TD>\n"; + echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[8]</FONT></TD>\n"; + echo "</TR>\n"; + } + echo "</TABLE>\n"; + } + + $rslt=mysql_query("$stmtB", $link); + $results_to_print = mysql_num_rows($rslt); + if ( ($results_to_print < 1) and ($results_to_printX < 1) ) + { + echo "\n<br><br><center>\n"; + echo "<b>There are no inbound calls matching your search criteria</b><br><br>\n"; + echo "</center>\n"; + } + else + { + echo "<BR><b>ENTRANTE LOG RESULTS: $results_to_print</b><BR>\n"; + echo "<TABLE BGCOLOR=WHITE CELLPADDING=1 CELLSPACING=0 WIDTH=770>\n"; + echo "<TR BGCOLOR=BLACK>\n"; + echo "<TD ALIGN=LEFT VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>#</B></FONT></TD>\n"; + echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>LEAD ID</B>  </FONT></TD>\n"; + echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>PHONE</B>  </FONT></TD>\n"; + echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>INGROUP</B>  </FONT></TD>\n"; + echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>CALL DATA</B>  </FONT></TD>\n"; + echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>STATUS</B>  </FONT></TD>\n"; + echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>USER</B>  </FONT></TD>\n"; + echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>ID DA LISTA</B>  </FONT></TD>\n"; + echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>LENGTH</B>  </FONT></TD>\n"; + echo "</TR>\n"; + $o=0; + while ($results_to_print > $o) + { + $row=mysql_fetch_row($rslt); + $o++; + $search_lead = $row[0]; + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo "<TR $bgcolor>\n"; + echo "<TD ALIGN=LEFT><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$o</FONT></TD>\n"; + echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1><a href=\"admin_modify_lead.php?lead_id=$row[0]\" target=\"_blank\">$row[0]</a></FONT></TD>\n"; + echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[1]</FONT></TD>\n"; + echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[2]</FONT></TD>\n"; + echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[3]</FONT></TD>\n"; + echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[4]</FONT></TD>\n"; + echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[5]</FONT></TD>\n"; + echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[6]</FONT></TD>\n"; + echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[7]</FONT></TD>\n"; + echo "</TR>\n"; + } + echo "</TABLE>\n"; + } + + if (strlen($stmtC) > 10) + { + $rslt=mysql_query("$stmtC", $link); + $results_to_print = mysql_num_rows($rslt); + if ( ($results_to_print < 1) and ($results_to_printX < 1) ) + { + echo "\n<br><br><center>\n"; + echo "<b>There are no inbound did calls matching your search criteria</b><br><br>\n"; + echo "</center>\n"; + } + else + { + echo "<BR><b>ENTRANTE DID LOG RESULTS: $results_to_print</b><BR>\n"; + echo "<TABLE BGCOLOR=WHITE CELLPADDING=1 CELLSPACING=0 WIDTH=770>\n"; + echo "<TR BGCOLOR=BLACK>\n"; + echo "<TD ALIGN=LEFT VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>#</B></FONT></TD>\n"; + echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>DID</B>  </FONT></TD>\n"; + echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>PHONE</B>  </FONT></TD>\n"; + echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>DID ID</B>  </FONT></TD>\n"; + echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>CALL DATA</B>  </FONT></TD>\n"; + echo "</TR>\n"; + $o=0; + while ($results_to_print > $o) + { + $row=mysql_fetch_row($rslt); + $o++; + $search_lead = $row[0]; + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo "<TR $bgcolor>\n"; + echo "<TD ALIGN=LEFT><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$o</FONT></TD>\n"; + echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[0]</FONT></TD>\n"; + echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[1]</FONT></TD>\n"; + echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[2]</FONT></TD>\n"; + echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[3]</FONT></TD>\n"; + echo "</TR>\n"; + } + echo "</TABLE>\n"; + } + } + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$PHP_AUTH_USER', ip_address='$ip', event_section='LEADS', event_type='SEARCH', record_id='$search_lead', event_code='ADMIN SEARCH LEAD', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $ENDtime = date("U"); + + $RUNtime = ($ENDtime - $STARTtime); + + echo "\n\n\n<br><br><br>\n<a href=\"$PHP_SELF\">NOVA PESQUISA</a>"; + + echo "\n\n\n<br><br><br>\nScript runtime: $RUNtime seconds"; + + echo "\n\n\n</body></html>"; + + exit; + } + ##### END Log search ##### + + + + + + ##### BEGIN Lead search ##### + if ($vendor_id) + { + $stmt="SELECT $vicidial_list_fields from vicidial_list where vendor_lead_code='" . mysql_real_escape_string($vendor_id) . "'"; + } + else + { + if ($phone) + { + if ($alt_phone_search=="Yes") + { + $stmt="SELECT $vicidial_list_fields from vicidial_list where phone_number='" . mysql_real_escape_string($phone) . "' or alt_phone='" . mysql_real_escape_string($phone) . "' or address3='" . mysql_real_escape_string($phone) . "'"; + } + else + { + $stmt="SELECT $vicidial_list_fields from vicidial_list where phone_number='" . mysql_real_escape_string($phone) . "'"; + } + } + else + { + if ($lead_id) + { + $stmt="SELECT $vicidial_list_fields from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + } + else + { + if ( (strlen($status)>0) or (strlen($list_id)>0) or (strlen($user)>0) ) + { + $statusSQL = ''; + $list_idSQL = ''; + $userSQL = ''; + if (strlen($status)>0) + { + $statusSQL = "status='" . mysql_real_escape_string($status) . "'"; $SQLctA++; + } + if (strlen($list_id)>0) + { + if ($SQLctA > 0) {$andA = 'and';} + $list_idSQL = "$andA list_id='" . mysql_real_escape_string($list_id) . "'"; $SQLctB++; + } + if (strlen($user)>0) + { + if ( ($SQLctA > 0) or ($SQLctB > 0) ) {$andB = 'and';} + $userSQL = "$andB user='" . mysql_real_escape_string($user) . "'"; + } + $stmt="SELECT $vicidial_list_fields from vicidial_list where $statusSQL $list_idSQL $userSQL"; + } + else + { + if ( (strlen($first_name)>0) or (strlen($last_name)>0) ) + { + $first_nameSQL = ''; + $last_nameSQL = ''; + if (strlen($first_name)>0) + { + $first_nameSQL = "first_name='" . mysql_real_escape_string($first_name) . "'"; $SQLctA++; + } + if (strlen($last_name)>0) + { + if ($SQLctA > 0) {$andA = 'and';} + $last_nameSQL = "$andA last_name='" . mysql_real_escape_string($last_name) . "'"; + } + $stmt="SELECT $vicidial_list_fields from vicidial_list where $first_nameSQL $last_nameSQL"; + } + else + { + print "ERROR: you must search for something! Go back and search for something"; + exit; + } + } + } + } + } + + $stmt_alt=''; + $results_to_printX=0; + if ( ($alt_phone_search=="Yes") and (strlen($phone) > 4) ) + { + $stmtX="SELECT lead_id from vicidial_list_alt_phones where phone_number='" . mysql_real_escape_string($phone) . "' limit 1000;"; + $rsltX=mysql_query($stmtX, $link); + $results_to_printX = mysql_num_rows($rsltX); + if ($DB) + {echo "\n\n$results_to_printX|$stmtX\n\n";} + $o=0; + while ($results_to_printX > $o) + { + $row=mysql_fetch_row($rsltX); + if ($o > 0) {$stmt_alt .= ",";} + $stmt_alt .= "'$row[0]'"; + $o++; + } + if (strlen($stmt_alt) > 2) + {$stmt_alt = "or lead_id IN($stmt_alt)";} + } + + $stmt = "$stmt$stmt_alt order by modify_date desc limit 1000;"; + + if ($DB) + { + echo "\n\n$stmt\n\n"; + } + + $rslt=mysql_query("$stmt", $link); + $results_to_print = mysql_num_rows($rslt); + if ( ($results_to_print < 1) and ($results_to_printX < 1) ) + { + echo date("l F j, Y G:i:s A"); + echo "\n<br><br><center>\n"; + echo "<b>As variáveis de pesquisa digitadas não estão ativas no sistema</b><br><br>\n"; + echo "<b>Por favor volte e verifique as informações digitadas, então envie novamente</b>\n"; + echo "</center>\n"; + echo "</body></html>\n"; + exit; + } + else + { + echo "<b>RESULTS: $results_to_print</b><BR><BR>\n"; + echo "<TABLE BGCOLOR=WHITE CELLPADDING=1 CELLSPACING=0 WIDTH=770>\n"; + echo "<TR BGCOLOR=BLACK>\n"; + echo "<TD ALIGN=LEFT VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>#</B></FONT></TD>\n"; + echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>LEAD ID</B>  </FONT></TD>\n"; + echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>STATUS</B>  </FONT></TD>\n"; + echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>VENDOR ID</B>  </FONT></TD>\n"; + echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>LAST AGENT</B>  </FONT></TD>\n"; + echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>ID DA LISTA</B>  </FONT></TD>\n"; + echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>PHONE</B>  </FONT></TD>\n"; + echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>NOME</B>  </FONT></TD>\n"; + echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>CITY</B>  </FONT></TD>\n"; + echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>SECURITY</B>  </FONT></TD>\n"; + echo "<TD ALIGN=CENTER VALIGN=TOP><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE><B>LAST CALL</B></FONT></TD>\n"; + echo "</TR>\n"; + $o=0; + while ($results_to_print > $o) + { + $row=mysql_fetch_row($rslt); + $o++; + $search_lead = $row[0]; + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo "<TR $bgcolor>\n"; + echo "<TD ALIGN=LEFT><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$o</FONT></TD>\n"; + echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1><a href=\"admin_modify_lead.php?lead_id=$row[0]\" target=\"_blank\">$row[0]</a></FONT></TD>\n"; + echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[3]</FONT></TD>\n"; + echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[5]</FONT></TD>\n"; + echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[4]</FONT></TD>\n"; + echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[7]</FONT></TD>\n"; + echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[11]</FONT></TD>\n"; + echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[13] $row[15]</FONT></TD>\n"; + echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[19]</FONT></TD>\n"; + echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[28]</FONT></TD>\n"; + echo "<TD ALIGN=CENTER><FONT FACE=\"ARIAL,HELVETICA\" SIZE=1>$row[31]</FONT></TD>\n"; + echo "</TR>\n"; + } + echo "</TABLE>\n"; + } + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$PHP_AUTH_USER', ip_address='$ip', event_section='LEADS', event_type='SEARCH', record_id='$search_lead', event_code='ADMIN SEARCH LEAD', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + ##### END Lead search ##### + + + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n<br><br><br>\n<a href=\"$PHP_SELF\">NOVA PESQUISA</a>"; + + +echo "\n\n\n<br><br><br>\nScript runtime: $RUNtime seconds"; + + +?> + + + +</body> +</html> diff --git a/LANG_www/vicidial_br/audio_store.php b/LANG_www/vicidial_br/audio_store.php new file mode 100644 index 00000000..f3e0624e --- /dev/null +++ b/LANG_www/vicidial_br/audio_store.php @@ -0,0 +1,343 @@ +<?php +# audio_store.php +# +# Copyright (C) 2010 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2 +# +# Central Audio Storage script +# +# CHANGES +# 90511-1325 - First build +# 90618-0640 - Fix for users going through proxy or tunnel +# 100401-1037 - remove spaces and special characters from filenames, admin log uploads +# + +$version = '2.2.0-3'; +$build = '100401-1037'; + +$MT[0]=''; + +require("dbconnect.php"); + +$server_name = getenv("SERVER_NAME"); +$PHP_SELF=$_SERVER['PHP_SELF']; +$audiofile=$_FILES["audiofile"]; + $AF_orig = $_FILES['audiofile']['name']; + $AF_path = $_FILES['audiofile']['tmp_name']; +if (isset($_GET["submit_file"])) {$submit_file=$_GET["submit_file"];} + elseif (isset($_POST["submit_file"])) {$submit_file=$_POST["submit_file"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["overwrite"])) {$overwrite=$_GET["overwrite"];} + elseif (isset($_POST["overwrite"])) {$overwrite=$_POST["overwrite"];} +if (isset($_GET["action"])) {$action=$_GET["action"];} + elseif (isset($_POST["action"])) {$action=$_POST["action"];} +if (isset($_GET["audio_server_ip"])) {$audio_server_ip=$_GET["audio_server_ip"];} + elseif (isset($_POST["audio_server_ip"])) {$audio_server_ip=$_POST["audio_server_ip"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} +if (isset($_GET["audiofile_name"])) {$audiofile_name=$_GET["audiofile_name"];} + elseif (isset($_POST["audiofile_name"])) {$audiofile_name=$_POST["audiofile_name"];} +if (isset($_FILES["audiofile"])) {$audiofile_name=$_FILES["audiofile"]['name'];} +if (isset($_GET["lead_file"])) {$lead_file=$_GET["lead_file"];} + elseif (isset($_POST["lead_file"])) {$lead_file=$_POST["lead_file"];} + + +header ("Content-type: text/html; charset=utf-8"); +header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header ("Pragma: no-cache"); // HTTP/1.0 + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin,sounds_central_control_active,sounds_web_server,sounds_web_directory,outbound_autodial_active FROM system_settings;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$ss_conf_ct = mysql_num_rows($rslt); +if ($ss_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $non_latin = $row[0]; + $sounds_central_control_active = $row[1]; + $sounds_web_server = $row[2]; + $sounds_web_directory = $row[3]; + $SSoutbound_autodial_active = $row[4]; + } +##### END SETTINGS LOOKUP ##### +########################################### + + +### check if sounds server matches this server IP, if not then exit with an error +if ( ( (strlen($sounds_web_server)) != (strlen($server_name)) ) or (!eregi("$sounds_web_server",$server_name) ) ) + { + echo "ERROR: server($server_name) does not match sounds web server ip($sounds_web_server)\n"; + exit; + } + + +### check if web directory exists, if not generate one +if (strlen($sounds_web_directory) < 30) + { + $sounds_web_directory = ''; + $possible = "0123456789cdfghjkmnpqrstvwxyz"; + $i = 0; + $length = 30; + while ($i < $length) + { + $char = substr($possible, mt_rand(0, strlen($possible)-1), 1); + $sounds_web_directory .= $char; + $i++; + } + mkdir("$WeBServeRRooT/$sounds_web_directory"); + chmod("$WeBServeRRooT/$sounds_web_directory", 0766); + if ($DB > 0) {echo "$WeBServeRRooT/$sounds_web_directory\n";} + + $stmt="UPDATE system_settings set sounds_web_directory='$sounds_web_directory';"; + $rslt=mysql_query($stmt, $link); + echo "NOTICE: new web directory created\n"; + } + + +### get list of all servers, if not one of them, then force authentication check +$stmt = "SELECT server_ip FROM servers;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$sv_conf_ct = mysql_num_rows($rslt); +$i=0; +$server_ips ='|'; +while ($sv_conf_ct > $i) + { + $row=mysql_fetch_row($rslt); + $server_ips .= "$row[0]|"; + $i++; + } + +$user_set=0; +$formIPvalid=0; +if (strlen($audio_server_ip) > 6) + { + if (preg_match("/\|$audio_server_ip\|/", $server_ips)) + {$formIPvalid=1;} + } +$ip = getenv("REMOTE_ADDR"); +if ( (!preg_match("/\|$ip\|/", $server_ips)) and ($formIPvalid < 1) ) + { + $user_set=1; + $PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; + $PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; + $PHP_AUTH_USER = ereg_replace("[^-_0-9a-zA-Z]","",$PHP_AUTH_USER); + $PHP_AUTH_PW = ereg_replace("[^-_0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7 and modify_campaigns='1'"; + if ($DB) {echo "|$stmt|\n";} + $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|$ip|\n"; + exit; + } + } + + +### list all files in sounds web directory +if ($action == "LIST") + { + $i=0; + $filename_sort=$MT; + $dirpath = "$WeBServeRRooT/$sounds_web_directory"; + $dh = opendir($dirpath); + while (false !== ($file = readdir($dh))) + { + # Do not list subdirectories + if ( (!is_dir("$dirpath/$file")) and (preg_match('/\.wav$|\.gsm$/', $file)) ) + { + if (file_exists("$dirpath/$file")) + { + $file_names[$i] = $file; + $file_epoch[$i] = filemtime("$dirpath/$file"); + $file_dates[$i] = date ("Y-m-d H:i:s.", filemtime("$dirpath/$file")); + $file_sizes[$i] = filesize("$dirpath/$file"); + $filename_sort[$i] = $file . "----------" . $i . "----------" . $file_sizes[$i]; + $i++; + } + } + } + closedir($dh); + + sort($filename_sort); + + sleep(1); + + $k=0; + while($k < $i) + { + $filename_split = explode('----------',$filename_sort[$k]); + $m = $filename_split[1]; + $size = $filename_split[2]; + $NOWsize = filesize("$dirpath/$file_names[$m]"); + if ($size == $NOWsize) + { + echo "$k\t$file_names[$m]\t$file_dates[$m]\t$file_sizes[$m]\t$file_epoch[$m]\n"; + } + $k++; + } + exit; + } + + +### upload audio file from server to webserver +# curl 'http://10.0.0.4/vicidial/audio_store.php?action=AUTOUPLOAD' -F "audiofile=@/var/lib/asterisk/sounds/beep.gsm" +if ($action == "AUTOUPLOAD") + { + if ($audiofile) + { + $AF_path = preg_replace("/ /",'\ ',$AF_path); + $AF_path = preg_replace("/@/",'\@',$AF_path); + $audiofile_name = preg_replace("/ /",'',$audiofile_name); + $audiofile_name = preg_replace("/@/",'',$audiofile_name); + copy($AF_path, "$WeBServeRRooT/$sounds_web_directory/$audiofile_name"); + chmod("$WeBServeRRooT/$sounds_web_directory/$audiofile_name", 0766); + + echo "SUCCESS: $audiofile_name uploaded size:" . filesize("$WeBServeRRooT/$sounds_web_directory/$audiofile_name") . "\n"; + exit; + } + else + { + echo "ERROR: no file uploaded\n"; + } + exit; + } + + + + +?> +<html> +<head> +<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8"> +<!-- VERSION: <?php echo $version ?> BUILD: <?php echo $build ?> --> +<title>ADMINISTRATION: Audio Store +<?php + + +if ($user_set < 1) + { + $PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; + $PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; + $PHP_AUTH_USER = ereg_replace("[^-_0-9a-zA-Z]","",$PHP_AUTH_USER); + $PHP_AUTH_PW = ereg_replace("[^-_0-9a-zA-Z]","",$PHP_AUTH_PW); + } +##### BEGIN Set variables to make header show properly ##### +$ADD = '311111111111111'; +$hh = 'admin'; +$LOGast_admin_access = '1'; +$ADMIN = 'admin.php'; +$page_width='770'; +$section_width='750'; +$header_font_size='3'; +$subheader_font_size='2'; +$subcamp_font_size='2'; +$header_selected_bold='<b>'; +$header_nonselected_bold=''; +$admin_color = '#FFFF99'; +$admin_font = 'BLACK'; +$admin_color = '#E6E6E6'; +$subcamp_color = '#C6C6C6'; +##### END Set variables to make header show properly ##### + +require("admin_header.php"); + +?> +<TABLE WIDTH=<?php echo $page_width ?> BGCOLOR=#E6E6E6 cellpadding=2 cellspacing=0><TR BGCOLOR=#E6E6E6><TD ALIGN=LEFT><FONT FACE="ARIAL,HELVETICA" SIZE=2><B>   Audio Store</TD><TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA" SIZE=2><B>   </TD></TR> + +<?php + +echo "<TR BGCOLOR=\"#F0F5FE\"><TD ALIGN=LEFT COLSPAN=2><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=3><B>   \n"; + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_datetime = $STARTtime; + +$date = date("r"); +$browser = getenv("HTTP_USER_AGENT"); +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +$admDIR = "$HTTPprotocol$server_name:$server_port$script_name"; +$admDIR = eregi_replace('audio_store.php','',$admDIR); +$admSCR = 'admin.php'; +$NWB = "   <a href=\"javascript:openNewWindow('$admDIR$admSCR?ADD=99999"; +$NWE = "')\"><IMG SRC=\"help.gif\" WIDTH=20 HEIGHT=20 BORDER=0 ALT=\"HELP\" ALIGN=TOP></A>"; + +$secX = date("U"); +$pulldate0 = "$year-$mon-$mday $hour:$min:$sec"; + +if ($action == "MANUALUPLOAD") + { + if ($audiofile) + { + $AF_path = preg_replace("/ /",'\ ',$AF_path); + $AF_path = preg_replace("/@/",'\@',$AF_path); + $audiofile_name = preg_replace("/ /",'',$audiofile_name); + $audiofile_name = preg_replace("/@/",'',$audiofile_name); + copy($AF_path, "$WeBServeRRooT/$sounds_web_directory/$audiofile_name"); + chmod("$WeBServeRRooT/$sounds_web_directory/$audiofile_name", 0766); + + echo "SUCCESS: $audiofile_name uploaded size:" . filesize("$WeBServeRRooT/$sounds_web_directory/$audiofile_name") . "\n"; + + $stmt="UPDATE servers SET sounds_update='Y';"; + $rslt=mysql_query($stmt, $link); + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date=NOW(), user='$PHP_AUTH_USER', ip_address='$ip', event_section='AUDIOSTORE', event_type='LOAD', record_id='manualupload', event_code='$audiofile_name " . filesize("$WeBServeRRooT/$sounds_web_directory/$audiofile_name") . "', event_sql=\"$SQL_log\", event_notes='$audiofile_name $AF_path $AF_orig';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + echo "ERROR: no file uploaded\n"; + } + } + +?> + + +<form action=<?php echo $PHP_SELF ?> method=post enctype="multipart/form-data"> +<input type=hidden name=action value="MANUALUPLOAD"> +<input type=hidden name=sample_prompt id=sample_prompt value=""> + +<table align=center width="700" border=0 cellpadding=5 cellspacing=0 bgcolor=#D9E6FE> + <tr> + <td align=right width="35%"><B><font face="arial, helvetica" size=2>Audio File to Upload:</font></B></td> + <td align=left width="65%"><input type=file name="audiofile" value=""> <?php echo "$NWB#audio_store$NWE"; ?></td> + </tr> + <tr> + <td align=center colspan=2><input type=submit name=submit value=submit></td> + </tr> + <tr><td align=left><font size=1>   </font></td><td align=right><font size=1>Audio Store-     VERSION: <?php echo $version ?>     BUILD: <?php echo $build ?>     </td></tr> +</table> +<BR><BR> +<CENTER><B>We STRONGLY recommend uploading only 16bit 8k PCM WAV audio files(.wav)</B> +<BR><BR><font size=1>All spaces will be stripped from uploaded audio file names</font><BR><BR> +<B><a href="javascript:launch_chooser('sample_prompt','date',30);">audio file list</a></CENTER> + + + +<?php + +echo "<BR><BR><BR><BR><BR><BR>\n"; + +echo "</B></B><br><br><a href=\"admin.php?ADD=720000000000000&category=AUDIOSTORE&stage=manualupload\">Click here to see a log of the uploads to the audio store</FONT>\n"; + +?> + +</TD></TR></TABLE> diff --git a/LANG_www/vicidial_br/calendar.css b/LANG_www/vicidial_br/calendar.css new file mode 100644 index 00000000..a3ddcae5 --- /dev/null +++ b/LANG_www/vicidial_br/calendar.css @@ -0,0 +1,95 @@ +/* calendar icon */ +img.tcalIcon { + cursor: pointer; + margin-left: 1px; + vertical-align: middle; +} +/* calendar container element */ +div#tcal { + position: absolute; + visibility: hidden; + z-index: 100; + width: 158px; + padding: 2px 0 0 0; +} +/* all tables in calendar */ +div#tcal table { + width: 100%; + border: 1px solid silver; + border-collapse: collapse; + background-color: white; +} +/* navigation table */ +div#tcal table.ctrl { + border-bottom: 0; +} +/* navigation buttons */ +div#tcal table.ctrl td { + width: 15px; + height: 20px; +} +/* month year header */ +div#tcal table.ctrl th { + background-color: white; + color: black; + border: 0; +} +/* week days header */ +div#tcal th { + border: 1px solid silver; + border-collapse: collapse; + text-align: center; + padding: 3px 0; + font-family: tahoma, verdana, arial; + font-size: 10px; + background-color: gray; + color: white; +} +/* date cells */ +div#tcal td { + border: 0; + border-collapse: collapse; + text-align: center; + padding: 2px 0; + font-family: tahoma, verdana, arial; + font-size: 11px; + width: 22px; + cursor: pointer; +} +/* date highlight + in case of conflicting settings order here determines the priority from least to most important */ +div#tcal td.othermonth { + color: silver; +} +div#tcal td.weekend { + background-color: #ACD6F5; +} +div#tcal td.today { + border: 1px solid red; +} +div#tcal td.selected { + background-color: #FFB3BE; +} +/* iframe element used to suppress windowed controls in IE5/6 */ +iframe#tcalIF { + position: absolute; + visibility: hidden; + z-index: 98; + border: 0; +} +/* transparent shadow */ +div#tcalShade { + position: absolute; + visibility: hidden; + z-index: 99; +} +div#tcalShade table { + border: 0; + border-collapse: collapse; + width: 100%; +} +div#tcalShade table td { + border: 0; + border-collapse: collapse; + padding: 0; +} diff --git a/LANG_www/vicidial_br/calendar_db.js b/LANG_www/vicidial_br/calendar_db.js new file mode 100644 index 00000000..ee6c8dd3 --- /dev/null +++ b/LANG_www/vicidial_br/calendar_db.js @@ -0,0 +1,335 @@ +// Tigra Calendar v4.0.2 (2009-01-12) Database (yyyy-mm-dd) +// http://www.softcomplex.com/products/tigra_calendar/ +// Public Domain Software... You're welcome. + +// default settins +var A_TCALDEF = { + 'months' : ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], + 'weekdays' : ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'], + 'yearscroll': true, // show year scroller + 'weekstart': 0, // first day of week: 0-Su or 1-Mo + 'centyear' : 70, // 2 digit years less than 'centyear' are in 20xx, othewise in 19xx. + 'imgpath' : 'images/' // directory with calendar images +} +// date parsing function +function f_tcalParseDate (s_date) { + + var re_date = /^\s*(\d{2,4})\-(\d{1,2})\-(\d{1,2})\s*$/; + if (!re_date.exec(s_date)) + return alert ("Invalid date: '" + s_date + "'.\nAccepted format is yyyy-mm-dd.") + var n_day = Number(RegExp.$3), + n_month = Number(RegExp.$2), + n_year = Number(RegExp.$1); + + if (n_year < 100) + n_year += (n_year < this.a_tpl.centyear ? 2000 : 1900); + if (n_month < 1 || n_month > 12) + return alert ("Invalid month value: '" + n_month + "'.\nAllowed range is 01-12."); + var d_numdays = new Date(n_year, n_month, 0); + if (n_day > d_numdays.getDate()) + return alert("Invalid day of month value: '" + n_day + "'.\nAllowed range for selected month is 01 - " + d_numdays.getDate() + "."); + + return new Date (n_year, n_month - 1, n_day); +} +// date generating function +function f_tcalGenerDate (d_date) { + return ( + d_date.getFullYear() + "-" + + (d_date.getMonth() < 9 ? '0' : '') + (d_date.getMonth() + 1) + "-" + + (d_date.getDate() < 10 ? '0' : '') + d_date.getDate() + ); +} + +// implementation +function tcal (a_cfg, a_tpl) { + + // apply default template if not specified + if (!a_tpl) + a_tpl = A_TCALDEF; + + // register in global collections + if (!window.A_TCALS) + window.A_TCALS = []; + if (!window.A_TCALSIDX) + window.A_TCALSIDX = []; + + this.s_id = a_cfg.id ? a_cfg.id : A_TCALS.length; + window.A_TCALS[this.s_id] = this; + window.A_TCALSIDX[window.A_TCALSIDX.length] = this; + + // assign methods + this.f_show = f_tcalShow; + this.f_hide = f_tcalHide; + this.f_toggle = f_tcalToggle; + this.f_update = f_tcalUpdate; + this.f_relDate = f_tcalRelDate; + this.f_parseDate = f_tcalParseDate; + this.f_generDate = f_tcalGenerDate; + + // create calendar icon + this.s_iconId = 'tcalico_' + this.s_id; + this.e_icon = f_getElement(this.s_iconId); + if (!this.e_icon) { + document.write('<img src="' + a_tpl.imgpath + 'cal.gif" id="' + this.s_iconId + '" onclick="A_TCALS[\'' + this.s_id + '\'].f_toggle()" class="tcalIcon" alt="Open Calendar" />'); + this.e_icon = f_getElement(this.s_iconId); + } + // save received parameters + this.a_cfg = a_cfg; + this.a_tpl = a_tpl; +} + +function f_tcalShow (d_date) { + + // find input field + if (!this.a_cfg.controlname) + throw("TC: control name is not specified"); + if (this.a_cfg.formname) { + var e_form = document.forms[this.a_cfg.formname]; + if (!e_form) + throw("TC: form '" + this.a_cfg.formname + "' can not be found"); + this.e_input = e_form.elements[this.a_cfg.controlname]; + } + else + this.e_input = f_getElement(this.a_cfg.controlname); + + if (!this.e_input || !this.e_input.tagName || this.e_input.tagName != 'INPUT') + throw("TC: element '" + this.a_cfg.controlname + "' does not exist in " + + (this.a_cfg.formname ? "form '" + this.a_cfg.controlname + "'" : 'this document')); + + // dynamically create HTML elements if needed + this.e_div = f_getElement('tcal'); + if (!this.e_div) { + this.e_div = document.createElement("DIV"); + this.e_div.id = 'tcal'; + document.body.appendChild(this.e_div); + } + this.e_shade = f_getElement('tcalShade'); + if (!this.e_shade) { + this.e_shade = document.createElement("DIV"); + this.e_shade.id = 'tcalShade'; + document.body.appendChild(this.e_shade); + } + this.e_iframe = f_getElement('tcalIF') + if (b_ieFix && !this.e_iframe) { + this.e_iframe = document.createElement("IFRAME"); + this.e_iframe.style.filter = 'alpha(opacity=0)'; + this.e_iframe.id = 'tcalIF'; + this.e_iframe.src = this.a_tpl.imgpath + 'pixel.gif'; + document.body.appendChild(this.e_iframe); + } + + // hide all calendars + f_tcalHideAll(); + + // generate HTML and show calendar + this.e_icon = f_getElement(this.s_iconId); + if (!this.f_update()) + return; + + this.e_div.style.visibility = 'visible'; + this.e_shade.style.visibility = 'visible'; + if (this.e_iframe) + this.e_iframe.style.visibility = 'visible'; + + // change icon and status + this.e_icon.src = this.a_tpl.imgpath + 'no_cal.gif'; + this.e_icon.title = 'Close Calendar'; + this.b_visible = true; +} + +function f_tcalHide (n_date) { + if (n_date) + this.e_input.value = this.f_generDate(new Date(n_date)); + + // no action if not visible + if (!this.b_visible) + return; + + // hide elements + if (this.e_iframe) + this.e_iframe.style.visibility = 'hidden'; + if (this.e_shade) + this.e_shade.style.visibility = 'hidden'; + this.e_div.style.visibility = 'hidden'; + + // change icon and status + this.e_icon = f_getElement(this.s_iconId); + this.e_icon.src = this.a_tpl.imgpath + 'cal.gif'; + this.e_icon.title = 'Open Calendar'; + this.b_visible = false; +} + +function f_tcalToggle () { + return this.b_visible ? this.f_hide() : this.f_show(); +} + +function f_tcalUpdate (d_date) { + + var d_today = this.a_cfg.today ? this.f_parseDate(this.a_cfg.today) : f_tcalResetTime(new Date()); + var d_selected = this.e_input.value == '' + ? (this.a_cfg.selected ? this.f_parseDate(this.a_cfg.selected) : d_today) + : this.f_parseDate(this.e_input.value); + + // figure out date to display + if (!d_date) + // selected by default + d_date = d_selected; + else if (typeof(d_date) == 'number') + // get from number + d_date = f_tcalResetTime(new Date(d_date)); + else if (typeof(d_date) == 'string') + // parse from string + this.f_parseDate(d_date); + + if (!d_date) return false; + + // first date to display + var d_firstday = new Date(d_date); + d_firstday.setDate(1); + d_firstday.setDate(1 - (7 + d_firstday.getDay() - this.a_tpl.weekstart) % 7); + + var a_class, s_html = '<table class="ctrl"><tbody><tr>' + + (this.a_tpl.yearscroll ? '<td' + this.f_relDate(d_date, -1, 'y') + ' title="Previous Year"><img src="' + this.a_tpl.imgpath + 'prev_year.gif" /></td>' : '') + + '<td' + this.f_relDate(d_date, -1) + ' title="Previous Month"><img src="' + this.a_tpl.imgpath + 'prev_mon.gif" /></td><th>' + + this.a_tpl.months[d_date.getMonth()] + ' ' + d_date.getFullYear() + + '</th><td' + this.f_relDate(d_date, 1) + ' title="Next Month"><img src="' + this.a_tpl.imgpath + 'next_mon.gif" /></td>' + + (this.a_tpl.yearscroll ? '<td' + this.f_relDate(d_date, 1, 'y') + ' title="Next Year"><img src="' + this.a_tpl.imgpath + 'next_year.gif" /></td></td>' : '') + + '</tr></tbody></table><table><tbody><tr class="wd">'; + + // print weekdays titles + for (var i = 0; i < 7; i++) + s_html += '<th>' + this.a_tpl.weekdays[(this.a_tpl.weekstart + i) % 7] + '</th>'; + s_html += '</tr>' ; + + // print calendar table + var n_date, n_month, d_current = new Date(d_firstday); + while (d_current.getMonth() == d_date.getMonth() || + d_current.getMonth() == d_firstday.getMonth()) { + + // print row heder + s_html +='<tr>'; + for (var n_wday = 0; n_wday < 7; n_wday++) { + + a_class = []; + n_date = d_current.getDate(); + n_month = d_current.getMonth(); + + // other month + if (d_current.getMonth() != d_date.getMonth()) + a_class[a_class.length] = 'othermonth'; + // weekend + if (d_current.getDay() == 0 || d_current.getDay() == 6) + a_class[a_class.length] = 'weekend'; + // today + if (d_current.valueOf() == d_today.valueOf()) + a_class[a_class.length] = 'today'; + // selected + if (d_current.valueOf() == d_selected.valueOf()) + a_class[a_class.length] = 'selected'; + + s_html += '<td onclick="A_TCALS[\'' + this.s_id + '\'].f_hide(' + d_current.valueOf() + ')"' + (a_class.length ? ' class="' + a_class.join(' ') + '">' : '>') + n_date + '</td>' + + d_current.setDate(++n_date); + while (d_current.getDate() != n_date && d_current.getMonth() == n_month) { + d_current.setHours(d_current.getHours + 1); + d_current = f_tcalResetTime(d_current); + } + } + // print row footer + s_html +='</tr>'; + } + s_html +='</tbody></table>'; + + // update HTML, positions and sizes + this.e_div.innerHTML = s_html; + + var n_width = this.e_div.offsetWidth; + var n_height = this.e_div.offsetHeight; + var n_top = f_getPosition (this.e_icon, 'Top') + this.e_icon.offsetHeight; + var n_left = f_getPosition (this.e_icon, 'Left') - n_width + this.e_icon.offsetWidth; + if (n_left < 0) n_left = 0; + + this.e_div.style.left = n_left + 'px'; + this.e_div.style.top = n_top + 'px'; + + this.e_shade.style.width = (n_width + 8) + 'px'; + this.e_shade.style.left = (n_left - 1) + 'px'; + this.e_shade.style.top = (n_top - 1) + 'px'; + this.e_shade.innerHTML = b_ieFix + ? '<table><tbody><tr><td rowspan="2" colspan="2" width="6"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td width="7" height="7" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_tr.png\', sizingMethod=\'scale\');"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td></tr><tr><td height="' + (n_height - 7) + '" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_mr.png\', sizingMethod=\'scale\');"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td></tr><tr><td width="7" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_bl.png\', sizingMethod=\'scale\');"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_bm.png\', sizingMethod=\'scale\');" height="7" align="left"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_br.png\', sizingMethod=\'scale\');"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td></tr><tbody></table>' + : '<table><tbody><tr><td rowspan="2" width="6"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td rowspan="2"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td width="7" height="7"><img src="' + this.a_tpl.imgpath + 'shade_tr.png"></td></tr><tr><td background="' + this.a_tpl.imgpath + 'shade_mr.png" height="' + (n_height - 7) + '"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td></tr><tr><td><img src="' + this.a_tpl.imgpath + 'shade_bl.png"></td><td background="' + this.a_tpl.imgpath + 'shade_bm.png" height="7" align="left"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td><img src="' + this.a_tpl.imgpath + 'shade_br.png"></td></tr><tbody></table>'; + + if (this.e_iframe) { + this.e_iframe.style.left = n_left + 'px'; + this.e_iframe.style.top = n_top + 'px'; + this.e_iframe.style.width = (n_width + 6) + 'px'; + this.e_iframe.style.height = (n_height + 6) +'px'; + } + return true; +} + +function f_getPosition (e_elemRef, s_coord) { + var n_pos = 0, n_offset, + e_elem = e_elemRef; + + while (e_elem) { + n_offset = e_elem["offset" + s_coord]; + n_pos += n_offset; + e_elem = e_elem.offsetParent; + } + // margin correction in some browsers + if (b_ieMac) + n_pos += parseInt(document.body[s_coord.toLowerCase() + 'Margin']); + else if (b_safari) + n_pos -= n_offset; + + e_elem = e_elemRef; + while (e_elem != document.body) { + n_offset = e_elem["scroll" + s_coord]; + if (n_offset && e_elem.style.overflow == 'scroll') + n_pos -= n_offset; + e_elem = e_elem.parentNode; + } + return n_pos; +} + +function f_tcalRelDate (d_date, d_diff, s_units) { + var s_units = (s_units == 'y' ? 'FullYear' : 'Month'); + var d_result = new Date(d_date); + d_result['set' + s_units](d_date['get' + s_units]() + d_diff); + if (d_result.getDate() != d_date.getDate()) + d_result.setDate(0); + return ' onclick="A_TCALS[\'' + this.s_id + '\'].f_update(' + d_result.valueOf() + ')"'; +} + +function f_tcalHideAll () { + for (var i = 0; i < window.A_TCALSIDX.length; i++) + window.A_TCALSIDX[i].f_hide(); +} + +function f_tcalResetTime (d_date) { + d_date.setHours(0); + d_date.setMinutes(0); + d_date.setSeconds(0); + d_date.setMilliseconds(0); + return d_date; +} + +f_getElement = document.all ? + function (s_id) { return document.all[s_id] } : + function (s_id) { return document.getElementById(s_id) }; + +if (document.addEventListener) + window.addEventListener('scroll', f_tcalHideAll, false); +if (window.attachEvent) + window.attachEvent('onscroll', f_tcalHideAll); + +// global variables +var s_userAgent = navigator.userAgent.toLowerCase(), + re_webkit = /WebKit\/(\d+)/i; +var b_mac = s_userAgent.indexOf('mac') != -1, + b_ie5 = s_userAgent.indexOf('msie 5') != -1, + b_ie6 = s_userAgent.indexOf('msie 6') != -1 && s_userAgent.indexOf('opera') == -1; +var b_ieFix = b_ie5 || b_ie6, + b_ieMac = b_mac && b_ie5, + b_safari = b_mac && re_webkit.exec(s_userAgent) && Number(RegExp.$1) < 500; diff --git a/LANG_www/vicidial_br/call_report_export.php b/LANG_www/vicidial_br/call_report_export.php new file mode 100644 index 00000000..f4599238 --- /dev/null +++ b/LANG_www/vicidial_br/call_report_export.php @@ -0,0 +1,598 @@ +<?php +# call_report_export.php +# +# displays options to select for downloading of leads and their vicidial_log +# and/or vicidial_closer_log information by status, list_id and date range. +# downloads to a flat text file that is tab delimited +# +# Copyright (C) 2010 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2 +# +# CHANGES +# +# 90310-2247 - First build +# 90330-1343 - Added more debug info, bug fixes +# 90508-0644 - Changed to PHP long tags +# 90721-1137 - Added rank and owner as vicidial_list fields +# 91121-0253 - Added list name, list description and status name +# 100119-1039 - Filtered comments for \n newlines +# 100214-1421 - Sort menu alphabetically +# 100216-0042 - Added popup date selector +# + +require("dbconnect.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["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["user_group"])) {$user_group=$_GET["user_group"];} + elseif (isset($_POST["user_group"])) {$user_group=$_POST["user_group"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["run_export"])) {$run_export=$_GET["run_export"];} + elseif (isset($_POST["run_export"])) {$run_export=$_POST["run_export"];} +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 (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); +if ($qm_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $non_latin = $row[0]; + } +##### END SETTINGS LOOKUP ##### +########################################### + +$PHP_AUTH_USER = ereg_replace("[^-_0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^-_0-9a-zA-Z]","",$PHP_AUTH_PW); + +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7 and export_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 or no export report permission: |$PHP_AUTH_USER|\n"; + exit; + } + + +##### START RUN THE EXPORT AND OUTPUT FLAT DATA FILE ##### +if ($run_export > 0) + { + $US='_'; + $MT[0]=''; + $ip = getenv("REMOTE_ADDR"); + $NOW_DATE = date("Y-m-d"); + $NOW_TIME = date("Y-m-d H:i:s"); + $FILE_TIME = date("Ymd-His"); + $STARTtime = date("U"); + if (!isset($group)) {$group = '';} + if (!isset($query_date)) {$query_date = $NOW_DATE;} + if (!isset($end_date)) {$end_date = $NOW_DATE;} + + $campaign_ct = count($campaign); + $group_ct = count($group); + $user_group_ct = count($user_group); + $list_ct = count($list_id); + $status_ct = count($status); + $campaign_string='|'; + $group_string='|'; + $user_group_string='|'; + $list_string='|'; + $status_string='|'; + + $i=0; + while($i < $campaign_ct) + { + $campaign_string .= "$campaign[$i]|"; + $campaign_SQL .= "'$campaign[$i]',"; + $i++; + } + if ( (ereg("--NONE--",$campaign_string) ) or ($campaign_ct < 1) ) + { + $campaign_SQL = "campaign_id IN('')"; + $RUNcampaign=0; + } + else + { + $campaign_SQL = eregi_replace(",$",'',$campaign_SQL); + $campaign_SQL = "and vl.campaign_id IN($campaign_SQL)"; + $RUNcampaign++; + } + + $i=0; + while($i < $group_ct) + { + $group_string .= "$group[$i]|"; + $group_SQL .= "'$group[$i]',"; + $i++; + } + if ( (ereg("--NONE--",$group_string) ) or ($group_ct < 1) ) + { + $group_SQL = "''"; + $group_SQL = "campaign_id IN('')"; + $RUNgroup=0; + } + else + { + $group_SQL = eregi_replace(",$",'',$group_SQL); + $group_SQL = "and vl.campaign_id IN($group_SQL)"; + $RUNgroup++; + } + + $i=0; + while($i < $user_group_ct) + { + $user_group_string .= "$user_group[$i]|"; + $user_group_SQL .= "'$user_group[$i]',"; + $i++; + } + if ( (ereg("--ALL--",$user_group_string) ) or ($user_group_ct < 1) ) + { + $user_group_SQL = ""; + } + else + { + $user_group_SQL = eregi_replace(",$",'',$user_group_SQL); + $user_group_SQL = "and vl.user_group IN($user_group_SQL)"; + } + + $i=0; + while($i < $list_ct) + { + $list_string .= "$list_id[$i]|"; + $list_SQL .= "'$list_id[$i]',"; + $i++; + } + if ( (ereg("--ALL--",$list_string) ) or ($list_ct < 1) ) + { + $list_SQL = ""; + } + else + { + $list_SQL = eregi_replace(",$",'',$list_SQL); + $list_SQL = "and vi.list_id IN($list_SQL)"; + } + + $i=0; + while($i < $status_ct) + { + $status_string .= "$status[$i]|"; + $status_SQL .= "'$status[$i]',"; + $i++; + } + if ( (ereg("--ALL--",$status_string) ) or ($status_ct < 1) ) + { + $status_SQL = ""; + } + else + { + $status_SQL = eregi_replace(",$",'',$status_SQL); + $status_SQL = "and vl.status IN($status_SQL)"; + } + + + if ($DB > 0) + { + echo "<BR>\n"; + echo "$campaign_ct|$campaign_string|$campaign_SQL\n"; + echo "<BR>\n"; + echo "$group_ct|$group_string|$group_SQL\n"; + echo "<BR>\n"; + echo "$user_group_ct|$user_group_string|$user_group_SQL\n"; + echo "<BR>\n"; + echo "$list_ct|$list_string|$list_SQL\n"; + echo "<BR>\n"; + echo "$status_ct|$status_string|$status_SQL\n"; + echo "<BR>\n"; + } + + $outbound_calls=0; + $export_rows=''; + $k=0; + if ($RUNcampaign > 0) + { + $stmt = "SELECT vl.call_date,vl.phone_number,vl.status,vl.user,vu.full_name,vl.campaign_id,vi.vendor_lead_code,vi.source_id,vi.list_id,vi.gmt_offset_now,vi.phone_code,vi.phone_number,vi.title,vi.first_name,vi.middle_initial,vi.last_name,vi.address1,vi.address2,vi.address3,vi.city,vi.state,vi.province,vi.postal_code,vi.country_code,vi.gender,vi.date_of_birth,vi.alt_phone,vi.email,vi.security_phrase,vi.comments,vl.length_in_sec,vl.user_group,vl.alt_dial,vi.rank,vi.owner,vi.lead_id from vicidial_users vu,vicidial_log vl,vicidial_list vi where vl.call_date >= '$query_date 00:00:00' and vl.call_date <= '$end_date 23:59:59' and vu.user=vl.user and vi.lead_id=vl.lead_id $list_SQL $campaign_SQL $user_group_SQL $status_SQL order by vl.call_date limit 100000;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $outbound_to_print = mysql_num_rows($rslt); + if ($outbound_to_print < 1) + { + echo "There are no outbound calls during this time period for these parameters\n"; + exit; + } + else + { + $i=0; + while ($i < $outbound_to_print) + { + $row=mysql_fetch_row($rslt); + + $row[29] = preg_replace("/\n|\r/",'!N',$row[29]); + + $export_status[$k] = $row[2]; + $export_list_id[$k] = $row[8]; + $export_rows[$k] = "$row[0]\t$row[1]\t$row[2]\t$row[3]\t$row[4]\t$row[5]\t$row[6]\t$row[7]\t$row[8]\t$row[9]\t$row[10]\t$row[11]\t$row[12]\t$row[13]\t$row[14]\t$row[15]\t$row[16]\t$row[17]\t$row[18]\t$row[19]\t$row[20]\t$row[21]\t$row[22]\t$row[23]\t$row[24]\t$row[25]\t$row[26]\t$row[27]\t$row[28]\t$row[29]\t$row[30]\t$row[31]\t$row[32]\t$row[33]\t$row[34]\t$row[35]\t"; + $i++; + $k++; + $outbound_calls++; + } + } + } + + if ($RUNgroup > 0) + { + $stmtA = "SELECT vl.call_date,vl.phone_number,vl.status,vl.user,vu.full_name,vl.campaign_id,vi.vendor_lead_code,vi.source_id,vi.list_id,vi.gmt_offset_now,vi.phone_code,vi.phone_number,vi.title,vi.first_name,vi.middle_initial,vi.last_name,vi.address1,vi.address2,vi.address3,vi.city,vi.state,vi.province,vi.postal_code,vi.country_code,vi.gender,vi.date_of_birth,vi.alt_phone,vi.email,vi.security_phrase,vi.comments,vl.length_in_sec,vl.user_group,vl.queue_seconds,vi.rank,vi.owner,vi.lead_id from vicidial_users vu,vicidial_closer_log vl,vicidial_list vi where vl.call_date >= '$query_date 00:00:00' and vl.call_date <= '$end_date 23:59:59' and vu.user=vl.user and vi.lead_id=vl.lead_id $list_SQL $group_SQL $user_group_SQL $status_SQL order by vl.call_date limit 100000;"; + $rslt=mysql_query($stmtA, $link); + if ($DB) {echo "$stmt\n";} + $inbound_to_print = mysql_num_rows($rslt); + if ( ($inbound_to_print < 1) and ($outbound_calls < 1) ) + { + echo "There are no inbound calls during this time period for these parameters\n"; + exit; + } + else + { + $i=0; + while ($i < $inbound_to_print) + { + $row=mysql_fetch_row($rslt); + + $row[29] = preg_replace("/\n|\r/",'!N',$row[29]); + + $export_status[$k] = $row[2]; + $export_list_id[$k] = $row[8]; + $export_rows[$k] = "$row[0]\t$row[1]\t$row[2]\t$row[3]\t$row[4]\t$row[5]\t$row[6]\t$row[7]\t$row[8]\t$row[9]\t$row[10]\t$row[11]\t$row[12]\t$row[13]\t$row[14]\t$row[15]\t$row[16]\t$row[17]\t$row[18]\t$row[19]\t$row[20]\t$row[21]\t$row[22]\t$row[23]\t$row[24]\t$row[25]\t$row[26]\t$row[27]\t$row[28]\t$row[29]\t$row[30]\t$row[31]\t$row[32]\t$row[33]\t$row[34]\t$row[35]\t"; + $i++; + $k++; + } + } + } + + + if ( ($outbound_to_print > 0) or ($inbound_to_print > 0) ) + { + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|$stmtA|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$PHP_AUTH_USER', ip_address='$ip', event_section='LEADS', event_type='EXPORT', record_id='', event_code='ADMIN EXPORT CALLS REPORT', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $TXTfilename = "EXPORT_CALL_REPORT_$FILE_TIME.txt"; + + // We'll be outputting a TXT file + header('Content-type: application/octet-stream'); + + // It will be called LIST_101_20090209-121212.txt + header("Content-Disposition: attachment; filename=\"$TXTfilename\""); + header('Expires: 0'); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header('Pragma: public'); + ob_clean(); + flush(); + + $i=0; + while ($k > $i) + { + $ex_list_name=''; + $ex_list_description=''; + $stmt = "SELECT list_name,list_description FROM vicidial_lists where list_id='$export_list_id[$i]';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $ex_list_ct = mysql_num_rows($rslt); + if ($ex_list_ct > 0) + { + $row=mysql_fetch_row($rslt); + $ex_list_name = $row[0]; + $ex_list_description = $row[1]; + } + + $ex_status_name=''; + $stmt = "SELECT status_name FROM vicidial_statuses where status='$export_status[$i]';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $ex_list_ct = mysql_num_rows($rslt); + if ($ex_list_ct > 0) + { + $row=mysql_fetch_row($rslt); + $ex_status_name = $row[0]; + } + else + { + $stmt = "SELECT status_name FROM vicidial_campaign_statuses where status='$export_status[$i]';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $ex_list_ct = mysql_num_rows($rslt); + if ($ex_list_ct > 0) + { + $row=mysql_fetch_row($rslt); + $ex_status_name = $row[0]; + } + } + + echo "$export_rows[$i]$ex_list_name\t$ex_list_description\t$ex_status_name\r\n"; + $i++; + } + } + else + { + echo "There are no calls during this time period for these parameters\n"; + exit; + } + } +##### END RUN THE EXPORT AND OUTPUT FLAT DATA FILE ##### + + +else + { + $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;} + if (!isset($end_date)) {$end_date = $NOW_DATE;} + + $stmt="select campaign_id from vicidial_campaigns order by campaign_id;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $campaigns_to_print = mysql_num_rows($rslt); + $i=0; + $LISTcampaigns[$i]='---NONE---'; + $i++; + $campaigns_to_print++; + while ($i < $campaigns_to_print) + { + $row=mysql_fetch_row($rslt); + $LISTcampaigns[$i] =$row[0]; + $i++; + } + + $stmt="select group_id from vicidial_inbound_groups order by group_id;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $groups_to_print = mysql_num_rows($rslt); + $i=0; + $LISTgroups[$i]='---NONE---'; + $i++; + $groups_to_print++; + while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $LISTgroups[$i] =$row[0]; + $i++; + } + + $stmt="select user_group from vicidial_user_groups order by user_group;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $user_groups_to_print = mysql_num_rows($rslt); + $i=0; + $LISTuser_groups[$i]='---ALL---'; + $i++; + $user_groups_to_print++; + while ($i < $user_groups_to_print) + { + $row=mysql_fetch_row($rslt); + $LISTuser_groups[$i] =$row[0]; + $i++; + } + + $stmt="select list_id from vicidial_lists order by list_id;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $lists_to_print = mysql_num_rows($rslt); + $i=0; + $LISTlists[$i]='---ALL---'; + $i++; + $lists_to_print++; + while ($i < $lists_to_print) + { + $row=mysql_fetch_row($rslt); + $LISTlists[$i] =$row[0]; + $i++; + } + + $stmt="select status from vicidial_statuses order by status;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $statuses_to_print = mysql_num_rows($rslt); + $i=0; + $LISTstatus[$i]='---ALL---'; + $i++; + $statuses_to_print++; + while ($i < $statuses_to_print) + { + $row=mysql_fetch_row($rslt); + $LISTstatus[$i] =$row[0]; + $i++; + } + + $stmt="select distinct status from vicidial_campaign_statuses order by status;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $Cstatuses_to_print = mysql_num_rows($rslt); + $j=0; + while ($j < $Cstatuses_to_print) + { + $row=mysql_fetch_row($rslt); + $LISTstatus[$i] =$row[0]; + $i++; + $j++; + } + $statuses_to_print = ($statuses_to_print + $Cstatuses_to_print); + + echo "<HTML><HEAD>\n"; + + echo "<script language=\"JavaScript\" src=\"calendar_db.js\"></script>\n"; + echo "<link rel=\"stylesheet\" href=\"calendar.css\">\n"; + + echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n"; + echo "<TITLE>ADMINISTRATION: Export Calls Report"; + + ##### BEGIN Set variables to make header show properly ##### + $ADD = '100'; + $hh = 'lists'; + $LOGast_admin_access = '1'; + $SSoutbound_autodial_active = '1'; + $ADMIN = 'admin.php'; + $page_width='770'; + $section_width='750'; + $header_font_size='3'; + $subheader_font_size='2'; + $subcamp_font_size='2'; + $header_selected_bold='<b>'; + $header_nonselected_bold=''; + $lists_color = '#FFFF99'; + $lists_font = 'BLACK'; + $lists_color = '#E6E6E6'; + $subcamp_color = '#C6C6C6'; + ##### END Set variables to make header show properly ##### + + require("admin_header.php"); + + + echo "<CENTER><BR>\n"; + echo "<FONT SIZE=3 FACE=\"Arial,Helvetica\"><B>Export Calls Report</B></FONT><BR><BR>\n"; + echo "<FORM ACTION=\"$PHP_SELF\" METHOD=GET name=vicidial_report id=vicidial_report>\n"; + echo "<INPUT TYPE=HIDDEN NAME=DB VALUE=\"$DB\">"; + echo "<INPUT TYPE=HIDDEN NAME=run_export VALUE=\"1\">"; + echo "<TABLE BORDER=0 CELLSPACING=8><TR><TD ALIGN=LEFT VALIGN=TOP ROWSPAN=3>\n"; + + echo "<font class=\"select_bold\"><B>Date Range:</B></font><BR><CENTER>\n"; + echo "<INPUT TYPE=TEXT NAME=query_date SIZE=10 MAXLENGTH=10 VALUE=\"$query_date\">"; + + ?> + <script language="JavaScript"> + var o_cal = new tcal ({ + // form name + 'formname': 'vicidial_report', + // input name + 'controlname': 'query_date' + }); + o_cal.a_tpl.yearscroll = false; + // o_cal.a_tpl.weekstart = 1; // Monday week start + </script> + <?php + + echo "<BR>to<BR>\n"; + echo "<INPUT TYPE=TEXT NAME=end_date SIZE=10 MAXLENGTH=10 VALUE=\"$end_date\">"; + + ?> + <script language="JavaScript"> + var o_cal = new tcal ({ + // form name + 'formname': 'vicidial_report', + // input name + 'controlname': 'end_date' + }); + o_cal.a_tpl.yearscroll = false; + // o_cal.a_tpl.weekstart = 1; // Monday week start + </script> + <?php + + echo "</TD><TD ALIGN=LEFT VALIGN=TOP ROWSPAN=2>\n"; + echo "<font class=\"select_bold\"><B>Campaigns:</B></font><BR><CENTER>\n"; + echo "<SELECT SIZE=15 NAME=campaign[] multiple>\n"; + $o=0; + while ($campaigns_to_print > $o) + { + if (ereg("\|$LISTcampaigns[$o]\|",$campaign_string)) + {echo "<option selected value=\"$LISTcampaigns[$o]\">$LISTcampaigns[$o]</option>\n";} + else + {echo "<option value=\"$LISTcampaigns[$o]\">$LISTcampaigns[$o]</option>\n";} + $o++; + } + echo "</SELECT>\n"; + + echo "</TD><TD ALIGN=LEFT VALIGN=TOP ROWSPAN=3>\n"; + echo "<font class=\"select_bold\"><B>Inbound Groups:</B></font><BR><CENTER>\n"; + echo "<SELECT SIZE=15 NAME=group[] multiple>\n"; + $o=0; + while ($groups_to_print > $o) + { + if (ereg("\|$LISTgroups[$o]\|",$group_string)) + {echo "<option selected value=\"$LISTgroups[$o]\">$LISTgroups[$o]</option>\n";} + else + {echo "<option value=\"$LISTgroups[$o]\">$LISTgroups[$o]</option>\n";} + $o++; + } + echo "</SELECT>\n"; + echo "</TD><TD ALIGN=LEFT VALIGN=TOP ROWSPAN=3>\n"; + echo "<font class=\"select_bold\"><B>Lists:</B></font><BR><CENTER>\n"; + echo "<SELECT SIZE=15 NAME=list_id[] multiple>\n"; + $o=0; + while ($lists_to_print > $o) + { + if (ereg("\|$LISTlists[$o]\|",$list_string)) + {echo "<option selected value=\"$LISTlists[$o]\">$LISTlists[$o]</option>\n";} + else + {echo "<option value=\"$LISTlists[$o]\">$LISTlists[$o]</option>\n";} + $o++; + } + echo "</SELECT>\n"; + echo "</TD><TD ALIGN=LEFT VALIGN=TOP ROWSPAN=3>\n"; + echo "<font class=\"select_bold\"><B>Statuses:</B></font><BR><CENTER>\n"; + echo "<SELECT SIZE=15 NAME=status[] multiple>\n"; + $o=0; + while ($statuses_to_print > $o) + { + if (ereg("\|$LISTstatus[$o]\|",$list_string)) + {echo "<option selected value=\"$LISTstatus[$o]\">$LISTstatus[$o]</option>\n";} + else + {echo "<option value=\"$LISTstatus[$o]\">$LISTstatus[$o]</option>\n";} + $o++; + } + echo "</SELECT>\n"; + echo "</TD><TD ALIGN=LEFT VALIGN=TOP ROWSPAN=3>\n"; + echo "<font class=\"select_bold\"><B>User Groups:</B></font><BR><CENTER>\n"; + echo "<SELECT SIZE=15 NAME=user_group[] multiple>\n"; + $o=0; + while ($user_groups_to_print > $o) + { + if (ereg("\|$LISTuser_groups[$o]\|",$user_group_string)) + {echo "<option selected value=\"$LISTuser_groups[$o]\">$LISTuser_groups[$o]</option>\n";} + else + {echo "<option value=\"$LISTuser_groups[$o]\">$LISTuser_groups[$o]</option>\n";} + $o++; + } + echo "</SELECT>\n"; + + echo "</TD></TR><TR></TD><TD ALIGN=LEFT VALIGN=TOP COLSPAN=2>\n"; + + echo "</TD></TR><TR></TD><TD ALIGN=LEFT VALIGN=TOP COLSPAN=3>\n"; + echo "<INPUT TYPE=SUBMIT NAME=SUBMIT VALUE=SUBMIT>\n"; + echo "</TD></TR></TABLE>\n"; + echo "</FORM>\n\n"; + + } +exit; + +?> \ No newline at end of file diff --git a/LANG_www/vicidial_br/count.htm b/LANG_www/vicidial_br/count.htm new file mode 100644 index 00000000..51f8a361 --- /dev/null +++ b/LANG_www/vicidial_br/count.htm @@ -0,0 +1 @@ + diff --git a/LANG_www/vicidial_br/dbconnect.php b/LANG_www/vicidial_br/dbconnect.php new file mode 100644 index 00000000..ca505cc0 --- /dev/null +++ b/LANG_www/vicidial_br/dbconnect.php @@ -0,0 +1,63 @@ +<?php +# +# dbconnect.php version 2.2.0 +# +# database connection settings and some global web settings +# +# Copyright (C) 2010 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2 +# +if ( file_exists("/etc/astguiclient.conf") ) + { + $DBCagc = file("/etc/astguiclient.conf"); + foreach ($DBCagc as $DBCline) + { + $DBCline = preg_replace("/ |>|\n|\r|\t|\#.*|;.*/","",$DBCline); + if (ereg("^PATHlogs", $DBCline)) + {$PATHlogs = $DBCline; $PATHlogs = preg_replace("/.*=/","",$PATHlogs);} + if (ereg("^PATHweb", $DBCline)) + {$WeBServeRRooT = $DBCline; $WeBServeRRooT = preg_replace("/.*=/","",$WeBServeRRooT);} + if (ereg("^VARserver_ip", $DBCline)) + {$WEBserver_ip = $DBCline; $WEBserver_ip = preg_replace("/.*=/","",$WEBserver_ip);} + if (ereg("^VARDB_server", $DBCline)) + {$VARDB_server = $DBCline; $VARDB_server = preg_replace("/.*=/","",$VARDB_server);} + if (ereg("^VARDB_database", $DBCline)) + {$VARDB_database = $DBCline; $VARDB_database = preg_replace("/.*=/","",$VARDB_database);} + if (ereg("^VARDB_user", $DBCline)) + {$VARDB_user = $DBCline; $VARDB_user = preg_replace("/.*=/","",$VARDB_user);} + if (ereg("^VARDB_pass", $DBCline)) + {$VARDB_pass = $DBCline; $VARDB_pass = preg_replace("/.*=/","",$VARDB_pass);} + if (ereg("^VARDB_port", $DBCline)) + {$VARDB_port = $DBCline; $VARDB_port = preg_replace("/.*=/","",$VARDB_port);} + } + } +else + { + #defaults for DB connection + $VARDB_server = 'localhost'; + $VARDB_port = '3306'; + $VARDB_user = 'cron'; + $VARDB_pass = '1234'; + $VARDB_database = '1234'; + $WeBServeRRooT = '/usr/local/apache2/htdocs'; + } + +$link=mysql_connect("$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass"); +if (!$link) + { + die('MySQL connect ERROR: ' . mysql_error()); + } +mysql_select_db("$VARDB_database"); + +$local_DEF = 'Local/'; +$conf_silent_prefix = '7'; +$local_AMP = '@'; +$ext_context = 'demo'; +$recording_exten = '8309'; +$WeBRooTWritablE = '1'; +$non_latin = '0'; # set to 1 for UTF rules +$AM_shift_BEGIN = '03:45:00'; +$AM_shift_END = '17:45:00'; +$PM_shift_BEGIN = '17:45:01'; +$PM_shift_END = '23:59:59'; +$admin_qc_enabled = '0'; +?> diff --git a/LANG_www/vicidial_br/fcstats.php b/LANG_www/vicidial_br/fcstats.php new file mode 100644 index 00000000..555f3a40 --- /dev/null +++ b/LANG_www/vicidial_br/fcstats.php @@ -0,0 +1,620 @@ +<?php +# fcstats.php +# +# Copyright (C) 2010 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2 +# +# CHANGES +# +# 70813-1526 - First Build +# 71008-1436 - Added shift to be defined in dbconnect.php +# 71217-1128 - Changed method for calculating stats +# 71228-1140 - added percentages, cross-day start/stop +# 80328-1139 - adapted for basic fronter/closer stats +# 90310-2132 - Added admin header +# 90508-0644 - Changed to PHP long tags +# 100214-1421 - Sort menu alphabetically +# 100216-0042 - Added popup date selector +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["shift"])) {$shift=$_GET["shift"];} + elseif (isset($_POST["shift"])) {$shift=$_POST["shift"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} + +$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';} + +$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";} +$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 "Nome ou Senha inválidos: |$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 = 'CL_TEST_L';} +if (!isset($query_date)) {$query_date = $NOW_DATE;} + +$stmt="select group_id from vicidial_inbound_groups order by group_id;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } +?> + +<HTML> +<HEAD> +<STYLE type="text/css"> +<!-- + .green {color: white; background-color: green} + .red {color: white; background-color: red} + .blue {color: white; background-color: blue} + .purple {color: white; background-color: purple} +--> + </STYLE> + +<script language="JavaScript" src="calendar_db.js"></script> +<link rel="stylesheet" href="calendar.css"> + +<?php +echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n"; +echo "<TITLE>In-Group Fronter-Closer Stats Report\n"; + + $short_header=1; + + require("admin_header.php"); + +echo "
"; + +echo "
\n"; +echo ""; + +?> + +\n"; + $o=0; + while ($groups_to_print > $o) + { + if ($groups[$o] == $group) {echo "\n";} + else {echo "\n";} + $o++; + } +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "           ALTERAR | RELATÓRIOS \n"; +echo "
\n\n"; + +echo "
\n\n";
+
+
+if (!$group)
+{
+echo "\n\n";
+echo "PLEASE SELECT AN IN-GROUP AND DATE ABOVE THEN CLICK ENVIAR\n";
+}
+
+else
+{
+#	$time_BEGIN=$AM_shift_BEGIN;
+#	$time_END=$AM_shift_END;
+#$query_date_BEGIN = "$query_date $time_BEGIN";   
+#$query_date_END = "$query_date $time_END";
+
+$Cqdate = explode('-',$query_date);
+
+if ($shift == 'AM') 
+	{
+	$query_date_BEGIN = date("Y-m-d H:i:s", mktime(1, 0, 0, $Cqdate[1], $Cqdate[2], $Cqdate[0]));
+	$query_date_END = date("Y-m-d H:i:s", mktime(17, 45, 0, $Cqdate[1], $Cqdate[2], $Cqdate[0]));
+	}
+if ($shift == 'PM') 
+	{
+	$query_date_BEGIN = date("Y-m-d H:i:s", mktime(17, 45, 1, $Cqdate[1], $Cqdate[2], $Cqdate[0]));
+	$query_date_END = date("Y-m-d H:i:s", mktime(24, 59, 59, $Cqdate[1], $Cqdate[2], $Cqdate[0]));
+	}
+if ($shift == 'ALL') 
+	{
+	$query_date_BEGIN = date("Y-m-d H:i:s", mktime(1, 0, 0, $Cqdate[1], $Cqdate[2], $Cqdate[0]));
+	$query_date_END = date("Y-m-d H:i:s", mktime(24, 59, 59, $Cqdate[1], $Cqdate[2], $Cqdate[0]));
+	}
+
+echo "In-Group Fronter-Closer Stats Report                      $NOW_TIME\n";
+
+echo "\n";
+echo "---------- TOTALS FOR $query_date_BEGIN to $query_date_END\n";
+
+$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id='" . mysql_real_escape_string($group) . "' and status = 'SALE';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$A1_points = ($row[0] * 1);
+$A1_points =	sprintf("%10s", $A1_points);
+$A1_tally =	sprintf("%10s", $row[0]);
+
+$TOT_tally = ($A1_tally + $A2_tally + $A3_tally + $A4_tally);
+$TOT_points = ($A1_points + $A2_points + $A3_points + $A4_points);
+$TOT_tally =	sprintf("%10s", $TOT_tally);
+$TOT_points =	sprintf("%10s", $TOT_points);
+
+echo "STATUS   CUSTOMERS\n";
+echo "SALES:   $A1_tally\n";
+
+echo "\n";
+
+
+
+
+
+
+
+
+
+##############################
+#########  FRONTER STATS
+
+$TOTagents=0;
+$TOTcalls=0;
+$TOTsales=0;
+$totA1=0;
+$totA2=0;
+$totA3=0;
+$totA4=0;
+$totA5=0;
+$totA6=0;
+$totA7=0;
+$totA8=0;
+$totA9=0;
+$totDROP=0;
+$totOTHER=0;
+
+echo "\n";
+echo "---------- FRONTER STATS\n";
+echo "+--------------------------+-------+--------+--------+------+------+------+\n";
+echo "| AGENTE                    |SUCCESS| XFERS  |SUCCESS%| SALE | DROP |OTHER |\n";
+echo "+--------------------------+-------+--------+--------+------+------+------+\n";
+
+#$stmt="select vicidial_xfer_log.user,full_name,count(*) from vicidial_xfer_log,vicidial_users where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and  campaign_id='" . mysql_real_escape_string($group) . "' and vicidial_xfer_log.user is not null and vicidial_xfer_log.user=vicidial_users.user group by vicidial_xfer_log.user;";
+$stmt="select user,count(distinct lead_id) from vicidial_xfer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and  campaign_id='" . mysql_real_escape_string($group) . "' and user is not null group by user;";
+if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");}
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$users_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $users_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+
+	$TOTcalls = ($TOTcalls + $row[1]);
+
+	$userRAW[$i]=$row[0];
+	$user[$i] =	sprintf("%-6s", $row[0]);while(strlen($user[$i])>6) {$user[$i] = substr("$user[$i]", 0, -1);}
+	$USERcallsRAW[$i] =	$row[1];
+	$USERcalls[$i] =	sprintf("%6s", $row[1]);
+
+	$i++;
+	}
+
+$i=0;
+while ($i < $users_to_print)
+	{
+	$stmt="select full_name from vicidial_users where user='$userRAW[$i]';";
+	if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");}
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$names_to_print = mysql_num_rows($rslt);
+	if ($names_to_print > 0)
+		{
+		$row=mysql_fetch_row($rslt);
+		if ($non_latin < 1)
+			{
+			 $full_name[$i] =	sprintf("%-15s", $row[0]); while(strlen($full_name[$i])>15) {$full_name[$i] = substr("$full_name[$i]", 0, -1);}	
+			}
+		else
+			{
+			 $full_name[$i] =	sprintf("%-45s", $row[0]); while(mb_strlen($full_name[$i],'utf-8')>15) {$full_name[$i] = mb_substr("$full_name[$i]", 0, -1,'utf-8');}	
+			}
+		}
+	else
+		{$full_name[$i] = '               ';}
+
+	$A1=0; $A2=0; $A3=0; $A4=0; $A5=0; $A6=0; $A7=0; $A8=0; $A9=0; $DROP=0; $OTHER=0; $sales=0; 
+	$stmt="select vc.status,count(distinct vc.lead_id) from vicidial_xfer_log vx, vicidial_closer_log vc where vx.call_date >= '$query_date_BEGIN' and vx.call_date <= '$query_date_END' and vc.call_date >= '$query_date_BEGIN' and vc.call_date <= '$query_date_END' and  vc.campaign_id='" . mysql_real_escape_string($group) . "' and vx.campaign_id='" . mysql_real_escape_string($group) . "' and vx.user='$userRAW[$i]' and vc.lead_id=vx.lead_id and vc.xfercallid=vx.xfercallid group by vc.status;";
+	if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");}
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$lead_ids_to_print = mysql_num_rows($rslt);
+	$j=0;
+	while ($j < $lead_ids_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		$recL=0;
+		if ( ($row[0]=='SALE') and ($recL < 1) ) {$A1=$row[1]; $recL++; $sales=($sales + $row[1]);}
+	#	if ( ($row[0]=='A2') and ($recL < 1) ) {$A2=$row[1]; $recL++; $sales=($sales + $row[1]);}
+	#	if ( ($row[0]=='A3') and ($recL < 1) ) {$A3=$row[1]; $recL++; $sales=($sales + $row[1]);}
+	#	if ( ($row[0]=='A4') and ($recL < 1) ) {$A4=$row[1]; $recL++; $sales=($sales + $row[1]);}
+	#	if ( ($row[0]=='A5') and ($recL < 1) ) {$A5=$row[1]; $recL++;}
+	#	if ( ($row[0]=='A6') and ($recL < 1) ) {$A6=$row[1]; $recL++;}
+	#	if ( ($row[0]=='A7') and ($recL < 1) ) {$A7=$row[1]; $recL++;}
+	#	if ( ($row[0]=='A8') and ($recL < 1) ) {$A8=$row[1]; $recL++;}
+	#	if ( ($row[0]=='A9') and ($recL < 1) ) {$A9=$row[1]; $recL++;}
+		if ( ($row[0]=='DROP') and ($recL < 1) ) {$DROP=$row[1]; $recL++;}
+		if ($recL < 1) {$OTHER=($row[1] + $OTHER); $recL++;}
+		$j++;
+		}
+
+	$totA1 = ($totA1 + $A1);
+	$totA2 = ($totA2 + $A2);
+	$totA3 = ($totA3 + $A3);
+	$totA4 = ($totA4 + $A4);
+	$totA5 = ($totA5 + $A5);
+	$totA6 = ($totA6 + $A6);
+	$totA7 = ($totA7 + $A7);
+	$totA8 = ($totA8 + $A8);
+	$totA9 = ($totA9 + $A9);
+	$totDROP = ($totDROP + $DROP);
+	$totOTHER = ($totOTHER + $OTHER);
+	$TOTsales = ($TOTsales + $sales);
+
+	if ( ($USERcallsRAW[$i] > 0) and ($sales > 0) ) {$Spct = ( ($sales / $USERcallsRAW[$i]) * 100);}
+		else {$Spct=0;}
+	$Spct = round($Spct, 2);
+	$Spct =	sprintf("%01.2f", $Spct);
+	
+
+	$A1 =	sprintf("%4s", $A1);
+	$A2 =	sprintf("%4s", $A2);
+	$A3 =	sprintf("%4s", $A3);
+	$A4 =	sprintf("%4s", $A4);
+	$A5 =	sprintf("%4s", $A5);
+	$A6 =	sprintf("%4s", $A6);
+	$A7 =	sprintf("%4s", $A7);
+	$A8 =	sprintf("%4s", $A8);
+	$A9 =	sprintf("%4s", $A9);
+	$DROP =	sprintf("%4s", $DROP);
+	$OTHER =	sprintf("%4s", $OTHER);
+	$sales =	sprintf("%5s", $sales);
+	$Spct =	sprintf("%6s", $Spct);
+
+	echo "| $user[$i] - $full_name[$i] | $sales | $USERcalls[$i] | $Spct%| $A1 | $DROP | $OTHER |\n";
+
+	$i++;
+	}
+
+
+if ( ($TOTcalls > 0) and ($TOTsales > 0) ) {$totSpct = ( ($TOTsales / $TOTcalls) * 100);}
+	else {$totSpct=0;}
+$totSpct = round($totSpct, 2);
+$totSpct =	sprintf("%01.2f", $totSpct);
+$totSpct =	sprintf("%6s", $totSpct);
+	
+$TOTagents =	sprintf("%6s", $i);
+$TOTcalls =		sprintf("%6s", $TOTcalls);
+$TOTsales =		sprintf("%5s", $TOTsales);
+$totA1 =		sprintf("%5s", $totA1);
+$totA2 =		sprintf("%5s", $totA2);
+$totA3 =		sprintf("%5s", $totA3);
+$totA4 =		sprintf("%5s", $totA4);
+$totA5 =		sprintf("%5s", $totA5);
+$totA6 =		sprintf("%5s", $totA6);
+$totA7 =		sprintf("%5s", $totA7);
+$totA8 =		sprintf("%5s", $totA8);
+$totA9 =		sprintf("%5s", $totA9);
+$totDROP =		sprintf("%5s", $totDROP);
+$totOTHER =		sprintf("%5s", $totOTHER);
+
+
+$stmt="select avg(queue_seconds) from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$AVGwait = $row[0];
+$AVGwait_M = ($AVGwait / 60);
+$AVGwait_M = round($AVGwait_M, 2);
+$AVGwait_M_int = intval("$AVGwait_M");
+$AVGwait_S = ($AVGwait_M - $AVGwait_M_int);
+$AVGwait_S = ($AVGwait_S * 60);
+$AVGwait_S = round($AVGwait_S, 0);
+if ($AVGwait_S < 10) {$AVGwait_S = "0$AVGwait_S";}
+$AVGwait_MS = "$AVGwait_M_int:$AVGwait_S";
+$AVGwait =		sprintf("%6s", $AVGwait_MS);
+
+
+echo "+--------------------------+-------+--------+--------+------+------+------+\n";
+echo "| TOTAL FRONTERS: $TOTagents   | $TOTsales | $TOTcalls | $totSpct%|$totA1 |$totDROP |$totOTHER |\n";
+echo "+--------------------------+-------+--------+--------+------+------+------+\n";
+echo "|                          Average time in Queue for customers:    $AVGwait |\n";
+echo "+--------------------------+-------+--------+--------+------+------+------+\n";
+
+
+
+
+
+##############################
+#########  CLOSER STATS
+
+$TOTagents=0;
+$TOTcalls=0;
+$totA1=0;
+$totA2=0;
+$totA3=0;
+$totA4=0;
+$totA5=0;
+$totA6=0;
+$totA7=0;
+$totA8=0;
+$totA9=0;
+$totDROP=0;
+$totOTHER=0;
+$TOTsales=0;
+
+echo "\n";
+echo "---------- CLOSER STATS\n";
+echo "+--------------------------+--------+------+------+------+------+-------+\n";
+echo "| AGENTE                    | CALLS  | SALE | DROP |OTHER | SALE | CONV %|\n";
+echo "+--------------------------+--------+------+------+------+------+-------+\n";
+
+$stmt="select user,count(*) from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and  campaign_id='" . mysql_real_escape_string($group) . "' and user is not null group by user;";
+if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");}
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$users_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $users_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+
+	$TOTcalls = ($TOTcalls + $row[1]);
+	$userRAW[$i]=$row[0];
+	$user[$i] =	sprintf("%-6s", $row[0]);while(strlen($user[$i])>6) {$user[$i] = substr("$user[$i]", 0, -1);}
+	$USERcalls[$i] =	sprintf("%6s", $row[1]);
+	$USERcallsRAW[$i] =	$row[1];
+
+	$i++;
+	}
+
+$i=0;
+while ($i < $users_to_print)
+	{
+	$stmt="select full_name from vicidial_users where user='$userRAW[$i]';";
+	if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");}
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$names_to_print = mysql_num_rows($rslt);
+	if ($names_to_print > 0)
+		{
+		$row=mysql_fetch_row($rslt);
+		if ($non_latin < 1)
+			{
+			 $full_name[$i] =	sprintf("%-15s", $row[0]); while(strlen($full_name[$i])>15) {$full_name[$i] = substr("$full_name[$i]", 0, -1);}	
+			}
+		else
+			{
+			 $full_name[$i] =	sprintf("%-45s", $row[0]); while(mb_strlen($full_name[$i],'utf-8')>15) {$full_name[$i] = mb_substr("$full_name[$i]", 0, -1,'utf-8');}	
+			}
+		}
+	else
+		{$full_name[$i] = '               ';}
+
+	$A1=0; $A2=0; $A3=0; $A4=0; $A5=0; $A6=0; $A7=0; $A8=0; $A9=0; $DROP=0; $OTHER=0; $sales=0; $uTOP=0; $uBOT=0; $points=0;
+	$stmt="select status,count(*) from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and  campaign_id='" . mysql_real_escape_string($group) . "' and user='$userRAW[$i]' group by status;";
+	if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");}
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$lead_ids_to_print = mysql_num_rows($rslt);
+	$j=0;
+	while ($j < $lead_ids_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		$recL=0;
+		if ( ($row[0]=='SALE') and ($recL < 1) ) 
+			{
+			$A1=$row[1]; $recL++; 
+			$sales=($sales + $row[1]);
+			$points = ($points + ($row[1] * 1) );
+			}
+		if ( ($row[0]=='A2') and ($recL < 1) ) 
+			{
+			$A2=$row[1]; $recL++; 
+			$sales=($sales + $row[1]); 
+			$uTOP=($uTOP + $row[1]);
+			$points = ($points + ($row[1] * 2) );
+			}
+		if ( ($row[0]=='A3') and ($recL < 1) ) 
+			{
+			$A3=$row[1]; $recL++; 
+			$sales=($sales + $row[1]); 
+			$uBOT=($uBOT + $row[1]);
+			$points = ($points + ($row[1] * 2) );
+			}
+		if ( ($row[0]=='A4') and ($recL < 1) ) 
+			{
+			$A4=$row[1]; $recL++; 
+			$sales=($sales + $row[1]); 
+			$uTOP=($uTOP + $row[1]); 
+			$uBOT=($uBOT + $row[1]);
+			$points = ($points + ($row[1] * 3) );
+			}
+#		if ( ($row[0]=='A5') and ($recL < 1) ) {$A5=$row[1]; $recL++;}
+#		if ( ($row[0]=='A6') and ($recL < 1) ) {$A6=$row[1]; $recL++;}
+#		if ( ($row[0]=='A7') and ($recL < 1) ) {$A7=$row[1]; $recL++;}
+#		if ( ($row[0]=='A8') and ($recL < 1) ) {$A8=$row[1]; $recL++;}
+#		if ( ($row[0]=='A9') and ($recL < 1) ) {$A9=$row[1]; $recL++;}
+		if ( ($row[0]=='DROP') and ($recL < 1) ) {$DROP=$row[1]; $recL++;}
+		if ($recL < 1) {$OTHER=($row[1] + $OTHER); $recL++;}
+		
+		$j++;
+		}
+
+	$totA1 = ($totA1 + $A1);	$TOTsales = ($TOTsales + $A1);
+	$totA2 = ($totA2 + $A2);	$TOTsales = ($TOTsales + $A2);	$totTOP = ($totTOP + $A2);
+	$totA3 = ($totA3 + $A3);	$TOTsales = ($TOTsales + $A3);	$totBOT = ($totBOT + $A3);
+	$totA4 = ($totA4 + $A4);	$TOTsales = ($TOTsales + $A4);	$totTOP = ($totTOP + $A4);	$totBOT = ($totBOT + $A4);
+	$totA5 = ($totA5 + $A5);
+	$totA6 = ($totA6 + $A6);
+	$totA7 = ($totA7 + $A7);
+	$totA8 = ($totA8 + $A8);
+	$totA9 = ($totA9 + $A9);
+	$totDROP = ($totDROP + $DROP);
+	$totOTHER = ($totOTHER + $OTHER);
+	$totPOINTS = ($totPOINTS + $points);
+
+	if ( ($USERcallsRAW[$i] > 0) and ($sales > 0) ) {$Cpct = ( ($sales / ( ($USERcallsRAW[$i] - 0) - $DROP) ) * 100);}
+		else {$Cpct=0;}
+	$Cpct = round($Cpct, 2);
+	$Cpct =	sprintf("%01.2f", $Cpct);
+	$Cpct =	sprintf("%6s", $Cpct);
+
+	if ( ($sales > 0) and ($uTOP > 0) ) {$TOP = ( ($uTOP / $sales) * 100);}
+		else {$TOP=0;}
+	$TOP = round($TOP, 0);
+	$TOP =	sprintf("%01.0f", $TOP);
+	$TOP =	sprintf("%3s", $TOP);
+
+	if ( ($sales > 0) and ($uBOT > 0) ) {$BOT = ( ($uBOT / $sales) * 100);}
+		else {$BOT=0;}
+	$BOT = round($BOT, 0);
+	$BOT =	sprintf("%01.0f", $BOT);
+	$BOT =	sprintf("%3s", $BOT);
+
+	if ( ($USERcallsRAW[$i] > 0) and ($points > 0) ) {$ppc = ($points / ( ($USERcallsRAW[$i] - 0) - $DROP) );}
+		else {$ppc=0;}
+	$ppc = round($ppc, 2);
+	$ppc =	sprintf("%01.2f", $ppc);
+	$ppc =	sprintf("%4s", $ppc);
+
+
+	$A1 =	sprintf("%4s", $A1);
+	$A2 =	sprintf("%4s", $A2);
+	$A3 =	sprintf("%4s", $A3);
+	$A4 =	sprintf("%4s", $A4);
+	$A5 =	sprintf("%4s", $A5);
+	$A6 =	sprintf("%4s", $A6);
+	$A7 =	sprintf("%4s", $A7);
+	$A8 =	sprintf("%4s", $A8);
+	$A9 =	sprintf("%4s", $A9);
+	$DROP =	sprintf("%4s", $DROP);
+	$OTHER =	sprintf("%4s", $OTHER);
+	$sales =	sprintf("%4s", $sales);
+
+	echo "| $user[$i] - $full_name[$i] | $USERcalls[$i] | $A1 | $DROP | $OTHER | $sales |$Cpct%|\n";
+
+	$i++;
+	}
+
+
+if ( ($TOTcalls > 0) and ($TOTsales > 0) ) {$totCpct = ( ($TOTsales / ( ($TOTcalls - 0) - $totDROP) ) * 100);}
+	else {$totCpct=0;}
+$totCpct = round($totCpct, 2);
+$totCpct =	sprintf("%01.2f", $totCpct);
+$totCpct =	sprintf("%6s", $totCpct);
+		
+if ( ($TOTcalls > 0) and ($totPOINTS > 0) ) {$ppc = ($totPOINTS / ( ($TOTcalls - $totOTHER) - $totDROP) );}
+	else {$ppc=0;}
+$ppc = round($ppc, 2);
+$ppc =	sprintf("%01.2f", $ppc);
+$ppc =	sprintf("%4s", $ppc);
+		
+if ( ($TOTsales > 0) and ($totTOP > 0) ) {$TOP = ( ($totTOP / $TOTsales) * 100);}
+	else {$TOP=0;}
+$TOP = round($TOP, 0);
+$TOP =	sprintf("%01.0f", $TOP);
+$TOP =	sprintf("%3s", $TOP);
+
+if ( ($TOTsales > 0) and ($totBOT > 0) ) {$BOT = ( ($totBOT / $TOTsales) * 100);}
+	else {$BOT=0;}
+$BOT = round($BOT, 0);
+$BOT =	sprintf("%01.0f", $BOT);
+$BOT =	sprintf("%3s", $BOT);
+
+$TOTagents =	sprintf("%6s", $i);
+$TOTcalls =		sprintf("%6s", $TOTcalls);
+$totA1 =		sprintf("%5s", $totA1);
+$totA2 =		sprintf("%5s", $totA2);
+$totA3 =		sprintf("%5s", $totA3);
+$totA4 =		sprintf("%5s", $totA4);
+$totA5 =		sprintf("%5s", $totA5);
+$totA6 =		sprintf("%5s", $totA6);
+$totA7 =		sprintf("%5s", $totA7);
+$totA8 =		sprintf("%5s", $totA8);
+$totA9 =		sprintf("%5s", $totA9);
+$totDROP =		sprintf("%5s", $totDROP);
+$totOTHER =		sprintf("%5s", $totOTHER);
+$TOTsales =		sprintf("%5s", $TOTsales);
+
+echo "+--------------------------+--------+------+------+------+------+-------+\n";
+echo "| TOTAL CLOSERS:  $TOTagents   | $TOTcalls |$totA1 |$totDROP |$totOTHER |$TOTsales |$totCpct%|\n";
+echo "+--------------------------+--------+------+------+------+------+-------+\n";
+
+
+
+
+
+
+
+
+
+$ENDtime = date("U");
+$RUNtime = ($ENDtime - $STARTtime);
+if ($DB) {echo "\nRun Time: $RUNtime seconds\n";}
+}
+
+
+
+
+
+?>
+
+
+ + + diff --git a/LANG_www/vicidial_br/functions.php b/LANG_www/vicidial_br/functions.php new file mode 100644 index 00000000..f3a6e7b7 --- /dev/null +++ b/LANG_www/vicidial_br/functions.php @@ -0,0 +1,91 @@ + LICENSE: AGPLv2 +# +# +# CHANGES: +# 90524-1503 - First Build +# + +##### reformat seconds into HH:MM:SS or MM:SS ##### +function sec_convert($sec,$precision) + { + $sec = round($sec,0); + + if ($sec < 1) + { + return "0:00"; + } + else + { + if ($sec < 3600) {$precision='M';} + + if ($precision == 'H') + { + $Fhours_H = ($sec / 3600); + $Fhours_H_int = floor($Fhours_H); + $Fhours_H_int = intval("$Fhours_H_int"); + $Fhours_M = ($Fhours_H - $Fhours_H_int); + $Fhours_M = ($Fhours_M * 60); + $Fhours_M_int = floor($Fhours_M); + $Fhours_M_int = intval("$Fhours_M_int"); + $Fhours_S = ($Fhours_M - $Fhours_M_int); + $Fhours_S = ($Fhours_S * 60); + $Fhours_S = round($Fhours_S, 0); + if ($Fhours_S < 10) {$Fhours_S = "0$Fhours_S";} + if ($Fhours_M_int < 10) {$Fhours_M_int = "0$Fhours_M_int";} + $Ftime = "$Fhours_H_int:$Fhours_M_int:$Fhours_S"; + } + if ($precision == 'M') + { + $Fminutes_M = ($sec / 60); + $Fminutes_M_int = floor($Fminutes_M); + $Fminutes_M_int = intval("$Fminutes_M_int"); + $Fminutes_S = ($Fminutes_M - $Fminutes_M_int); + $Fminutes_S = ($Fminutes_S * 60); + $Fminutes_S = round($Fminutes_S, 0); + if ($Fminutes_S < 10) {$Fminutes_S = "0$Fminutes_S";} + $Ftime = "$Fminutes_M_int:$Fminutes_S"; + } + if ($precision == 'S') + { + $Ftime = $sec; + } + return "$Ftime"; + } + } + + +##### counts like elements in an array, optional sort asc desc ##### +function array_group_count($array, $sort = false) + { + $tally_array = array(); + + $i=0; + foreach (array_unique($array) as $value) + { + $count = 0; + foreach ($array as $element) + { + if ($element == "$value") + {$count++;} + } + + $count = sprintf("%010s", $count); + $tally_array[$i] = "$count $value"; + $i++; + } + + if ( $sort == 'desc' ) + {rsort($tally_array);} + elseif ( $sort == 'asc' ) + {sort($tally_array);} + + return $tally_array; + } + +?> \ No newline at end of file diff --git a/LANG_www/vicidial_br/group_hourly_stats.php b/LANG_www/vicidial_br/group_hourly_stats.php new file mode 100644 index 00000000..ee678b65 --- /dev/null +++ b/LANG_www/vicidial_br/group_hourly_stats.php @@ -0,0 +1,295 @@ + LICENSE: AGPLv2 +# +# CHANGES +# +# 60620-1014 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# 90310-2138 - Added admin header +# 90508-0644 - Changed to PHP long tags +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["date_with_hour"])) {$date_with_hour=$_GET["date_with_hour"];} + elseif (isset($_POST["date_with_hour"])) {$date_with_hour=$_POST["date_with_hour"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin,webroot_writable,outbound_autodial_active,user_territories_active 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]; + $webroot_writable = $row[1]; + $SSoutbound_autodial_active = $row[2]; + $user_territories_active = $row[3]; + $i++; + } +##### END SETTINGS LOOKUP ##### +########################################### + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$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 "Nome ou Senha inválidos: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$date_with_hour_default = date("Y-m-d H"); +$date_no_hour_default = $TODAY; + +if (!isset($date_with_hour)) {$date_with_hour = $date_with_hour_default;} + $date_no_hour = $date_with_hour; + $date_no_hour = eregi_replace(" ([0-9]{2})",'',$date_no_hour); +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + 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 "Nome ou Senha inválidos: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + header ("Content-type: text/html; charset=utf-8"); + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + +# $stmt="SELECT full_name from vicidial_users where user='$user';"; +# $rslt=mysql_query($stmt, $link); +# $row=mysql_fetch_row($rslt); +# $full_name = $row[0]; + + } + + + + +?> + + + +ADMINISTRATION: Estatísticas Horárias do Grupo +<?php + +##### BEGIN Set variables to make header show properly ##### +$ADD = '311111'; +$hh = 'usergroups'; +$LOGast_admin_access = '1'; +$ADMIN = 'admin.php'; +$page_width='770'; +$section_width='750'; +$header_font_size='3'; +$subheader_font_size='2'; +$subcamp_font_size='2'; +$header_selected_bold='<b>'; +$header_nonselected_bold=''; +$usergroups_color = '#FFFF99'; +$usergroups_font = 'BLACK'; +$usergroups_color = '#E6E6E6'; +$subcamp_color = '#C6C6C6'; +##### END Set variables to make header show properly ##### + +require("admin_header.php"); + +?> + + +<CENTER> +<TABLE WIDTH=620 BGCOLOR=#D9E6FE cellpadding=2 cellspacing=0><TR BGCOLOR=#015B91><TD ALIGN=LEFT><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=2><B>   Estatísticas Horárias do Grupo <?php echo $group ?></TD><TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=2><B>   </TD></TR> + + + + +<?php + +if ( ($group) and ($status) and ($date_with_hour) ) +{ +$stmt="SELECT user,full_name from vicidial_users where user_group = '" . mysql_real_escape_string($group) . "' order by full_name desc;"; + if ($DB) {echo "$stmt\n";} +$rslt=mysql_query($stmt, $link); +$tsrs_to_print = mysql_num_rows($rslt); + $o=0; + while($o < $tsrs_to_print) + { + $row=mysql_fetch_row($rslt); + $VDuser[$o] = "$row[0]"; + $VDname[$o] = "$row[1]"; + $o++; + } + + $o=0; + while($o < $tsrs_to_print) + { + $stmt="select count(*) from vicidial_log where call_date >= '" . mysql_real_escape_string($date_with_hour) . ":00:00' and call_date <= '" . mysql_real_escape_string($date_with_hour) . ":59:59' and user='$VDuser[$o]';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $VDtotal[$o] = "$row[0]"; + + $stmt="select count(*) from vicidial_log where call_date >= '" . mysql_real_escape_string($date_no_hour) . " 00:00:00' and call_date <= '" . mysql_real_escape_string($date_no_hour) . " 23:59:59' and user='$VDuser[$o]' and status='" . mysql_real_escape_string($status) . "';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $VDday[$o] = "$row[0]"; + + $stmt="select count(*) from vicidial_log where call_date >= '" . mysql_real_escape_string($date_with_hour) . ":00:00' and call_date <= '" . mysql_real_escape_string($date_with_hour) . ":59:59' and user='$VDuser[$o]' and status='" . mysql_real_escape_string($status) . "';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $VDcount[$o] = "$row[0]"; + $o++; + } + +echo "<TR><TD ALIGN=LEFT COLSPAN=2>\n"; + +echo "<br><center>\n"; + +echo "<B>CONTAGEM DE HORAS TSR: <a href=\"./admin.php?ADD=3111&group_id=$group\">$group</a> | $status | $date_with_hour | $date_no_hour</B>\n"; + +echo "<center><TABLE width=600 cellspacing=0 cellpadding=1>\n"; +echo "<tr><td><font size=2>TSR </td><td align=left><font size=2>ID </td><td align=right><font size=2>   $status</td><td align=right><font size=2>   TOTAL DE CHAMADAS</td><td align=right><font size=2>   $status DAY</td><td align=right><font size=2>     </td></tr>\n"; + + $day_calls=0; + $hour_calls=0; + $total_calls=0; + $o=0; + while($o < $tsrs_to_print) + { + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo "<tr $bgcolor><td><font size=2>$VDuser[$o]</td>"; + echo "<td align=left><font size=2> $VDname[$o]</td>\n"; + echo "<td align=right><font size=2> $VDcount[$o]</td>\n"; + echo "<td align=right><font size=2> $VDtotal[$o]</td>\n"; + echo "<td align=right><font size=2> $VDday[$o]</td>\n"; + echo "<td align=right><font size=1><a href=\"./admin.php?ADD=3&user=$VDuser[$o]\">ALTERAR</a> | <a href=\"./user_stats.php?user=$VDuser[$o]\">ESTATÍSTICAS</a></td></tr>\n"; + $total_calls = ($total_calls + $VDtotal[$o]); + $hour_calls = ($hour_calls + $VDcount[$o]); + $day_calls = ($day_calls + $VDday[$o]); + + $o++; + } + +echo "<tr><td><font size=2>TOTAL </td><td align=right><font size=2> $status </td><td align=right><font size=2> $hour_calls</td><td align=right><font size=2> $total_calls</td><td align=right><font size=2> $day_calls</td></tr>\n"; + + +} + +echo "</TABLE></center>\n"; +echo "<br><br>\n"; + + + echo "<br>Por favor entre com o grupo que deseja visualizar estatísticas horárias: <form action=$PHP_SELF method=POST>\n"; + echo "<input type=hidden name=DB value=$DB>\n"; + echo "group: <select size=1 name=group>\n"; + + $stmt="SELECT user_group,group_name from vicidial_user_groups order by user_group"; + $rslt=mysql_query($stmt, $link); + $groups_to_print = mysql_num_rows($rslt); + $o=0; + $groups_list=''; + while ($groups_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + if ($group == $group) + {$groups_list .= "<option selected value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";} + else + {$groups_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n";} + $o++; + } + echo "$groups_list</select><br>\n"; + echo "status: <input type=text name=status size=10 maxlength=10 value=\"$status\">   (example: XFER)<br>\n"; + echo "date with hour: <input type=text name=date_with_hour size=14 maxlength=13 value=\"$date_with_hour\">   (example: 2004-06-25 14)<br>\n"; + echo "<input type=submit name=submit value=ENVIAR>\n"; + echo "<BR><BR><BR>\n"; + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n<br><br><br>\n\n"; + + +echo "<font size=0>\n\n\n<br><br><br>\nScript runtime: $RUNtime seconds</font>"; + + +?> + + +</TD></TR></TABLE> +</body> +</html> + +<?php + +exit; + + + +?> + + + + + diff --git a/LANG_www/vicidial_br/help.gif b/LANG_www/vicidial_br/help.gif new file mode 100644 index 00000000..5575d7c8 Binary files /dev/null and b/LANG_www/vicidial_br/help.gif differ diff --git a/LANG_www/vicidial_br/images/cal.gif b/LANG_www/vicidial_br/images/cal.gif new file mode 100644 index 00000000..8526cf5d Binary files /dev/null and b/LANG_www/vicidial_br/images/cal.gif differ diff --git a/LANG_www/vicidial_br/images/help.gif b/LANG_www/vicidial_br/images/help.gif new file mode 100644 index 00000000..5575d7c8 Binary files /dev/null and b/LANG_www/vicidial_br/images/help.gif differ diff --git a/LANG_www/vicidial_br/images/next_mon.gif b/LANG_www/vicidial_br/images/next_mon.gif new file mode 100644 index 00000000..14c622f9 Binary files /dev/null and b/LANG_www/vicidial_br/images/next_mon.gif differ diff --git a/LANG_www/vicidial_br/images/next_year.gif b/LANG_www/vicidial_br/images/next_year.gif new file mode 100644 index 00000000..b66f2888 Binary files /dev/null and b/LANG_www/vicidial_br/images/next_year.gif differ diff --git a/LANG_www/vicidial_br/images/no_cal.gif b/LANG_www/vicidial_br/images/no_cal.gif new file mode 100644 index 00000000..adc58e2a Binary files /dev/null and b/LANG_www/vicidial_br/images/no_cal.gif differ diff --git a/LANG_www/vicidial_br/images/pixel.gif b/LANG_www/vicidial_br/images/pixel.gif new file mode 100644 index 00000000..46a2cf08 Binary files /dev/null and b/LANG_www/vicidial_br/images/pixel.gif differ diff --git a/LANG_www/vicidial_br/images/prev_mon.gif b/LANG_www/vicidial_br/images/prev_mon.gif new file mode 100644 index 00000000..12ce7ff5 Binary files /dev/null and b/LANG_www/vicidial_br/images/prev_mon.gif differ diff --git a/LANG_www/vicidial_br/images/prev_year.gif b/LANG_www/vicidial_br/images/prev_year.gif new file mode 100644 index 00000000..c726b0e4 Binary files /dev/null and b/LANG_www/vicidial_br/images/prev_year.gif differ diff --git a/LANG_www/vicidial_br/images/shade_bl.png b/LANG_www/vicidial_br/images/shade_bl.png new file mode 100644 index 00000000..29bd5543 Binary files /dev/null and b/LANG_www/vicidial_br/images/shade_bl.png differ diff --git a/LANG_www/vicidial_br/images/shade_bm.png b/LANG_www/vicidial_br/images/shade_bm.png new file mode 100644 index 00000000..5c4e0af9 Binary files /dev/null and b/LANG_www/vicidial_br/images/shade_bm.png differ diff --git a/LANG_www/vicidial_br/images/shade_br.png b/LANG_www/vicidial_br/images/shade_br.png new file mode 100644 index 00000000..ce8a2fad Binary files /dev/null and b/LANG_www/vicidial_br/images/shade_br.png differ diff --git a/LANG_www/vicidial_br/images/shade_mr.png b/LANG_www/vicidial_br/images/shade_mr.png new file mode 100644 index 00000000..4594bc4e Binary files /dev/null and b/LANG_www/vicidial_br/images/shade_mr.png differ diff --git a/LANG_www/vicidial_br/images/shade_tr.png b/LANG_www/vicidial_br/images/shade_tr.png new file mode 100644 index 00000000..2e598c95 Binary files /dev/null and b/LANG_www/vicidial_br/images/shade_tr.png differ diff --git a/LANG_www/vicidial_br/list_download.php b/LANG_www/vicidial_br/list_download.php new file mode 100644 index 00000000..3ecaca97 --- /dev/null +++ b/LANG_www/vicidial_br/list_download.php @@ -0,0 +1,133 @@ +<?php +# list_download.php +# +# downloads the entire contents of a vicidial list ID to a flat text file +# that is tab delimited +# +# Copyright (C) 2010 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2 +# +# CHANGES +# +# 90209-1310 - First build +# 90508-0644 - Changed to PHP long tags +# 90721-1238 - Added rank and owner as vicidial_list fields +# 100119-1039 - Filtered comments for \n newlines +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} + +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); +if ($qm_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $non_latin = $row[0]; + } +##### END SETTINGS LOOKUP ##### +########################################### + +$PHP_AUTH_USER = ereg_replace("[^-_0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^-_0-9a-zA-Z]","",$PHP_AUTH_PW); + +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7 and download_lists='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 "Nome ou Senha inválidos or no list download permission: |$PHP_AUTH_USER|\n"; + exit; + } + +$stmt="select count(*) from vicidial_list where list_id='$list_id';"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$count_to_print = mysql_num_rows($rslt); +if ($count_to_print > 0) + { + $row=mysql_fetch_row($rslt); + $leads_count =$row[0]; + $i++; + } + +if ($leads_count < 1) + { + echo "There are no leads in list_id: $list_id\n"; + exit; + } + +$US='_'; +$MT[0]=''; +$ip = getenv("REMOTE_ADDR"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_TIME = date("Ymd-His"); +$STARTtime = date("U"); +if (!isset($group)) {$group = '';} +if (!isset($query_date)) {$query_date = $NOW_DATE;} +if (!isset($end_date)) {$end_date = $NOW_DATE;} + +### LOG INSERTION Admin Log Table ### +$SQL_log = "$stmt|$stmtA|"; +$SQL_log = ereg_replace(';','',$SQL_log); +$SQL_log = addslashes($SQL_log); +$stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$PHP_AUTH_USER', ip_address='$ip', event_section='LEADS', event_type='EXPORT', record_id='$list_id', event_code='ADMIN EXPORT LIST', event_sql=\"$SQL_log\", event_notes='';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); + + +$TXTfilename = "LIST_$list_id$US$FILE_TIME.txt"; + +// We'll be outputting a TXT file +header('Content-type: application/octet-stream'); + +// It will be called LIST_101_20090209-121212.txt +header("Content-Disposition: attachment; filename=\"$TXTfilename\""); +header('Expires: 0'); +header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); +header('Pragma: public'); +ob_clean(); +flush(); + +$stmt="select lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner from vicidial_list where list_id='$list_id';"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$leads_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $leads_to_print) + { + $row=mysql_fetch_row($rslt); + + $row[29] = preg_replace("/\n|\r/",'!N',$row[29]); + + echo "$row[0]\t$row[1]\t$row[2]\t$row[3]\t$row[4]\t$row[5]\t$row[6]\t$row[7]\t$row[8]\t$row[9]\t$row[10]\t$row[11]\t$row[12]\t$row[13]\t$row[14]\t$row[15]\t$row[16]\t$row[17]\t$row[18]\t$row[19]\t$row[20]\t$row[21]\t$row[22]\t$row[23]\t$row[24]\t$row[25]\t$row[26]\t$row[27]\t$row[28]\t$row[29]\t$row[30]\t$row[31]\t$row[32]\t$row[33]\r\n"; + + $i++; + } + +exit; + +?> \ No newline at end of file diff --git a/LANG_www/vicidial_br/listloader.pl b/LANG_www/vicidial_br/listloader.pl new file mode 100644 index 00000000..72094d84 --- /dev/null +++ b/LANG_www/vicidial_br/listloader.pl @@ -0,0 +1,1311 @@ +#!/usr/bin/perl +# +# listloader.pl version 2.2.0 +# +# Copyright (C) 2010 Matt Florell,Joe Johnson <vicidial@gmail.com> LICENSE: AGPLv2 +# +# +# CHANGES +# 60616-1548 - Added listID override feature to force all leads into same list +# - Added gmt_offset_now lookup for each lead +# 60811-1232 - Changed to DBI +# 60811-1329 - changed to use /etc/astguiclient.conf for configs +# 60822-1121 - fixed for nonwritable directories +# 60906-1058 - added filter of non-digits in alt_phone field +# 61110-1229 - added new USA-Canada DST scheme and Brazil DST scheme +# 61128-1215 - added postal code GMT lookup and duplicate check options +# 70205-1703 - Defaulted phone_code to 1 if not populated +# 70417-1059 - Fixed default phone_code bug +# 70510-1518 - Added campaign and system duplicate check and phonecode override +# 80428-0144 - UTF8 cleanup +# 80713-0023 - added last_local_call_time field default of 2008-01-01 +# 90721-1425 - Added rank and owner as vicidial_list fields +# 91112-0616 - Added title/alt-phone duplicate checking +# 100118-0537 - Added new Australian and New Zealand DST schemes (FSO-FSA and LSS-FSA) +# + +### begin parsing run-time options ### +if (length($ARGV[0])>1) + { + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + $i++; + } + + if ($args =~ /--help|-h/i) + { + print "allowed run time options:\n [-forcelistid=1234] = overrides the listID given in the file with the 1234\n [-h] = this help screen\n\n"; + + exit; + } + else + { + if ($args =~ /-duplicate-check/i) + {$dupcheck=1;} + if ($args =~ /-duplicate-campaign-check/i) + {$dupcheckcamp=1;} + if ($args =~ /-duplicate-system-check/i) + {$dupchecksys=1;} + if ($args =~ /-duplicate-tap-list-check/i) + {$duptapchecklist=1;} + if ($args =~ /-duplicate-tap-system-check/i) + {$duptapchecksys=1;} + if ($args =~ /-postal-code-gmt/i) + {$postalgmt=1;} + if ($args =~ /--forcelistid=/i) + { + @data_in = split(/--forcelistid=/,$args); + $forcelistid = $data_in[1]; + $forcelistid =~ s/ .*//gi; + print "\n----- FORCE LISTID OVERRIDE: $forcelistid -----\n\n"; + } + else + {$forcelistid = '';} + + if ($args =~ /--forcephonecode=/i) + { + @data_in = split(/--forcephonecode=/,$args); + $forcephonecode = $data_in[1]; + $forcephonecode =~ s/ .*//gi; + print "\n----- FORCE PHONECODE OVERRIDE: $forcephonecode -----\n\n"; + } + else + {$forcephonecode = '';} + + if ($args =~ /--lead-file=/i) + { + @data_in = split(/--lead-file=/,$args); + $lead_file = $data_in[1]; + $lead_file =~ s/ .*//gi; + # print "\n----- LEAD FILE: $lead_file -----\n\n"; + } + else + {$lead_file = './vicidial_temp_file.xls';} + } + } +### end parsing run-time options ### + + +use Spreadsheet::ParseExcel; +use Time::Local; +use DBI; + + +# default path to astguiclient configuration file: +$PATHconf = '/etc/astguiclient.conf'; + +open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n"; +@conf = <conf>; +close(conf); +$i=0; +foreach(@conf) + { + $line = $conf[$i]; + $line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi; + if ( ($line =~ /^PATHhome/) && ($CLIhome < 1) ) + {$PATHhome = $line; $PATHhome =~ s/.*=//gi;} + if ( ($line =~ /^PATHlogs/) && ($CLIlogs < 1) ) + {$PATHlogs = $line; $PATHlogs =~ s/.*=//gi;} + if ( ($line =~ /^PATHagi/) && ($CLIagi < 1) ) + {$PATHagi = $line; $PATHagi =~ s/.*=//gi;} + if ( ($line =~ /^PATHweb/) && ($CLIweb < 1) ) + {$PATHweb = $line; $PATHweb =~ s/.*=//gi;} + if ( ($line =~ /^PATHsounds/) && ($CLIsounds < 1) ) + {$PATHsounds = $line; $PATHsounds =~ s/.*=//gi;} + if ( ($line =~ /^PATHmonitor/) && ($CLImonitor < 1) ) + {$PATHmonitor = $line; $PATHmonitor =~ s/.*=//gi;} + if ( ($line =~ /^VARserver_ip/) && ($CLIserver_ip < 1) ) + {$VARserver_ip = $line; $VARserver_ip =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_server/) && ($CLIDB_server < 1) ) + {$VARDB_server = $line; $VARDB_server =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_database/) && ($CLIDB_database < 1) ) + {$VARDB_database = $line; $VARDB_database =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_user/) && ($CLIDB_user < 1) ) + {$VARDB_user = $line; $VARDB_user =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_pass/) && ($CLIDB_pass < 1) ) + {$VARDB_pass = $line; $VARDB_pass =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_port/) && ($CLIDB_port < 1) ) + {$VARDB_port = $line; $VARDB_port =~ s/.*=//gi;} + $i++; + } + +# Customized Variables +$server_ip = $VARserver_ip; # Asterisk server IP + +if (!$VARDB_port) {$VARDB_port='3306';} + +$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass") + or die "Couldn't connect to database: " . DBI->errstr; + + +$|=0; +$secX = time(); + +($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); +$year = ($year + 1900); +$mon++; +if ($hour < 10) {$hour = "0$hour";} +if ($min < 10) {$min = "0$min";} +if ($sec < 10) {$sec = "0$sec";} +if ($mon < 10) {$mon = "0$mon";} +if ($mday < 10) {$mday = "0$mday";} +$pulldate0 = "$year-$mon-$mday $hour:$min:$sec"; +$pulldate="$year-$mon-$mday $hour:$min:$sec"; +$inSD = $pulldate0; +$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmtA = "SELECT use_non_latin FROM system_settings;"; +$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; +$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; +$sthArows=$sthA->rows; +if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $non_latin = "$aryA[0]"; + } +$sthA->finish(); +##### END SETTINGS LOOKUP ##### +########################################### + + +if ($non_latin > 0) {$affected_rows = $dbhA->do("SET NAMES 'UTF8'");} + + ### Grab Server values from the database + $stmtA = "SELECT local_gmt FROM servers where server_ip = '$server_ip';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $DBSERVER_GMT = "$aryA[0]"; + if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;} + $rec_count++; + } + $sthA->finish(); + + $LOCAL_GMT_OFF = $SERVER_GMT; + $LOCAL_GMT_OFF_STD = $SERVER_GMT; + +if ($isdst) {$LOCAL_GMT_OFF++;} +if ($DB) {print "SEED TIME $secX : $year-$mon-$mday $hour:$min:$sec LOCAL GMT OFFSET NOW: $LOCAL_GMT_OFF\n";} + + + +$total=0; $good=0; $bad=0; +print "<center><font face='arial, helvetica' size=3 color='#009900'><B>Processing Excel file...\n"; +open(STMT_FILE, "> $PATHlogs/listloader_stmts.txt"); + +$oBook = Spreadsheet::ParseExcel::Workbook->Parse("$lead_file"); +my($iR, $iC, $oWkS, $oWkC); + +foreach $oWkS (@{$oBook->{Worksheet}}) { + for($iR = 0 ; defined $oWkS->{MaxRow} && $iR <= $oWkS->{MaxRow} ; $iR++) { + + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user = ""; + $oWkC = $oWkS->{Cells}[$iR][0]; + if ($oWkC) {$vendor_lead_code=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][1]; + if ($oWkC) {$source_code=$oWkC->Value; } + $source_id=$source_code; + $oWkC = $oWkS->{Cells}[$iR][2]; + if ($oWkC) {$list_id=$oWkC->Value; } + $gmt_offset = '0'; + $called_since_last_reset='N'; + $oWkC = $oWkS->{Cells}[$iR][3]; + if ($oWkC) {$phone_code=$oWkC->Value; } + $phone_code=~s/[^0-9]//g; + $oWkC = $oWkS->{Cells}[$iR][4]; + if ($oWkC) {$phone_number=$oWkC->Value; } + $phone_number=~s/[^0-9]//g; + $USarea = substr($phone_number, 0, 3); + $oWkC = $oWkS->{Cells}[$iR][5]; + if ($oWkC) {$title=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][6]; + if ($oWkC) {$first_name=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][7]; + if ($oWkC) {$middle_initial=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][8]; + if ($oWkC) {$last_name=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][9]; + if ($oWkC) {$address1=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][10]; + if ($oWkC) {$address2=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][11]; + if ($oWkC) {$address3=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][12]; + if ($oWkC) {$city=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][13]; + if ($oWkC) {$state=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][14]; + if ($oWkC) {$province=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][15]; + if ($oWkC) {$postal_code=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][16]; + if ($oWkC) {$country=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][17]; + if ($oWkC) {$gender=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][18]; + if ($oWkC) {$date_of_birth=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][19]; + if ($oWkC) {$alt_phone=$oWkC->Value; } + $alt_phone=~s/[^0-9]//g; + $oWkC = $oWkS->{Cells}[$iR][20]; + if ($oWkC) {$email=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][21]; + if ($oWkC) {$security_phrase=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][22]; + if ($oWkC) {$comments=$oWkC->Value; } + $comments=~s/^\s*(.*?)\s*$/$1/; + $oWkC = $oWkS->{Cells}[$iR][23]; + if ($oWkC) {$rank=$oWkC->Value; } + if (length($rank)<1) {$rank='0';} + $oWkC = $oWkS->{Cells}[$iR][24]; + if ($oWkC) {$owner=$oWkC->Value; } + + if (length($forcelistid) > 0) + { + $list_id = $forcelistid; # set list_id to override value + } + if (length($forcephonecode) > 0) + { + $phone_code = $forcephonecode; # set phone_code to override value + } + + ##### Check for duplicate phone numbers in vicidial_list table entire database ##### + if ($dupchecksys > 0) + { + $dup_lead=0; + $stmtA = "select count(*) from vicidial_list where phone_number='$phone_number';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $dup_lead = $aryA[0]; + $dup_lead_list=$list_id; + } + $sthA->finish(); + if ($dup_lead < 1) + { + if ($phone_list =~ /\|$phone_number$US$list_id\|/) + {$dup_lead++;} + } + } + ##### Check for duplicate phone numbers in vicidial_list table for one list_id ##### + if ($dupcheck > 0) + { + $dup_lead=0; + $stmtA = "select list_id from vicidial_list where phone_number='$phone_number' and list_id='$list_id' limit 1;"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $dup_lead_list = $aryA[0]; + $dup_lead++; + } + $sthA->finish(); + if ($dup_lead < 1) + { + if ($phone_list =~ /\|$phone_number$US$list_id\|/) + {$dup_lead++;} + } + } + ##### Check for duplicate phone numbers in vicidial_list table for all lists in a campaign ##### + if ($dupcheckcamp > 0) + { + $dup_lead=0; + $dup_lists=''; + + $stmtA = "select count(*) from vicidial_lists where list_id='$list_id';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + @aryA = $sthA->fetchrow_array; + $ci_recs = $aryA[0]; + $sthA->finish(); + if ($ci_recs > 0) + { + $stmtA = "select campaign_id from vicidial_lists where list_id='$list_id';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + @aryA = $sthA->fetchrow_array; + $dup_camp = $aryA[0]; + $sthA->finish(); + + $stmtA = "select list_id from vicidial_lists where campaign_id='$dup_camp';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $dup_lists .= "'$aryA[0]',"; + $rec_count++; + } + $sthA->finish(); + + chop($dup_lists); + $stmtA = "select list_id from vicidial_list where phone_number='$phone_number' and list_id IN($dup_lists) limit 1;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $dup_lead_list = "'$aryA[0]',"; + $rec_count++; + $dup_lead=1; + } + $sthA->finish(); + } + if ($dup_lead < 1) + { + if ($phone_list =~ /\|$phone_number$US$list_id\|/) + {$dup_lead++;} + } + } + ##### Check for duplicate title/alt-phone in vicidial_list table entire database ##### + if ($duptapchecksys > 0) + { + $dup_lead=0; + $stmtA = "select count(*) from vicidial_list where title='$title' and alt_phone='$alt_phone';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $dup_lead = $aryA[0]; + $dup_lead_list=$list_id; + } + $sthA->finish(); + if ($dup_lead < 1) + { + if ($phone_list =~ /\|$alt_phone$title$US$list_id\|/) + {$dup_lead++;} + } + } + ##### Check for duplicate title/alt-phone in vicidial_list table for one list_id ##### + if ($duptapchecklist > 0) + { + $dup_lead=0; + $stmtA = "select list_id from vicidial_list where title='$title' and alt_phone='$alt_phone' and list_id='$list_id' limit 1;"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $dup_lead_list = $aryA[0]; + $dup_lead++; + } + $sthA->finish(); + if ($dup_lead < 1) + { + if ($phone_list =~ /\|$alt_phone$title$US$list_id\|/) + {$dup_lead++;} + } + } + + if ( (length($phone_number)>6) && ($dup_lead < 1) ) + { + if ( ($duptapchecklist > 0) || ($duptapchecksys > 0) ) + {$phone_list .= "$alt_phone$title$US$list_id|";} + else + {$phone_list .= "$phone_number$US$list_id|";} + $postalgmt_found=0; + if (length($phone_code)<1) {$phone_code = '1';} + + if ( ($postalgmt > 0) && (length($postal_code)>4) ) + { + if ($phone_code =~ /^1$/) + { + $stmtA = "select postal_code,state,GMT_offset,DST,DST_range,country,country_code from vicidial_postal_codes where country_code='$phone_code' and postal_code LIKE \"$postal_code%\";"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $gmt_offset = $aryA[2]; $gmt_offset =~ s/\+| //gi; + $dst = $aryA[3]; + $dst_range = $aryA[4]; + $PC_processed++; + $rec_count++; + $postalgmt_found++; + if ($DBX) {print " Postal GMT record found for $postal_code: |$gmt_offset|$dst|$dst_range|\n";} + } + $sthA->finish(); + } + } + if ($postalgmt_found < 1) + { + $PC_processed=0; + ### UNITED STATES ### + if ($phone_code =~ /^1$/) + { + $stmtA = "select country_code,country,areacode,state,GMT_offset,DST,DST_range,geographic_description from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $gmt_offset = $aryA[4]; $gmt_offset =~ s/\+| //gi; + $dst = $aryA[5]; + $dst_range = $aryA[6]; + $PC_processed++; + $rec_count++; + } + $sthA->finish(); + } + ### MEXICO ### + if ($phone_code =~ /^52$/) + { + $stmtA = "select country_code,country,areacode,state,GMT_offset,DST,DST_range,geographic_description from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $gmt_offset = $aryA[4]; $gmt_offset =~ s/\+| //gi; + $dst = $aryA[5]; + $dst_range = $aryA[6]; + $PC_processed++; + $rec_count++; + } + $sthA->finish(); + } + ### AUSTRALIA ### + if ($phone_code =~ /^61$/) + { + $stmtA = "select country_code,country,areacode,state,GMT_offset,DST,DST_range,geographic_description from vicidial_phone_codes where country_code='$phone_code' and state='$state';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $gmt_offset = $aryA[4]; $gmt_offset =~ s/\+| //gi; + $dst = $aryA[5]; + $dst_range = $aryA[6]; + $PC_processed++; + $rec_count++; + } + $sthA->finish(); + } + ### ALL OTHER COUNTRY CODES ### + if (!$PC_processed) + { + $stmtA = "select country_code,country,areacode,state,GMT_offset,DST,DST_range,geographic_description from vicidial_phone_codes where country_code='$phone_code';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $gmt_offset = $aryA[4]; $gmt_offset =~ s/\+| //gi; + $dst = $aryA[5]; + $dst_range = $aryA[6]; + $PC_processed++; + $rec_count++; + } + $sthA->finish(); + } + } + + ### Find out if DST to raise the gmt offset ### + $AC_GMT_diff = ($gmt_offset - $LOCAL_GMT_OFF_STD); + $AC_localtime = ($secX + (3600 * $AC_GMT_diff)); + ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($AC_localtime); + $year = ($year + 1900); + $mon++; + if ($mon < 10) {$mon = "0$mon";} + if ($mday < 10) {$mday = "0$mday";} + if ($hour < 10) {$hour = "0$hour";} + if ($min < 10) {$min = "0$min";} + if ($sec < 10) {$sec = "0$sec";} + $dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + + $AC_processed=0; + + if ( (!$AC_processed) && ($dst_range =~ /SSM-FSN/) ) + { + if ($DBX) {print " Second Sunday March to First Sunday November\n";} + &USACAN_dstcalc; + if ($DBX) {print " DST: $USACAN_DST\n";} + if ($USACAN_DST) {$area_GMT++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($dst_range =~ /FSA-LSO/) ) + { + if ($DBX) {print " First Sunday April to Last Sunday October\n";} + &NA_dstcalc; + if ($DBX) {print " DST: $NA_DST\n";} + if ($NA_DST) {$area_GMT++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($dst_range =~ /LSM-LSO/) ) + { + if ($DBX) {print " Last Sunday March to Last Sunday October\n";} + &GBR_dstcalc; + if ($DBX) {print " DST: $GBR_DST\n";} + if ($GBR_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($dst_range =~ /LSO-LSM/) ) + { + if ($DBX) {print " Last Sunday October to Last Sunday March\n";} + &AUS_dstcalc; + if ($DBX) {print " DST: $AUS_DST\n";} + if ($AUS_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($dst_range =~ /FSO-LSM/) ) + { + if ($DBX) {print " First Sunday October to Last Sunday March\n";} + &AUST_dstcalc; + if ($DBX) {print " DST: $AUST_DST\n";} + if ($AUST_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($area_GMT_method =~ /FSO-FSA/) ) + { + if ($DBX) {print " First Sunday October to First Sunday April\n";} + &AUSE_dstcalc; + if ($DBX) {print " DST: $AUSE_DST\n";} + if ($AUSE_DST) {$area_GMT++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($dst_range =~ /FSO-TSM/) ) + { + if ($DBX) {print " First Sunday October to Third Sunday March\n";} + &NZL_dstcalc; + if ($DBX) {print " DST: $NZL_DST\n";} + if ($NZL_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($area_GMT_method =~ /LSS-FSA/) ) + { + if ($DBX) {print " Last Sunday September to First Sunday April\n";} + &NZLN_dstcalc; + if ($DBX) {print " DST: $NZLN_DST\n";} + if ($NZLN_DST) {$area_GMT++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($dst_range =~ /TSO-LSF/) ) + { + if ($DBX) {print " Third Sunday October to Last Sunday February\n";} + &BZL_dstcalc; + if ($DBX) {print " DST: $BZL_DST\n";} + if ($BZL_DST) {$area_GMT++;} + $AC_processed++; + } + if (!$AC_processed) + { + if ($DBX) {print " No DST Method Found\n";} + if ($DBX) {print " DST: 0\n";} + $AC_processed++; + } + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list (lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner) values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0,'2008-01-01 00:00:00','$rank','$owner');"; + $affected_rows = $dbhA->do($stmtZ); + print STMT_FILE $stmtZ."\r\n"; + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0,'2008-01-01 00:00:00','$rank','$owner'),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 10000) {print "<BR></b><font size=1 color=red>record $total BAD- PHONE: $phone_number ROW: |$row[0]| $dup_lead_list</font><b>\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print "<script language='JavaScript1.2'>ShowProgress($good, $bad, $total, $dup_lead, $postalgmt_found)</script>"; + sleep(1); +# flush(); + } + } +} + +if ($multi_insert_counter > 0) { + $stmtZ = "INSERT INTO vicidial_list (lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner) values ".substr($multistmt, 0, -1).";"; + $affected_rows = $dbhA->do($stmtZ); + print STMT_FILE $stmtZ."\r\n"; +} + +print "<BR><BR>Done</B> GOOD: $good       BAD: $bad       TOTAL: $total</font></center>"; + +exit; + + + + + + +sub USACAN_dstcalc { +#********************************************************************** +# SSM-FSN +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on Second Sunday March to First Sunday November at 2 am. +# INPUTS: +# mm INTEGER Month. +# dd INTEGER Day of the month. +# ns INTEGER Seconds into the day. +# dow INTEGER Day of week (0=Sunday, to 6=Saturday) +# OPTIONAL INPUT: +# timezone INTEGER hour difference UTC - local standard time +# (DEFAULT is blank) +# make calculations based on UTC time, +# which means shift at 10:00 UTC in April +# and 9:00 UTC in October +# OUTPUT: +# INTEGER 1 = DST, 0 = not DST +# +# S M T W T F S +# 1 2 3 4 5 6 7 +# 8 9 10 11 12 13 14 +#15 16 17 18 19 20 21 +#22 23 24 25 26 27 28 +#29 30 31 +# +# S M T W T F S +# 1 2 3 4 5 6 +# 7 8 9 10 11 12 13 +#14 15 16 17 18 19 20 +#21 22 23 24 25 26 27 +#28 29 30 31 +# +#********************************************************************** + + $USACAN_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 11) { + $USACAN_DST=0; return 0; + } elsif ($mm >= 4 && $mm <= 10) { + $USACAN_DST=1; return 1; + } elsif ($mm == 3) { + if ($dd > 13) { + $USACAN_DST=1; return 1; + } elsif ($dd >= ($dow+8)) { + if ($timezone) { + if ($dow == 0 && $ns < (7200+$timezone*3600)) { + $USACAN_DST=0; return 0; + } else { + $USACAN_DST=1; return 1; + } + } else { + if ($dow == 0 && $ns < 7200) { + $USACAN_DST=0; return 0; + } else { + $USACAN_DST=1; return 1; + } + } + } else { + $USACAN_DST=0; return 0; + } + } elsif ($mm == 11) { + if ($dd > 7) { + $USACAN_DST=0; return 0; + } elsif ($dd < ($dow+1)) { + $USACAN_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (7200+($timezone-1)*3600)) { + $USACAN_DST=1; return 1; + } else { + $USACAN_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 7200) { + $USACAN_DST=1; return 1; + } else { + $USACAN_DST=0; return 0; + } + } + } else { + $USACAN_DST=0; return 0; + } + } # end of month checks +} # end of subroutine dstcalc + + + + +sub NA_dstcalc { +#********************************************************************** +# FSA-LSO +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on first Sunday in April and last Sunday in October at 2 am. +#********************************************************************** + + $NA_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 4 || $mm > 10) { + $NA_DST=0; return 0; + } elsif ($mm >= 5 && $mm <= 9) { + $NA_DST=1; return 1; + } elsif ($mm == 4) { + if ($dd > 7) { + $NA_DST=1; return 1; + } elsif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 && $ns < (7200+$timezone*3600)) { + $NA_DST=0; return 0; + } else { + $NA_DST=1; return 1; + } + } else { + if ($dow == 0 && $ns < 7200) { + $NA_DST=0; return 0; + } else { + $NA_DST=1; return 1; + } + } + } else { + $NA_DST=0; return 0; + } + } elsif ($mm == 10) { + if ($dd < 25) { + $NA_DST=1; return 1; + } elsif ($dd < ($dow+25)) { + $NA_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (7200+($timezone-1)*3600)) { + $NA_DST=1; return 1; + } else { + $NA_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 7200) { + $NA_DST=1; return 1; + } else { + $NA_DST=0; return 0; + } + } + } else { + $NA_DST=0; return 0; + } + } # end of month checks +} # end of subroutine dstcalc + + + + +sub GBR_dstcalc { +#********************************************************************** +# LSM-LSO +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on last Sunday in March and last Sunday in October at 1 am. +#********************************************************************** + + $GBR_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $GBR_DST=0; return 0; + } elsif ($mm >= 4 && $mm <= 9) { + $GBR_DST=1; return 1; + } elsif ($mm == 3) { + if ($dd < 25) { + $GBR_DST=0; return 0; + } elsif ($dd < ($dow+25)) { + $GBR_DST=0; return 0; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=0; return 0; + } else { + $GBR_DST=1; return 1; + } + } else { # local time calculations + if ($ns < 3600) { + $GBR_DST=0; return 0; + } else { + $GBR_DST=1; return 1; + } + } + } else { + $GBR_DST=1; return 1; + } + } elsif ($mm == 10) { + if ($dd < 25) { + $GBR_DST=1; return 1; + } elsif ($dd < ($dow+25)) { + $GBR_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=1; return 1; + } else { + $GBR_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 3600) { + $GBR_DST=1; return 1; + } else { + $GBR_DST=0; return 0; + } + } + } else { + $GBR_DST=0; return 0; + } + } # end of month checks +} # end of subroutine dstcalc + + + + +sub AUS_dstcalc { +#********************************************************************** +# LSO-LSM +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on last Sunday in October and last Sunday in March at 1 am. +#********************************************************************** + + $AUS_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUS_DST=1; return 1; + } elsif ($mm >= 4 && $mm <= 9) { + $AUS_DST=0; return 0; + } elsif ($mm == 3) { + if ($dd < 25) { + $AUS_DST=1; return 1; + } elsif ($dd < ($dow+25)) { + $AUS_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=1; return 1; + } else { + $AUS_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 3600) { + $AUS_DST=1; return 1; + } else { + $AUS_DST=0; return 0; + } + } + } else { + $AUS_DST=0; return 0; + } + } elsif ($mm == 10) { + if ($dd < 25) { + $AUS_DST=0; return 0; + } elsif ($dd < ($dow+25)) { + $AUS_DST=0; return 0; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=0; return 0; + } else { + $AUS_DST=1; return 1; + } + } else { # local time calculations + if ($ns < 3600) { + $AUS_DST=0; return 0; + } else { + $AUS_DST=1; return 1; + } + } + } else { + $AUS_DST=1; return 1; + } + } # end of month checks +} # end of subroutine dstcalc + + + + + +sub AUST_dstcalc { +#********************************************************************** +# FSO-LSM +# TASMANIA ONLY +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on first Sunday in October and last Sunday in March at 1 am. +#********************************************************************** + + $AUST_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUST_DST=1; return 1; + } elsif ($mm >= 4 && $mm <= 9) { + $AUST_DST=0; return 0; + } elsif ($mm == 3) { + if ($dd < 25) { + $AUST_DST=1; return 1; + } elsif ($dd < ($dow+25)) { + $AUST_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUST_DST=1; return 1; + } else { + $AUST_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 3600) { + $AUST_DST=1; return 1; + } else { + $AUST_DST=0; return 0; + } + } + } else { + $AUST_DST=0; return 0; + } + } elsif ($mm == 10) { + if ($dd >= 8) { + $AUST_DST=1; return 1; + } elsif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 && $ns < (7200+$timezone*3600)) { + $AUST_DST=0; return 0; + } else { + $AUST_DST=1; return 1; + } + } else { + if ($dow == 0 && $ns < 3600) { + $AUST_DST=0; return 0; + } else { + $AUST_DST=1; return 1; + } + } + } else { + $AUST_DST=0; return 0; + } + } # end of month checks +} # end of subroutine dstcalc + + + + + +sub AUSE_dstcalc { +#********************************************************************** +# FSO-FSA +# 2008+ AUSTRALIA ONLY (country code 61) +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on first Sunday in October and first Sunday in April at 1 am. +#********************************************************************** + + $AUSE_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 4 || $mm > 10) { + $AUSE_DST=1; return 1; + } elsif ($mm >= 5 && $mm <= 9) { + $AUSE_DST=0; return 0; + } elsif ($mm == 4) { + if ($dd > 7) { + $AUSE_DST=0; return 1; + } elsif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 && $ns < (3600+$timezone*3600)) { + $AUSE_DST=1; return 0; + } else { + $AUSE_DST=0; return 1; + } + } else { + if ($dow == 0 && $ns < 7200) { + $AUSE_DST=1; return 0; + } else { + $AUSE_DST=0; return 1; + } + } + } else { + $AUSE_DST=1; return 0; + } + } elsif ($mm == 10) { + if ($dd >= 8) { + $AUSE_DST=1; return 1; + } elsif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 && $ns < (7200+$timezone*3600)) { + $AUSE_DST=0; return 0; + } else { + $AUSE_DST=1; return 1; + } + } else { + if ($dow == 0 && $ns < 3600) { + $AUSE_DST=0; return 0; + } else { + $AUSE_DST=1; return 1; + } + } + } else { + $AUSE_DST=0; return 0; + } + } # end of month checks +} # end of subroutine dstcalc + + + + + +sub NZL_dstcalc { +#********************************************************************** +# FSO-TSM +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on first Sunday in October and third Sunday in March at 1 am. +#********************************************************************** + + $NZL_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $NZL_DST=1; return 1; + } elsif ($mm >= 4 && $mm <= 9) { + $NZL_DST=0; return 0; + } elsif ($mm == 3) { + if ($dd < 14) { + $NZL_DST=1; return 1; + } elsif ($dd < ($dow+14)) { + $NZL_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $NZL_DST=1; return 1; + } else { + $NZL_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 3600) { + $NZL_DST=1; return 1; + } else { + $NZL_DST=0; return 0; + } + } + } else { + $NZL_DST=0; return 0; + } + } elsif ($mm == 10) { + if ($dd >= 8) { + $NZL_DST=1; return 1; + } elsif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 && $ns < (7200+$timezone*3600)) { + $NZL_DST=0; return 0; + } else { + $NZL_DST=1; return 1; + } + } else { + if ($dow == 0 && $ns < 3600) { + $NZL_DST=0; return 0; + } else { + $NZL_DST=1; return 1; + } + } + } else { + $NZL_DST=0; return 0; + } + } # end of month checks +} # end of subroutine dstcalc + + + + +sub NZLN_dstcalc { +#********************************************************************** +# LSS-FSA +# 2007+ NEW ZEALAND (country code 64) +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on last Sunday in September and first Sunday in April at 1 am. +#********************************************************************** + + $NZLN_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 4 || $mm > 9) { + $NZLN_DST=1; return 1; + } elsif ($mm >= 5 && $mm <= 9) { + $NZLN_DST=0; return 0; + } elsif ($mm == 4) { + if ($dd > 7) { + $NZLN_DST=0; return 1; + } elsif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 && $ns < (3600+$timezone*3600)) { + $NZLN_DST=1; return 0; + } else { + $NZLN_DST=0; return 1; + } + } else { + if ($dow == 0 && $ns < 7200) { + $NZLN_DST=1; return 0; + } else { + $NZLN_DST=0; return 1; + } + } + } else { + $NZLN_DST=1; return 0; + } + } elsif ($mm == 9) { + if ($dd < 25) { + $NZLN_DST=0; return 0; + } elsif ($dd < ($dow+25)) { + $NZLN_DST=0; return 0; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $NZLN_DST=0; return 0; + } else { + $NZLN_DST=1; return 1; + } + } else { # local time calculations + if ($ns < 3600) { + $NZLN_DST=0; return 0; + } else { + $NZLN_DST=1; return 1; + } + } + } else { + $NZLN_DST=1; return 1; + } + } # end of month checks +} # end of subroutine dstcalc + + + + + +sub BZL_dstcalc { +#********************************************************************** +# TSO-LSF +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. Brazil +# Based on Third Sunday October to Last Sunday February at 1 am. +#********************************************************************** + + $BZL_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 2 || $mm > 10) { + $BZL_DST=1; return 1; + } elsif ($mm >= 3 && $mm <= 9) { + $BZL_DST=0; return 0; + } elsif ($mm == 2) { + if ($dd < 22) { + $BZL_DST=1; return 1; + } elsif ($dd < ($dow+22)) { + $BZL_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $BZL_DST=1; return 1; + } else { + $BZL_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 3600) { + $BZL_DST=1; return 1; + } else { + $BZL_DST=0; return 0; + } + } + } else { + $BZL_DST=0; return 0; + } + } elsif ($mm == 10) { + if ($dd < 22) { + $BZL_DST=0; return 0; + } elsif ($dd < ($dow+22)) { + $BZL_DST=0; return 0; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $BZL_DST=0; return 0; + } else { + $BZL_DST=1; return 1; + } + } else { # local time calculations + if ($ns < 3600) { + $BZL_DST=0; return 0; + } else { + $BZL_DST=1; return 1; + } + } + } else { + $BZL_DST=1; return 1; + } + } # end of month checks +} # end of subroutine dstcalc diff --git a/LANG_www/vicidial_br/listloaderMAIN.php b/LANG_www/vicidial_br/listloaderMAIN.php new file mode 100644 index 00000000..209c109f --- /dev/null +++ b/LANG_www/vicidial_br/listloaderMAIN.php @@ -0,0 +1,87 @@ +<?php +# listloaderMAIN.php +# +# Copyright (C) 2009 Matt Florell,Joe Johnson <vicidial@gmail.com> LICENSE: AGPLv2 +# +# this is the main frame page for the lead loading section. This is where you +# would upload a file and have it inserted into vicidial_list +# +# changes: +# 60620-1149 - Added variable filtering to eliminate SQL injection attack threat +# 60822-1105 - fixed for nonwritable directories +# 90508-0644 - Changed to PHP long tags +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_datetime = $STARTtime; + +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$auth=$row[0]; + +if ($WeBRooTWritablE > 0) {$fp = fopen ("./project_auth_entries.txt", "a");} +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICIDIAL-LEAD-LOADER\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Nome ou Senha inválidos: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + header ("Content-type: text/html; charset=utf-8"); + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT load_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGload_leads =$row[0]; + + if ($LOGload_leads < 1) + { + echo "You do not have permissions to load leads\n"; + exit; + } + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "LIST_LOAD|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + } + else + { + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "LIST_LOAD|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + } + +?><HTML> +<HEAD> +<TITLE>VICIDIAL: Módulo de Carregar Registros + + + + + \ No newline at end of file diff --git a/LANG_www/vicidial_br/listloader_rowdisplay.pl b/LANG_www/vicidial_br/listloader_rowdisplay.pl new file mode 100644 index 00000000..9caaeab2 --- /dev/null +++ b/LANG_www/vicidial_br/listloader_rowdisplay.pl @@ -0,0 +1,154 @@ +#!/usr/bin/perl +# +# listloader_rowdisplay.pl version 2.2.0 +# +# Copyright (C) 2009 Matt Florell,Joe Johnson LICENSE: AGPLv2 +# +# +# CHANGES +# +# 60811-1232 - Changed to DBI +# 60811-1329 - changed to use /etc/astguiclient.conf for configs +# 90721-1340 - Added rank and owner as vicidial_list fields +# + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + $i++; + } + + if ($args =~ /--help|-h/i) + { + print "allowed run time options:\n [-forcelistid=1234] = overrides the listID given in the file with the 1234\n [-h] = this help screen\n\n"; + + exit; + } + else + { + if ($args =~ /-duplicate-check/i) + {$dupcheck=1;} + if ($args =~ /-postal-code-gmt/i) + {$postalgmt=1;} + if ($args =~ /--lead-file=/i) + { + @data_in = split(/--lead-file=/,$args); + $lead_file = $data_in[1]; + $lead_file =~ s/ .*//gi; + # print "\n----- LEAD FILE: $lead_file -----\n\n"; + } + else + {$lead_file = './vicidial_temp_file.xls';} + } +} +### end parsing run-time options ### + +use Spreadsheet::ParseExcel; +use Time::Local; +use DBI; + + +# default path to astguiclient configuration file: +$PATHconf = '/etc/astguiclient.conf'; + +open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n"; +@conf = ; +close(conf); +$i=0; +foreach(@conf) + { + $line = $conf[$i]; + $line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi; + if ( ($line =~ /^PATHhome/) && ($CLIhome < 1) ) + {$PATHhome = $line; $PATHhome =~ s/.*=//gi;} + if ( ($line =~ /^PATHlogs/) && ($CLIlogs < 1) ) + {$PATHlogs = $line; $PATHlogs =~ s/.*=//gi;} + if ( ($line =~ /^PATHagi/) && ($CLIagi < 1) ) + {$PATHagi = $line; $PATHagi =~ s/.*=//gi;} + if ( ($line =~ /^PATHweb/) && ($CLIweb < 1) ) + {$PATHweb = $line; $PATHweb =~ s/.*=//gi;} + if ( ($line =~ /^PATHsounds/) && ($CLIsounds < 1) ) + {$PATHsounds = $line; $PATHsounds =~ s/.*=//gi;} + if ( ($line =~ /^PATHmonitor/) && ($CLImonitor < 1) ) + {$PATHmonitor = $line; $PATHmonitor =~ s/.*=//gi;} + if ( ($line =~ /^VARserver_ip/) && ($CLIserver_ip < 1) ) + {$VARserver_ip = $line; $VARserver_ip =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_server/) && ($CLIDB_server < 1) ) + {$VARDB_server = $line; $VARDB_server =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_database/) && ($CLIDB_database < 1) ) + {$VARDB_database = $line; $VARDB_database =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_user/) && ($CLIDB_user < 1) ) + {$VARDB_user = $line; $VARDB_user =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_pass/) && ($CLIDB_pass < 1) ) + {$VARDB_pass = $line; $VARDB_pass =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_port/) && ($CLIDB_port < 1) ) + {$VARDB_port = $line; $VARDB_port =~ s/.*=//gi;} + $i++; + } + +# Customized Variables +$server_ip = $VARserver_ip; # Asterisk server IP + +if (!$VARDB_port) {$VARDB_port='3306';} + +$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass") + or die "Couldn't connect to database: " . DBI->errstr; + + +$oBook = Spreadsheet::ParseExcel::Workbook->Parse("$lead_file"); +my($iR, $iC, $oWkS, $oWkC); +$var_str=""; + +foreach $oWkS (@{$oBook->{Worksheet}}) { + for(my $iC = $oWkS->{MinCol} ; defined $oWkS->{MaxCol} && $iC <= $oWkS->{MaxCol} ; $iC++) { + $oWkC = $oWkS->{Cells}[0][$iC]; + if ($oWkC) { + $var_str.=$oWkC->Value."|"; + } else { + $var_str.="|"; + } + } +} + +@xls_row=split(/\|/, $var_str); + + +$stmtA = "select vendor_lead_code, source_id, list_id, phone_code, phone_number, title, first_name, middle_initial, last_name, address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email, security_phrase, comments, rank, owner from vicidial_list limit 1;"; +$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; +$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; +$sthArows=$sthA->rows; +$rec_count=0; +while ($sthArows > $rec_count) + { + my $names = $sthA->{'NAME'}; + my $numFields = $sthA->{'NUM_OF_FIELDS'}; + for (my $i = 0; $i < $numFields; $i++) + { + # printf("%s%s", $i ? "," : "", $$names[$i]); + # printf("%s%s", $i ? "," : "", $$ref[$i]); + + $field_name=uc($$names[$i]); + $field_name=~s/\_/ /g; + print "
".$field_name.": \r\n"; + print " \r\n"; + print "
"; +?> + + +
method=post onSubmit="ParseFileName()" enctype="multipart/form-data"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Carregar registros do arquivo:
ID da Lista Override: (somente números or leave blank for values in the file)
Sobrepor Código do Telefone: (somente números or leave blank for values in the file)
Layout do arquivo a usar:Standard Format    Layout Customizado
Verificação de Duplicidade de Registro:
Pesquisa do Fuso Horário do Registro:
        
        VOLTAR PARA ADMINLIST LOADER-     VERSÃO:     BUILD:    
+ + +document.forms[0].leadfile.disabled=true;document.forms[0].list_id_override.disabled=true;document.forms[0].phone_code_override.disabled=true; document.forms[0].submit_file.disabled=true; document.forms[0].reload_page.disabled=true;"; + flush(); + $total=0; $good=0; $bad=0; $dup=0; $post=0; $phone_list=''; + + if (!eregi(".csv", $leadfile_name) && !eregi(".xls", $leadfile_name)) { + # copy($leadfile, "./vicidial_temp_file.txt"); + $file=fopen("$lead_file", "r"); + if ($WeBRooTWritablE > 0) + { + $stmt_file=fopen("listloader_stmts.txt", "w"); + } + $buffer=fgets($file, 4096); + $tab_count=substr_count($buffer, "\t"); + $pipe_count=substr_count($buffer, "|"); + + if ($tab_count>$pipe_count) {$delimiter="\t"; $delim_name="tab";} else {$delimiter="|"; $delim_name="pipe";} + $field_check=explode($delimiter, $buffer); + + if (count($field_check)>=5) { + flush(); + $file=fopen("$lead_file", "r"); + print "
Procesando$delim_name-delimited file...\n"; + + if (strlen($list_id_override)>0) + { + print "

ID DA LISTA OVERRIDE FOR THIS FILE: $list_id_override

"; + } + + if (strlen($phone_code_override)>0) + { + print "

SOBREPOR CÓDIGO DO TELEFONE PARA ESTE ARQUIVO: $phone_code_override

"; + } + + while (!feof($file)) { + $record++; + $buffer=rtrim(fgets($file, 4096)); + $buffer=stripslashes($buffer); + + if (strlen($buffer)>0) { + $row=explode($delimiter, eregi_replace("[\'\"]", "", $buffer)); + + $pulldate=date("Y-m-d H:i:s"); + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user =""; + $vendor_lead_code = $row[$vendor_lead_code_field]; + $source_code = $row[$source_id_field]; + $source_id=$source_code; + $list_id = $row[$list_id_field]; + $gmt_offset = '0'; + $called_since_last_reset='N'; + $phone_code = eregi_replace("[^0-9]", "", $row[$phone_code_field]); + $phone_number = eregi_replace("[^0-9]", "", $row[$phone_number_field]); + $USarea = substr($phone_number, 0, 3); + $title = $row[$title_field]; + $first_name = $row[$first_name_field]; + $middle_initial = $row[$middle_initial_field]; + $last_name = $row[$last_name_field]; + $address1 = $row[$address1_field]; + $address2 = $row[$address2_field]; + $address3 = $row[$address3_field]; + $city =$row[$city_field]; + $state = $row[$state_field]; + $province = $row[$province_field]; + $postal_code = $row[$postal_code_field]; + $country_code = $row[$country_code_field]; + $gender = $row[$gender_field]; + $date_of_birth = $row[$date_of_birth_field]; + $alt_phone = eregi_replace("[^0-9]", "", $row[$alt_phone_field]); + $email = $row[$email_field]; + $security_phrase = $row[$security_phrase_field]; + $comments = trim($row[$comments_field]); + $rank = $row[$rank_field]; + $owner = $row[$owner_field]; + + if (strlen($list_id_override)>0) + { + # print "

ID DA LISTA OVERRIDE FOR THIS FILE: $list_id_override

"; + $list_id = $list_id_override; + } + if (strlen($phone_code_override)>0) + { + $phone_code = $phone_code_override; + } + + ##### Check for duplicate phone numbers in vicidial_list table for all lists in a campaign ##### + if (eregi("DUPCAMP",$dupcheck)) + { + $dup_lead=0; + $dup_lists=''; + $stmt="select campaign_id from vicidial_lists where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + $ci_recs = mysql_num_rows($rslt); + if ($ci_recs > 0) + { + $row=mysql_fetch_row($rslt); + $dup_camp = $row[0]; + + $stmt="select list_id from vicidial_lists where campaign_id='$dup_camp';"; + $rslt=mysql_query($stmt, $link); + $li_recs = mysql_num_rows($rslt); + if ($li_recs > 0) + { + $L=0; + while ($li_recs > $L) + { + $row=mysql_fetch_row($rslt); + $dup_lists .= "'$row[0]',"; + $L++; + } + $dup_lists = eregi_replace(",$",'',$dup_lists); + + $stmt="select list_id from vicidial_list where phone_number='$phone_number' and list_id IN($dup_lists) limit 1;"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $dup_lead=1; + $row=mysql_fetch_row($rslt); + $dup_lead_list = $row[0]; + } + if ($dup_lead < 1) + { + if (eregi("$phone_number$US$list_id",$phone_list)) + {$dup_lead++; $dup++;} + } + } + } + } + + ##### Check for duplicate phone numbers in vicidial_list table entire database ##### + if (eregi("DUPSYS",$dupcheck)) + { + $dup_lead=0; + $stmt="select list_id from vicidial_list where phone_number='$phone_number';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $dup_lead=1; + $row=mysql_fetch_row($rslt); + $dup_lead_list = $row[0]; + } + if ($dup_lead < 1) + { + if (eregi("$phone_number$US$list_id",$phone_list)) + {$dup_lead++; $dup++;} + } + } + + ##### Check for duplicate phone numbers in vicidial_list table for one list_id ##### + if (eregi("DUPLIST",$dupcheck)) + { + $dup_lead=0; + $stmt="select count(*) from vicidial_list where phone_number='$phone_number' and list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $dup_lead = $row[0]; + $dup_lead_list = $list_id; + } + if ($dup_lead < 1) + { + if (eregi("$phone_number$US$list_id",$phone_list)) + {$dup_lead++; $dup++;} + } + } + + ##### Check for duplicate title and alt-phone in vicidial_list table for one list_id ##### + if (eregi("DUPTITLEALTPHONELIST",$dupcheck)) + { + $dup_lead=0; + $stmt="select count(*) from vicidial_list where title='$title' and alt_phone='$alt_phone' and list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $dup_lead = $row[0]; + $dup_lead_list = $list_id; + } + if ($dup_lead < 1) + { + if (eregi("$alt_phone$title$US$list_id",$phone_list)) + {$dup_lead++; $dup++;} + } + } + + ##### Check for duplicate phone numbers in vicidial_list table entire database ##### + if (eregi("DUPTITLEALTPHONESYS",$dupcheck)) + { + $dup_lead=0; + $stmt="select list_id from vicidial_list where title='$title' and alt_phone='$alt_phone';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $dup_lead=1; + $row=mysql_fetch_row($rslt); + $dup_lead_list = $row[0]; + } + if ($dup_lead < 1) + { + if (eregi("$alt_phone$title$US$list_id",$phone_list)) + {$dup_lead++; $dup++;} + } + } + + + if ( (strlen($phone_number)>6) and ($dup_lead<1) ) + { + if (strlen($phone_code)<1) {$phone_code = '1';} + + if (eregi("TITLEALTPHONE",$dupcheck)) + {$phone_list .= "$alt_phone$title$US$list_id|";} + else + {$phone_list .= "$phone_number$US$list_id|";} + + $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmt,$postal_code); + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list (lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner) values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0,'2008-01-01 00:00:00','$rank','$owner');"; + $rslt=mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0,'2008-01-01 00:00:00','$rank','$owner'),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 1000000) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]| DUP: $dup_lead $dup_lead_list\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + usleep(1000); + flush(); + } + } + } + if ($multi_insert_counter!=0) { + $stmtZ = "INSERT INTO vicidial_list (lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner) values".substr($multistmt, 0, -1).";"; + mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + } + + print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total
"; + + } else { + print "
ERRO: O arquivo não possui a quantidade de campos requerida para continuar.
"; + } + } else if (!eregi(".csv", $leadfile_name)) { + # copy($leadfile, "./vicidial_temp_file.xls"); + $file=fopen("$lead_file", "r"); + + print "
ProcesandoExcel file... \n"; + if (strlen($list_id_override)>0) + { + print "

ID DA LISTA OVERRIDE FOR THIS FILE: $list_id_override

\n"; + } + if (strlen($phone_code_override)>0) + { + print "

SOBREPOR CÓDIGO DO TELEFONE PARA ESTE ARQUIVO: $phone_code_override

\n"; + } + # print "|$WeBServeRRooT/vicidial/listloader_super.pl $vendor_lead_code_field,$source_id_field,$list_id_field,$phone_code_field,$phone_number_field,$title_field,$first_name_field,$middle_initial_field,$last_name_field,$address1_field,$address2_field,$address3_field,$city_field,$state_field,$province_field,$postal_code_field,$country_code_field,$gender_field,$date_of_birth_field,$alt_phone_field,$email_field,$security_phrase_field,$comments_field,$rank_field,$owner_field, --forcelistid=$list_id_override --lead_file=$lead_file|"; + $dupcheckCLI=''; $postalgmtCLI=''; + if (eregi("DUPLIST",$dupcheck)) {$dupcheckCLI='--duplicate-check';} + if (eregi("DUPCAMP",$dupcheck)) {$dupcheckCLI='--duplicate-campaign-check';} + if (eregi("DUPSYS",$dupcheck)) {$dupcheckCLI='--duplicate-system-check';} + if (eregi("DUPTITLEALTPHONELIST",$dupcheck)) {$dupcheckCLI='--duplicate-tap-list-check';} + if (eregi("DUPTITLEALTPHONESYS",$dupcheck)) {$dupcheckCLI='--duplicate-tap-system-check';} + if (eregi("POSTAL",$postalgmt)) {$postalgmtCLI='--postal-code-gmt';} + passthru("$WeBServeRRooT/vicidial/listloader_super.pl $vendor_lead_code_field,$source_id_field,$list_id_field,$phone_code_field,$phone_number_field,$title_field,$first_name_field,$middle_initial_field,$last_name_field,$address1_field,$address2_field,$address3_field,$city_field,$state_field,$province_field,$postal_code_field,$country_code_field,$gender_field,$date_of_birth_field,$alt_phone_field,$email_field,$security_phrase_field,$comments_field,$rank_field,$owner_field, --forcelistid=$list_id_override --forcephonecode=$phone_code_override --lead-file=$lead_file $postalgmtCLI $dupcheckCLI"); + } else { + # copy($leadfile, "./vicidial_temp_file.csv"); + $file=fopen("$lead_file", "r"); + + if ($WeBRooTWritablE > 0) + {$stmt_file=fopen("$WeBServeRRooT/vicidial/listloader_stmts.txt", "w");} + + print "
ProcesandoCSV file... \n"; + if (strlen($list_id_override)>0) + { + print "

ID DA LISTA OVERRIDE FOR THIS FILE: $list_id_override

"; + } + + if (strlen($phone_code_override)>0) + { + print "

SOBREPOR CÓDIGO DO TELEFONE PARA ESTE ARQUIVO: $phone_code_override

"; + } + + while($row=fgetcsv($file, 1000, ",")) { + + $pulldate=date("Y-m-d H:i:s"); + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user =""; + $vendor_lead_code = $row[$vendor_lead_code_field]; + $source_code = $row[$source_id_field]; + $source_id=$source_code; + $list_id = $row[$list_id_field]; + $gmt_offset = '0'; + $called_since_last_reset='N'; + $phone_code = eregi_replace("[^0-9]", "", $row[$phone_code_field]); + $phone_number = eregi_replace("[^0-9]", "", $row[$phone_number_field]); + $USarea = substr($phone_number, 0, 3); + $title = $row[$title_field]; + $first_name = $row[$first_name_field]; + $middle_initial = $row[$middle_initial_field]; + $last_name = $row[$last_name_field]; + $address1 = $row[$address1_field]; + $address2 = $row[$address2_field]; + $address3 = $row[$address3_field]; + $city =$row[$city_field]; + $state = $row[$state_field]; + $province = $row[$province_field]; + $postal_code = $row[$postal_code_field]; + $country_code = $row[$country_code_field]; + $gender = $row[$gender_field]; + $date_of_birth = $row[$date_of_birth_field]; + $alt_phone = eregi_replace("[^0-9]", "", $row[$alt_phone_field]); + $email = $row[$email_field]; + $security_phrase = $row[$security_phrase_field]; + $comments = trim($row[$comments_field]); + $rank = $row[$rank_field]; + $owner = $row[$owner_field]; + + if (strlen($rank)<1) {$rank='0';} + + if (strlen($list_id_override)>0) + { + $list_id = $list_id_override; + } + if (strlen($phone_code_override)>0) + { + $phone_code = $phone_code_override; + } + + ##### Check for duplicate phone numbers in vicidial_list table for all lists in a campaign ##### + if (eregi("DUPCAMP",$dupcheck)) + { + $dup_lead=0; + $dup_lists=''; + $stmt="select campaign_id from vicidial_lists where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + $ci_recs = mysql_num_rows($rslt); + if ($ci_recs > 0) + { + $row=mysql_fetch_row($rslt); + $dup_camp = $row[0]; + + $stmt="select list_id from vicidial_lists where campaign_id='$dup_camp';"; + $rslt=mysql_query($stmt, $link); + $li_recs = mysql_num_rows($rslt); + if ($li_recs > 0) + { + $L=0; + while ($li_recs > $L) + { + $row=mysql_fetch_row($rslt); + $dup_lists .= "'$row[0]',"; + $L++; + } + $dup_lists = eregi_replace(",$",'',$dup_lists); + + $stmt="select list_id from vicidial_list where phone_number='$phone_number' and list_id IN($dup_lists) limit 1;"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $dup_lead=1; + $row=mysql_fetch_row($rslt); + $dup_lead_list = $row[0]; + } + if ($dup_lead < 1) + { + if (eregi("$phone_number$US$list_id",$phone_list)) + {$dup_lead++; $dup++;} + } + } + } + } + + ##### Check for duplicate phone numbers in vicidial_list table entire database ##### + if (eregi("DUPSYS",$dupcheck)) + { + $dup_lead=0; + $stmt="select list_id from vicidial_list where phone_number='$phone_number';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $dup_lead=1; + $row=mysql_fetch_row($rslt); + $dup_lead_list = $row[0]; + } + if ($dup_lead < 1) + { + if (eregi("$phone_number$US$list_id",$phone_list)) + {$dup_lead++; $dup++;} + } + } + + ##### Check for duplicate phone numbers in vicidial_list table for one list_id ##### + if (eregi("DUPLIST",$dupcheck)) + { + $dup_lead=0; + $stmt="select count(*) from vicidial_list where phone_number='$phone_number' and list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $dup_lead = $row[0]; + } + if ($dup_lead < 1) + { + if (eregi("$phone_number$US$list_id",$phone_list)) + {$dup_lead++; $dup++;} + } + } + + ##### Check for duplicate title and alt-phone in vicidial_list table for one list_id ##### + if (eregi("DUPTITLEALTPHONELIST",$dupcheck)) + { + $dup_lead=0; + $stmt="select count(*) from vicidial_list where title='$title' and alt_phone='$alt_phone' and list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $dup_lead = $row[0]; + $dup_lead_list = $list_id; + } + if ($dup_lead < 1) + { + if (eregi("$alt_phone$title$US$list_id",$phone_list)) + {$dup_lead++; $dup++;} + } + } + + ##### Check for duplicate phone numbers in vicidial_list table entire database ##### + if (eregi("DUPTITLEALTPHONESYS",$dupcheck)) + { + $dup_lead=0; + $stmt="select list_id from vicidial_list where title='$title' and alt_phone='$alt_phone';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $dup_lead=1; + $row=mysql_fetch_row($rslt); + $dup_lead_list = $row[0]; + } + if ($dup_lead < 1) + { + if (eregi("$alt_phone$title$US$list_id",$phone_list)) + {$dup_lead++; $dup++;} + } + } + + if ( (strlen($phone_number)>6) and ($dup_lead<1) ) + { + if (strlen($phone_code)<1) {$phone_code = '1';} + + if (eregi("TITLEALTPHONE",$dupcheck)) + {$phone_list .= "$alt_phone$title$US$list_id|";} + else + {$phone_list .= "$phone_number$US$list_id|";} + + + $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmt,$postal_code); + + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list (lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner) values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0,'2008-01-01 00:00:00','$rank','$owner');"; + $rslt=mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0,'2008-01-01 00:00:00','$rank','$owner'),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 1000000) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]| DUP: $dup_lead\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + usleep(1000); + flush(); + } + } + if ($multi_insert_counter!=0) { + $stmtZ = "INSERT INTO vicidial_list (lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner) values".substr($multistmt, 0, -1).";"; + mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + } + print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total
"; + } + print ""; + } + +if ($leadfile) { + $total=0; $good=0; $bad=0; $dup=0; $post=0; $phone_list=''; + + ### LOG INSERTION Admin Log Table ### + $stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$PHP_AUTH_USER', ip_address='$ip', event_section='LISTAS', event_type='LOAD', record_id='$list_id_override', event_code='ADMIN LOAD LIST', event_sql='', event_notes='File Name: $leadfile_name';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + if ($file_layout=="standard") { + + print ""; + flush(); + + if (!eregi(".csv", $leadfile_name) && !eregi(".xls", $leadfile_name)) { + + if ($WeBRooTWritablE > 0) + { + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.txt"); + $lead_file = "./vicidial_temp_file.txt"; + } + else + { + copy($LF_path, "/tmp/vicidial_temp_file.txt"); + $lead_file = "/tmp/vicidial_temp_file.txt"; + } + $file=fopen("$lead_file", "r"); + if ($WeBRooTWritablE > 0) + {$stmt_file=fopen("$WeBServeRRooT/vicidial/listloader_stmts.txt", "w");} + + $buffer=fgets($file, 4096); + $tab_count=substr_count($buffer, "\t"); + $pipe_count=substr_count($buffer, "|"); + + if ($tab_count>$pipe_count) {$delimiter="\t"; $delim_name="tab";} else {$delimiter="|"; $delim_name="pipe";} + $field_check=explode($delimiter, $buffer); + + if (count($field_check)>=5) { + flush(); + $file=fopen("$lead_file", "r"); + $total=0; $good=0; $bad=0; $dup=0; $post=0; $phone_list=''; + print "
Procesando$delim_name-delimited file... ($tab_count|$pipe_count)\n"; + if (strlen($list_id_override)>0) + { + print "

ID DA LISTA OVERRIDE FOR THIS FILE: $list_id_override

"; + } + if (strlen($phone_code_override)>0) + { + print "

SOBREPOR CÓDIGO DO TELEFONE PARA ESTE ARQUIVO: $phone_code_override

\n"; + } + while (!feof($file)) { + $record++; + $buffer=rtrim(fgets($file, 4096)); + $buffer=stripslashes($buffer); + + if (strlen($buffer)>0) { + $row=explode($delimiter, eregi_replace("[\'\"]", "", $buffer)); + + $pulldate=date("Y-m-d H:i:s"); + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user =""; + $vendor_lead_code = $row[0]; + $source_code = $row[1]; + $source_id=$source_code; + $list_id = $row[2]; + $gmt_offset = '0'; + $called_since_last_reset='N'; + $phone_code = eregi_replace("[^0-9]", "", $row[3]); + $phone_number = eregi_replace("[^0-9]", "", $row[4]); + $USarea = substr($phone_number, 0, 3); + $title = $row[5]; + $first_name = $row[6]; + $middle_initial = $row[7]; + $last_name = $row[8]; + $address1 = $row[9]; + $address2 = $row[10]; + $address3 = $row[11]; + $city =$row[12]; + $state = $row[13]; + $province = $row[14]; + $postal_code = $row[15]; + $country_code = $row[16]; + $gender = $row[17]; + $date_of_birth = $row[18]; + $alt_phone = eregi_replace("[^0-9]", "", $row[19]); + $email = $row[20]; + $security_phrase = $row[21]; + $comments = trim($row[22]); + $rank = $row[23]; + $owner = $row[24]; + + if (strlen($list_id_override)>0) + { + $list_id = $list_id_override; + } + if (strlen($phone_code_override)>0) + { + $phone_code = $phone_code_override; + } + + ##### Check for duplicate phone numbers in vicidial_list table for all lists in a campaign ##### + if (eregi("DUPCAMP",$dupcheck)) + { + $dup_lead=0; + $dup_lists=''; + $stmt="select campaign_id from vicidial_lists where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + $ci_recs = mysql_num_rows($rslt); + if ($ci_recs > 0) + { + $row=mysql_fetch_row($rslt); + $dup_camp = $row[0]; + + $stmt="select list_id from vicidial_lists where campaign_id='$dup_camp';"; + $rslt=mysql_query($stmt, $link); + $li_recs = mysql_num_rows($rslt); + if ($li_recs > 0) + { + $L=0; + while ($li_recs > $L) + { + $row=mysql_fetch_row($rslt); + $dup_lists .= "'$row[0]',"; + $L++; + } + $dup_lists = eregi_replace(",$",'',$dup_lists); + + $stmt="select list_id from vicidial_list where phone_number='$phone_number' and list_id IN($dup_lists) limit 1;"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $dup_lead=1; + $row=mysql_fetch_row($rslt); + $dup_lead_list = $row[0]; + } + if ($dup_lead < 1) + { + if (eregi("$phone_number$US$list_id",$phone_list)) + {$dup_lead++; $dup++;} + } + } + } + } + + ##### Check for duplicate phone numbers in vicidial_list table entire database ##### + if (eregi("DUPSYS",$dupcheck)) + { + $dup_lead=0; + $stmt="select list_id from vicidial_list where phone_number='$phone_number';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $dup_lead=1; + $row=mysql_fetch_row($rslt); + $dup_lead_list = $row[0]; + } + if ($dup_lead < 1) + { + if (eregi("$phone_number$US$list_id",$phone_list)) + {$dup_lead++; $dup++;} + } + } + + ##### Check for duplicate phone numbers in vicidial_list table for one list_id ##### + if (eregi("DUPLIST",$dupcheck)) + { + $dup_lead=0; + $stmt="select count(*) from vicidial_list where phone_number='$phone_number' and list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $dup_lead = $row[0]; + } + if ($dup_lead < 1) + { + if (eregi("$phone_number$US$list_id",$phone_list)) + {$dup_lead++; $dup++;} + } + } + + ##### Check for duplicate title and alt-phone in vicidial_list table for one list_id ##### + if (eregi("DUPTITLEALTPHONELIST",$dupcheck)) + { + $dup_lead=0; + $stmt="select count(*) from vicidial_list where title='$title' and alt_phone='$alt_phone' and list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $dup_lead = $row[0]; + $dup_lead_list = $list_id; + } + if ($dup_lead < 1) + { + if (eregi("$alt_phone$title$US$list_id",$phone_list)) + {$dup_lead++; $dup++;} + } + } + + ##### Check for duplicate phone numbers in vicidial_list table entire database ##### + if (eregi("DUPTITLEALTPHONESYS",$dupcheck)) + { + $dup_lead=0; + $stmt="select list_id from vicidial_list where title='$title' and alt_phone='$alt_phone';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $dup_lead=1; + $row=mysql_fetch_row($rslt); + $dup_lead_list = $row[0]; + } + if ($dup_lead < 1) + { + if (eregi("$alt_phone$title$US$list_id",$phone_list)) + {$dup_lead++; $dup++;} + } + } + + if ( (strlen($phone_number)>6) and ($dup_lead<1) ) + { + if (strlen($phone_code)<1) {$phone_code = '1';} + + if (eregi("TITLEALTPHONE",$dupcheck)) + {$phone_list .= "$alt_phone$title$US$list_id|";} + else + {$phone_list .= "$phone_number$US$list_id|";} + + + $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmt,$postal_code); + + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list (lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner) values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0,'2008-01-01 00:00:00','$rank','$owner');"; + $rslt=mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0,'2008-01-01 00:00:00','$rank','$owner'),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 1000000) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]| DUP: $dup_lead\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + usleep(1000); + flush(); + } + } + } + if ($multi_insert_counter!=0) { + $stmtZ = "INSERT INTO vicidial_list (lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner) values".substr($multistmt, 0, -1).";"; + mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + } + + print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total
"; + + } else { + print "
ERRO: O arquivo não possui a quantidade de campos requerida para continuar.
"; + } + } else if (!eregi(".csv", $leadfile_name)) + { + if ($WeBRooTWritablE > 0) + { + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.xls"); + $lead_file = "$WeBServeRRooT/vicidial/vicidial_temp_file.xls"; + } + else + { + copy($LF_path, "/tmp/vicidial_temp_file.xls"); + $lead_file = "/tmp/vicidial_temp_file.xls"; + } + $file=fopen("$lead_file", "r"); + + # echo "|$WeBServeRRooT/vicidial/listloader.pl --forcelistid=$list_id_override --lead-file=$lead_file|"; + $dupcheckCLI=''; $postalgmtCLI=''; + if (eregi("DUPLIST",$dupcheck)) {$dupcheckCLI='--duplicate-check';} + if (eregi("DUPCAMP",$dupcheck)) {$dupcheckCLI='--duplicate-campaign-check';} + if (eregi("DUPSYS",$dupcheck)) {$dupcheckCLI='--duplicate-system-check';} + if (eregi("DUPTITLEALTPHONELIST",$dupcheck)) {$dupcheckCLI='--duplicate-tap-list-check';} + if (eregi("DUPTITLEALTPHONESYS",$dupcheck)) {$dupcheckCLI='--duplicate-tap-system-check';} + if (eregi("POSTAL",$postalgmt)) {$postalgmtCLI='--postal-code-gmt';} + passthru("$WeBServeRRooT/vicidial/listloader.pl --forcelistid=$list_id_override --forcephonecode=$phone_code_override --lead-file=$lead_file $postalgmtCLI $dupcheckCLI"); + + } + else + { + if ($WeBRooTWritablE > 0) + { + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.csv"); + $lead_file = "$WeBServeRRooT/vicidial/vicidial_temp_file.csv"; + } + else + { + copy($LF_path, "/tmp/vicidial_temp_file.csv"); + $lead_file = "/tmp/vicidial_temp_file.csv"; + } + $file=fopen("$lead_file", "r"); + if ($WeBRooTWritablE > 0) + {$stmt_file=fopen("$WeBServeRRooT/vicidial/listloader_stmts.txt", "w");} + + print "
ProcesandoCSV file... \n"; + + if (strlen($list_id_override)>0) + { + print "

ID DA LISTA OVERRIDE FOR THIS FILE: $list_id_override

"; + } + if (strlen($phone_code_override)>0) + { + print "

SOBREPOR CÓDIGO DO TELEFONE PARA ESTE ARQUIVO: $phone_code_override

"; + } + + while($row=fgetcsv($file, 1000, ",")) { + $pulldate=date("Y-m-d H:i:s"); + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user =""; + $vendor_lead_code = $row[0]; + $source_code = $row[1]; + $source_id=$source_code; + $list_id = $row[2]; + $gmt_offset = '0'; + $called_since_last_reset='N'; + $phone_code = eregi_replace("[^0-9]", "", $row[3]); + $phone_number = eregi_replace("[^0-9]", "", $row[4]); + $USarea = substr($phone_number, 0, 3); + $title = $row[5]; + $first_name = $row[6]; + $middle_initial = $row[7]; + $last_name = $row[8]; + $address1 = $row[9]; + $address2 = $row[10]; + $address3 = $row[11]; + $city =$row[12]; + $state = $row[13]; + $province = $row[14]; + $postal_code = $row[15]; + $country_code = $row[16]; + $gender = $row[17]; + $date_of_birth = $row[18]; + $alt_phone = eregi_replace("[^0-9]", "", $row[19]); + $email = $row[20]; + $security_phrase = $row[21]; + $comments = trim($row[22]); + $rank = $row[23]; + $owner = $row[24]; + + if (strlen($list_id_override)>0) + { + $list_id = $list_id_override; + } + if (strlen($phone_code_override)>0) + { + $phone_code = $phone_code_override; + } + + ##### Check for duplicate phone numbers in vicidial_list table for all lists in a campaign ##### + if (eregi("DUPCAMP",$dupcheck)) + { + $dup_lead=0; + $dup_lists=''; + $stmt="select campaign_id from vicidial_lists where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + $ci_recs = mysql_num_rows($rslt); + if ($ci_recs > 0) + { + $row=mysql_fetch_row($rslt); + $dup_camp = $row[0]; + + $stmt="select list_id from vicidial_lists where campaign_id='$dup_camp';"; + $rslt=mysql_query($stmt, $link); + $li_recs = mysql_num_rows($rslt); + if ($li_recs > 0) + { + $L=0; + while ($li_recs > $L) + { + $row=mysql_fetch_row($rslt); + $dup_lists .= "'$row[0]',"; + $L++; + } + $dup_lists = eregi_replace(",$",'',$dup_lists); + + $stmt="select list_id from vicidial_list where phone_number='$phone_number' and list_id IN($dup_lists) limit 1;"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $dup_lead=1; + $row=mysql_fetch_row($rslt); + $dup_lead_list = $row[0]; + } + if ($dup_lead < 1) + { + if (eregi("$phone_number$US$list_id",$phone_list)) + {$dup_lead++; $dup++;} + } + } + } + } + + ##### Check for duplicate phone numbers in vicidial_list table entire database ##### + if (eregi("DUPSYS",$dupcheck)) + { + $dup_lead=0; + $stmt="select list_id from vicidial_list where phone_number='$phone_number';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $dup_lead=1; + $row=mysql_fetch_row($rslt); + $dup_lead_list = $row[0]; + } + if ($dup_lead < 1) + { + if (eregi("$phone_number$US$list_id",$phone_list)) + {$dup_lead++; $dup++;} + } + } + + ##### Check for duplicate phone numbers in vicidial_list table for one list_id ##### + if (eregi("DUPLIST",$dupcheck)) + { + $dup_lead=0; + $stmt="select count(*) from vicidial_list where phone_number='$phone_number' and list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $dup_lead = $row[0]; + } + if ($dup_lead < 1) + { + if (eregi("$phone_number$US$list_id",$phone_list)) + {$dup_lead++; $dup++;} + } + } + + ##### Check for duplicate title and alt-phone in vicidial_list table for one list_id ##### + if (eregi("DUPTITLEALTPHONELIST",$dupcheck)) + { + $dup_lead=0; + $stmt="select count(*) from vicidial_list where title='$title' and alt_phone='$alt_phone' and list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $dup_lead = $row[0]; + $dup_lead_list = $list_id; + } + if ($dup_lead < 1) + { + if (eregi("$alt_phone$title$US$list_id",$phone_list)) + {$dup_lead++; $dup++;} + } + } + + ##### Check for duplicate phone numbers in vicidial_list table entire database ##### + if (eregi("DUPTITLEALTPHONESYS",$dupcheck)) + { + $dup_lead=0; + $stmt="select list_id from vicidial_list where title='$title' and alt_phone='$alt_phone';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $dup_lead=1; + $row=mysql_fetch_row($rslt); + $dup_lead_list = $row[0]; + } + if ($dup_lead < 1) + { + if (eregi("$alt_phone$title$US$list_id",$phone_list)) + {$dup_lead++; $dup++;} + } + } + + if ( (strlen($phone_number)>6) and ($dup_lead<1) ) + { + if (strlen($phone_code)<1) {$phone_code = '1';} + + if (eregi("TITLEALTPHONE",$dupcheck)) + {$phone_list .= "$alt_phone$title$US$list_id|";} + else + {$phone_list .= "$phone_number$US$list_id|";} + + $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmt,$postal_code); + + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list (lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner) values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0,'2008-01-01 00:00:00','$rank','$owner');"; + $rslt=mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0,'2008-01-01 00:00:00','$rank','$owner'),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 1000000) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]| DUP: $dup_lead\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + usleep(1000); + flush(); + } + } + if ($multi_insert_counter!=0) { + $stmtZ = "INSERT INTO vicidial_list (lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner) values".substr($multistmt, 0, -1).";"; + mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + } + + print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total
"; + + } + print ""; + + } else { + print "
"; + flush(); + print "\r\n"; + print " \r\n"; + print " \r\n"; + print " \r\n"; + print " \r\n"; + + $rslt=mysql_query("select vendor_lead_code, source_id, list_id, phone_code, phone_number, title, first_name, middle_initial, last_name, address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email, security_phrase, comments, rank, owner from vicidial_list limit 1", $link); + + + if (!eregi(".csv", $leadfile_name) && !eregi(".xls", $leadfile_name)) + { + if ($WeBRooTWritablE > 0) + { + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.txt"); + $lead_file = "$WeBServeRRooT/vicidial/vicidial_temp_file.txt"; + } + else + { + copy($LF_path, "/tmp/vicidial_temp_file.txt"); + $lead_file = "/tmp/vicidial_temp_file.txt"; + } + $file=fopen("$lead_file", "r"); + if ($WeBRooTWritablE > 0) + {$stmt_file=fopen("$WeBServeRRooT/vicidial/listloader_stmts.txt", "w");} + + $buffer=fgets($file, 4096); + $tab_count=substr_count($buffer, "\t"); + $pipe_count=substr_count($buffer, "|"); + + if ($tab_count>$pipe_count) {$delimiter="\t"; $delim_name="tab";} else {$delimiter="|"; $delim_name="pipe";} + $field_check=explode($delimiter, $buffer); + flush(); + $file=fopen("$lead_file", "r"); + print "
Procesando$delim_name-delimited file...\n"; + + if (strlen($list_id_override)>0) + { + print "

ID DA LISTA OVERRIDE FOR THIS FILE: $list_id_override

"; + } + if (strlen($phone_code_override)>0) + { + print "

SOBREPOR CÓDIGO DO TELEFONE PARA ESTE ARQUIVO: $phone_code_override

"; + } + $buffer=rtrim(fgets($file, 4096)); + $buffer=stripslashes($buffer); + $row=explode($delimiter, eregi_replace("[\'\"]", "", $buffer)); + + for ($i=0; $i\n"; + } else { + print "
\r\n"; + print " \r\n"; + print " \r\n"; + print " \r\n"; + } + + } + } + else if (!eregi(".csv", $leadfile_name)) + { + if ($WeBRooTWritablE > 0) + { + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.xls"); + $lead_file = "$WeBServeRRooT/vicidial/vicidial_temp_file.xls"; + } + else + { + copy($LF_path, "/tmp/vicidial_temp_file.xls"); + $lead_file = "/tmp/vicidial_temp_file.xls"; + } + + # echo "|$WeBServeRRooT/vicidial/listloader_rowdisplay.pl --lead-file=$lead_file|"; + $dupcheckCLI=''; $postalgmtCLI=''; + if (eregi("DUPLIST",$dupcheck)) {$dupcheckCLI='--duplicate-check';} + if (eregi("DUPCAMP",$dupcheck)) {$dupcheckCLI='--duplicate-campaign-check';} + if (eregi("DUPSYS",$dupcheck)) {$dupcheckCLI='--duplicate-system-check';} + if (eregi("DUPTITLEALTPHONELIST",$dupcheck)) {$dupcheckCLI='--duplicate-tap-list-check';} + if (eregi("DUPTITLEALTPHONESYS",$dupcheck)) {$dupcheckCLI='--duplicate-tap-system-check';} + if (eregi("POSTAL",$postalgmt)) {$postalgmtCLI='--postal-code-gmt';} + passthru("$WeBServeRRooT/vicidial/listloader_rowdisplay.pl --lead-file=$lead_file $postalgmtCLI $dupcheckCLI"); + } + else + { + if ($WeBRooTWritablE > 0) + { + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.csv"); + $lead_file = "$WeBServeRRooT/vicidial/vicidial_temp_file.csv"; + } + else + { + copy($LF_path, "/tmp/vicidial_temp_file.csv"); + $lead_file = "/tmp/vicidial_temp_file.csv"; + } + $file=fopen("$lead_file", "r"); + + if ($WeBRooTWritablE > 0) + {$stmt_file=fopen("$WeBServeRRooT/vicidial/listloader_stmts.txt", "w");} + + print "
ProcesandoCSV file... \n"; + + if (strlen($list_id_override)>0) + { + print "

ID DA LISTA OVERRIDE FOR THIS FILE: $list_id_override

"; + } + if (strlen($phone_code_override)>0) + { + print "

SOBREPOR CÓDIGO DO TELEFONE PARA ESTE ARQUIVO: $phone_code_override

"; + } + + $total=0; $good=0; $bad=0; $dup=0; $post=0; $phone_list=''; + $row=fgetcsv($file, 1000, ","); + for ($i=0; $i\n"; + } else { + print "
\r\n"; + print " \r\n"; + print " \r\n"; + print " \r\n"; + } + } + } + print " \r\n"; + print " \r\n"; + print " \r\n"; + print " \r\n"; + print " \r\n"; + print " \r\n"; + print " \r\n"; + print " \r\n"; + print "
VICIDIAL ColunaDados do arquivo
".strtoupper(eregi_replace("_", " ", mysql_field_name($rslt, $i))).":
".strtoupper(eregi_replace("_", " ", mysql_field_name($rslt, $i))).":
        
\r\n"; + # } + print ""; + } +#} else if (filesize($leadfile)>8388608) { +# print "
ERROR: File exceeds the 8MB limit.
"; +} +?> + + + + + + + + +4) ) + { + if (preg_match('/^1$/', $phone_code)) + { + $stmt="select postal_code,state,GMT_offset,DST,DST_range,country,country_code from vicidial_postal_codes where country_code='$phone_code' and postal_code LIKE \"$postal_code%\";"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[2]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[3]; + $dst_range = $row[4]; + $PC_processed++; + $postalgmt_found++; + $post++; + } + } + } +if ($postalgmt_found < 1) + { + $PC_processed=0; + ### UNITED STATES ### + if ($phone_code =='1') + { + $stmt="select country_code,country,areacode,state,GMT_offset,DST,DST_range,geographic_description from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + ### MEXICO ### + if ($phone_code =='52') + { + $stmt="select country_code,country,areacode,state,GMT_offset,DST,DST_range,geographic_description from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + ### AUSTRALIA ### + if ($phone_code =='61') + { + $stmt="select country_code,country,areacode,state,GMT_offset,DST,DST_range,geographic_description from vicidial_phone_codes where country_code='$phone_code' and state='$state';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + ### ALL OTHER COUNTRY CODES ### + if (!$PC_processed) + { + $PC_processed++; + $stmt="select country_code,country,areacode,state,GMT_offset,DST,DST_range,geographic_description from vicidial_phone_codes where country_code='$phone_code';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + } + +### Find out if DST to raise the gmt offset ### +$AC_GMT_diff = ($gmt_offset - $LOCAL_GMT_OFF_STD); +$AC_localtime = mktime(($Shour + $AC_GMT_diff), $Smin, $Ssec, $Smon, $Smday, $Syear); + $hour = date("H",$AC_localtime); + $min = date("i",$AC_localtime); + $sec = date("s",$AC_localtime); + $mon = date("m",$AC_localtime); + $mday = date("d",$AC_localtime); + $wday = date("w",$AC_localtime); + $year = date("Y",$AC_localtime); +$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + +$AC_processed=0; +if ( (!$AC_processed) and ($dst_range == 'SSM-FSN') ) + { + if ($DBX) {print " Second Domingo March to First Domingo November\n";} + #********************************************************************** + # SSM-FSN + # This is returns 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on Second Domingo March to First Domingo November at 2 am. + # INPUTS: + # mm INTEGER Month. + # dd INTEGER Day of the month. + # ns INTEGER Seconds into the day. + # dow INTEGER Day of week (0=Domingo, to 6=Sábado) + # OPTIONAL INPUT: + # timezone INTEGER hour difference UTC - local standard time + # (DEFAULT is blank) + # make calculations based on UTC time, + # which means shift at 10:00 UTC in April + # and 9:00 UTC in October + # OUTPUT: + # INTEGER 1 = DST, 0 = not DST + # + # S M T W T F S + # 1 2 3 4 5 6 7 + # 8 9 10 11 12 13 14 + #15 16 17 18 19 20 21 + #22 23 24 25 26 27 28 + #29 30 31 + # + # S M T W T F S + # 1 2 3 4 5 6 + # 7 8 9 10 11 12 13 + #14 15 16 17 18 19 20 + #21 22 23 24 25 26 27 + #28 29 30 31 + # + #********************************************************************** + + $USACAN_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 11) { + $USACAN_DST=0; + } elseif ($mm >= 4 and $mm <= 10) { + $USACAN_DST=1; + } elseif ($mm == 3) { + if ($dd > 13) { + $USACAN_DST=1; + } elseif ($dd >= ($dow+8)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $USACAN_DST=0; + } else { + $USACAN_DST=1; + } + } else { + if ($dow == 0 and $ns < 7200) { + $USACAN_DST=0; + } else { + $USACAN_DST=1; + } + } + } else { + $USACAN_DST=0; + } + } elseif ($mm == 11) { + if ($dd > 7) { + $USACAN_DST=0; + } elseif ($dd < ($dow+1)) { + $USACAN_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (7200+($timezone-1)*3600)) { + $USACAN_DST=1; + } else { + $USACAN_DST=0; + } + } else { # horário local calculations + if ($ns < 7200) { + $USACAN_DST=1; + } else { + $USACAN_DST=0; + } + } + } else { + $USACAN_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $USACAN_DST\n";} + if ($USACAN_DST) {$gmt_offset++;} + $AC_processed++; + } + +if ( (!$AC_processed) and ($dst_range == 'FSA-LSO') ) + { + if ($DBX) {print " First Domingo April to Last Domingo October\n";} + #********************************************************************** + # FSA-LSO + # This is returns 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Domingo in April and last Domingo in October at 2 am. + #********************************************************************** + + $USA_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 4 || $mm > 10) { + $USA_DST=0; + } elseif ($mm >= 5 and $mm <= 9) { + $USA_DST=1; + } elseif ($mm == 4) { + if ($dd > 7) { + $USA_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $USA_DST=0; + } else { + $USA_DST=1; + } + } else { + if ($dow == 0 and $ns < 7200) { + $USA_DST=0; + } else { + $USA_DST=1; + } + } + } else { + $USA_DST=0; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $USA_DST=1; + } elseif ($dd < ($dow+25)) { + $USA_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (7200+($timezone-1)*3600)) { + $USA_DST=1; + } else { + $USA_DST=0; + } + } else { # horário local calculations + if ($ns < 7200) { + $USA_DST=1; + } else { + $USA_DST=0; + } + } + } else { + $USA_DST=0; + } + } # end of month checks + + if ($DBX) {print " DST: $USA_DST\n";} + if ($USA_DST) {$gmt_offset++;} + $AC_processed++; + } + +if ( (!$AC_processed) and ($dst_range == 'LSM-LSO') ) + { + if ($DBX) {print " Last Domingo March to Last Domingo October\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on last Domingo in March and last Domingo in October at 1 am. + #********************************************************************** + + $GBR_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $GBR_DST=0; + } elseif ($mm >= 4 and $mm <= 9) { + $GBR_DST=1; + } elseif ($mm == 3) { + if ($dd < 25) { + $GBR_DST=0; + } elseif ($dd < ($dow+25)) { + $GBR_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=0; + } else { + $GBR_DST=1; + } + } else { # horário local calculations + if ($ns < 3600) { + $GBR_DST=0; + } else { + $GBR_DST=1; + } + } + } else { + $GBR_DST=1; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $GBR_DST=1; + } elseif ($dd < ($dow+25)) { + $GBR_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=1; + } else { + $GBR_DST=0; + } + } else { # horário local calculations + if ($ns < 3600) { + $GBR_DST=1; + } else { + $GBR_DST=0; + } + } + } else { + $GBR_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $GBR_DST\n";} + if ($GBR_DST) {$gmt_offset++;} + $AC_processed++; + } +if ( (!$AC_processed) and ($dst_range == 'LSO-LSM') ) + { + if ($DBX) {print " Last Domingo October to Last Domingo March\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on last Domingo in October and last Domingo in March at 1 am. + #********************************************************************** + + $AUS_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUS_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $AUS_DST=0; + } elseif ($mm == 3) { + if ($dd < 25) { + $AUS_DST=1; + } elseif ($dd < ($dow+25)) { + $AUS_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=1; + } else { + $AUS_DST=0; + } + } else { # horário local calculations + if ($ns < 3600) { + $AUS_DST=1; + } else { + $AUS_DST=0; + } + } + } else { + $AUS_DST=0; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $AUS_DST=0; + } elseif ($dd < ($dow+25)) { + $AUS_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=0; + } else { + $AUS_DST=1; + } + } else { # horário local calculations + if ($ns < 3600) { + $AUS_DST=0; + } else { + $AUS_DST=1; + } + } + } else { + $AUS_DST=1; + } + } # end of month checks + if ($DBX) {print " DST: $AUS_DST\n";} + if ($AUS_DST) {$gmt_offset++;} + $AC_processed++; + } + +if ( (!$AC_processed) and ($dst_range == 'FSO-LSM') ) + { + if ($DBX) {print " First Domingo October to Last Domingo March\n";} + #********************************************************************** + # TASMANIA ONLY + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Domingo in October and last Domingo in March at 1 am. + #********************************************************************** + + $AUST_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUST_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $AUST_DST=0; + } elseif ($mm == 3) { + if ($dd < 25) { + $AUST_DST=1; + } elseif ($dd < ($dow+25)) { + $AUST_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUST_DST=1; + } else { + $AUST_DST=0; + } + } else { # horário local calculations + if ($ns < 3600) { + $AUST_DST=1; + } else { + $AUST_DST=0; + } + } + } else { + $AUST_DST=0; + } + } elseif ($mm == 10) { + if ($dd > 7) { + $AUST_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $AUST_DST=0; + } else { + $AUST_DST=1; + } + } else { + if ($dow == 0 and $ns < 3600) { + $AUST_DST=0; + } else { + $AUST_DST=1; + } + } + } else { + $AUST_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $AUST_DST\n";} + if ($AUST_DST) {$gmt_offset++;} + $AC_processed++; + } + +if ( (!$AC_processed) and ($dst_range == 'FSO-FSA') ) + { + if ($DBX) {print " Domingo in October to First Domingo in April\n";} + #********************************************************************** + # FSO-FSA + # 2008+ AUSTRALIA ONLY (country code 61) + # This is returns 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Domingo in October and first Domingo in April at 1 am. + #********************************************************************** + + $AUSE_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 4 or $mm > 10) { + $AUSE_DST=1; + } elseif ($mm >= 5 and $mm <= 9) { + $AUSE_DST=0; + } elseif ($mm == 4) { + if ($dd > 7) { + $AUSE_DST=0; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (3600+$timezone*3600)) { + $AUSE_DST=1; + } else { + $AUSE_DST=0; + } + } else { + if ($dow == 0 and $ns < 7200) { + $AUSE_DST=1; + } else { + $AUSE_DST=0; + } + } + } else { + $AUSE_DST=1; + } + } elseif ($mm == 10) { + if ($dd >= 8) { + $AUSE_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $AUSE_DST=0; + } else { + $AUSE_DST=1; + } + } else { + if ($dow == 0 and $ns < 3600) { + $AUSE_DST=0; + } else { + $AUSE_DST=1; + } + } + } else { + $AUSE_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $AUSE_DST\n";} + if ($AUSE_DST) {$gmt_offset++;} + $AC_processed++; + } + +if ( (!$AC_processed) and ($dst_range == 'FSO-TSM') ) + { + if ($DBX) {print " First Domingo October to Third Domingo March\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Domingo in October and third Domingo in March at 1 am. + #********************************************************************** + + $NZL_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $NZL_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $NZL_DST=0; + } elseif ($mm == 3) { + if ($dd < 14) { + $NZL_DST=1; + } elseif ($dd < ($dow+14)) { + $NZL_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $NZL_DST=1; + } else { + $NZL_DST=0; + } + } else { # horário local calculations + if ($ns < 3600) { + $NZL_DST=1; + } else { + $NZL_DST=0; + } + } + } else { + $NZL_DST=0; + } + } elseif ($mm == 10) { + if ($dd > 7) { + $NZL_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $NZL_DST=0; + } else { + $NZL_DST=1; + } + } else { + if ($dow == 0 and $ns < 3600) { + $NZL_DST=0; + } else { + $NZL_DST=1; + } + } + } else { + $NZL_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $NZL_DST\n";} + if ($NZL_DST) {$gmt_offset++;} + $AC_processed++; + } + +if ( (!$AC_processed) and ($dst_range == 'LSS-FSA') ) + { + if ($DBX) {print " Last Domingo in September to First Domingo in April\n";} + #********************************************************************** + # LSS-FSA + # 2007+ NEW ZEALAND (country code 64) + # This is returns 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on last Domingo in September and first Domingo in April at 1 am. + #********************************************************************** + + $NZLN_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 4 || $mm > 9) { + $NZLN_DST=1; + } elseif ($mm >= 5 && $mm <= 9) { + $NZLN_DST=0; + } elseif ($mm == 4) { + if ($dd > 7) { + $NZLN_DST=0; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 && $ns < (3600+$timezone*3600)) { + $NZLN_DST=1; + } else { + $NZLN_DST=0; + } + } else { + if ($dow == 0 && $ns < 7200) { + $NZLN_DST=1; + } else { + $NZLN_DST=0; + } + } + } else { + $NZLN_DST=1; + } + } elseif ($mm == 9) { + if ($dd < 25) { + $NZLN_DST=0; + } elseif ($dd < ($dow+25)) { + $NZLN_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $NZLN_DST=0; + } else { + $NZLN_DST=1; + } + } else { # horário local calculations + if ($ns < 3600) { + $NZLN_DST=0; + } else { + $NZLN_DST=1; + } + } + } else { + $NZLN_DST=1; + } + } # end of month checks + if ($DBX) {print " DST: $NZLN_DST\n";} + if ($NZLN_DST) {$gmt_offset++;} + $AC_processed++; + } + +if ( (!$AC_processed) and ($dst_range == 'TSO-LSF') ) + { + if ($DBX) {print " Third Domingo October to Last Domingo February\n";} + #********************************************************************** + # TSO-LSF + # This is returns 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. Brazil + # Based on Third Domingo October to Last Domingo February at 1 am. + #********************************************************************** + + $BZL_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 2 || $mm > 10) { + $BZL_DST=1; + } elseif ($mm >= 3 and $mm <= 9) { + $BZL_DST=0; + } elseif ($mm == 2) { + if ($dd < 22) { + $BZL_DST=1; + } elseif ($dd < ($dow+22)) { + $BZL_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $BZL_DST=1; + } else { + $BZL_DST=0; + } + } else { # horário local calculations + if ($ns < 3600) { + $BZL_DST=1; + } else { + $BZL_DST=0; + } + } + } else { + $BZL_DST=0; + } + } elseif ($mm == 10) { + if ($dd < 22) { + $BZL_DST=0; + } elseif ($dd < ($dow+22)) { + $BZL_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $BZL_DST=0; + } else { + $BZL_DST=1; + } + } else { # horário local calculations + if ($ns < 3600) { + $BZL_DST=0; + } else { + $BZL_DST=1; + } + } + } else { + $BZL_DST=1; + } + } # end of month checks + if ($DBX) {print " DST: $BZL_DST\n";} + if ($BZL_DST) {$gmt_offset++;} + $AC_processed++; + } + +if (!$AC_processed) + { + if ($DBX) {print " No DST Method Found\n";} + if ($DBX) {print " DST: 0\n";} + $AC_processed++; + } + +return $gmt_offset; +} + +?> +
diff --git a/LANG_www/vicidial_br/non_agent_api.php b/LANG_www/vicidial_br/non_agent_api.php new file mode 100644 index 00000000..faecfc20 --- /dev/null +++ b/LANG_www/vicidial_br/non_agent_api.php @@ -0,0 +1,2638 @@ + LICENSE: AGPLv2 +# +# This script is designed as an API(Application Programming Interface) to allow +# other programs to interact with all non-agent-screen VICIDIAL functions +# +# required variables: +# - $user +# - $pass +# - $function - ('add_lead','version') +# - $source - ('vtiger','webform','adminweb') +# - $format - ('text','debug') + +# CHANGELOG: +# 80724-0021 - First build of script +# 80801-0047 - Added gmt lookup and hopper insert time validation +# 80909-2012 - Added support for campaign-specific DNC lists +# 80910-0020 - Added support for multi-alt-phones, added version function +# 90118-1056 - Added logging of API functions +# 90428-0209 - Added blind_monitor function +# 90508-0642 - Changed to PHP long tags +# 90514-0602 - Added sounds_list function +# 90522-0506 - Security fix +# 90530-0946 - Added QueueMetrics blind monitoring option +# 90721-1428 - Added rank and owner as vicidial_list fields +# 90904-1535 - Added moh_list musiconhold list +# 90916-2342 - Added vm_list voicemail list +# 91026-1059 - Added AREACODE DNC option +# 91203-1140 - Added agent_ingroup_info feature +# 91216-0331 - Added duplication check features to add_lead function +# 100118-0543 - Added new Australian and New Zealand DST schemes (FSO-FSA and LSS-FSA) +# + +$version = '2.2.0-17'; +$build = '100118-0543'; + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["function"])) {$function=$_GET["function"];} + elseif (isset($_POST["function"])) {$function=$_POST["function"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["vendor_lead_code"])) {$vendor_lead_code=$_GET["vendor_lead_code"];} + elseif (isset($_POST["vendor_lead_code"])) {$vendor_lead_code=$_POST["vendor_lead_code"];} +if (isset($_GET["source_id"])) {$source_id=$_GET["source_id"];} + elseif (isset($_POST["source_id"])) {$source_id=$_POST["source_id"];} +if (isset($_GET["gmt_offset_now"])) {$gmt_offset_now=$_GET["gmt_offset_now"];} + elseif (isset($_POST["gmt_offset_now"])) {$gmt_offset_now=$_POST["gmt_offset_now"];} +if (isset($_GET["title"])) {$title=$_GET["title"];} + elseif (isset($_POST["title"])) {$title=$_POST["title"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["middle_initial"])) {$middle_initial=$_GET["middle_initial"];} + elseif (isset($_POST["middle_initial"])) {$middle_initial=$_POST["middle_initial"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["gender"])) {$gender=$_GET["gender"];} + elseif (isset($_POST["gender"])) {$gender=$_POST["gender"];} +if (isset($_GET["date_of_birth"])) {$date_of_birth=$_GET["date_of_birth"];} + elseif (isset($_POST["date_of_birth"])) {$date_of_birth=$_POST["date_of_birth"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["security_phrase"])) {$security_phrase=$_GET["security_phrase"];} + elseif (isset($_POST["security_phrase"])) {$security_phrase=$_POST["security_phrase"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["dnc_check"])) {$dnc_check=$_GET["dnc_check"];} + elseif (isset($_POST["dnc_check"])) {$dnc_check=$_POST["dnc_check"];} +if (isset($_GET["campaign_dnc_check"])) {$campaign_dnc_check=$_GET["campaign_dnc_check"];} + elseif (isset($_POST["campaign_dnc_check"])) {$campaign_dnc_check=$_POST["campaign_dnc_check"];} +if (isset($_GET["add_to_hopper"])) {$add_to_hopper=$_GET["add_to_hopper"];} + elseif (isset($_POST["add_to_hopper"])) {$add_to_hopper=$_POST["add_to_hopper"];} +if (isset($_GET["hopper_priority"])) {$hopper_priority=$_GET["hopper_priority"];} + elseif (isset($_POST["hopper_priority"])) {$hopper_priority=$_POST["hopper_priority"];} +if (isset($_GET["hopper_local_call_time_check"])) {$hopper_local_call_time_check=$_GET["hopper_local_call_time_check"];} + elseif (isset($_POST["hopper_local_call_time_check"])) {$hopper_local_call_time_check=$_POST["hopper_local_call_time_check"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["multi_alt_phones"])) {$multi_alt_phones=$_GET["multi_alt_phones"];} + elseif (isset($_POST["multi_alt_phones"])) {$multi_alt_phones=$_POST["multi_alt_phones"];} +if (isset($_GET["source"])) {$source=$_GET["source"];} + elseif (isset($_POST["source"])) {$source=$_POST["source"];} +if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];} + elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];} +if (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];} + elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["rank"])) {$rank=$_GET["rank"];} + elseif (isset($_POST["rank"])) {$rank=$_POST["rank"];} +if (isset($_GET["owner"])) {$owner=$_GET["owner"];} + elseif (isset($_POST["owner"])) {$owner=$_POST["owner"];} +if (isset($_GET["agent_user"])) {$agent_user=$_GET["agent_user"];} + elseif (isset($_POST["agent_user"])) {$agent_user=$_POST["agent_user"];} +if (isset($_GET["duplicate_check"])) {$duplicate_check=$_GET["duplicate_check"];} + elseif (isset($_POST["duplicate_check"])) {$duplicate_check=$_POST["duplicate_check"];} + +header ("Content-type: text/html; charset=utf-8"); +header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header ("Pragma: no-cache"); // HTTP/1.0 + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin FROM system_settings;"; +$rslt=mysql_query($stmt, $link); +$qm_conf_ct = mysql_num_rows($rslt); +if ($qm_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $non_latin = $row[0]; + } +##### END SETTINGS LOOKUP ##### +########################################### + +if ($non_latin < 1) + { + $DB=ereg_replace("[^0-9]","",$DB); + $user=ereg_replace("[^0-9a-zA-Z]","",$user); + $pass=ereg_replace("[^0-9a-zA-Z]","",$pass); + $function = ereg_replace("[^-\_0-9a-zA-Z]","",$function); + $format = ereg_replace("[^0-9a-zA-Z]","",$format); + $list_id = ereg_replace("[^0-9]","",$list_id); + $phone_code = ereg_replace("[^0-9]","",$phone_code); + $phone_number = ereg_replace("[^0-9]","",$phone_number); + $vendor_lead_code = ereg_replace(";","",$vendor_lead_code); + $vendor_lead_code = ereg_replace("\+"," ",$vendor_lead_code); + $source_id = ereg_replace(";","",$source_id); + $source_id = ereg_replace("\+"," ",$source_id); + $gmt_offset_now = ereg_replace("-\_\.0-9","",$gmt_offset_now); + $title = ereg_replace("[^- \_\.0-9a-zA-Z]","",$title); + $first_name = ereg_replace("[^- \+\_\.0-9a-zA-Z]","",$first_name); + $first_name = ereg_replace("\+"," ",$first_name); + $middle_initial = ereg_replace("[^0-9a-zA-Z]","",$middle_initial); + $last_name = ereg_replace("[^- \+\_\.0-9a-zA-Z]","",$last_name); + $last_name = ereg_replace("\+"," ",$last_name); + $address1 = ereg_replace("[^- \+\.\:\/\@\_0-9a-zA-Z]","",$address1); + $address2 = ereg_replace("[^- \+\.\:\/\@\_0-9a-zA-Z]","",$address2); + $address3 = ereg_replace("[^- \+\.\:\/\@\_0-9a-zA-Z]","",$address3); + $address1 = ereg_replace("\+"," ",$address1); + $address2 = ereg_replace("\+"," ",$address2); + $address3 = ereg_replace("\+"," ",$address3); + $city = ereg_replace("[^- \+\.\:\/\@\_0-9a-zA-Z]","",$city); + $city = ereg_replace("\+"," ",$city); + $state = ereg_replace("[^- 0-9a-zA-Z]","",$state); + $province = ereg_replace("[^- \+\.\_0-9a-zA-Z]","",$province); + $province = ereg_replace("\+"," ",$province); + $postal_code = ereg_replace("[^- \+0-9a-zA-Z]","",$postal_code); + $postal_code = ereg_replace("\+"," ",$postal_code); + $country_code = ereg_replace("[^A-Z]","",$country_code); + $gender = ereg_replace("[^A-Z]","",$gender); + $date_of_birth = ereg_replace("[^-0-9]","",$date_of_birth); + $alt_phone = ereg_replace("[^- \+\_\.0-9a-zA-Z]","",$alt_phone); + $alt_phone = ereg_replace("\+"," ",$alt_phone); + $email = ereg_replace("[^- \+\.\:\/\@\_0-9a-zA-Z]","",$email); + $email = ereg_replace("\+"," ",$email); + $security_phrase = ereg_replace("[^- \+\.\:\/\@\_0-9a-zA-Z]","",$security_phrase); + $security_phrase = ereg_replace("\+"," ",$security_phrase); + $comments = ereg_replace(";","",$comments); + $comments = ereg_replace("\+"," ",$comments); + $dnc_check = ereg_replace("[^A-Z]","",$dnc_check); + $campaign_dnc_check = ereg_replace("[^A-Z]","",$campaign_dnc_check); + $add_to_hopper = ereg_replace("[^A-Z]","",$add_to_hopper); + $hopper_priority = ereg_replace("-0-9","",$hopper_priority); + $hopper_local_call_time_check = ereg_replace("[^A-Z]","",$hopper_local_call_time_check); + $campaign_id = ereg_replace("[^-\_0-9a-zA-Z]","",$campaign_id); + $multi_alt_phones = ereg_replace("[^- \+\!\:\_0-9a-zA-Z]","",$multi_alt_phones); + $multi_alt_phones = ereg_replace("\+"," ",$multi_alt_phones); + $source = ereg_replace("[^0-9a-zA-Z]","",$source); + $phone_login = ereg_replace("[^0-9a-zA-Z]","",$phone_login); + $session_id = ereg_replace("[^0-9]","",$session_id); + $server_ip = ereg_replace("[^\.0-9]","",$server_ip); + $stage = ereg_replace("[^a-zA-Z]","",$stage); + $rank = ereg_replace("[^0-9]","",$rank); + $owner = ereg_replace("[^-_0-9a-zA-Z]","",$owner); + $duplicate_check = ereg_replace("[^-_0-9a-zA-Z]","",$duplicate_check); + } +else + { + $user = ereg_replace("'|\"|\\\\|;","",$user); + $pass = ereg_replace("'|\"|\\\\|;","",$pass); + $source = ereg_replace("'|\"|\\\\|;","",$source); + } + +if (strlen($list_id)<1) {$list_id='999';} +if (strlen($phone_code)<1) {$phone_code='1';} +$USarea = substr($phone_number, 0, 3); +if (strlen($hopper_priority)<1) {$hopper_priority=0;} +if (strlen($gender)<1) {$gender='U';} +if (strlen($rank)<1) {$rank='0';} + +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$CIDdate = date("mdHis"); +$ENTRYdate = date("YmdHis"); +$MT[0]=''; +$postalgmt=''; +$api_script = 'non-agent'; +$api_logging = 1; + + +$secX = date("U"); +$hour = date("H"); +$min = date("i"); +$sec = date("s"); +$mon = date("m"); +$mday = date("d"); +$year = date("Y"); +$isdst = date("I"); +$Shour = date("H"); +$Smin = date("i"); +$Ssec = date("s"); +$Smon = date("m"); +$Smday = date("d"); +$Syear = date("Y"); +$pulldate0 = "$year-$mon-$mday $hour:$min:$sec"; +$inSD = $pulldate0; +$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + +### Grab Server GMT value from the database +$stmt="SELECT local_gmt FROM servers where active='Y' limit 1;"; +if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");} +$rslt=mysql_query($stmt, $link); +$gmt_recs = mysql_num_rows($rslt); +if ($gmt_recs > 0) + { + $row=mysql_fetch_row($rslt); + $DBSERVER_GMT = "$row[0]"; + if (strlen($DBSERVER_GMT)>0) {$SERVER_GMT = $DBSERVER_GMT;} + if ($isdst) {$SERVER_GMT++;} + } +else + { + $SERVER_GMT = date("O"); + $SERVER_GMT = eregi_replace("\+","",$SERVER_GMT); + $SERVER_GMT = ($SERVER_GMT + 0); + $SERVER_GMT = ($SERVER_GMT / 100); + } + +$LOCAL_GMT_OFF = $SERVER_GMT; +$LOCAL_GMT_OFF_STD = $SERVER_GMT; + + + + + +################################################################################ +### version - show version and date information for the API +################################################################################ +if ($function == 'version') + { + $data = "VERSION: $version|BUILD: $build|DATE: $NOW_TIME|EPOCH: $StarTtime"; + $result = 'SUCCESS'; + echo "$data\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } +################################################################################ +### END version +################################################################################ + + + + +################################################################################ +### sounds_list - sends a list of the sounds in the audio store +################################################################################ +if ($function == 'sounds_list') + { + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 6;"; + if ($DB>0) {echo "DEBUG: sounds_list query - $stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $allowed_user=$row[0]; + if ($allowed_user < 1) + { + $result = 'ERROR'; + $result_reason = "sounds_list USER DOES NOT HAVE PERMISSION TO VIEW SOUNDS LIST"; + echo "$result: $result_reason: |$user|$allowed_user|\n"; + $data = "$allowed_user"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + else + { + $server_name = getenv("SERVER_NAME"); + $server_port = getenv("SERVER_PORT"); + if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} + $admDIR = "$HTTPprotocol$server_name:$server_port"; + + ############################################# + ##### START SYSTEM_SETTINGS LOOKUP ##### + $stmt = "SELECT use_non_latin,sounds_central_control_active,sounds_web_server,sounds_web_directory FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + $ss_conf_ct = mysql_num_rows($rslt); + if ($ss_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $non_latin = $row[0]; + $sounds_central_control_active = $row[1]; + $sounds_web_server = $row[2]; + $sounds_web_directory = $row[3]; + } + ##### END SETTINGS LOOKUP ##### + ########################################### + + if ($sounds_central_control_active < 1) + { + $result = 'ERROR'; + $result_reason = "sounds_list CENTRAL SOUND CONTROL IS NOT ACTIVE"; + echo "$result: $result_reason: |$user|$sounds_central_control_active|\n"; + $data = "$sounds_central_control_active"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + else + { + $i=0; + $filename_sort=$MT; + $dirpath = "$WeBServeRRooT/$sounds_web_directory"; + $dh = opendir($dirpath); + if ($DB>0) {echo "DEBUG: sounds_list variables - $dirpath|$stage|$format\n";} + while (false !== ($file = readdir($dh))) + { + # Do not list subdirectories + if ( (!is_dir("$dirpath/$file")) and (preg_match('/\.wav$|\.gsm$/', $file)) ) + { + if (file_exists("$dirpath/$file")) + { + $file_names[$i] = $file; + $file_namesPROMPT[$i] = preg_replace("/\.wav$|\.gsm$/","",$file); + $file_epoch[$i] = filemtime("$dirpath/$file"); + $file_dates[$i] = date ("Y-m-d H:i:s.", filemtime("$dirpath/$file")); + $file_sizes[$i] = filesize("$dirpath/$file"); + $file_sizesPAD[$i] = sprintf("[%020s]\n",filesize("$dirpath/$file")); + if (eregi('date',$stage)) {$file_sort[$i] = $file_epoch[$i] . "----------" . $i;} + if (eregi('name',$stage)) {$file_sort[$i] = $file_names[$i] . "----------" . $i;} + if (eregi('size',$stage)) {$file_sort[$i] = $file_sizesPAD[$i] . "----------" . $i;} + + $i++; + } + } + } + closedir($dh); + + if (eregi('date',$stage)) {rsort($file_sort);} + if (eregi('name',$stage)) {sort($file_sort);} + if (eregi('size',$stage)) {rsort($file_sort);} + + sleep(1); + + $k=0; + $sf=0; + while($k < $i) + { + $file_split = explode('----------',$file_sort[$k]); + $m = $file_split[1]; + $NOWsize = filesize("$dirpath/$file_names[$m]"); + if ($DB>0) {echo "DEBUG: sounds_list variables - $file_sort[$k]|$size|$NOWsize|\n";} + if ($file_sizes[$m] == $NOWsize) + { + if (eregi('tab',$format)) + {echo "$k\t$file_names[$m]\t$file_dates[$m]\t$file_sizes[$m]\t$file_epoch[$m]\n";} + if (eregi('link',$format)) + {echo "$file_names[$m]
\n";} + if (eregi('selectframe',$format)) + { + if ($sf < 1) + { + echo "\n"; + echo "NON-AGENT API\n"; + echo "\n"; + echo "\n\n"; + + echo "\n"; + echo "close frame\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + $sf++; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + } + $k++; + } + if ($sf > 0) + { + echo "
#FILENAMEDATESIZEPLAY
$sf$file_names[$m]$file_dates[$m]$file_sizes[$m]PLAY
\n"; + } + + exit; + + } + } + } +################################################################################ +### END sounds_list +################################################################################ + + + +################################################################################ +### moh_list - sends a list of the moh classes in the system +################################################################################ +if ($function == 'moh_list') + { + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 6;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $allowed_user=$row[0]; + if ($allowed_user < 1) + { + $result = 'ERROR'; + $result_reason = "sounds_list USER DOES NOT HAVE PERMISSION TO VIEW SOUNDS LIST"; + echo "$result: $result_reason: |$user|$allowed_user|\n"; + $data = "$allowed_user"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + else + { + $server_name = getenv("SERVER_NAME"); + $server_port = getenv("SERVER_PORT"); + if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} + $admDIR = "$HTTPprotocol$server_name:$server_port"; + + ############################################# + ##### START SYSTEM_SETTINGS LOOKUP ##### + $stmt = "SELECT use_non_latin,sounds_central_control_active,sounds_web_server,sounds_web_directory FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + $ss_conf_ct = mysql_num_rows($rslt); + if ($ss_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $non_latin = $row[0]; + $sounds_central_control_active = $row[1]; + $sounds_web_server = $row[2]; + $sounds_web_directory = $row[3]; + } + ##### END SETTINGS LOOKUP ##### + ########################################### + + if ($sounds_central_control_active < 1) + { + $result = 'ERROR'; + $result_reason = "sounds_list CENTRAL SOUND CONTROL IS NOT ACTIVE"; + echo "$result: $result_reason: |$user|$sounds_central_control_active|\n"; + $data = "$sounds_central_control_active"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + else + { + echo "\n"; + echo "NON-AGENT API\n"; + echo "\n"; + echo "\n\n"; + + echo "\n"; + echo "close frame\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + $stmt="SELECT moh_id,moh_name,random from vicidial_music_on_hold where active='Y' order by moh_id"; + $rslt=mysql_query($stmt, $link); + $moh_to_print = mysql_num_rows($rslt); + $k=0; + $sf=0; + while ($moh_to_print > $k) + { + $rowx=mysql_fetch_row($rslt); + $moh_id[$k] = $rowx[0]; + $moh_name[$k] = $rowx[1]; + $random[$k] = $rowx[2]; + $k++; + } + + $k=0; + $sf=0; + while ($moh_to_print > $k) + { + $sf++; + if (eregi("1$|3$|5$|7$|9$", $sf)) + {$bgcolor='bgcolor="#E6E6E6"';} + else + {$bgcolor='bgcolor="#F6F6F6"';} + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + $stmt="SELECT filename from vicidial_music_on_hold_files where moh_id='$moh_id[$k]';"; + $rslt=mysql_query($stmt, $link); + $mohfiles_to_print = mysql_num_rows($rslt); + $m=0; + while ($mohfiles_to_print > $m) + { + $rowx=mysql_fetch_row($rslt); + $MOHfiles .= "$rowx[0]   "; + $m++; + } + + + echo "\n"; + echo "\n"; + + $k++; + } + echo "
#Music On Hold ClassNameRandom
$sf$moh_id[$k]$moh_name[$k]$random[$k]
 Files: $MOHfiles
\n"; + + exit; + } + } + } +################################################################################ +### END moh_list +################################################################################ + + + + +################################################################################ +### vm_list - sends a list of the voicemail boxes in the system +################################################################################ +if ($function == 'vm_list') + { + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 6;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $allowed_user=$row[0]; + if ($allowed_user < 1) + { + $result = 'ERROR'; + $result_reason = "vm_list USER DOES NOT HAVE PERMISSION TO VIEW VOICEMAIL BOXES LIST"; + echo "$result: $result_reason: |$user|$allowed_user|\n"; + $data = "$allowed_user"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + else + { + $server_name = getenv("SERVER_NAME"); + $server_port = getenv("SERVER_PORT"); + if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} + $admDIR = "$HTTPprotocol$server_name:$server_port"; + + echo "\n"; + echo "NON-AGENT API\n"; + echo "\n"; + echo "\n\n"; + + echo "\n"; + echo "close frame\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + $stmt="SELECT voicemail_id,fullname,email from vicidial_voicemail where active='Y' order by voicemail_id"; + $rslt=mysql_query($stmt, $link); + $vm_to_print = mysql_num_rows($rslt); + $k=0; + $sf=0; + while ($vm_to_print > $k) + { + $rowx=mysql_fetch_row($rslt); + $voicemail_id[$k] = $rowx[0]; + $fullname[$k] = $rowx[1]; + $email[$k] = $rowx[2]; + $sf++; + if (eregi("1$|3$|5$|7$|9$", $sf)) + {$bgcolor='bgcolor="#E6E6E6"';} + else + {$bgcolor='bgcolor="#F6F6F6"';} + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + $k++; + } + + $stmt="SELECT voicemail_id,fullname,email,extension from phones where active='Y' order by voicemail_id"; + $rslt=mysql_query($stmt, $link); + $vm_to_print = mysql_num_rows($rslt); + $k=0; + $sf=0; + while ($vm_to_print > $k) + { + $rowx=mysql_fetch_row($rslt); + $voicemail_id[$k] = $rowx[0]; + $fullname[$k] = $rowx[1]; + $email[$k] = $rowx[2]; + $extension[$k] = $rowx[3]; + $sf++; + if (eregi("1$|3$|5$|7$|9$", $sf)) + {$bgcolor='bgcolor="#E6E6E6"';} + else + {$bgcolor='bgcolor="#F6F6F6"';} + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + $k++; + } + echo "
#Voicemail BoxesNameEmail
$sf$voicemail_id[$k]$fullname[$k]$email[$k]
$sf$voicemail_id[$k]$extension[$k] - $fullname[$k]$email[$k]
\n"; + + exit; + } + } +################################################################################ +### END vm_list +################################################################################ + + + + +################################################################################ +### agent_ingroup_info - displays agent in-group info in an HTML form allowing for changes +################################################################################ +if ($function == 'agent_ingroup_info') + { + if(strlen($source)<2) + { + $result = 'ERROR'; + $result_reason = "Invalid Source"; + echo "$result: $result_reason - $source\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + echo "ERROR: Invalid Source: |$source|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and vdc_agent_api_access='1' and user_level > 6;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $allowed_user=$row[0]; + if ( ($allowed_user < 1) and ($source != 'queuemetrics') ) + { + $result = 'ERROR'; + $result_reason = "agent_ingroup_info USER DOES NOT HAVE PERMISSION TO GET AGENT INFO"; + echo "$result: $result_reason: |$user|$allowed_user|\n"; + $data = "$allowed_user"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + else + { + $stmt="SELECT count(*) from vicidial_live_agents where user='$agent_user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $session_exists=$row[0]; + + if ($session_exists < 1) + { + $result = 'ERROR'; + $result_reason = "agent_ingroup_info INVALID USER ID"; + echo "$result: $result_reason - $agent_user|$user\n"; + $data = "$session_id"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + else + { + $stmt="SELECT campaign_id,closer_campaigns,outbound_autodial,manager_ingroup_set,external_igb_set_user from vicidial_live_agents where user='$agent_user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $campaign_id = $row[0]; + $closer_campaigns = $row[1]; + $blended = $row[2]; + $manager_ingroup_set = $row[3]; + $external_igb_set_user = $row[4]; + + $stmt="SELECT full_name from vicidial_users where user='$agent_user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $full_name = $row[0]; + + $stmt = "select count(*) from vicidial_campaigns where campaign_id='$campaign_id' and campaign_allow_inbound='Y' and dial_method NOT IN('MANUAL');"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $allowed_campaign_inbound=$row[0]; + + $stmt = "select count(*) from vicidial_campaigns where campaign_id='$campaign_id' and dial_method NOT IN('MANUAL','INBOUND_MAN');"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $allowed_campaign_autodial=$row[0]; + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and change_agent_campaign='1';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $allowed_user_change_ingroups=$row[0]; + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and modify_users='1';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $allowed_user_modify_user=$row[0]; + + + $result = 'SUCCESS'; + $result_reason = ""; + $data = "$agent_user|$stage"; + + if ($stage == 'text') + { + $output .= "SELECTED INGROUPS: $closer_campaigns\n"; + $output .= "OUTBOUND AUTODIAL: $blended\n"; + $output .= "MANAGER OVERRIDE: $manager_ingroup_set\n"; + $output .= "MANAGER: $external_igb_set_user\n"; + echo "$result: $result_reason - $data\n$output\n"; + } + else + { + $output = ''; + $output .= "
\n"; + $output .= "Agent: $agent_user - $full_name \n"; + $output .= "   Campaign: $campaign_id\n"; + $output .= "Close
\n"; + + $stmt="SELECT closer_campaigns from vicidial_campaigns where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($allowed_campaign_inbound < 1) + {$row[0]='';} + $closer_groups_pre = preg_replace('/-$/','',$row[0]); + $closer_groups = explode(" ",$closer_groups_pre); + $closer_groups_ct = count($closer_groups); + + $in_groups_pre = preg_replace('/-$/','',$closer_campaigns); + $in_groups = explode(" ",$in_groups_pre); + $in_groups_ct = count($in_groups); + $k=1; + while ($k < $closer_groups_ct) + { + $closer_select[$k]=0; + if (strlen($closer_groups[$k])>1) + { + $m=0; + while ($m < $in_groups_ct) + { + if (strlen($in_groups[$m])>1) + { + if ($closer_groups[$k] == $in_groups[$m]) + {$closer_select[$k]++;} + } + $m++; + } + } + $k++; + } + + if ( ($allowed_user_change_ingroups > 0) and ($stage == 'change') ) + { + $output .= "\n"; + $output .= "\n"; + + $output .= "\n"; + + $output .= "\n"; + + if ( ($manager_ingroup_set == 'SET') or ($manager_ingroup_set == 'Y') ) + { + $stmt="SELECT full_name from vicidial_users where user='$external_igb_set_user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $Mfull_name = $row[0]; + + $output .= "\n"; + } + + $output .= "\n"; + + $output .= "
Selected In-Groups: \n"; + $output .= "\n"; + $output .= "
Change, Add, Remove:\n"; + $output .= "\n"; + $output .= "\n"; + $output .= "
Blended Outbound Autodial:\n"; + $output .= "\n"; + $output .= "\n"; + $output .= "
Manager In-Group Override:\n"; + $output .= "\n"; + $output .= "$manager_ingroup_set - $external_igb_set_user - $Mfull_name\n"; + $output .= "
\n"; + $output .= "\n"; + $output .= "
\n"; + $output .= "
\n"; + } + else + { + $output .= "\n"; + + $m=0; + $m_printed=0; + while ($m < $closer_groups_ct) + { + if (strlen($closer_groups[$m])>1) + { + $stmt="SELECT group_name from vicidial_inbound_groups where group_id='$closer_groups[$m]';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + + $output .= "\n"; + $m_printed++; + } + $m++; + } + + if ($m_printed < 1) + {$output .= "\n";} + + $output .= "
$closer_groups[$m]"; + + if ($closer_select[$m] > 0) + {$output .= " *";} + $output .= "$row[0]
No In-Groups Allowed

\n"; + + $output .= "SELECTED INGROUPS: $closer_campaigns
\n"; + $output .= "OUTBOUND AUTODIAL: $blended
\n"; + $output .= "MANAGER OVERRIDE: $manager_ingroup_set
\n"; + $output .= "MANAGER: $external_igb_set_user
\n"; + $output .= "\n"; + $output .= "
\n"; + } + + echo "$output"; + } + + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + } + } + } + exit; + } +################################################################################ +### END agent_ingroup_info +################################################################################ + + + + +################################################################################ +### blind_monitor - sends call to phone from session from listening +################################################################################ +if ($function == 'blind_monitor') + { + if(strlen($source)<2) + { + $result = 'ERROR'; + $result_reason = "Invalid Source"; + echo "$result: $result_reason - $source\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + echo "ERROR: Invalid Source: |$source|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and vdc_agent_api_access='1' and user_level > 6;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $allowed_user=$row[0]; + if ( ($allowed_user < 1) and ($source != 'queuemetrics') ) + { + $result = 'ERROR'; + $result_reason = "blind_monitor USER DOES NOT HAVE PERMISSION TO BLIND MONITOR"; + echo "$result: $result_reason: |$user|$allowed_user|\n"; + $data = "$allowed_user"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + else + { + $stmt="SELECT count(*) from vicidial_conferences where conf_exten='$session_id' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $session_exists=$row[0]; + + if ($session_exists < 1) + { + $result = 'ERROR'; + $result_reason = "blind_monitor INVALID SESSION ID"; + echo "$result: $result_reason - $session_id|$server_ip|$user\n"; + $data = "$session_id"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + else + { + $stmt="SELECT count(*) from phones where login='$phone_login';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $phone_exists=$row[0]; + + if ( ($phone_exists < 1) and ($source != 'queuemetrics') ) + { + $result = 'ERROR'; + $result_reason = "blind_monitor INVALID PHONE LOGIN"; + echo "$result: $result_reason - $phone_login|$user\n"; + $data = "$phone_login"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + else + { + if ($source == 'queuemetrics') + { + $stmt="SELECT active_voicemail_server from system_settings;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $monitor_server_ip = $row[0]; + $dialplan_number = $phone_login; + $outbound_cid = ''; + if (strlen($monitor_server_ip)<7) + {$monitor_server_ip = $server_ip;} + } + else + { + $stmt="SELECT dialplan_number,server_ip,outbound_cid from phones where login='$phone_login';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $dialplan_number = $row[0]; + $monitor_server_ip =$row[1]; + $outbound_cid = $row[2]; + } + + $S='*'; + $D_s_ip = explode('.', $server_ip); + if (strlen($D_s_ip[0])<2) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[0])<3) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[1])<2) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[1])<3) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[2])<2) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[2])<3) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[3])<2) {$D_s_ip[3] = "0$D_s_ip[3]";} + if (strlen($D_s_ip[3])<3) {$D_s_ip[3] = "0$D_s_ip[3]";} + $monitor_dialstring = "$D_s_ip[0]$S$D_s_ip[1]$S$D_s_ip[2]$S$D_s_ip[3]$S"; + + $PADuser = sprintf("%08s", $user); + while (strlen($PADuser) > 8) {$PADuser = substr("$PADuser", 0, -1);} + $BMquery = "BM$StarTtime$PADuser"; + + if ( (ereg('MONITOR',$stage)) or (strlen($stage)<1) ) {$stage = '0';} + if (ereg('BARGE',$stage)) {$stage = '';} + if (ereg('HIJACK',$stage)) {$stage = '';} + + ### insert a new lead in the system with this phone number + $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$monitor_server_ip','','Originate','$BMquery','Channel: Local/$monitor_dialstring$stage$session_id@default','Context; default','Exten: $dialplan_number','Priority: 1','Callerid: \"VC Blind Monitor\" <$outbound_cid>','','','','','');"; + if ($DB>0) {echo "DEBUG: blind_monitor query - $stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + if ($affected_rows > 0) + { + $man_id = mysql_insert_id($link); + + $result = 'SUCCESS'; + $result_reason = "blind_monitor HAS BEEN LAUNCHED"; + echo "$result: $result_reason - $phone_login|$monitor_dialstring$stage$session_id|$dialplan_number|$session_id|$man_id|$user\n"; + $data = "$phone_login|$monitor_dialstring|$session_id|$man_id"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + } + } + } + } + } + exit; + } +################################################################################ +### END blind_monitor +################################################################################ + + + + + +################################################################################ +### add_lead - inserts a lead into the vicidial_list table +################################################################################ +if ($function == 'add_lead') + { + if(strlen($source)<2) + { + $result = 'ERROR'; + $result_reason = "Invalid Source"; + echo "$result: $result_reason - $source\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + echo "ERROR: Invalid Source: |$source|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and vdc_agent_api_access='1' and modify_leads='1' and user_level > 7;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $modify_leads=$row[0]; + + if ($modify_leads < 1) + { + $result = 'ERROR'; + $result_reason = "add_lead USER DOES NOT HAVE PERMISSION TO ADD LEADS TO THE SYSTEM"; + echo "$result: $result_reason: |$user|$modify_leads|\n"; + $data = "$modify_leads"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + else + { + if ( (strlen($phone_number)<6) || (strlen($phone_number)>16) ) + { + $result = 'ERROR'; + $result_reason = "add_lead INVALID PHONE NUMBER"; + echo "$result: $result_reason - $phone_number|$user\n"; + $data = "$phone_number"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + else + { + ### START checking for DNC if defined ### + if ( ($dnc_check == 'Y') or ($dnc_check == 'AREACODE') ) + { + if ($DB>0) {echo "DEBUG: Checking for system DNC\n";} + if ($dnc_check == 'AREACODE') + { + $phone_areacode = substr($phone_number, 0, 3); + $phone_areacode .= "XXXXXXX"; + $stmt="SELECT count(*) from vicidial_dnc where phone_number IN('$phone_number','$phone_areacode');"; + } + else + {$stmt="SELECT count(*) from vicidial_dnc where phone_number='$phone_number';";} + if ($DB>0) {echo "DEBUG: add_lead query - $stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $dnc_found=$row[0]; + + if ($dnc_found > 0) + { + $result = 'ERROR'; + $result_reason = "add_lead PHONE NUMBER IN DNC"; + echo "$result: $result_reason - $phone_number|$user\n"; + $data = "$phone_number"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + } + if ( ($campaign_dnc_check == 'Y') or ($campaign_dnc_check == 'AREACODE') ) + { + if ($DB>0) {echo "DEBUG: Checking for campaign DNC\n";} + if ($campaign_dnc_check == 'AREACODE') + { + $phone_areacode = substr($phone_number, 0, 3); + $phone_areacode .= "XXXXXXX"; + $stmt="SELECT count(*) from vicidial_campaign_dnc where phone_number IN('$phone_number','$phone_areacode') and campaign_id='$campaign_id';"; + } + else + {$stmt="SELECT count(*) from vicidial_campaign_dnc where phone_number='$phone_number' and campaign_id='$campaign_id';";} + if ($DB>0) {echo "DEBUG: add_lead query - $stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $dnc_found=$row[0]; + + if ($dnc_found > 0) + { + $result = 'ERROR'; + $result_reason = "add_lead PHONE NUMBER IN CAMPAIGN DNC"; + echo "$result: $result_reason - $phone_number|$campaign_id|$user\n"; + $data = "$phone_number|$campaign_id"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + } + ### END checking for DNC if defined ### + + ### START checking for duplicate if defined ### + if (eregi("CAMP",$duplicate_check)) # find lists within campaign + { + $stmt="SELECT campaign_id from vicidial_lists where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + $ci_recs = mysql_num_rows($rslt); + if ($ci_recs > 0) + { + $row=mysql_fetch_row($rslt); + $duplicate_camp = $row[0]; + + $stmt="select list_id from vicidial_lists where campaign_id='$duplicate_camp';"; + $rslt=mysql_query($stmt, $link); + $li_recs = mysql_num_rows($rslt); + if ($li_recs > 0) + { + $L=0; + while ($li_recs > $L) + { + $row=mysql_fetch_row($rslt); + $duplicate_lists .= "'$row[0]',"; + $L++; + } + $duplicate_lists = eregi_replace(",$",'',$duplicate_lists); + } + } + } + ### find list of list_ids in this campaign + if (eregi("DUPLIST",$duplicate_check)) # duplicate check within list + { + if ($DB>0) {echo "DEBUG: Checking for duplicates - DUPLIST\n";} + $duplicate_found=0; + $stmt="SELECT lead_id,list_id from vicidial_list where phone_number='$phone_number' and list_id='$list_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $duplicate_found=1; + $row=mysql_fetch_row($rslt); + $duplicate_lead_id = $row[0]; + $duplicate_lead_list = $row[1]; + } + + if ($duplicate_found > 0) + { + $result = 'ERROR'; + $result_reason = "add_lead DUPLICATE PHONE NUMBER IN LIST"; + $data = "$phone_number|$list_id|$duplicate_lead_id"; + echo "$result: $result_reason - $data\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + } + if (eregi("DUPCAMP",$duplicate_check)) # duplicate check within campaign lists + { + if ($DB>0) {echo "DEBUG: Checking for duplicates - DUPCAMP - $duplicate_lists\n";} + $duplicate_found=0; + $stmt="SELECT lead_id,list_id from vicidial_list where phone_number='$phone_number' and list_id IN($duplicate_lists) limit 1;"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $duplicate_found=1; + $row=mysql_fetch_row($rslt); + $duplicate_lead_id = $row[0]; + $duplicate_lead_list = $row[1]; + } + + if ($duplicate_found > 0) + { + $result = 'ERROR'; + $result_reason = "add_lead DUPLICATE PHONE NUMBER IN CAMPAIGN LISTS"; + $data = "$phone_number|$list_id|$duplicate_lead_id|$duplicate_lead_list"; + echo "$result: $result_reason - $data\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + } + if (eregi("DUPSYS",$duplicate_check)) # duplicate check within entire system + { + if ($DB>0) {echo "DEBUG: Checking for duplicates - DUPSYS\n";} + $duplicate_found=0; + $stmt="SELECT lead_id,list_id from vicidial_list where phone_number='$phone_number' limit 1;"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $duplicate_found=1; + $row=mysql_fetch_row($rslt); + $duplicate_lead_id = $row[0]; + $duplicate_lead_list = $row[1]; + } + + if ($duplicate_found > 0) + { + $result = 'ERROR'; + $result_reason = "add_lead DUPLICATE PHONE NUMBER IN SYSTEM"; + $data = "$phone_number|$list_id|$duplicate_lead_id|$duplicate_lead_list"; + echo "$result: $result_reason - $data\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + } + if (eregi("DUPTITLEALTPHONELIST",$duplicate_check)) # duplicate title/alt_phone check within list + { + if ($DB>0) {echo "DEBUG: Checking for duplicates - DUPTITLEALTPHONELIST\n";} + $duplicate_found=0; + $stmt="SELECT lead_id,list_id from vicidial_list where title='$title' and alt_phone='$alt_phone' and list_id='$list_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $duplicate_found=1; + $row=mysql_fetch_row($rslt); + $duplicate_lead_id = $row[0]; + $duplicate_lead_list = $row[1]; + } + + if ($duplicate_found > 0) + { + $result = 'ERROR'; + $result_reason = "add_lead DUPLICATE TITLE ALT_PHONE IN LIST"; + $data = "$title|$alt_phone|$list_id|$duplicate_lead_id"; + echo "$result: $result_reason - $data\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + } + if (eregi("DUPTITLEALTPHONECAMP",$duplicate_check)) # duplicate title/alt_phone check within campaign lists + { + if ($DB>0) {echo "DEBUG: Checking for duplicates - DUPTITLEALTPHONECAMP\n";} + $duplicate_found=0; + $stmt="SELECT lead_id,list_id from vicidial_list where title='$title' and alt_phone='$alt_phone' and list_id IN($duplicate_lists) limit 1;"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $duplicate_found=1; + $row=mysql_fetch_row($rslt); + $duplicate_lead_id = $row[0]; + $duplicate_lead_list = $row[1]; + } + + if ($duplicate_found > 0) + { + $result = 'ERROR'; + $result_reason = "add_lead DUPLICATE TITLE ALT_PHONE IN CAMPAIGN LISTS"; + $data = "$title|$alt_phone|$list_id|$duplicate_lead_id|$duplicate_lead_list"; + echo "$result: $result_reason - $data\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + } + if (eregi("DUPTITLEALTPHONESYS",$duplicate_check)) # duplicate title/alt_phone check within entire system + { + if ($DB>0) {echo "DEBUG: Checking for duplicates - DUPTITLEALTPHONESYS\n";} + $duplicate_found=0; + $stmt="SELECT lead_id,list_id from vicidial_list where title='$title' and alt_phone='$alt_phone' limit 1;"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $duplicate_found=1; + $row=mysql_fetch_row($rslt); + $duplicate_lead_id = $row[0]; + $duplicate_lead_list = $row[1]; + } + + if ($duplicate_found > 0) + { + $result = 'ERROR'; + $result_reason = "add_lead DUPLICATE TITLE ALT_PHONE IN SYSTEM"; + $data = "$title|$alt_phone|$list_id|$duplicate_lead_id|$duplicate_lead_list"; + echo "$result: $result_reason - $data\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + } + ### END checking for duplicate if defined ### + + + ### get current gmt_offset of the phone_number + $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmt,$postal_code); + + + ### insert a new lead in the system with this phone number + $stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='NEW',user='$user',vendor_lead_code='$vendor_lead_code',source_id='$source_id',gmt_offset_now='$gmt_offset',title='$title',first_name='$first_name',middle_initial='$middle_initial',last_name='$last_name',address1='$address1',address2='$address2',address3='$address3',city='$city',state='$state',province='$province',postal_code='$postal_code',country_code='$country_code',gender='$gender',date_of_birth='$date_of_birth',alt_phone='$alt_phone',email='$email',security_phrase='$security_phrase',comments='$comments',called_since_last_reset='N',entry_date='$ENTRYdate',last_local_call_time='$NOW_TIME',rank='$rank',owner='$owner';"; + if ($DB>0) {echo "DEBUG: add_lead query - $stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + if ($affected_rows > 0) + { + $lead_id = mysql_insert_id($link); + + $result = 'SUCCESS'; + $result_reason = "add_lead LEAD HAS BEEN ADDED"; + echo "$result: $result_reason - $phone_number|$list_id|$lead_id|$gmt_offset|$user\n"; + $data = "$phone_number|$list_id|$lead_id|$gmt_offset"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + + if (strlen($multi_alt_phones) > 5) + { + $map=$MT; $ALTm_phone_code=$MT; $ALTm_phone_number=$MT; $ALTm_phone_note=$MT; + $map = explode('!', $multi_alt_phones); + $map_count = count($map); + if ($DB>0) {echo "DEBUG: add_lead multi-al-entry - $a|$map_count|$multi_alt_phones\n";} + $g++; + $r=0; $s=0; $inserted_alt_phones=0; + while ($r < $map_count) + { + $s++; + $ncn=$MT; + $ncn = explode('_', $map[$r]); + print "$ncn[0]|$ncn[1]|$ncn[2]"; + + if (strlen($forcephonecode) > 0) + {$ALTm_phone_code[$r] = $forcephonecode;} + else + {$ALTm_phone_code[$r] = $ncn[1];} + if (strlen($ALTm_phone_code[$r]) < 1) + {$ALTm_phone_code[$r]='1';} + $ALTm_phone_number[$r] = $ncn[0]; + $ALTm_phone_note[$r] = $ncn[2]; + $stmt = "INSERT INTO vicidial_list_alt_phones (lead_id,phone_code,phone_number,alt_phone_note,alt_phone_count) values('$lead_id','$ALTm_phone_code[$r]','$ALTm_phone_number[$r]','$ALTm_phone_note[$r]','$s');"; + if ($DB>0) {echo "DEBUG: add_lead query - $stmt\n";} + $rslt=mysql_query($stmt, $link); + $Zaffected_rows = mysql_affected_rows($link); + $inserted_alt_phones = ($inserted_alt_phones + $Zaffected_rows); + $r++; + } + $result = 'NOTICE'; + $result_reason = "add_lead MULTI-ALT-PHONE NUMBERS LOADED"; + echo "$result: $result_reason - $inserted_alt_phones|$lead_id|$user\n"; + $data = "$inserted_alt_phones|$lead_id"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + } + + if ($add_to_hopper == 'Y') + { + $dialable=1; + + $stmt="SELECT local_call_time,vicidial_campaigns.campaign_id from vicidial_campaigns,vicidial_lists where list_id='$list_id' and vicidial_campaigns.campaign_id=vicidial_lists.campaign_id;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $local_call_time=$row[0]; + $VD_campaign_id=$row[1]; + + if ($hopper_local_call_time_check == 'Y') + { + ### call function to determine if lead is dialable + $dialable = dialable_gmt($DB,$link,$local_call_time,$gmt_offset,$state); + } + if ($dialable < 1) + { + $result = 'NOTICE'; + $result_reason = "add_lead NOT ADDED TO HOPPER, OUTSIDE OF LOCAL TIME"; + echo "$result: $result_reason - $phone_number|$lead_id|$gmt_offset|$dialable|$user\n"; + $data = "$phone_number|$lead_id|$gmt_offset|$dialable"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + } + else + { + ### code to insert into hopper goes here + + ### insert record into vicidial_hopper for alt_phone call attempt + $stmt = "INSERT INTO vicidial_hopper SET lead_id='$lead_id',campaign_id='$VD_campaign_id',status='READY',list_id='$list_id',gmt_offset_now='$gmt_offset',state='$state',user='',priority='$hopper_priority';"; + if ($DB>0) {echo "DEBUG: add_lead query - $stmt\n";} + $rslt=mysql_query($stmt, $link); + $Haffected_rows = mysql_affected_rows($link); + if ($Haffected_rows > 0) + { + $hopper_id = mysql_insert_id($link); + + $result = 'NOTICE'; + $result_reason = "add_lead ADDED TO HOPPER"; + echo "$result: $result_reason - $phone_number|$lead_id|$hopper_id|$user\n"; + $data = "$phone_number|$lead_id|$hopper_id"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + } + else + { + $result = 'NOTICE'; + $result_reason = "add_lead NOT ADDED TO HOPPER"; + echo "$result: $result_reason - $phone_number|$lead_id|$stmt|$user\n"; + $data = "$phone_number|$lead_id|$stmt"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + } + } + } + } + else + { + $result = 'ERROR'; + $result_reason = "add_lead LEAD HAS NOT BEEN ADDED"; + echo "$result: $result_reason - $phone_number|$list_id|$stmt|$user\n"; + $data = "$phone_number|$list_id|$stmt"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + } + } + } + exit; + } + } +################################################################################ +### END add_lead +################################################################################ + + + +$result = 'ERROR'; +$result_reason = "NO FUNCTION SPECIFIED"; +echo "$result: $result_reason\n"; +api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + + + + + + + + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + + + + + + + +##### FUNCTIONS ##### + +##### LOOKUP GMT, FINDS THE CURRENT GMT OFFSET FOR A PHONE NUMBER ##### + +function lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmt,$postal_code) +{ +require("dbconnect.php"); + +$postalgmt_found=0; +if ( (eregi("POSTAL",$postalgmt)) && (strlen($postal_code)>4) ) + { + if (preg_match('/^1$/', $phone_code)) + { + $stmt="select postal_code,state,GMT_offset,DST,DST_range,country,country_code from vicidial_postal_codes where country_code='$phone_code' and postal_code LIKE \"$postal_code%\";"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[2]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[3]; + $dst_range = $row[4]; + $PC_processed++; + $postalgmt_found++; + $post++; + } + } + } +if ($postalgmt_found < 1) + { + $PC_processed=0; + ### UNITED STATES ### + if ($phone_code =='1') + { + $stmt="select country_code,country,areacode,state,GMT_offset,DST,DST_range,geographic_description from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + ### MEXICO ### + if ($phone_code =='52') + { + $stmt="select country_code,country,areacode,state,GMT_offset,DST,DST_range,geographic_description from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + ### AUSTRALIA ### + if ($phone_code =='61') + { + $stmt="select country_code,country,areacode,state,GMT_offset,DST,DST_range,geographic_description from vicidial_phone_codes where country_code='$phone_code' and state='$state';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + ### ALL OTHER COUNTRY CODES ### + if (!$PC_processed) + { + $PC_processed++; + $stmt="select country_code,country,areacode,state,GMT_offset,DST,DST_range,geographic_description from vicidial_phone_codes where country_code='$phone_code';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + } + +### Find out if DST to raise the gmt offset ### +$AC_GMT_diff = ($gmt_offset - $LOCAL_GMT_OFF_STD); +$AC_localtime = mktime(($Shour + $AC_GMT_diff), $Smin, $Ssec, $Smon, $Smday, $Syear); + $hour = date("H",$AC_localtime); + $min = date("i",$AC_localtime); + $sec = date("s",$AC_localtime); + $mon = date("m",$AC_localtime); + $mday = date("d",$AC_localtime); + $wday = date("w",$AC_localtime); + $year = date("Y",$AC_localtime); +$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + +$AC_processed=0; +if ( (!$AC_processed) and ($dst_range == 'SSM-FSN') ) + { + if ($DBX) {print " Second Sunday March to First Sunday November\n";} + #********************************************************************** + # SSM-FSN + # This is returns 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on Second Sunday March to First Sunday November at 2 am. + # INPUTS: + # mm INTEGER Month. + # dd INTEGER Day of the month. + # ns INTEGER Seconds into the day. + # dow INTEGER Day of week (0=Sunday, to 6=Saturday) + # OPTIONAL INPUT: + # timezone INTEGER hour difference UTC - local standard time + # (DEFAULT is blank) + # make calculations based on UTC time, + # which means shift at 10:00 UTC in April + # and 9:00 UTC in October + # OUTPUT: + # INTEGER 1 = DST, 0 = not DST + # + # S M T W T F S + # 1 2 3 4 5 6 7 + # 8 9 10 11 12 13 14 + #15 16 17 18 19 20 21 + #22 23 24 25 26 27 28 + #29 30 31 + # + # S M T W T F S + # 1 2 3 4 5 6 + # 7 8 9 10 11 12 13 + #14 15 16 17 18 19 20 + #21 22 23 24 25 26 27 + #28 29 30 31 + # + #********************************************************************** + + $USACAN_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 11) { + $USACAN_DST=0; + } elseif ($mm >= 4 and $mm <= 10) { + $USACAN_DST=1; + } elseif ($mm == 3) { + if ($dd > 13) { + $USACAN_DST=1; + } elseif ($dd >= ($dow+8)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $USACAN_DST=0; + } else { + $USACAN_DST=1; + } + } else { + if ($dow == 0 and $ns < 7200) { + $USACAN_DST=0; + } else { + $USACAN_DST=1; + } + } + } else { + $USACAN_DST=0; + } + } elseif ($mm == 11) { + if ($dd > 7) { + $USACAN_DST=0; + } elseif ($dd < ($dow+1)) { + $USACAN_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (7200+($timezone-1)*3600)) { + $USACAN_DST=1; + } else { + $USACAN_DST=0; + } + } else { # local time calculations + if ($ns < 7200) { + $USACAN_DST=1; + } else { + $USACAN_DST=0; + } + } + } else { + $USACAN_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $USACAN_DST\n";} + if ($USACAN_DST) {$gmt_offset++;} + $AC_processed++; + } + +if ( (!$AC_processed) and ($dst_range == 'FSA-LSO') ) + { + if ($DBX) {print " First Sunday April to Last Sunday October\n";} + #********************************************************************** + # FSA-LSO + # This is returns 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in April and last Sunday in October at 2 am. + #********************************************************************** + + $USA_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 4 || $mm > 10) { + $USA_DST=0; + } elseif ($mm >= 5 and $mm <= 9) { + $USA_DST=1; + } elseif ($mm == 4) { + if ($dd > 7) { + $USA_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $USA_DST=0; + } else { + $USA_DST=1; + } + } else { + if ($dow == 0 and $ns < 7200) { + $USA_DST=0; + } else { + $USA_DST=1; + } + } + } else { + $USA_DST=0; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $USA_DST=1; + } elseif ($dd < ($dow+25)) { + $USA_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (7200+($timezone-1)*3600)) { + $USA_DST=1; + } else { + $USA_DST=0; + } + } else { # local time calculations + if ($ns < 7200) { + $USA_DST=1; + } else { + $USA_DST=0; + } + } + } else { + $USA_DST=0; + } + } # end of month checks + + if ($DBX) {print " DST: $USA_DST\n";} + if ($USA_DST) {$gmt_offset++;} + $AC_processed++; + } + +if ( (!$AC_processed) and ($dst_range == 'LSM-LSO') ) + { + if ($DBX) {print " Last Sunday March to Last Sunday October\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on last Sunday in March and last Sunday in October at 1 am. + #********************************************************************** + + $GBR_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $GBR_DST=0; + } elseif ($mm >= 4 and $mm <= 9) { + $GBR_DST=1; + } elseif ($mm == 3) { + if ($dd < 25) { + $GBR_DST=0; + } elseif ($dd < ($dow+25)) { + $GBR_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=0; + } else { + $GBR_DST=1; + } + } else { # local time calculations + if ($ns < 3600) { + $GBR_DST=0; + } else { + $GBR_DST=1; + } + } + } else { + $GBR_DST=1; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $GBR_DST=1; + } elseif ($dd < ($dow+25)) { + $GBR_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=1; + } else { + $GBR_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $GBR_DST=1; + } else { + $GBR_DST=0; + } + } + } else { + $GBR_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $GBR_DST\n";} + if ($GBR_DST) {$gmt_offset++;} + $AC_processed++; + } +if ( (!$AC_processed) and ($dst_range == 'LSO-LSM') ) + { + if ($DBX) {print " Last Sunday October to Last Sunday March\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on last Sunday in October and last Sunday in March at 1 am. + #********************************************************************** + + $AUS_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUS_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $AUS_DST=0; + } elseif ($mm == 3) { + if ($dd < 25) { + $AUS_DST=1; + } elseif ($dd < ($dow+25)) { + $AUS_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=1; + } else { + $AUS_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $AUS_DST=1; + } else { + $AUS_DST=0; + } + } + } else { + $AUS_DST=0; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $AUS_DST=0; + } elseif ($dd < ($dow+25)) { + $AUS_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=0; + } else { + $AUS_DST=1; + } + } else { # local time calculations + if ($ns < 3600) { + $AUS_DST=0; + } else { + $AUS_DST=1; + } + } + } else { + $AUS_DST=1; + } + } # end of month checks + if ($DBX) {print " DST: $AUS_DST\n";} + if ($AUS_DST) {$gmt_offset++;} + $AC_processed++; + } + +if ( (!$AC_processed) and ($dst_range == 'FSO-LSM') ) + { + if ($DBX) {print " First Sunday October to Last Sunday March\n";} + #********************************************************************** + # TASMANIA ONLY + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in October and last Sunday in March at 1 am. + #********************************************************************** + + $AUST_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUST_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $AUST_DST=0; + } elseif ($mm == 3) { + if ($dd < 25) { + $AUST_DST=1; + } elseif ($dd < ($dow+25)) { + $AUST_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUST_DST=1; + } else { + $AUST_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $AUST_DST=1; + } else { + $AUST_DST=0; + } + } + } else { + $AUST_DST=0; + } + } elseif ($mm == 10) { + if ($dd > 7) { + $AUST_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $AUST_DST=0; + } else { + $AUST_DST=1; + } + } else { + if ($dow == 0 and $ns < 3600) { + $AUST_DST=0; + } else { + $AUST_DST=1; + } + } + } else { + $AUST_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $AUST_DST\n";} + if ($AUST_DST) {$gmt_offset++;} + $AC_processed++; + } + +if ( (!$AC_processed) and ($dst_range == 'FSO-FSA') ) + { + if ($DBX) {print " Sunday in October to First Sunday in April\n";} + #********************************************************************** + # FSO-FSA + # 2008+ AUSTRALIA ONLY (country code 61) + # This is returns 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in October and first Sunday in April at 1 am. + #********************************************************************** + + $AUSE_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 4 or $mm > 10) { + $AUSE_DST=1; + } elseif ($mm >= 5 and $mm <= 9) { + $AUSE_DST=0; + } elseif ($mm == 4) { + if ($dd > 7) { + $AUSE_DST=0; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (3600+$timezone*3600)) { + $AUSE_DST=1; + } else { + $AUSE_DST=0; + } + } else { + if ($dow == 0 and $ns < 7200) { + $AUSE_DST=1; + } else { + $AUSE_DST=0; + } + } + } else { + $AUSE_DST=1; + } + } elseif ($mm == 10) { + if ($dd >= 8) { + $AUSE_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $AUSE_DST=0; + } else { + $AUSE_DST=1; + } + } else { + if ($dow == 0 and $ns < 3600) { + $AUSE_DST=0; + } else { + $AUSE_DST=1; + } + } + } else { + $AUSE_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $AUSE_DST\n";} + if ($AUSE_DST) {$gmt_offset++;} + $AC_processed++; + } + +if ( (!$AC_processed) and ($dst_range == 'FSO-TSM') ) + { + if ($DBX) {print " First Sunday October to Third Sunday March\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in October and third Sunday in March at 1 am. + #********************************************************************** + + $NZL_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $NZL_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $NZL_DST=0; + } elseif ($mm == 3) { + if ($dd < 14) { + $NZL_DST=1; + } elseif ($dd < ($dow+14)) { + $NZL_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $NZL_DST=1; + } else { + $NZL_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $NZL_DST=1; + } else { + $NZL_DST=0; + } + } + } else { + $NZL_DST=0; + } + } elseif ($mm == 10) { + if ($dd > 7) { + $NZL_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $NZL_DST=0; + } else { + $NZL_DST=1; + } + } else { + if ($dow == 0 and $ns < 3600) { + $NZL_DST=0; + } else { + $NZL_DST=1; + } + } + } else { + $NZL_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $NZL_DST\n";} + if ($NZL_DST) {$gmt_offset++;} + $AC_processed++; + } + +if ( (!$AC_processed) and ($dst_range == 'LSS-FSA') ) + { + if ($DBX) {print " Last Sunday in September to First Sunday in April\n";} + #********************************************************************** + # LSS-FSA + # 2007+ NEW ZEALAND (country code 64) + # This is returns 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on last Sunday in September and first Sunday in April at 1 am. + #********************************************************************** + + $NZLN_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 4 || $mm > 9) { + $NZLN_DST=1; + } elseif ($mm >= 5 && $mm <= 9) { + $NZLN_DST=0; + } elseif ($mm == 4) { + if ($dd > 7) { + $NZLN_DST=0; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 && $ns < (3600+$timezone*3600)) { + $NZLN_DST=1; + } else { + $NZLN_DST=0; + } + } else { + if ($dow == 0 && $ns < 7200) { + $NZLN_DST=1; + } else { + $NZLN_DST=0; + } + } + } else { + $NZLN_DST=1; + } + } elseif ($mm == 9) { + if ($dd < 25) { + $NZLN_DST=0; + } elseif ($dd < ($dow+25)) { + $NZLN_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $NZLN_DST=0; + } else { + $NZLN_DST=1; + } + } else { # local time calculations + if ($ns < 3600) { + $NZLN_DST=0; + } else { + $NZLN_DST=1; + } + } + } else { + $NZLN_DST=1; + } + } # end of month checks + if ($DBX) {print " DST: $NZLN_DST\n";} + if ($NZLN_DST) {$gmt_offset++;} + $AC_processed++; + } + +if ( (!$AC_processed) and ($dst_range == 'TSO-LSF') ) + { + if ($DBX) {print " Third Sunday October to Last Sunday February\n";} + #********************************************************************** + # TSO-LSF + # This is returns 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. Brazil + # Based on Third Sunday October to Last Sunday February at 1 am. + #********************************************************************** + + $BZL_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 2 || $mm > 10) { + $BZL_DST=1; + } elseif ($mm >= 3 and $mm <= 9) { + $BZL_DST=0; + } elseif ($mm == 2) { + if ($dd < 22) { + $BZL_DST=1; + } elseif ($dd < ($dow+22)) { + $BZL_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $BZL_DST=1; + } else { + $BZL_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $BZL_DST=1; + } else { + $BZL_DST=0; + } + } + } else { + $BZL_DST=0; + } + } elseif ($mm == 10) { + if ($dd < 22) { + $BZL_DST=0; + } elseif ($dd < ($dow+22)) { + $BZL_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $BZL_DST=0; + } else { + $BZL_DST=1; + } + } else { # local time calculations + if ($ns < 3600) { + $BZL_DST=0; + } else { + $BZL_DST=1; + } + } + } else { + $BZL_DST=1; + } + } # end of month checks + if ($DBX) {print " DST: $BZL_DST\n";} + if ($BZL_DST) {$gmt_offset++;} + $AC_processed++; + } + +if (!$AC_processed) + { + if ($DBX) {print " No DST Method Found\n";} + if ($DBX) {print " DST: 0\n";} + $AC_processed++; + } + +return $gmt_offset; +} + + + + + +##### DETERMINE IF LEAD IS DIALABLE ##### +function dialable_gmt($DB,$link,$local_call_time,$gmt_offset,$state) + { + $dialable=0; + + $pzone=3600 * $gmt_offset; + $pmin=(gmdate("i", time() + $pzone)); + $phour=( (gmdate("G", time() + $pzone)) * 100); + $pday=gmdate("w", time() + $pzone); + $tz = sprintf("%.2f", $p); + $GMT_gmt = "$tz"; + $GMT_day = "$pday"; + $GMT_hour = ($phour + $pmin); + + $stmt="SELECT call_time_id,call_time_name,call_time_comments,ct_default_start,ct_default_stop,ct_sunday_start,ct_sunday_stop,ct_monday_start,ct_monday_stop,ct_tuesday_start,ct_tuesday_stop,ct_wednesday_start,ct_wednesday_stop,ct_thursday_start,ct_thursday_stop,ct_friday_start,ct_friday_stop,ct_saturday_start,ct_saturday_stop,ct_state_call_times FROM vicidial_call_times where call_time_id='$local_call_time';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $Gct_default_start = "$rowx[3]"; + $Gct_default_stop = "$rowx[4]"; + $Gct_sunday_start = "$rowx[5]"; + $Gct_sunday_stop = "$rowx[6]"; + $Gct_monday_start = "$rowx[7]"; + $Gct_monday_stop = "$rowx[8]"; + $Gct_tuesday_start = "$rowx[9]"; + $Gct_tuesday_stop = "$rowx[10]"; + $Gct_wednesday_start = "$rowx[11]"; + $Gct_wednesday_stop = "$rowx[12]"; + $Gct_thursday_start = "$rowx[13]"; + $Gct_thursday_stop = "$rowx[14]"; + $Gct_friday_start = "$rowx[15]"; + $Gct_friday_stop = "$rowx[16]"; + $Gct_saturday_start = "$rowx[17]"; + $Gct_saturday_stop = "$rowx[18]"; + $Gct_state_call_times = "$rowx[19]"; + + if ($GMT_day==0) #### Sunday local time + { + if (($Gct_sunday_start==0) and ($Gct_sunday_stop==0)) + { + if ( ($GMT_hour>=$Gct_default_start) and ($GMT_hour<$Gct_default_stop) ) + {$dialable=1;} + } + else + { + if ( ($GMT_hour>=$Gct_sunday_start) and ($GMT_hour<$Gct_sunday_stop) ) + {$dialable=1;} + } + } + if ($GMT_day==1) #### Monday local time + { + if (($Gct_monday_start==0) and ($Gct_monday_stop==0)) + { + if ( ($GMT_hour>=$Gct_default_start) and ($GMT_hour<$Gct_default_stop) ) + {$dialable=1;} + } + else + { + if ( ($GMT_hour>=$Gct_monday_start) and ($GMT_hour<$Gct_monday_stop) ) + {$dialable=1;} + } + } + if ($GMT_day==2) #### Tuesday local time + { + if (($Gct_tuesday_start==0) and ($Gct_tuesday_stop==0)) + { + if ( ($GMT_hour>=$Gct_default_start) and ($GMT_hour<$Gct_default_stop) ) + {$dialable=1;} + } + else + { + if ( ($GMT_hour>=$Gct_tuesday_start) and ($GMT_hour<$Gct_tuesday_stop) ) + {$dialable=1;} + } + } + if ($GMT_day==3) #### Wednesday local time + { + if (($Gct_wednesday_start==0) and ($Gct_wednesday_stop==0)) + { + if ( ($GMT_hour>=$Gct_default_start) and ($GMT_hour<$Gct_default_stop) ) + {$dialable=1;} + } + else + { + if ( ($GMT_hour>=$Gct_wednesday_start) and ($GMT_hour<$Gct_wednesday_stop) ) + {$dialable=1;} + } + } + if ($GMT_day==4) #### Thursday local time + { + if (($Gct_thursday_start==0) and ($Gct_thursday_stop==0)) + { + if ( ($GMT_hour>=$Gct_default_start) and ($GMT_hour<$Gct_default_stop) ) + {$dialable=1;} + } + else + { + if ( ($GMT_hour>=$Gct_thursday_start) and ($GMT_hour<$Gct_thursday_stop) ) + {$dialable=1;} + } + } + if ($GMT_day==5) #### Friday local time + { + if (($Gct_friday_start==0) and ($Gct_friday_stop==0)) + { + if ( ($GMT_hour>=$Gct_default_start) and ($GMT_hour<$Gct_default_stop) ) + {$dialable=1;} + } + else + { + if ( ($GMT_hour>=$Gct_friday_start) and ($GMT_hour<$Gct_friday_stop) ) + {$dialable=1;} + } + } + if ($GMT_day==6) #### Saturday local time + { + if (($Gct_saturday_start==0) and ($Gct_saturday_stop==0)) + { + if ( ($GMT_hour>=$Gct_default_start) and ($GMT_hour<$Gct_default_stop) ) + {$dialable=1;} + } + else + { + if ( ($GMT_hour>=$Gct_saturday_start) and ($GMT_hour<$Gct_saturday_stop) ) + {$dialable=1;} + } + } + + return $dialable; + } + +/* + $ct_states = ''; + $ct_state_gmt_SQL = ''; + $ct_srs=0; + $b=0; + if (strlen($Gct_state_call_times)>2) + { + $state_rules = explode('|',$Gct_state_call_times); + $ct_srs = ((count($state_rules)) - 2); + } + while($ct_srs >= $b) + { + if ( (strlen($state_rules[$b])>1) and (strlen($state)>1) ) + { + $stmt="SELECT STAR from vicidial_state_call_times where state_call_time_id='$state_rules[$b]' and state_call_time_state='$state';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $Gstate_call_time_id = "$row[0]"; + $Gstate_call_time_state = "$row[1]"; + $Gsct_default_start = "$row[4]"; + $Gsct_default_stop = "$row[5]"; + $Gsct_sunday_start = "$row[6]"; + $Gsct_sunday_stop = "$row[7]"; + $Gsct_monday_start = "$row[8]"; + $Gsct_monday_stop = "$row[9]"; + $Gsct_tuesday_start = "$row[10]"; + $Gsct_tuesday_stop = "$row[11]"; + $Gsct_wednesday_start = "$row[12]"; + $Gsct_wednesday_stop = "$row[13]"; + $Gsct_thursday_start = "$row[14]"; + $Gsct_thursday_stop = "$row[15]"; + $Gsct_friday_start = "$row[16]"; + $Gsct_friday_stop = "$row[17]"; + $Gsct_saturday_start = "$row[18]"; + $Gsct_saturday_stop = "$row[19]"; + + $ct_states .="'$Gstate_call_time_state',"; + + $r=0; + $state_gmt=''; + while($r < $g) + { + if ($GMT_day[$r]==0) #### Sunday local time + { + if (($Gsct_sunday_start==0) and ($Gsct_sunday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_sunday_start) and ($GMT_hour[$r]<$Gsct_sunday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==1) #### Monday local time + { + if (($Gsct_monday_start==0) and ($Gsct_monday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_monday_start) and ($GMT_hour[$r]<$Gsct_monday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==2) #### Tuesday local time + { + if (($Gsct_tuesday_start==0) and ($Gsct_tuesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_tuesday_start) and ($GMT_hour[$r]<$Gsct_tuesday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==3) #### Wednesday local time + { + if (($Gsct_wednesday_start==0) and ($Gsct_wednesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_wednesday_start) and ($GMT_hour[$r]<$Gsct_wednesday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==4) #### Thursday local time + { + if (($Gsct_thursday_start==0) and ($Gsct_thursday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_thursday_start) and ($GMT_hour[$r]<$Gsct_thursday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==5) #### Friday local time + { + if (($Gsct_friday_start==0) and ($Gsct_friday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_friday_start) and ($GMT_hour[$r]<$Gsct_friday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==6) #### Saturday local time + { + if (($Gsct_saturday_start==0) and ($Gsct_saturday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_saturday_start) and ($GMT_hour[$r]<$Gsct_saturday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + $r++; + } + $state_gmt = "$state_gmt'99'"; + $ct_state_gmt_SQL .= "or (state='$Gstate_call_time_state' and gmt_offset_now IN($state_gmt)) "; + } + + $b++; + } + if (strlen($ct_states)>2) + { + $ct_states = eregi_replace(",$",'',$ct_states); + $ct_statesSQL = "and state NOT IN($ct_states)"; + } + else + { + $ct_statesSQL = ""; + } + +*/ + + + + +##### Logging ##### +function api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data) + { + if ($api_logging > 0) + { + $NOW_TIME = date("Y-m-d H:i:s"); + # api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + $stmt="INSERT INTO vicidial_api_log set user='$user',agent_user='$agent_user',function='$function',value='$value',result='$result',result_reason='$result_reason',source='$source',data='$data',api_date='$NOW_TIME',api_script='$api_script';"; + $rslt=mysql_query($stmt, $link); + } + return 1; + } + +?> diff --git a/LANG_www/vicidial_br/remote_dispo.php b/LANG_www/vicidial_br/remote_dispo.php new file mode 100644 index 00000000..dd8a67cd --- /dev/null +++ b/LANG_www/vicidial_br/remote_dispo.php @@ -0,0 +1,330 @@ + LICENSE: AGPLv2 +# +# this is the remote agent disposition screen for calls sent to remote agents. +# This allows the remote agent to modify customer information and disposition +# the call +# +# CHANGES +# +# 60619-1626 - Added variable filtering to eliminate SQL injection attack threat +# 90508-0644 - Changed to PHP long tags +# + + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];} + elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["channel_group"])) {$channel_group=$_GET["channel_group"];} + elseif (isset($_POST["channel_group"])) {$channel_group=$_POST["channel_group"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["customer_zap_channel"])) {$customer_zap_channel=$_GET["customer_zap_channel"];} + elseif (isset($_POST["customer_zap_channel"])) {$customer_zap_channel=$_POST["customer_zap_channel"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];} + elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];} + elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];} + elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["security"])) {$security=$_GET["security"];} + elseif (isset($_POST["security"])) {$security=$_POST["security"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];} + elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];} + elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} + elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_datetime = $STARTtime; + +$ext_context = 'demo'; +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 2;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICIDIAL-CLOSER\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Nome ou Senha inválidos: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + $fullname = $row[0]; + fwrite ($fp, "VD_CLOSER|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + } + else + { + fwrite ($fp, "VD_CLOSER|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +?> + + +VICIDIAL REMOTO: Finaliz. de chamada +\n"; +?> + + +
+ +"; + +if ($end_call > 0) +{ + +$call_length = ($STARTtime - $call_began); + + ### insert a NEW record to the vicidial_closer_log table + $stmt="UPDATE vicidial_closer_log set end_epoch='$STARTtime', length_in_sec='" . mysql_real_escape_string($call_length) . "', status='" . mysql_real_escape_string($status) . "', user='$PHP_AUTH_USER' where lead_id='" . mysql_real_escape_string($lead_id) . "' order by start_epoch desc limit 1;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + ### update the lead record in the vicidial_list table + $stmt="UPDATE vicidial_list set status='" . mysql_real_escape_string($status) . "',first_name='" . mysql_real_escape_string($first_name) . "',last_name='" . mysql_real_escape_string($last_name) . "',address1='" . mysql_real_escape_string($address1) . "',address2='" . mysql_real_escape_string($address2) . "',address3='" . mysql_real_escape_string($address3) . "',city='" . mysql_real_escape_string($city) . "',state='" . mysql_real_escape_string($state) . "',province='" . mysql_real_escape_string($province) . "',postal_code='" . mysql_real_escape_string($postal_code) . "',country_code='" . mysql_real_escape_string($country_code) . "',alt_phone='" . mysql_real_escape_string($alt_phone) . "',email='" . mysql_real_escape_string($email) . "',security_phrase='" . mysql_real_escape_string($security) . "',comments='" . mysql_real_escape_string($comments) . "',user='$PHP_AUTH_USER' where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "Chamada finalizada       $NOW_TIME\n

\n"; + + echo "
\n"; + +} +else +{ + $stmt="SELECT count(*) from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $lead_count = $row[0]; + + if ($lead_count > 0) + { + + $stmt="SELECT lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $lead_id = "$row[0]"; + $tsr = "$row[4]"; + $vendor_id = "$row[5]"; + $list_id = "$row[7]"; + $campaign_id = "$row[8]"; + $phone_code = "$row[10]"; + $phone_number = "$row[11]"; + $title = "$row[12]"; + $first_name = "$row[13]"; # + $middle_initial = "$row[14]"; + $last_name = "$row[15]"; # + $address1 = "$row[16]"; # + $address2 = "$row[17]"; # + $address3 = "$row[18]"; # + $city = "$row[19]"; # + $state = "$row[20]"; # + $province = "$row[21]"; # + $postal_code = "$row[22]"; # + $country_code = "$row[23]"; # + $gender = "$row[24]"; + $date_of_birth = "$row[25]"; + $alt_phone = "$row[26]"; # + $email = "$row[27]"; # + $security = "$row[28]"; # + $comments = "$row[29]"; # + + echo "
Informações da Chamada: $first_name $last_name - $phone_number

\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + + echo "\n"; + echo "
Vendor ID: $vendor_id     ID da Campanha: $campaign_id
Fronter: $tsr     ID da Lista: $list_id
Nome:   \n"; + echo " Sobrenome:
Endereço 1 :
Endereço 2 :
Endereço 3 :
Cidade :
Estado:   \n"; + echo " CEP:
Província:
País :
Tel. Alt. :
Email :
Segurança:
Comentários :
Finalização:
\n"; + echo "


\n"; + + } + else + { + echo "procura de registro FALHOU para este lead_id $lead_id       $NOW_TIME\n

\n"; +# echo "Close this window\n

\n"; + } + + + + + + +} + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nScript runtime: $RUNtime seconds
"; + + +?> + + + + + + + + + + + diff --git a/LANG_www/vicidial_br/timeclock_edit.php b/LANG_www/vicidial_br/timeclock_edit.php new file mode 100644 index 00000000..d938594f --- /dev/null +++ b/LANG_www/vicidial_br/timeclock_edit.php @@ -0,0 +1,481 @@ + LICENSE: AGPLv2 +# +# CHANGES +# +# 80624-1342 - First build +# 80701-1323 - functional beta version done +# 90310-2109 - Added admin header +# 90508-0644 - Changed to PHP long tags +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["oldLOGINepoch"])) {$oldLOGINepoch=$_GET["oldLOGINepoch"];} + elseif (isset($_POST["oldLOGINepoch"])) {$oldLOGINepoch=$_POST["oldLOGINepoch"];} +if (isset($_GET["oldLOGOUTepoch"])) {$oldLOGOUTepoch=$_GET["oldLOGOUTepoch"];} + elseif (isset($_POST["oldLOGOUTepoch"])) {$oldLOGOUTepoch=$_POST["oldLOGOUTepoch"];} +if (isset($_GET["oldLOGINdate"])) {$oldLOGINdate=$_GET["oldLOGINdate"];} + elseif (isset($_POST["oldLOGINdate"])) {$oldLOGINdate=$_POST["oldLOGINdate"];} +if (isset($_GET["oldLOGOUTdate"])) {$oldLOGOUTdate=$_GET["oldLOGOUTdate"];} + elseif (isset($_POST["oldLOGOUTdate"])) {$oldLOGOUTdate=$_POST["oldLOGOUTdate"];} +if (isset($_GET["LOGINepoch"])) {$LOGINepoch=$_GET["LOGINepoch"];} + elseif (isset($_POST["LOGINepoch"])) {$LOGINepoch=$_POST["LOGINepoch"];} +if (isset($_GET["LOGOUTepoch"])) {$LOGOUTepoch=$_GET["LOGOUTepoch"];} + elseif (isset($_POST["LOGOUTepoch"])) {$LOGOUTepoch=$_POST["LOGOUTepoch"];} +if (isset($_GET["notes"])) {$notes=$_GET["notes"];} + elseif (isset($_POST["notes"])) {$notes=$_POST["notes"];} +if (isset($_GET["LOGINevent_id"])) {$LOGINevent_id=$_GET["LOGINevent_id"];} + elseif (isset($_POST["LOGINevent_id"])) {$LOGINevent_id=$_POST["LOGINevent_id"];} +if (isset($_GET["LOGOUTevent_id"])) {$LOGOUTevent_id=$_GET["LOGOUTevent_id"];} + elseif (isset($_POST["LOGOUTevent_id"])) {$LOGOUTevent_id=$_POST["LOGOUTevent_id"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["timeclock_id"])) {$timeclock_id=$_GET["timeclock_id"];} + elseif (isset($_POST["timeclock_id"])) {$timeclock_id=$_POST["timeclock_id"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin,webroot_writable,outbound_autodial_active,user_territories_active 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]; + $webroot_writable = $row[1]; + $SSoutbound_autodial_active = $row[2]; + $user_territories_active = $row[3]; + $i++; + } +##### END SETTINGS LOOKUP ##### +########################################### + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$StarTtimE = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$ip = getenv("REMOTE_ADDR"); +$invalid_record=0; + +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7 and view_reports='1';"; +if ($non_latin > 0) { $rslt=mysql_query("SET NAMES 'UTF8'");} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + 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 "Nome ou Senha inválidos: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $stmt="SELECT full_name,modify_timeclock_log from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname = $row[0]; + $modify_timeclock_log = $row[1]; + if ($webroot_writable > 0) + { + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + } + else + { + if ($webroot_writable > 0) + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + + $stmt="SELECT full_name,user_group from vicidial_users where user='" . mysql_real_escape_string($user) . "';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $full_name = $row[0]; + $user_group = $row[1]; + + $stmt="SELECT event,tcid_link from vicidial_timeclock_log where timeclock_id='" . mysql_real_escape_string($timeclock_id) . "';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $tc_logs_to_print = mysql_num_rows($rslt); + if ($tc_logs_to_print > 0) + { + $row=mysql_fetch_row($rslt); + $event = $row[0]; + $tcid_link = $row[1]; + } + if (ereg("LOGIN",$event)) + { + $LOGINevent_id = $timeclock_id; + $LOGOUTevent_id = $tcid_link; + if ( (ereg('NULL',$LOGOUTevent_id)) or (strlen($LOGOUTevent_id)<1) ) + {$invalid_record++;} + } + if (ereg("LOGOUT",$event)) + { + $LOGOUTevent_id = $timeclock_id; + $stmt="SELECT timeclock_id from vicidial_timeclock_log where tcid_link='" . mysql_real_escape_string($timeclock_id) . "';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $tc_logs_to_print = mysql_num_rows($rslt); + if ($tc_logs_to_print > 0) + { + $row=mysql_fetch_row($rslt); + $LOGINevent_id = $row[0]; + } + if ( (ereg('NULL',$LOGOUTevent_id)) or (strlen($LOGOUTevent_id)<1) ) + {$invalid_record++;} + } + if (strlen($LOGOUTevent_id)<1) + {$invalid_record++;} + + ### + if ($invalid_record < 1) + { + $stmt="SELECT event_epoch,event_date,login_sec,event,user,user_group,ip_address,shift_id,notes,manager_user,manager_ip,event_datestamp from vicidial_timeclock_log where timeclock_id='$LOGINevent_id';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $tc_logs_to_print = mysql_num_rows($rslt); + if ($tc_logs_to_print > 0) + { + $row=mysql_fetch_row($rslt); + $LOGINevent_epoch = $row[0]; + $LOGINevent_date = $row[1]; + $LOGINlogin_sec = $row[2]; + $LOGINevent = $row[3]; + $LOGINuser = $row[4]; + $LOGINuser_group = $row[5]; + $LOGINip_address = $row[6]; + $LOGINshift_id = $row[7]; + $LOGINnotes = $row[8]; + $LOGINmanager_user = $row[9]; + $LOGINmanager_ip = $row[10]; + $LOGINevent_datestamp = $row[11]; + } + $stmt="SELECT event_epoch,event_date,login_sec,event,user,user_group,ip_address,shift_id,notes,manager_user,manager_ip,event_datestamp from vicidial_timeclock_log where timeclock_id='$LOGOUTevent_id';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $tc_logs_to_print = mysql_num_rows($rslt); + if ($tc_logs_to_print > 0) + { + $row=mysql_fetch_row($rslt); + $LOGOUTevent_epoch = $row[0]; + $LOGOUTevent_date = $row[1]; + $LOGOUTlogin_sec = $row[2]; + $LOGOUTevent = $row[3]; + $LOGOUTuser = $row[4]; + $LOGOUTuser_group = $row[5]; + $LOGOUTip_address = $row[6]; + $LOGOUTshift_id = $row[7]; + $LOGOUTnotes = $row[8]; + $LOGOUTmanager_user = $row[9]; + $LOGOUTmanager_ip = $row[10]; + $LOGOUTevent_datestamp =$row[11]; + } + + $user=$LOGINuser; + } + } + + + +?> + + + +ADMINISTRATION: Alteração de Ponto +<?php + +##### BEGIN Set variables to make header show properly ##### +$ADD = '3'; +$hh = 'users'; +$TCedit_javascript = '1'; +$LOGast_admin_access = '1'; +$ADMIN = 'admin.php'; +$page_width='770'; +$section_width='750'; +$header_font_size='3'; +$subheader_font_size='2'; +$subcamp_font_size='2'; +$header_selected_bold='<b>'; +$header_nonselected_bold=''; +$users_color = '#FFFF99'; +$users_font = 'BLACK'; +$users_color = '#E6E6E6'; +$subcamp_color = '#C6C6C6'; +##### END Set variables to make header show properly ##### + +require("admin_header.php"); + +?> + + +<CENTER> +<TABLE WIDTH=720 BGCOLOR=#D9E6FE cellpadding=2 cellspacing=0><TR BGCOLOR=#015B91><TD ALIGN=LEFT><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=2><B>Alteração de Ponto for <?php echo $user ?></TD><TD ALIGN=RIGHT>   </TD></TR> + +<?php + +echo "<TR BGCOLOR=\"#F0F5FE\"><TD ALIGN=LEFT COLSPAN=2><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=3><B>   \n"; + + + + + +##### BEGIN TIMECLOCK RECORD MODIFY ##### + +if ( ($invalid_record < 1) or (strlen($timeclock_id)<1) ) +{ + +if ($stage == "edit_TC_log") + { + $log_time = ($LOGOUTepoch - $LOGINepoch); + $NEXTevent_epoch = $StarTtimE; + $PREVevent_epoch = 0; + + $stmt="SELECT event_epoch,timeclock_id from vicidial_timeclock_log where timeclock_id > '$LOGOUTevent_id' and user='$user' order by timeclock_id limit 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $tc_logs_to_print = mysql_num_rows($rslt); + if ($tc_logs_to_print > 0) + { + $row=mysql_fetch_row($rslt); + $NEXTevent_epoch = $row[0]; + $NEXTevent_id = $row[1]; + } + $stmt="SELECT event_epoch,timeclock_id from vicidial_timeclock_log where timeclock_id < '$LOGINevent_id' and user='$user' order by timeclock_id desc limit 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $tc_logs_to_print = mysql_num_rows($rslt); + if ($tc_logs_to_print > 0) + { + $row=mysql_fetch_row($rslt); + $PREVevent_epoch = $row[0]; + $PREVevent_id = $row[1]; + } + + if ( ($LOGINepoch <= $PREVevent_epoch) || ($LOGOUTepoch >= $NEXTevent_epoch) ) + { + echo "ERRO - Existe um problema com os dados digitados, por favor retorne<BR>\n"; + echo "Uma sessão de Ponto não pode sobrepor outra sessão de ponto<BR>\n"; + echo "$LOGINepoch<BR>\n"; + echo "$LOGOUTepoch<BR>\n"; + echo "$LOGINevent_id<BR>\n"; + echo "$LOGOUTevent_id<BR>\n"; + echo "$LOGINuser<BR>\n"; + echo "$PREVevent_epoch<BR>\n"; + echo "$PREVevent_id<BR>\n"; + echo "$NEXTevent_epoch<BR>\n"; + echo "$NEXTevent_id<BR>\n"; + exit; + } + if ( ($LOGINepoch > $StarTtimE) || ($LOGOUTepoch > $StarTtimE) || ($log_time > 86400) || ($log_time < 1) ) + { + echo "ERRO - Existe um problema com os dados digitados, por favor retorne<BR>\n"; + echo "$LOGINepoch<BR>\n"; + echo "$LOGOUTepoch<BR>\n"; + echo "$notes<BR>\n"; + echo "$LOGINevent_id<BR>\n"; + echo "$LOGOUTevent_id<BR>\n"; + echo "$LOGINuser<BR>\n"; + exit; + } + else + { + $LOGINdatetime = date("Y-m-d H:i:s", $LOGINepoch); + $LOGOUTdatetime = date("Y-m-d H:i:s", $LOGOUTepoch); + + ### update LOGIN record in the timeclock log + $stmtA="UPDATE vicidial_timeclock_log set event_epoch='$LOGINepoch', event_date='$LOGINdatetime', manager_user='$PHP_AUTH_USER', manager_ip='$ip', notes='Manager MODIFY', login_sec='$log_time' where timeclock_id='$LOGINevent_id';"; + if ($DB) {echo "$stmtA\n";} + $rslt=mysql_query($stmtA, $link); + $affected_rows = mysql_affected_rows($link); + $timeclock_id = mysql_insert_id($link); + print "<!-- UPDATE vicidial_timeclock_log record updated for $user: |$affected_rows|$timeclock_id| -->\n"; + + ### Add a record to the vicidial_admin_log + $SQL_log = "$stmtA|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$PHP_AUTH_USER', ip_address='$ip', event_section='TIMECLOCK', event_type='MODIFY', record_id='$LOGINevent_id', event_code='MANAGER MODIFY TIMECLOCK LOG', event_sql=\"$SQL_log\", event_notes='user: $user|$oldLOGINepoch|$oldLOGINdate|sec: $log_time|';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "<!-- NEW vicidial_admin_log record inserted for $PHP_AUTH_USER: |$affected_rows| -->\n"; + + ### update LOGOUT record in the timeclock log + $stmtB="UPDATE vicidial_timeclock_log set event_epoch='$LOGOUTepoch', event_date='$LOGOUTdatetime', manager_user='$PHP_AUTH_USER', manager_ip='$ip', notes='Manager MODIFY', login_sec='$log_time' where timeclock_id='$LOGOUTevent_id';"; + if ($DB) {echo "$stmtB\n";} + $rslt=mysql_query($stmtB, $link); + $affected_rows = mysql_affected_rows($link); + $timeclock_id = mysql_insert_id($link); + print "<!-- UPDATE vicidial_timeclock_log record updated for $user: |$affected_rows|$timeclock_id| -->\n"; + + ### Add a record to the vicidial_admin_log + $SQL_log = "$stmtB|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$PHP_AUTH_USER', ip_address='$ip', event_section='TIMECLOCK', event_type='MODIFY', record_id='$LOGOUTevent_id', event_code='MANAGER MODIFY TIMECLOCK LOG', event_sql=\"$SQL_log\", event_notes='user: $user|$oldLOGOUTepoch|$oldLOGOUTdate|sec: $log_time|';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "<!-- NEW vicidial_admin_log record inserted for $PHP_AUTH_USER: |$affected_rows| -->\n"; + + echo "The timeclock session has been updated. <A HREF=\"$PHP_SELF?timeclock_id=$LOGINevent_id\">Click here to view</A>.<BR>\n"; + exit; + } + } +##### END TIMECLOCK RECORD MODIFY ##### + + + + +echo "\n<BR>"; + +if ($modify_timeclock_log > 0) + { +# $LOGINevent_id = $timeclock_id; +# $LOGOUTevent_id = $tcid_link; + + $event_hours = ($LOGINlogin_sec / 3600); + $event_hours_int = round($event_hours, 2); + $event_hours_int = intval("$event_hours_int"); + $event_minutes = ($event_hours - $event_hours_int); + $event_minutes = ($event_minutes * 60); + $event_minutes_int = round($event_minutes, 0); + if ($event_minutes_int < 10) {$event_minutes_int = "0$event_minutes_int";} + + $stmt="SELECT full_name from vicidial_users where user='$LOGINuser';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $full_name = $row[0]; + + echo "<BR><BR>\n"; + echo "<form action=$PHP_SELF method=POST name=edit_log id=edit_log>\n"; + echo "<input type=hidden name=DB value=\"$DB\">\n"; + echo "<input type=hidden name=user value=\"$user\">\n"; + echo "<input type=hidden name=stage value=edit_TC_log>\n"; + echo "<input type=hidden name=oldLOGINepoch id=oldLOGINepoch value=\"$LOGINevent_epoch\">\n"; + echo "<input type=hidden name=oldLOGOUTepoch id=oldLOGOUTepoch value=\"$LOGOUTevent_epoch\">\n"; + echo "<input type=hidden name=oldLOGINdate id=oldLOGINdate value=\"$LOGINevent_date\">\n"; + echo "<input type=hidden name=oldLOGOUTdate id=oldLOGOUTdate value=\"$LOGOUTevent_date\">\n"; + echo "<input type=hidden name=LOGINepoch id=LOGINepoch value=\"$LOGINevent_epoch\">\n"; + echo "<input type=hidden name=LOGOUTepoch id=LOGOUTepoch value=\"$LOGOUTevent_epoch\">\n"; + echo "<input type=hidden name=LOGINevent_id id=LOGINevent_id value=\"$LOGINevent_id\">\n"; + echo "<input type=hidden name=LOGOUTevent_id id=LOGOUTevent_id value=\"$LOGOUTevent_id\">\n"; + echo "<input type=hidden name=stage value=edit_TC_log>\n"; + echo "<TABLE Border=0><TR><TD COLSPAN=3 ALIGN=LEFT>\n"; + echo "        USER: $LOGINuser ($full_name)         \n"; + echo "HOURS: <span name=login_time id=login_time> $event_hours_int:$event_minutes_int </span>\n"; + echo "</TD></TR>\n"; + echo "<TR><TD>\n"; + echo "<TABLE Border=0>\n"; + echo "<TR><TD ALIGN=RIGHT>LOGIN TIME: </TD><TD ALIGN=RIGHT><input type=text name=LOGINbegin_date id=LOGINbegin_date value=\"$LOGINevent_date\" size=20 maxlength=20 onchange=\"calculate_hours();\"></TD></TR>\n"; + echo "<TR><TD ALIGN=RIGHT>TIMECLOCK ID: </TD><TD ALIGN=RIGHT>$LOGINevent_id</TD></TR>\n"; + echo "<TR><TD ALIGN=RIGHT>GRUPO DE USUÁRIOS: </TD><TD ALIGN=RIGHT>$LOGINuser_group</TD></TR>\n"; + echo "<TR><TD ALIGN=RIGHT>IP ADDRESS: </TD><TD ALIGN=RIGHT>$LOGINip_address</TD></TR>\n"; + echo "<TR><TD ALIGN=RIGHT>MANAGER USER: </TD><TD ALIGN=RIGHT>$LOGINmanager_user</TD></TR>\n"; + echo "<TR><TD ALIGN=RIGHT>MANAGER IP: </TD><TD ALIGN=RIGHT>$LOGINmanager_ip</TD></TR>\n"; + echo "<TR><TD ALIGN=RIGHT>NOTES: </TD><TD ALIGN=RIGHT>$LOGINnotes</TD></TR>\n"; + echo "<TR><TD ALIGN=RIGHT>LAST CHANGE: </TD><TD ALIGN=RIGHT>$LOGINevent_datestamp</TD></TR>\n"; + echo "</TABLE>\n"; + + echo "</TD><TD>         \n"; + echo "</TD><TD>\n"; + echo "<TABLE Border=0>\n"; + echo "<TR><TD ALIGN=RIGHT>LOGOUT TIME: </TD><TD ALIGN=RIGHT><input type=text name=LOGOUTbegin_date id=LOGOUTbegin_date value=\"$LOGOUTevent_date\" size=20 maxlength=20 onchange=\"calculate_hours();\"></TD></TR>\n"; + echo "<TR><TD ALIGN=RIGHT>TIMECLOCK ID: </TD><TD ALIGN=RIGHT>$LOGOUTevent_id</TD></TR>\n"; + echo "<TR><TD ALIGN=RIGHT>GRUPO DE USUÁRIOS: </TD><TD ALIGN=RIGHT>$LOGOUTuser_group</TD></TR>\n"; + echo "<TR><TD ALIGN=RIGHT>IP ADDRESS: </TD><TD ALIGN=RIGHT>$LOGOUTip_address</TD></TR>\n"; + echo "<TR><TD ALIGN=RIGHT>MANAGER USER: </TD><TD ALIGN=RIGHT>$LOGOUTmanager_user</TD></TR>\n"; + echo "<TR><TD ALIGN=RIGHT>MANAGER IP: </TD><TD ALIGN=RIGHT>$LOGOUTmanager_ip</TD></TR>\n"; + echo "<TR><TD ALIGN=RIGHT>NOTES: </TD><TD ALIGN=RIGHT>$LOGOUTnotes</TD></TR>\n"; + echo "<TR><TD ALIGN=RIGHT>LAST CHANGE: </TD><TD ALIGN=RIGHT>$LOGOUTevent_datestamp</TD></TR>\n"; + echo "</TABLE>\n"; + echo "</TD></TR>\n"; + + echo "<TR><TD COLSPAN=3 ALIGN=LEFT>\n"; + echo "NEW NOTES: <input type=text name=notes value='' size=80 maxlength=255>\n"; + echo "</TD></TR>\n"; + echo "<TR><TD COLSPAN=3 ALIGN=CENTER>\n"; + echo "<input type=button name=go_submit id=go_submit value=ENVIAR onclick=\"run_submit();\"><BR></form>\n"; + echo "</TD></TR></TABLE>\n"; + echo "<BR><BR>\n"; + } + + +echo "<a href=\"./AST_agent_time_sheet.php?agent=$user\">Agent Planilha de Tempo</a>\n"; +echo " - <a href=\"./user_stats.php?user=$user\">Estatísticas de Usuário</a>\n"; +echo " - <a href=\"./admin.php?ADD=3&user=$user\">Alterar Usuário</a>\n"; + +echo "</B></TD></TR>\n"; +echo "<TR><TD ALIGN=LEFT COLSPAN=2>\n"; + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $StarTtimE); + +echo "\n\n\n<br><br><br>\n\n"; + + +echo "<font size=0>\n\n\n<br><br><br>\nScript runtime: $RUNtime seconds</font>"; + +echo "|$stage|$group|"; + +} +else +{ + +echo "ERROR! You cannot edit this timeclock record: $timeclock_id\n"; +} +?> + + +</TD></TR><TABLE> +</body> +</html> + +<?php + +exit; + + + +?> + diff --git a/LANG_www/vicidial_br/timeclock_report.php b/LANG_www/vicidial_br/timeclock_report.php new file mode 100644 index 00000000..4aca8d6f --- /dev/null +++ b/LANG_www/vicidial_br/timeclock_report.php @@ -0,0 +1,392 @@ +<?php +# timeclock_report.php +# +# Copyright (C) 2010 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2 +# +# CHANGES +# +# 80529-0055 - First build +# 80617-1416 - Fixed totals tally bug +# 80707-0754 - Fixed groups bug, changed formatting +# 90310-2059 - Added admin header +# 90508-0644 - Changed to PHP long tags +# 100214-1421 - Sort menu alphabetically +# 100216-0042 - Added popup date selector +# + +require("dbconnect.php"); + +##### Pull values from posted form variables ##### +$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["user_group"])) {$user_group=$_GET["user_group"];} + elseif (isset($_POST["user_group"])) {$user_group=$_POST["user_group"];} +if (isset($_GET["shift"])) {$shift=$_GET["shift"];} + elseif (isset($_POST["shift"])) {$shift=$_POST["shift"];} +if (isset($_GET["order"])) {$order=$_GET["order"];} + elseif (isset($_POST["order"])) {$order=$_POST["order"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} + +if (strlen($shift)<2) {$shift='ALL';} +if (strlen($order)<2) {$order='hours_down';} + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin,webroot_writable,outbound_autodial_active FROM system_settings;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$qm_conf_ct = mysql_num_rows($rslt); +if ($qm_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $non_latin = $row[0]; + $webroot_writable = $row[1]; + $SSoutbound_autodial_active = $row[2]; + } +##### END SETTINGS LOOKUP ##### +########################################### + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$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 "Nome ou Senha inválidos: |$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;} +if (!isset($end_date)) {$end_date = $NOW_DATE;} + +$stmt="select user_group from vicidial_user_groups order by user_group;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$user_groups_to_print = mysql_num_rows($rslt); +$i=0; + $LISTuser_groups[$i]='---ALL---'; + $i++; + $user_groups_to_print++; +while ($i < $user_groups_to_print) + { + $row=mysql_fetch_row($rslt); + $LISTuser_groups[$i] =$row[0]; + $i++; + } + +##### START HTML ##### +?> + +<HTML> +<HEAD> + +<style type="text/css"> +<!-- + div.scroll_callback {height: 300px; width: 620px; overflow: scroll;} + div.scroll_list {height: 400px; width: 140px; overflow: scroll;} + div.scroll_script {height: 331px; width: 600px; background: #FFF5EC; overflow: scroll; font-size: 12px; font-family: sans-serif;} + div.text_input {overflow: auto; font-size: 10px; font-family: sans-serif;} + .body_text {font-size: 13px; font-family: sans-serif;} + .preview_text {font-size: 13px; font-family: sans-serif; background: #CCFFCC} + .preview_text_red {font-size: 13px; font-family: sans-serif; background: #FFCCCC} + .body_small {font-size: 11px; font-family: sans-serif;} + .body_tiny {font-size: 10px; font-family: sans-serif;} + .log_text {font-size: 11px; font-family: monospace;} + .log_text_red {font-size: 11px; font-family: monospace; font-weight: bold; background: #FF3333} + .sd_text {font-size: 16px; font-family: sans-serif; font-weight: bold;} + .sh_text {font-size: 14px; font-family: sans-serif; font-weight: bold;} + .sb_text {font-size: 12px; font-family: sans-serif;} + .sk_text {font-size: 11px; font-family: sans-serif;} + .skb_text {font-size: 13px; font-family: sans-serif; font-weight: bold;} + .ON_conf {font-size: 11px; font-family: monospace; color: black; background: #FFFF99} + .OFF_conf {font-size: 11px; font-family: monospace; color: black; background: #FFCC77} + .cust_form {font-family: sans-serif; font-size: 10px; overflow: auto} + + .select_bold {font-size: 14px; font-family: sans-serif; font-weight: bold;} + .header_white {font-size: 14px; font-family: sans-serif; font-weight: bold; color: white} + .data_records {font-size: 12px; font-family: sans-serif; color: black} + .data_records_fix {font-size: 12px; font-family: monospace; color: black} + .data_records_fix_small {font-size: 9px; font-family: monospace; color: black} + +--> +</style> + +<script language="JavaScript" src="calendar_db.js"></script> +<link rel="stylesheet" href="calendar.css"> + +<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8"> +<TITLE>UsuárioRelógio Ponto Report + +<?php + +##### BEGIN Set variables to make header show properly ##### +$ADD = '311111'; +$hh = 'usergroups'; +$LOGast_admin_access = '1'; +$ADMIN = 'admin.php'; +$page_width='770'; +$section_width='750'; +$header_font_size='3'; +$subheader_font_size='2'; +$subcamp_font_size='2'; +$header_selected_bold='<b>'; +$header_nonselected_bold=''; +$usergroups_color = '#FFFF99'; +$usergroups_font = 'BLACK'; +$usergroups_color = '#E6E6E6'; +$subcamp_color = '#C6C6C6'; +##### END Set variables to make header show properly ##### + +require("admin_header.php"); + + + +$user_group_ct = count($user_group); +$user_group_string='|'; + +$i=0; +while($i < $user_group_ct) + { + $user_group_string .= "$user_group[$i]|"; + $user_group_SQL .= "'$user_group[$i]',"; + $i++; + } +if ( (ereg("--ALL--",$user_group_string) ) or ($user_group_ct < 1) ) + { + $user_group_SQL = ""; + } +else + { + $user_group_SQL = eregi_replace(",$",'',$user_group_SQL); + $user_group_SQL = "and vicidial_timeclock_log.user_group IN($user_group_SQL)"; + } + +if ($DB > 0) + { + echo "<BR>\n"; + echo "$user_group_ct|$user_group_string|$user_group_SQL\n"; + echo "<BR>\n"; + } + +echo "<CENTER>\n"; +echo "<FORM ACTION=\"$PHP_SELF\" METHOD=GET name=vicidial_report id=vicidial_report>\n"; +echo "<INPUT TYPE=HIDDEN NAME=DB VALUE=\"$DB\">"; +echo "<TABLE Border=0 CELLSPACING=6><TR><TD ALIGN=LEFT VALIGN=TOP>\n"; + +echo "<font class=\"select_bold\"><B>Período:</B></font><BR><CENTER>\n"; +echo "<INPUT TYPE=TEXT NAME=query_date SIZE=10 MAXLENGTH=10 VALUE=\"$query_date\">"; + +?> +<script language="JavaScript"> +var o_cal = new tcal ({ + // form name + 'formname': 'vicidial_report', + // input name + 'controlname': 'query_date' +}); +o_cal.a_tpl.yearscroll = false; +// o_cal.a_tpl.weekstart = 1; // Segunda week start +</script> +<?php + +echo "<BR>to<BR>\n"; +echo "<INPUT TYPE=TEXT NAME=end_date SIZE=10 MAXLENGTH=10 VALUE=\"$end_date\">"; + +?> +<script language="JavaScript"> +var o_cal = new tcal ({ + // form name + 'formname': 'vicidial_report', + // input name + 'controlname': 'end_date' +}); +o_cal.a_tpl.yearscroll = false; +// o_cal.a_tpl.weekstart = 1; // Segunda week start +</script> +<?php + +echo "</TD><TD ALIGN=LEFT VALIGN=TOP>\n"; +echo "<font class=\"select_bold\"><B>Grupos de Usuário:</B></font><BR><CENTER>\n"; +echo "<SELECT SIZE=5 NAME=user_group[] multiple>\n"; + $o=0; + while ($user_groups_to_print > $o) + { + if (ereg("\|$LISTuser_groups[$o]\|",$user_group_string)) + {echo "<option selected value=\"$LISTuser_groups[$o]\">$LISTuser_groups[$o]</option>\n";} + else + {echo "<option value=\"$LISTuser_groups[$o]\">$LISTuser_groups[$o]</option>\n";} + $o++; + } +echo "</SELECT>\n"; + +echo "</TD></TD><TD ALIGN=LEFT VALIGN=TOP>\n"; +echo "<font class=\"select_bold\"><B>Order:</B></font><BR>\n"; +echo "<SELECT SIZE=1 NAME=order>\n"; +echo "<option selected value=\"$order\">$order</option>\n"; +echo "<option value=\"\">--</option>\n"; +echo "<option>hours_up</option>\n"; +echo "<option>hours_down</option>\n"; +echo "<option>user_up</option>\n"; +echo "<option>user_down</option>\n"; +echo "<option>name_up</option>\n"; +echo "<option>name_down</option>\n"; +echo "<option>group_up</option>\n"; +echo "<option>group_down</option>\n"; +echo "</SELECT><BR><CENTER>\n"; + +echo "</TD><TD ALIGN=LEFT VALIGN=TOP>\n"; +echo "<font class=\"select_bold\"><B>Usuário:</B></font><BR>\n"; +echo "<INPUT TYPE=text NAME=user SIZE=7 MAXLENGTH=20 VALUE=\"$user\">\n"; + +echo "<BR><BR><INPUT TYPE=Submit NAME=ENVIAR VALUE=ENVIAR>\n"; +echo "</TD></TD><TD ALIGN=LEFT VALIGN=TOP>\n"; +echo "</TD><TD ALIGN=CENTER VALIGN=TOP ROWSPAN=3>\n"; +echo "<FONT class=\"select_bold\" COLOR=BLACK SIZE=2>     <a href=\"./admin.php?ADD=999999\">RELATÓRIOS</a> </FONT>\n"; + +echo "</TD></TR></TABLE>\n"; +echo "</FORM>\n\n"; + +echo "<PRE><FONT SIZE=3>\n"; + + +echo "UsuárioRelógio Ponto Report $NOW_TIME\n"; + +echo "Time range: $query_date to $end_date\n\n"; +echo "---------- USER TIMECLOCK DETAILS -------------\n"; +echo "These totals do NOT include any active sessions\n</PRE>\n"; + +echo "<TABLE Border=0 CELLSPACING=1 CELLPADDING=3><TR BGCOLOR=BLACK>\n"; +echo "<TD ALIGN=CENTER><FONT class=\"header_white\">#</TD>\n"; +echo "<TD ALIGN=CENTER><FONT class=\"header_white\">  USER  </TD>\n"; +echo "<TD ALIGN=CENTER><FONT class=\"header_white\">  NAME  </TD>\n"; +echo "<TD ALIGN=CENTER><FONT class=\"header_white\">  GROUP  </TD>\n"; +echo "<TD ALIGN=CENTER><FONT class=\"header_white\">  HOURS  </TD>\n"; +echo "</TR>\n"; + +$order_SQL=''; +if ($order == 'hours_up') {$order_SQL = "order by login";} +if ($order == 'hours_down') {$order_SQL = "order by login desc";} +if ($order == 'user_up') {$order_SQL = "order by vicidial_users.user";} +if ($order == 'user_down') {$order_SQL = "order by vicidial_users.user desc";} +if ($order == 'name_up') {$order_SQL = "order by full_name";} +if ($order == 'name_down') {$order_SQL = "order by full_name desc";} +if ($order == 'group_up') {$order_SQL = "order by vicidial_timeclock_log.user_group";} +if ($order == 'group_down') {$order_SQL = "order by vicidial_timeclock_log.user_group desc";} + +if (strlen($user) > 0) {$user_SQL = "and vicidial_timeclock_log.user='$user'";} +else {$user_SQL='';} + +$stmt="select vicidial_users.user,full_name,sum(login_sec) as login,vicidial_timeclock_log.user_group from vicidial_users,vicidial_timeclock_log where event IN('LOGIN','START') and event_date >= '$query_date 00:00:00' and event_date <= '$end_date 23:59:59' and vicidial_users.user=vicidial_timeclock_log.user $user_SQL $user_group_SQL group by vicidial_users.user,vicidial_timeclock_log.user_group $order_SQL limit 100000;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$rows_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $rows_to_print) + { + $dbHOURS=0; + $row=mysql_fetch_row($rslt); + $user_id[$i] = $row[0]; + $full_name[$i] = $row[1]; + $login_sec[$i] = $row[2]; $TOTlogin_sec = ($TOTlogin_sec + $row[2]); + $u_group[$i] = $row[3]; + + if ($login_sec[$i] > 0) + { + $dbHOURS = ($login_sec[$i] / 3600); + $dbHOURS = round($dbHOURS, 2); + $dbHOURS = sprintf("%01.2f", $dbHOURS); + } + else + {$dbHOURS='0.00';} + + $hours[$i] = $dbHOURS; + $hoursSORT[$i] = "$dbHOURS-----$i"; + + $i++; + } + + +$j=0; +while ($j < $rows_to_print) + { + + $hours_split = explode("-----",$hoursSORT[$j]); + $i = $hours_split[1]; + + if (eregi("1$|3$|5$|7$|9$", $j)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "<TR $bgcolor>\n"; + echo "<TD ALIGN=LEFT><FONT class=\"data_records_fix_small\">$j</TD>\n"; + echo "<TD><FONT class=\"data_records\"><A HREF=\"user_status.php?user=$user_id[$i]\">$user_id[$i]</A> </TD>\n"; + echo "<TD><FONT class=\"data_records\">$full_name[$i] </TD>\n"; + echo "<TD><FONT class=\"data_records\">$u_group[$i] </TD>\n"; + echo "<TD ALIGN=RIGHT><FONT class=\"data_records_fix\"> $hours[$i]</TD>\n"; + echo "</TR>\n"; + + $j++; + } + + +if ($TOTlogin_sec > 0) + { + $TOTdbHOURS = ($TOTlogin_sec / 3600); + $TOTdbHOURS = round($TOTdbHOURS, 0); + $TOTdbHOURS = sprintf("%01.0f", $TOTdbHOURS); + } +else + {$TOTdbHOURS='0.00';} + +$TOThours = $TOTdbHOURS; + + +echo "<TR BGCOLOR=#E6E6E6>\n"; +echo "<TD ALIGN=LEFT COLSPAN=4><FONT class=\"data_records\">TOTALS</TD>\n"; +echo "<TD ALIGN=RIGHT><FONT class=\"data_records_fix\"> $TOThours</TD>\n"; +echo "</TR>\n"; + +echo "</TABLE>\n"; + +echo "\n"; + +/* + $TOTavgWAIT_M = ( ($TOTtotWAIT / $TOTcalls) / 60); + $TOTavgWAIT_M = round($TOTavgWAIT_M, 2); + $TOTavgWAIT_M_int = intval("$TOTavgWAIT_M"); + $TOTavgWAIT_S = ($TOTavgWAIT_M - $TOTavgWAIT_M_int); + $TOTavgWAIT_S = ($TOTavgWAIT_S * 60); + $TOTavgWAIT_S = round($TOTavgWAIT_S, 0); + if ($TOTavgWAIT_S < 10) {$TOTavgWAIT_S = "0$TOTavgWAIT_S";} + $TOTavgWAIT_MS = "$TOTavgWAIT_M_int:$TOTavgWAIT_S"; + $TOTavgWAIT_MS = sprintf("%6s", $TOTavgWAIT_MS); + while(strlen($TOTavgWAIT_MS)>6) {$TOTavgWAIT_MS = substr("$TOTavgWAIT_MS", 0, -1);} +*/ +?> +</CENTER> +</BODY></HTML> diff --git a/LANG_www/vicidial_br/timeclock_status.php b/LANG_www/vicidial_br/timeclock_status.php new file mode 100644 index 00000000..1932961f --- /dev/null +++ b/LANG_www/vicidial_br/timeclock_status.php @@ -0,0 +1,547 @@ +<?php +# timeclock_status.php +# +# Copyright (C) 2010 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2 +# +# CHANGES +# +# 80602-0201 - First Build +# 80603-1500 - formatting changes +# 90310-2103 - Added admin header +# 90508-0644 - Changed to PHP long tags +# 100214-1421 - Sort menu alphabetically +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["begin_date"])) {$begin_date=$_GET["begin_date"];} + elseif (isset($_POST["begin_date"])) {$begin_date=$_POST["begin_date"];} +if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];} + elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["user_group"])) {$user_group=$_GET["user_group"];} + elseif (isset($_POST["user_group"])) {$user_group=$_POST["user_group"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} + + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin,webroot_writable,timeclock_end_of_day,outbound_autodial_active FROM system_settings;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$qm_conf_ct = mysql_num_rows($rslt); +if ($qm_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $non_latin = $row[0]; + $webroot_writable = $row[1]; + $timeclock_end_of_day = $row[2]; + $SSoutbound_autodial_active = $row[3]; + } +##### END SETTINGS LOOKUP ##### +########################################### + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$HHMM = date("Hi"); +$HHteod = substr($timeclock_end_of_day,0,2); +$MMteod = substr($timeclock_end_of_day,2,2); + +if ($HHMM < $timeclock_end_of_day) + {$EoD = mktime($HHteod, $MMteod, 10, date("m"), date("d")-1, date("Y"));} +else + {$EoD = mktime($HHteod, $MMteod, 10, date("m"), date("d"), date("Y"));} + +$EoDdate = date("Y-m-d H:i:s", $EoD); + +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7 and view_reports='1';"; +if ($non_latin > 0) { $rslt=mysql_query("SET NAMES 'UTF8'");} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + +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 "Nome ou Senha inválidos: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } +else + { + if($auth>0) + { + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + if ($webroot_writable > 0) + { + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + } + else + { + if ($webroot_writable > 0) + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + + } + + +$stmt="select user_group from vicidial_user_groups order by user_group;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$user_groups_to_print = mysql_num_rows($rslt); + $i=0; + $user_groups_to_print++; +while ($i < $user_groups_to_print) + { + $row=mysql_fetch_row($rslt); + $LISTuser_groups[$i] =$row[0]; + if ($row[0]==$user_group) + {$FORMuser_groups.="<option value=\"$row[0]\" SELECTED>$row[0]</option>";} + else + {$FORMuser_groups.="<option value=\"$row[0]\">$row[0]</option>";} + $i++; + } + +if (strlen($user_group) > 0) + { + $stmt="SELECT group_name from vicidial_user_groups where user_group='$user_group';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $group_name = $row[0]; + } + +?> +<html> +<head> +<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8"> +<title>ADMINISTRATION:Relógio Ponto Status +<?php + +##### BEGIN Set variables to make header show properly ##### +$ADD = '311111'; +$hh = 'usergroups'; +$LOGast_admin_access = '1'; +$ADMIN = 'admin.php'; +$page_width='770'; +$section_width='750'; +$header_font_size='3'; +$subheader_font_size='2'; +$subcamp_font_size='2'; +$header_selected_bold='<b>'; +$header_nonselected_bold=''; +$usergroups_color = '#FFFF99'; +$usergroups_font = 'BLACK'; +$usergroups_color = '#E6E6E6'; +$subcamp_color = '#C6C6C6'; +##### END Set variables to make header show properly ##### + +require("admin_header.php"); + + + +?> +<CENTER> +<TABLE WIDTH=750 BGCOLOR=#D9E6FE cellpadding=2 cellspacing=0><TR BGCOLOR=#015B91><TD ALIGN=LEFT> +<FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=2><B>Relógio Ponto Status for <?php echo $user_group ?></TD><TD ALIGN=RIGHT>             +<?php +echo "<a href=\"./timeclock_report.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE SIZE=2><B>TIMECLOCK REPORT</a> | "; +echo "<a href=\"./admin.php?ADD=311111&user_group=$user_group\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=WHITE SIZE=2><B>GRUPO DE USUÁRIOS</a>\n"; +?> +</TD></TR> + + + + +<?php + +echo "<TR BGCOLOR=\"#F0F5FE\"><TD ALIGN=LEFT COLSPAN=2><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2><B>   \n"; + +echo "<form action=$PHP_SELF method=POST>\n"; +echo "<input type=hidden name=DB value=\"$DB\">\n"; +echo "<select size=1 name=user_group>$FORMuser_groups</select>"; +echo "<input type=submit name=submit value=submit>\n"; + +echo "</B></TD></TR>\n"; +echo "<TR><TD ALIGN=LEFT COLSPAN=2>\n"; +echo "<br><center>\n"; + +if (strlen($user_group) < 1) + { + exit; + } + + +##### grab all users in this user_group ##### +$stmt="SELECT user,full_name from vicidial_users where user_group='" . mysql_real_escape_string($user_group) . "' order by full_name;"; +if ($DB>0) {echo "|$stmt|";} +$rslt=mysql_query($stmt, $link); +$users_to_print = mysql_num_rows($rslt); +$o=0; +while ($users_to_print > $o) + { + $row=mysql_fetch_row($rslt); + $users[$o] = $row[0]; + $full_name[$o] = $row[1]; + $Vevent_time[$o] = ''; + $Vevent_epoch[$o] = 0; + $Vcampaign[$o] = ''; + $Tevent_epoch[$o] = ''; + $Tevent_date[$o] = ''; + $Tstatus[$o] = ''; + $Tip_address[$o] = ''; + $Tlogin_time[$o] = ''; + $Tlogin_sec[$o] = 0; + + $o++; + } + +$o=0; +while ($users_to_print > $o) + { + $total_login_time = 0; + ##### grab timeclock status record for this user ##### + $stmt="SELECT event_epoch,event_date,status,ip_address from vicidial_timeclock_status where user='$users[$o]' and event_epoch >= '$EoD';"; + if ($DB>0) {echo "|$stmt|";} + $rslt=mysql_query($stmt, $link); + $stats_to_print = mysql_num_rows($rslt); + if ($stats_to_print > 0) + { + $row=mysql_fetch_row($rslt); + $Tevent_epoch[$o] = $row[0]; + $Tevent_date[$o] = $row[1]; + $Tstatus[$o] = $row[2]; + $Tip_address[$o] = $row[3]; + + if ( ($row[2]=='START') or ($row[2]=='LOGIN') ) + {$bgcolor[$o]='bgcolor="#B9CBFD"';} + else + {$bgcolor[$o]='bgcolor="#9BB9FB"';} + } + + ##### grab timeclock logged-in time for each user ##### + $stmt="SELECT event,event_epoch,login_sec from vicidial_timeclock_log where user='$users[$o]' and event_epoch >= '$EoD';"; + if ($DB>0) {echo "|$stmt|";} + $rslt=mysql_query($stmt, $link); + $logs_to_parse = mysql_num_rows($rslt); + $p=0; + while ($logs_to_parse > $p) + { + $row=mysql_fetch_row($rslt); + if ( (ereg("LOGIN", $row[0])) or (ereg("START", $row[0])) ) + { + $login_sec=''; + $Tevent_time[$o] = date("Y-m-d H:i:s", $row[1]); + } + if (ereg("LOGOUT", $row[0])) + { + $login_sec = $row[2]; + $total_login_time = ($total_login_time + $login_sec); + } + $p++; + } + if ( (strlen($login_sec)<1) and ($logs_to_parse > 0) ) + { + $login_sec = ($STARTtime - $row[1]); + $total_login_time = ($total_login_time + $login_sec); + } + if ($logs_to_parse > 0) + { + $total_login_hours = ($total_login_time / 3600); + $total_login_hours_int = round($total_login_hours, 2); + $total_login_hours_int = intval("$total_login_hours"); + $total_login_minutes = ($total_login_hours - $total_login_hours_int); + $total_login_minutes = ($total_login_minutes * 60); + $total_login_minutes_int = round($total_login_minutes, 0); + if ($total_login_minutes_int < 10) {$total_login_minutes_int = "0$total_login_minutes_int";} + + $Tlogin_time[$o] = "$total_login_hours_int:$total_login_minutes_int"; + $Tlogin_sec[$o] = $total_login_time; + } + else + { + $total_login_time = 0; + $Tlogin_time[$o] = "0:00"; + $Tlogin_sec[$o] = $total_login_time; + } + + if ($DB>0) {echo "|$Tlogin_sec[$o]|$Tlogin_time[$o]|";} + + ##### grab vicidial_agent_log records in this user_group ##### + $stmt="SELECT event_time,UNIX_TIMESTAMP(event_time),campaign_id from vicidial_agent_log where user='$users[$o]' and event_time >= '$EoDdate' order by agent_log_id desc limit 1;"; + if ($DB>0) {echo "|$stmt|";} + $rslt=mysql_query($stmt, $link); + $vals_to_print = mysql_num_rows($rslt); + if ($vals_to_print > 0) + { + $row=mysql_fetch_row($rslt); + $Vevent_time[$o] = $row[0]; + $Vevent_epoch[$o] = $row[1]; + $Vcampaign[$o] = $row[2]; + } + + $o++; + } + + +##### print each user that has any activity for today ##### +echo "<br>\n"; +echo "<center>\n"; + +echo "<TABLE width=720 cellspacing=0 cellpadding=1>\n"; +echo "<TR>\n"; +echo "<TD bgcolor=\"#99FF33\">     </TD><TD align=left> TC Logged in and VICI active</TD>\n"; # bright green +echo "<TD bgcolor=\"#FFFF33\">     </TD><TD align=left> TC Logged in only</TD>\n"; # bright yellow +echo "<TD bgcolor=\"#FF6666\">     </TD><TD align=left> VICI active only</TD>\n"; # bright red +echo "</TR><TR>\n"; +echo "<TD bgcolor=\"#66CC66\">     </TD><TD align=left> TC Logged out and VICI active</TD>\n"; # dull green +echo "<TD bgcolor=\"#CCCC00\">     </TD><TD align=left> TC Logged out only</TD>\n"; # dull yellow +echo "<TD>     </TD><TD align=left>   </TD>\n"; +echo "</TR></TABLE><BR>\n"; + +echo "<B>USER STATUS FOR GRUPO DE USUÁRIOS: $user_group</B>\n"; +echo "<TABLE width=700 cellspacing=0 cellpadding=1>\n"; +echo "<tr><td><font size=2># </td><td><font size=2>USER </td><td align=left><font size=2>NAME </td><td align=right><font size=2> IP ADDRESS</td><td align=right><font size=2> TC TIME</td><td align=right><font size=2>TC LOGIN</td><td align=right><font size=2> VICI LAST LOG</td><td align=right><font size=2> VICI CAMPANHA</td></tr>\n"; + +$o=0; +$s=0; +while ($users_to_print > $o) + { + if ( ($Tlogin_sec[$o] > 0) or (strlen($Vevent_time[$o]) > 0) ) + { + if ( ($Tstatus[$o]=='START') or ($Tstatus[$o]=='LOGIN') ) + { + if ($Tlogin_sec[$o] > 0) + {$bgcolor[$o]='bgcolor="#FFFF33"';} # yellow + if ( ($Tlogin_sec[$o] > 0) and (strlen($Vevent_time[$o]) > 0) ) + {$bgcolor[$o]='bgcolor="#99FF33"';} # green + } + else + { + if ($Tlogin_sec[$o] > 0) + {$bgcolor[$o]='bgcolor="#CCCC00"';} # yellow + if (strlen($Vevent_time[$o]) > 0) + {$bgcolor[$o]='bgcolor="#FF6666"';} # red + if ( ($Tlogin_sec[$o] > 0) and (strlen($Vevent_time[$o]) > 0) ) + {$bgcolor[$o]='bgcolor="#66CC66"';} # green + } + + $s++; + echo "<tr $bgcolor[$o]>"; + echo "<td><font size=1>$s</td>"; + echo "<td><font size=2><a href=\"./user_status.php?user=$users[$o]\">$users[$o]</a></td>"; + echo "<td><font size=2>$full_name[$o]</td>"; + echo "<td><font size=2>$Tip_address[$o]</td>"; + echo "<td align=right><font size=2>$Tlogin_time[$o]</td>"; + echo "<td align=right><font size=2>$Tevent_time[$o]</td>"; + echo "<td align=right><font size=2>$Vevent_time[$o]</td>"; + echo "<td align=right><font size=2>$Vcampaign[$o]</td>"; + echo "</tr>"; + + if (strlen($Tstatus[$o])>0) + {$TOTlogin_sec = ($TOTlogin_sec + $Tlogin_sec[$o]);} + } + $o++; + } + + + +$total_login_hours = ($TOTlogin_sec / 3600); +$total_login_hours_int = round($total_login_hours, 2); +$total_login_hours_int = intval("$total_login_hours"); +$total_login_minutes = ($total_login_hours - $total_login_hours_int); +$total_login_minutes = ($total_login_minutes * 60); +$total_login_minutes_int = round($total_login_minutes, 0); +if ($total_login_minutes_int < 10) {$total_login_minutes_int = "0$total_login_minutes_int";} + +echo "<tr bgcolor=white>"; +echo "<td colspan=4><font size=2>TOTALS</td>"; +echo "<td align=right><font size=2>$total_login_hours_int:$total_login_minutes_int</td>"; +echo "<td align=right><font size=2></td>"; +echo "<td align=right><font size=2></td>"; +echo "<td align=right><font size=2></td>"; +echo "</tr>"; +echo "</table>"; + + + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n<br><br><br>\n\n"; + + +echo "<font size=0>\n\n\n<br><br><br>\nScript runtime: $RUNtime seconds</font>"; + + +?> + + +</TD></TR><TABLE> +</body> +</html> + +<?php +exit; + + + + + + + + + + + +##### vicidial_timeclock log records for user ##### + +$SQday_ARY = explode('-',$begin_date); +$EQday_ARY = explode('-',$end_date); +$SQepoch = mktime(0, 0, 0, $SQday_ARY[1], $SQday_ARY[2], $SQday_ARY[0]); +$EQepoch = mktime(23, 59, 59, $EQday_ARY[1], $EQday_ARY[2], $EQday_ARY[0]); + +echo "<br><br>\n"; + +echo "<center>\n"; + +echo "<B>TIMECLOCK HORÁRIO DE LOGIN/LOGOUT:</B>\n"; +echo "<TABLE width=550 cellspacing=0 cellpadding=1>\n"; +echo "<tr><td><font size=2>ID </td><td><font size=2>EDIT </td><td align=right><font size=2>EVENTO</td><td align=right><font size=2> DATA</td><td align=right><font size=2> IP ADDRESS</td><td align=right><font size=2> GROUP</td><td align=right><font size=2>HORAS:MINUTOS</td></tr>\n"; + + $stmt="SELECT event,event_epoch,user_group,login_sec,ip_address,timeclock_id,manager_user from vicidial_timeclock_log where user='" . mysql_real_escape_string($user) . "' and event_epoch >= '$SQepoch' and event_epoch <= '$EQepoch';"; + if ($DB>0) {echo "|$stmt|";} + $rslt=mysql_query($stmt, $link); + $events_to_print = mysql_num_rows($rslt); + + $total_logs=0; + $o=0; + while ($events_to_print > $o) { + $row=mysql_fetch_row($rslt); + if ( ($row[0]=='START') or ($row[0]=='LOGIN') ) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $TC_log_date = date("Y-m-d H:i:s", $row[1]); + + $manager_edit=''; + if (strlen($row[6])>0) {$manager_edit = ' * ';} + + if (ereg("LOGIN", $row[0])) + { + $login_sec=''; + echo "<tr $bgcolor><td><font size=2>$row[5]</td>"; + echo "<td align=right><font size=2>$manager_edit</td>"; + echo "<td align=right><font size=2>$row[0]</td>"; + echo "<td align=right><font size=2> $TC_log_date</td>\n"; + echo "<td align=right><font size=2> $row[4]</td>\n"; + echo "<td align=right><font size=2> $row[2]</td>\n"; + echo "<td align=right><font size=2> </td></tr>\n"; + } + if (ereg("LOGOUT", $row[0])) + { + $login_sec = $row[3]; + $total_login_time = ($total_login_time + $login_sec); + $event_hours = ($login_sec / 3600); + $event_hours_int = round($event_hours, 2); + $event_hours_int = intval("$event_hours_int"); + $event_minutes = ($event_hours - $event_hours_int); + $event_minutes = ($event_minutes * 60); + $event_minutes_int = round($event_minutes, 0); + if ($event_minutes_int < 10) {$event_minutes_int = "0$event_minutes_int";} + echo "<tr $bgcolor><td><font size=2>$row[5]</td>"; + echo "<td align=right><font size=2>$manager_edit</td>"; + echo "<td align=right><font size=2>$row[0]</td>"; + echo "<td align=right><font size=2> $TC_log_date</td>\n"; + echo "<td align=right><font size=2> $row[4]</td>\n"; + echo "<td align=right><font size=2> $row[2]</td>\n"; + echo "<td align=right><font size=2> $event_hours_int:$event_minutes_int</td></tr>\n"; + } + $o++; + } +if (strlen($login_sec)<1) + { + $login_sec = ($STARTtime - $row[1]); + $total_login_time = ($total_login_time + $login_sec); + } +$total_login_hours = ($total_login_time / 3600); +$total_login_hours_int = round($total_login_hours, 2); +$total_login_hours_int = intval("$total_login_hours"); +$total_login_minutes = ($total_login_hours - $total_login_hours_int); +$total_login_minutes = ($total_login_minutes * 60); +$total_login_minutes_int = round($total_login_minutes, 0); +if ($total_login_minutes_int < 10) {$total_login_minutes_int = "0$total_login_minutes_int";} + +echo "<tr><td align=right><font size=2> </td>"; +echo "<td align=right><font size=2> </td>\n"; +echo "<td align=right><font size=2> </td>\n"; +echo "<td align=right><font size=2> </td>\n"; +echo "<td align=right><font size=2><font size=2>TOTAL </td>\n"; +echo "<td align=right><font size=2> $total_login_hours_int:$total_login_minutes_int </td></tr>\n"; + +echo "</TABLE></center>\n"; + + + + + + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n<br><br><br>\n\n"; + + +echo "<font size=0>\n\n\n<br><br><br>\nScript runtime: $RUNtime seconds</font>"; + + +?> + + +</TD></TR><TABLE> +</body> +</html> + +<?php + +exit; + + + +?> + + + + + diff --git a/LANG_www/vicidial_br/user_group_bulk_change.php b/LANG_www/vicidial_br/user_group_bulk_change.php new file mode 100644 index 00000000..22dce925 --- /dev/null +++ b/LANG_www/vicidial_br/user_group_bulk_change.php @@ -0,0 +1,271 @@ +<?php +# user_group_bulk_change.php +# +# Copyright (C) 2009 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2 +# +# CHANGES +# 81119-0918 - First build +# 90309-1830 - Added admin_log logging +# 90310-2144 - Added admin header +# 90508-0644 - Changed to PHP long tags +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["old_group"])) {$old_group=$_GET["old_group"];} + elseif (isset($_POST["old_group"])) {$old_group=$_POST["old_group"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin,webroot_writable,outbound_autodial_active 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]; + $webroot_writable = $row[1]; + $SSoutbound_autodial_active = $row[2]; + $i++; + } +##### END SETTINGS LOOKUP ##### +########################################### + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$StarTtimE = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$ip = getenv("REMOTE_ADDR"); + +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7 and view_reports='1';"; + if ($non_latin > 0) { $rslt=mysql_query("SET NAMES 'UTF8'");} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + 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 "Nome ou Senha inválidos: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $stmt="SELECT full_name,change_agent_campaign,modify_timeclock_log from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname = $row[0]; + $change_agent_campaign = $row[1]; + $modify_timeclock_log = $row[2]; + if ($webroot_writable > 0) + { + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + } + else + { + if ($webroot_writable > 0) + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + } + +$stmt="select user_group,group_name from vicidial_user_groups order by user_group desc;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] = $row[0]; + $group_names[$i] = $row[1]; + $i++; + } + + + +?> +<html> +<head> +<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8"> +<title>ADMINISTRATION: Troca de Grupo de Usuário em Lote +<?php + +##### BEGIN Set variables to make header show properly ##### +$ADD = '311111'; +$hh = 'usergroups'; +$LOGast_admin_access = '1'; +$ADMIN = 'admin.php'; +$page_width='770'; +$section_width='750'; +$header_font_size='3'; +$subheader_font_size='2'; +$subcamp_font_size='2'; +$header_selected_bold='<b>'; +$header_nonselected_bold=''; +$usergroups_color = '#FFFF99'; +$usergroups_font = 'BLACK'; +$usergroups_color = '#E6E6E6'; +$subcamp_color = '#C6C6C6'; +##### END Set variables to make header show properly ##### + +require("admin_header.php"); + + + + +?> + +<CENTER> +<TABLE WIDTH=620 BGCOLOR=#D9E6FE cellpadding=2 cellspacing=0><TR BGCOLOR=#015B91><TD ALIGN=LEFT><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=2><B>   Troca de Grupo de Usuário em Lote</TD><TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=2><B>   </TD></TR> + + + + +<?php + +echo "<TR BGCOLOR=\"#F0F5FE\"><TD ALIGN=LEFT COLSPAN=2><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=3><B>   \n"; + +##### GROUP CHANGE FOR ALL USERS IN A USER GROUP ##### +if ($stage == "one_user_group_change") + { + $stmt="UPDATE vicidial_users set user_group='" . mysql_real_escape_string($group) . "' where user_group='" . mysql_real_escape_string($old_group) . "';"; + $rslt=mysql_query($stmt, $link); + + echo "All Grupo do Usuário $old_group Usuários changed to the $group Grupo do Usuário<BR>\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$PHP_AUTH_USER', ip_address='$ip', event_section='USERGROUPS', event_type='MODIFY', record_id='$group', event_code='ADMIN BULK GRUPO DE USUÁRIOS CHANGE', event_sql=\"$SQL_log\", event_notes='Old Grupo: $old_group';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + exit; + } + +##### GROUP CHANGE FOR ALL USERS IN THE SYSTEM EXCEPT FOR LEVEL > 6 AND ADMIN GROUP ##### +if ($stage == "all_user_group_change") + { + $stmt="UPDATE vicidial_users set user_group='" . mysql_real_escape_string($group) . "' where user_group!='ADMIN' and user_group < 7;"; + $rslt=mysql_query($stmt, $link); + + echo "All non-Admin Usuários changed to the $group Grupo do Usuário<BR>\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$PHP_AUTH_USER', ip_address='$ip', event_section='USERGROUPS', event_type='MODIFY', record_id='$group', event_code='ADMIN BULK GRUPO DE USUÁRIOS CHANGE', event_sql=\"$SQL_log\", event_notes='ALL NON-ADMIN;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + exit; + } + +### one user_group change +echo "<form action=$PHP_SELF method=POST>\n"; +echo "<input type=hidden name=DB value=\"$DB\">\n"; +echo "<input type=hidden name=stage value=\"one_user_group_change\">\n"; +echo "Change Usuários in this group: <SELECT SIZE=1 NAME=old_group>\n"; +$o=0; +while ($groups_to_print > $o) + { + echo "<option value=\"$groups[$o]\">$groups[$o] - $group_names[$o]</option>\n"; + $o++; + } +echo "</SELECT>\n"; +echo "<BR>   to this group: <SELECT SIZE=1 NAME=group>\n"; +$o=0; +while ($groups_to_print > $o) + { + echo "<option value=\"$groups[$o]\">$groups[$o] - $group_names[$o]</option>\n"; + $o++; + } +echo "</SELECT>\n"; +echo "<BR><CENTER><input type=submit name=submit value=ENVIAR></CENTER><BR></form>\n"; + +echo "\n<BR><BR><BR>"; + + + +### all user_group change +echo "<form action=$PHP_SELF method=POST>\n"; +echo "<input type=hidden name=DB value=\"$DB\">\n"; +echo "<input type=hidden name=stage value=\"all_user_group_change\">\n"; +echo "Change ALL non-Admin Usuários to this group: <BR><SELECT SIZE=1 NAME=group>\n"; +$o=0; +while ($groups_to_print > $o) + { + echo "<option value=\"$groups[$o]\">$groups[$o] - $group_names[$o]</option>\n"; + $o++; + } +echo "</SELECT>\n"; +echo "<BR><CENTER><input type=submit name=submit value=ENVIAR></CENTER><BR></form>\n"; + +echo "\n<BR>"; + + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $StarTtimE); + +echo "\n\n\n<br><br><br>\n\n"; + + +echo "<font size=0>\n\n\n<br><br><br>\nScript runtime: $RUNtime seconds</font>"; + +echo "|$stage|$group|"; + +?> + + +</TD></TR><TABLE> +</body> +</html> + +<?php + +exit; + + + +?> + diff --git a/LANG_www/vicidial_br/user_stats.php b/LANG_www/vicidial_br/user_stats.php new file mode 100644 index 00000000..5c28f03f --- /dev/null +++ b/LANG_www/vicidial_br/user_stats.php @@ -0,0 +1,821 @@ +<?php +# user_stats.php +# +# Copyright (C) 2010 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2 +# +# CHANGES +# +# 60619-1743 - Added variable filtering to eliminate SQL injection attack threat +# 61201-1136 - Added recordings display and changed calls to time range with 10000 limit +# 70118-1605 - Added user group column to login/out and calls lists +# 70702-1231 - Added recording location link and truncation +# 80117-0316 - Added vicidial_user_closer_log entries to display +# 80501-0506 - Added Hangup Reason to logs display +# 80523-2012 - Added vicidial timeclock records display +# 80617-1402 - Fixed timeclock total logged-in time +# 81210-1634 - Added server recording display options +# 90208-0504 - Added link to multi-day report and fixed call status summary section +# 90305-1226 - Added user_call_log manual dial logs +# 90310-0734 - Added admin header +# 90508-0644 - Changed to PHP long tags +# 90524-2009 - Changed time display to use functions.php +# 91130-2037 - Added user closer log manager flag display +# 100203-1008 - Added agent activity log section +# 100216-0042 - Added popup date selector +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); +require("functions.php"); + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin,outbound_autodial_active,user_territories_active FROM system_settings;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$ss_conf_ct = mysql_num_rows($rslt); +if ($ss_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $non_latin = $row[0]; + $SSoutbound_autodial_active = $row[1]; + $user_territories_active = $row[2]; + } +##### END SETTINGS LOOKUP ##### +########################################### + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["begin_date"])) {$begin_date=$_GET["begin_date"];} + elseif (isset($_POST["begin_date"])) {$begin_date=$_POST["begin_date"];} +if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];} + elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); + +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7 and view_reports='1';"; +if ($non_latin > 0) { $rslt=mysql_query("SET NAMES 'UTF8'");} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + +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 "Nome ou Senha inválidos: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } +else + { + + if($auth>0) + { + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + echo "Nome ou Senha inválidos: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + + $stmt="SELECT full_name from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $full_name = $row[0]; + } + + + + +?> +<html> +<head> + +<script language="JavaScript" src="calendar_db.js"></script> +<link rel="stylesheet" href="calendar.css"> + +<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8"> +<title>ADMINISTRATION: Estatísticas de Usuário +<?php + + +##### BEGIN Set variables to make header show properly ##### +$ADD = '3'; +$hh = 'users'; +$LOGast_admin_access = '1'; +$ADMIN = 'admin.php'; +$page_width='770'; +$section_width='750'; +$header_font_size='3'; +$subheader_font_size='2'; +$subcamp_font_size='2'; +$header_selected_bold='<b>'; +$header_nonselected_bold=''; +$users_color = '#FFFF99'; +$users_font = 'BLACK'; +$users_color = '#E6E6E6'; +$subcamp_color = '#C6C6C6'; +##### END Set variables to make header show properly ##### + +require("admin_header.php"); + + + +?> +<TABLE WIDTH=770 BGCOLOR=#E6E6E6 cellpadding=2 cellspacing=0><TR BGCOLOR=#E6E6E6><TD ALIGN=LEFT><FONT FACE="ARIAL,HELVETICA" SIZE=2><B>   Estatísticas de Usuário for <?php echo $user ?></TD><TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA" SIZE=2>   </TD></TR> + + + + +<?php + +echo "<TR BGCOLOR=\"#F0F5FE\"><TD ALIGN=LEFT COLSPAN=2><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2><B>   \n"; + +echo "<form action=$PHP_SELF method=POST name=vicidial_report id=vicidial_report>\n"; +echo "<input type=hidden name=DB value=\"$DB\">\n"; +echo "<input type=text name=begin_date value=\"$begin_date\" size=10 maxsize=10>"; + +?> +<script language="JavaScript"> +var o_cal = new tcal ({ + // form name + 'formname': 'vicidial_report', + // input name + 'controlname': 'begin_date' +}); +o_cal.a_tpl.yearscroll = false; +// o_cal.a_tpl.weekstart = 1; // Segunda week start +</script> +<?php + +echo " to <input type=text name=end_date value=\"$end_date\" size=10 maxsize=10>"; + +?> +<script language="JavaScript"> +var o_cal = new tcal ({ + // form name + 'formname': 'vicidial_report', + // input name + 'controlname': 'end_date' +}); +o_cal.a_tpl.yearscroll = false; +// o_cal.a_tpl.weekstart = 1; // Segunda week start +</script> +<?php + +if (strlen($user)>1) + {echo "  <input type=hidden name=user value=\"$user\">\n";} +else + {echo "  <input type=text name=user size=12 maxlength=10>\n";} +echo "<input type=submit name=submit value=submit>\n"; + + +echo "           $user - $full_name<BR><BR>\n"; + +echo "<center>\n"; +echo "<a href=\"./AST_agent_time_sheet.php?agent=$user\">Agent Planilha de Tempo</a>\n"; +echo " | <a href=\"./user_status.php?user=$user\">Status do Usuário</a>\n"; +echo " | <a href=\"./admin.php?ADD=3&user=$user\">Alterar Usuário</a>\n"; +echo " | <a href=\"./AST_agent_days_detail.php?user=$user&query_date=$begin_date&end_date=$end_date&group[]=--ALL--&shift=ALL\">Usuário multiple day status detail report</a>"; +echo "</center>\n"; + + +echo "</B></TD></TR>\n"; +echo "<TR><TD ALIGN=LEFT COLSPAN=2>\n"; + +echo "<br><center>\n"; + +##### vicidial agent talk time and status ##### + +echo "<B>AGENTE TEMPO E STATUS DA CHAMADA:</B>\n"; + +echo "<center><TABLE width=300 cellspacing=0 cellpadding=1>\n"; +echo "<tr><td><font size=2>STATUS</td><td align=right><font size=2>QUANTIDADE</td><td align=right><font size=2>HOURS:MM:SS</td></tr>\n"; + +$stmt="SELECT count(*),status, sum(length_in_sec) from vicidial_log where user='" . mysql_real_escape_string($user) . "' and call_date >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and call_date <= '" . mysql_real_escape_string($end_date) . " 23:59:59' group by status order by status"; +$rslt=mysql_query($stmt, $link); +$VLstatuses_to_print = mysql_num_rows($rslt); +$total_calls=0; +$o=0; $p=0; +while ($VLstatuses_to_print > $o) + { + $row=mysql_fetch_row($rslt); + $counts[$p] = $row[0]; + $status[$p] = $row[1]; + $call_sec[$p] = $row[2]; + $p++; + $o++; + } + +$stmt="SELECT count(*),status, sum(length_in_sec) from vicidial_closer_log where user='" . mysql_real_escape_string($user) . "' and call_date >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and call_date <= '" . mysql_real_escape_string($end_date) . " 23:59:59' group by status order by status"; +$rslt=mysql_query($stmt, $link); +$VCLstatuses_to_print = mysql_num_rows($rslt); +$o=0; +while ($VCLstatuses_to_print > $o) + { + $status_match=0; + $r=0; + $row=mysql_fetch_row($rslt); + while ($VLstatuses_to_print > $r) + { + if ($status[$r] == $row[1]) + { + $counts[$r] = ($counts[$r] + $row[0]); + $call_sec[$r] = ($call_sec[$r] + $row[2]); + $status_match++; + } + $r++; + } + if ($status_match < 1) + { + $counts[$p] = $row[0]; + $status[$p] = $row[1]; + $call_sec[$p] = $row[2]; + $VLstatuses_to_print++; + $p++; + } + $o++; + } + +$o=0; +$total_sec=0; +while ($o < $p) + { + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $call_hours_minutes = sec_convert($call_sec[$o],'H'); + + echo "<tr $bgcolor><td><font size=2>$status[$o]</td>"; + echo "<td align=right><font size=2> $counts[$o]</td>\n"; + echo "<td align=right><font size=2> $call_hours_minutes</td></tr>\n"; + $total_calls = ($total_calls + $counts[$o]); + $total_sec = ($total_sec + $call_sec[$o]); + $call_seconds=0; + $o++; + } + +$call_hours_minutes = sec_convert($total_sec,'H'); + +echo "<tr><td><font size=2>TOTAL DE CHAMADAS </td><td align=right><font size=2> $total_calls</td><td align=right><font size=2> $call_hours_minutes</td></tr>\n"; +echo "</TABLE></center>\n"; + + +##### Login and Logout time from vicidial agent interface ##### + +echo "<br><br>\n"; + +echo "<center>\n"; + +echo "<B>AGENTE HORÁRIO DE LOGIN/LOGOUT:</B>\n"; +echo "<TABLE width=500 cellspacing=0 cellpadding=1>\n"; +echo "<tr><td><font size=2>EVENTO</td><td align=right><font size=2> DATA</td><td align=right><font size=2> CAMPANHA</td><td align=right><font size=2> GROUP</td><td align=right><font size=2>HOURS:MM:SS</td></tr>\n"; + + $stmt="SELECT event,event_epoch,event_date,campaign_id,user_group from vicidial_user_log where user='" . mysql_real_escape_string($user) . "' and event_date >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and event_date <= '" . mysql_real_escape_string($end_date) . " 23:59:59'"; + $rslt=mysql_query($stmt, $link); + $events_to_print = mysql_num_rows($rslt); + + $total_calls=0; + $o=0; + $event_start_seconds=''; + $event_stop_seconds=''; + while ($events_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("LOGIN", $row[0])) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + if (ereg("LOGIN", $row[0])) + { + $event_start_seconds = $row[1]; + echo "<tr $bgcolor><td><font size=2>$row[0]</td>"; + echo "<td align=right><font size=2> $row[2]</td>\n"; + echo "<td align=right><font size=2> $row[3]</td>\n"; + echo "<td align=right><font size=2> $row[4]</td>\n"; + echo "<td align=right><font size=2> </td></tr>\n"; + } + if (ereg("LOGOUT", $row[0])) + { + if ($event_start_seconds) + { + + $event_stop_seconds = $row[1]; + $event_seconds = ($event_stop_seconds - $event_start_seconds); + $total_login_time = ($total_login_time + $event_seconds); + $event_hours_minutes = sec_convert($event_seconds,'H'); + + echo "<tr $bgcolor><td><font size=2>$row[0]</td>"; + echo "<td align=right><font size=2> $row[2]</td>\n"; + echo "<td align=right><font size=2> $row[3]</td>\n"; + echo "<td align=right><font size=2> $row[4]</td>\n"; + echo "<td align=right><font size=2> $event_hours_minutes</td></tr>\n"; + $event_start_seconds=''; + $event_stop_seconds=''; + } + else + { + echo "<tr $bgcolor><td><font size=2>$row[0]</td>"; + echo "<td align=right><font size=2> $row[2]</td>\n"; + echo "<td align=right><font size=2> $row[3]</td>\n"; + echo "<td align=right><font size=2> </td></tr>\n"; + } + } + + $total_calls = ($total_calls + $row[0]); + + $call_seconds=0; + $o++; + } + +$total_login_hours_minutes = sec_convert($total_login_time,'H'); + +echo "<tr><td><font size=2>TOTAL</td>"; +echo "<td align=right><font size=2> </td>\n"; +echo "<td align=right><font size=2> </td>\n"; +echo "<td align=right><font size=2> </td>\n"; +echo "<td align=right><font size=2> $total_login_hours_minutes</td></tr>\n"; + +echo "</TABLE></center>\n"; + + + + + +##### vicidial_timeclock log records for user ##### + +$total_login_time=0; +$SQday_ARY = explode('-',$begin_date); +$EQday_ARY = explode('-',$end_date); +$SQepoch = mktime(0, 0, 0, $SQday_ARY[1], $SQday_ARY[2], $SQday_ARY[0]); +$EQepoch = mktime(23, 59, 59, $EQday_ARY[1], $EQday_ARY[2], $EQday_ARY[0]); + +echo "<br><br>\n"; + +echo "<center>\n"; + +echo "<B>TIMECLOCK HORÁRIO DE LOGIN/LOGOUT:</B>\n"; +echo "<TABLE width=550 cellspacing=0 cellpadding=1>\n"; +echo "<tr><td><font size=2>ID </td><td><font size=2>EDIT </td><td align=right><font size=2>EVENTO</td><td align=right><font size=2> DATA</td><td align=right><font size=2> IP ADDRESS</td><td align=right><font size=2> GROUP</td><td align=right><font size=2>HOURS:MM:SS</td></tr>\n"; + + $stmt="SELECT event,event_epoch,user_group,login_sec,ip_address,timeclock_id,manager_user from vicidial_timeclock_log where user='" . mysql_real_escape_string($user) . "' and event_epoch >= '$SQepoch' and event_epoch <= '$EQepoch';"; + if ($DB>0) {echo "|$stmt|";} + $rslt=mysql_query($stmt, $link); + $events_to_print = mysql_num_rows($rslt); + + $total_logs=0; + $o=0; + while ($events_to_print > $o) { + $row=mysql_fetch_row($rslt); + if ( ($row[0]=='START') or ($row[0]=='LOGIN') ) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $TC_log_date = date("Y-m-d H:i:s", $row[1]); + + $manager_edit=''; + if (strlen($row[6])>0) {$manager_edit = ' * ';} + + if (ereg("LOGIN", $row[0])) + { + $login_sec=''; + echo "<tr $bgcolor><td><font size=2><A HREF=\"./timeclock_edit.php?timeclock_id=$row[5]\">$row[5]</A></td>"; + echo "<td align=right><font size=2>$manager_edit</td>"; + echo "<td align=right><font size=2>$row[0]</td>"; + echo "<td align=right><font size=2> $TC_log_date</td>\n"; + echo "<td align=right><font size=2> $row[4]</td>\n"; + echo "<td align=right><font size=2> $row[2]</td>\n"; + echo "<td align=right><font size=2> </td></tr>\n"; + } + if (ereg("LOGOUT", $row[0])) + { + $login_sec = $row[3]; + $total_login_time = ($total_login_time + $login_sec); + $event_hours_minutes = sec_convert($login_sec,'H'); + + echo "<tr $bgcolor><td><font size=2><A HREF=\"./timeclock_edit.php?timeclock_id=$row[5]\">$row[5]</A></td>"; + echo "<td align=right><font size=2>$manager_edit</td>"; + echo "<td align=right><font size=2>$row[0]</td>"; + echo "<td align=right><font size=2> $TC_log_date</td>\n"; + echo "<td align=right><font size=2> $row[4]</td>\n"; + echo "<td align=right><font size=2> $row[2]</td>\n"; + echo "<td align=right><font size=2> $event_hours_minutes"; + if ($DB) {echo " - $total_login_time - $login_sec";} + echo "</td></tr>\n"; + } + $o++; + } +if (strlen($login_sec)<1) + { + $login_sec = ($STARTtime - $row[1]); + $total_login_time = ($total_login_time + $login_sec); + if ($DB) {echo "LOGIN ONLY - $total_login_time - $login_sec";} + } +$total_login_hours_minutes = sec_convert($total_login_time,'H'); + +if ($DB) {echo " - $total_login_time - $login_sec";} + +echo "<tr><td align=right><font size=2> </td>"; +echo "<td align=right><font size=2> </td>\n"; +echo "<td align=right><font size=2> </td>\n"; +echo "<td align=right><font size=2> </td>\n"; +echo "<td align=right><font size=2><font size=2>TOTAL </td>\n"; +echo "<td align=right><font size=2> $total_login_hours_minutes </td></tr>\n"; + +echo "</TABLE></center>\n"; + + + +##### closer in-group selection logs ##### + +echo "<br><br>\n"; + +echo "<center>\n"; + +echo "<B>CLOSER IN-GROUP SELECTION LOGS:</B>\n"; +echo "<TABLE width=670 cellspacing=0 cellpadding=1>\n"; +echo "<tr><td><font size=1># </td><td><font size=2>DATE/TIME </td><td align=left><font size=2> CAMPANHA</td><td align=left><font size=2>BLEND</td><td align=left><font size=2> GROUPS</td><td align=left><font size=2> MANAGER</td></tr>\n"; + +$stmt="select user,campaign_id,event_date,blended,closer_campaigns,manager_change from vicidial_user_closer_log where user='" . mysql_real_escape_string($user) . "' and event_date >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and event_date <= '" . mysql_real_escape_string($end_date) . " 23:59:59' order by event_date desc limit 1000;"; +$rslt=mysql_query($stmt, $link); +$logs_to_print = mysql_num_rows($rslt); + +$u=0; +while ($logs_to_print > $u) + { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $u)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $u++; + echo "<tr $bgcolor>"; + echo "<td><font size=1>$u</td>"; + echo "<td><font size=2>$row[2]</td>"; + echo "<td align=left><font size=2> $row[1]</td>\n"; + echo "<td align=left><font size=2> $row[3]</td>\n"; + echo "<td align=left><font size=2> $row[4] </td>\n"; + echo "<td align=left><font size=2> $row[5]</td>\n"; + echo "</tr>\n"; + } + + +echo "</TABLE><BR><BR>\n"; + + +##### vicidial agent outbound calls for this time period ##### + +echo "<B>SAINTE CALLS FOR THIS TIME PERIOD: (10000 record limit)</B>\n"; +echo "<TABLE width=670 cellspacing=0 cellpadding=1>\n"; +echo "<tr><td><font size=1># </td><td><font size=2>DATE/TIME </td><td align=left><font size=2>LENGTH</td><td align=left><font size=2> STATUS</td><td align=left><font size=2> PHONE</td><td align=right><font size=2> CAMPANHA</td><td align=right><font size=2> GROUP</td><td align=right><font size=2> LIST</td><td align=right><font size=2> LEAD</td><td align=right><font size=2> HANGUP REASON</td></tr>\n"; + +$stmt="select uniqueid,lead_id,list_id,campaign_id,call_date,start_epoch,end_epoch,length_in_sec,status,phone_code,phone_number,user,comments,processed,user_group,term_reason,alt_dial from vicidial_log where user='" . mysql_real_escape_string($user) . "' and call_date >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and call_date <= '" . mysql_real_escape_string($end_date) . " 23:59:59' order by call_date desc limit 10000;"; +$rslt=mysql_query($stmt, $link); +$logs_to_print = mysql_num_rows($rslt); + +$u=0; +while ($logs_to_print > $u) + { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $u)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $u++; + echo "<tr $bgcolor>"; + echo "<td><font size=1>$u</td>"; + echo "<td><font size=2>$row[4]</td>"; + echo "<td align=left><font size=2> $row[7]</td>\n"; + echo "<td align=left><font size=2> $row[8]</td>\n"; + echo "<td align=left><font size=2> $row[10] </td>\n"; + echo "<td align=right><font size=2> $row[3] </td>\n"; + echo "<td align=right><font size=2> $row[14] </td>\n"; + echo "<td align=right><font size=2> $row[2] </td>\n"; + echo "<td align=right><font size=2> <A HREF=\"admin_modify_lead.php?lead_id=$row[1]\" target=\"_blank\">$row[1]</A> </td>\n"; + echo "<td align=right><font size=2> $row[15] </td></tr>\n"; + } + + +echo "</TABLE><BR><BR>\n"; + + +##### vicidial agent inbound calls for this time period ##### + +echo "<B>ENTRANTE/CLOSER CALLS FOR THIS TIME PERIOD: (10000 record limit)</B>\n"; +echo "<TABLE width=750 cellspacing=0 cellpadding=1>\n"; +echo "<tr><td><font size=1># </td><td><font size=2>DATE/TIME </td><td align=left><font size=2>LENGTH</td><td align=left><font size=2> STATUS</td><td align=left><font size=2> PHONE</td><td align=right><font size=2> CAMPANHA</td><td align=right><font size=2> WAIT (S)</td><td align=right><font size=2> AGENTE (S)</td><td align=right><font size=2> LIST</td><td align=right><font size=2> LEAD</td><td align=right><font size=2> HANGUP REASON</td></tr>\n"; + +$stmt="select call_date,length_in_sec,status,phone_number,campaign_id,queue_seconds,list_id,lead_id,term_reason from vicidial_closer_log where user='" . mysql_real_escape_string($user) . "' and call_date >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and call_date <= '" . mysql_real_escape_string($end_date) . " 23:59:59' order by call_date desc limit 10000;"; +$rslt=mysql_query($stmt, $link); +$logs_to_print = mysql_num_rows($rslt); + +$u=0; +$TOTALinSECONDS=0; +$TOTALagentSECONDS=0; +while ($logs_to_print > $u) + { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $u)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $TOTALinSECONDS = ($TOTALinSECONDS + $row[1]); + $AGENTseconds = ($row[1] - $row[5]); + if ($AGENTseconds < 0) + {$AGENTseconds=0;} + + $TOTALagentSECONDS = ($TOTALagentSECONDS + $AGENTseconds); + + $u++; + echo "<tr $bgcolor>"; + echo "<td><font size=1>$u</td>"; + echo "<td><font size=2>$row[0]</td>"; + echo "<td align=left><font size=2> $row[1]</td>\n"; + echo "<td align=left><font size=2> $row[2]</td>\n"; + echo "<td align=left><font size=2> $row[3] </td>\n"; + echo "<td align=right><font size=2> $row[4] </td>\n"; + echo "<td align=right><font size=2> $row[5] </td>\n"; + echo "<td align=right><font size=2> $AGENTseconds </td>\n"; + echo "<td align=right><font size=2> $row[6] </td>\n"; + echo "<td align=right><font size=2> <A HREF=\"admin_modify_lead.php?lead_id=$row[7]\" target=\"_blank\">$row[7]</A> </td>\n"; + echo "<td align=right><font size=2> $row[8] </td></tr>\n"; + } + +echo "<tr bgcolor=white>"; +echo "<td colspan=2><font size=2>TOTALS</td>"; +echo "<td align=left><font size=2> $TOTALinSECONDS</td>\n"; +echo "<td colspan=4><font size=2>   </td>\n"; +echo "<td align=right><font size=2> $TOTALagentSECONDS</td>\n"; +echo "<td colspan=3><font size=2>   </td></tr>\n"; +echo "</TABLE></center><BR><BR>\n"; + + +##### vicidial agent activity records for this time period ##### +echo "<B>AGENTE ACTIVITY FOR THIS TIME PERIOD: (10000 record limit)</B>\n"; +echo "<TABLE width=750 cellspacing=0 cellpadding=1>\n"; +echo "<tr><td colspan=2><font size=1>   </td><td colspan=6 align=center bgcolor=white><font size=1>these fields are in seconds </td><td colspan=4><font size=1>   </td></tr>\n"; +echo "<tr><td><font size=1># </td><td><font size=2>DATE/TIME </td><td align=left><font size=2>PAUSE</td><td align=left><font size=2> WAIT</td><td align=left><font size=2> TALK</td><td align=right><font size=2> DISPO</td><td align=right><font size=2> DEAD</td><td align=right><font size=2> CUSTOMER</td><td align=right><font size=2> STATUS</td><td align=right><font size=2> LEAD</td><td align=right><font size=2> CAMPANHA</td><td align=right><font size=2> PAUSE CODE</td></tr>\n"; + +$stmt="select event_time,lead_id,campaign_id,pause_sec,wait_sec,talk_sec,dispo_sec,dead_sec,status,sub_status,user_group from vicidial_agent_log where user='" . mysql_real_escape_string($user) . "' and event_time >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and event_time <= '" . mysql_real_escape_string($end_date) . " 23:59:59' and ( (pause_sec > 0) or (wait_sec > 0) or (talk_sec > 0) or (dispo_sec > 0) ) order by event_time desc limit 10000;"; +$rslt=mysql_query($stmt, $link); +$logs_to_print = mysql_num_rows($rslt); + +$u=0; +$TOTALpauseSECONDS=0; +$TOTALwaitSECONDS=0; +$TOTALtalkSECONDS=0; +$TOTALdispoSECONDS=0; +$TOTALdeadSECONDS=0; +$TOTALcustomerSECONDS=0; +while ($logs_to_print > $u) + { + $row=mysql_fetch_row($rslt); + $event_time = $row[0]; + $lead_id = $row[1]; + $campaign_id = $row[2]; + $pause_sec = $row[3]; + $wait_sec = $row[4]; + $talk_sec = $row[5]; + $dispo_sec = $row[6]; + $dead_sec = $row[7]; + $status = $row[8]; + $pause_code = $row[9]; + $user_group = $row[10]; + $customer_sec = ($talk_sec - $dead_sec); + if ($customer_sec < 0) + {$customer_sec=0;} + + if (eregi("1$|3$|5$|7$|9$", $u)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $TOTALpauseSECONDS = ($TOTALpauseSECONDS + $pause_sec); + $TOTALwaitSECONDS = ($TOTALwaitSECONDS + $wait_sec); + $TOTALtalkSECONDS = ($TOTALtalkSECONDS + $talk_sec); + $TOTALdispoSECONDS = ($TOTALdispoSECONDS + $dispo_sec); + $TOTALdeadSECONDS = ($TOTALdeadSECONDS + $dead_sec); + $TOTALcustomerSECONDS = ($TOTALcustomerSECONDS + $customer_sec); + + + $u++; + echo "<tr $bgcolor>"; + echo "<td><font size=1>$u</td>"; + echo "<td><font size=2>$event_time</td>"; + echo "<td align=right><font size=2> $pause_sec</td>\n"; + echo "<td align=right><font size=2> $wait_sec</td>\n"; + echo "<td align=right><font size=2> $talk_sec </td>\n"; + echo "<td align=right><font size=2> $dispo_sec </td>\n"; + echo "<td align=right><font size=2> $dead_sec </td>\n"; + echo "<td align=right><font size=2> $customer_sec </td>\n"; + echo "<td align=right><font size=2> $status </td>\n"; + echo "<td align=right><font size=2> <A HREF=\"admin_modify_lead.php?lead_id=$lead_id\" target=\"_blank\">$lead_id</A> </td>\n"; + echo "<td align=right><font size=2> $campaign_id </td>\n"; + echo "<td align=right><font size=2> $pause_code </td></tr>\n"; + } + +echo "<tr bgcolor=white>"; +echo "<td colspan=2><font size=2>TOTALS</td>"; +echo "<td align=right><font size=2> $TOTALpauseSECONDS</td>\n"; +echo "<td align=right><font size=2> $TOTALwaitSECONDS</td>\n"; +echo "<td align=right><font size=2> $TOTALtalkSECONDS</td>\n"; +echo "<td align=right><font size=2> $TOTALdispoSECONDS</td>\n"; +echo "<td align=right><font size=2> $TOTALdeadSECONDS</td>\n"; +echo "<td align=right><font size=2> $TOTALcustomerSECONDS</td>\n"; +echo "<td colspan=4><font size=2>   </td></tr>\n"; + +$TOTALpauseSECONDShh = sec_convert($TOTALpauseSECONDS,'H'); +$TOTALwaitSECONDShh = sec_convert($TOTALwaitSECONDS,'H'); +$TOTALtalkSECONDShh = sec_convert($TOTALtalkSECONDS,'H'); +$TOTALdispoSECONDShh = sec_convert($TOTALdispoSECONDS,'H'); +$TOTALdeadSECONDShh = sec_convert($TOTALdeadSECONDS,'H'); +$TOTALcustomerSECONDShh = sec_convert($TOTALcustomerSECONDS,'H'); + +echo "<tr bgcolor=white>"; +echo "<td colspan=2><font size=1>(in HH:MM:SS)</td>"; +echo "<td align=right><font size=2> $TOTALpauseSECONDShh</td>\n"; +echo "<td align=right><font size=2> $TOTALwaitSECONDShh</td>\n"; +echo "<td align=right><font size=2> $TOTALtalkSECONDShh</td>\n"; +echo "<td align=right><font size=2> $TOTALdispoSECONDShh</td>\n"; +echo "<td align=right><font size=2> $TOTALdeadSECONDShh</td>\n"; +echo "<td align=right><font size=2> $TOTALcustomerSECONDShh</td>\n"; +echo "<td colspan=4><font size=2>   </td></tr>\n"; + +echo "</TABLE></center><BR><BR>\n"; + + + +##### vicidial recordings for this time period ##### + +echo "<B>RECORDINGS FOR THIS TIME PERIOD: (10000 record limit)</B>\n"; +echo "<TABLE width=750 cellspacing=0 cellpadding=1>\n"; +echo "<tr><td><font size=1># </td><td align=left><font size=2> LEAD</td><td><font size=2>DATE/TIME </td><td align=left><font size=2>SECONDS </td><td align=left><font size=2>   RECID</td><td align=center><font size=2>FILENAME</td><td align=center><font size=2>LOCATION   </td></tr>\n"; + + $stmt="select recording_id,channel,server_ip,extension,start_time,start_epoch,end_time,end_epoch,length_in_sec,length_in_min,filename,location,lead_id,user,vicidial_id from recording_log where user='" . mysql_real_escape_string($user) . "' and start_time >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and start_time <= '" . mysql_real_escape_string($end_date) . " 23:59:59' order by recording_id desc limit 10000;"; + $rslt=mysql_query($stmt, $link); + $logs_to_print = mysql_num_rows($rslt); + + $u=0; + while ($logs_to_print > $u) + { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $u)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $location = $row[11]; + + if (strlen($location)>2) + { + $URLserver_ip = $location; + $URLserver_ip = eregi_replace('http://','',$URLserver_ip); + $URLserver_ip = eregi_replace('https://','',$URLserver_ip); + $URLserver_ip = eregi_replace("\/.*",'',$URLserver_ip); + $stmt="select count(*) from servers where server_ip='$URLserver_ip';"; + $rsltx=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rsltx); + + if ($rowx[0] > 0) + { + $stmt="select recording_web_link,alt_server_ip from servers where server_ip='$URLserver_ip';"; + $rsltx=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rsltx); + + if (eregi("ALT_IP",$rowx[0])) + { + $location = eregi_replace($URLserver_ip, $rowx[1], $location); + } + } + } + + if (strlen($location)>30) + {$locat = substr($location,0,27); $locat = "$locat...";} + else + {$locat = $location;} + if (eregi("http",$location)) + {$location = "<a href=\"$location\">$locat</a>";} + else + {$location = $locat;} + $u++; + echo "<tr $bgcolor>"; + echo "<td><font size=1>$u</td>"; + echo "<td align=left><font size=2> <A HREF=\"admin_modify_lead.php?lead_id=$row[12]\" target=\"_blank\">$row[12]</A> </td>"; + echo "<td align=left><font size=2> $row[4] </td>\n"; + echo "<td align=left><font size=2> $row[8] </td>\n"; + echo "<td align=left><font size=2> $row[0] </td>\n"; + echo "<td align=center><font size=2> $row[10] </td>\n"; + echo "<td align=right><font size=2> $location   </td>\n"; + echo "</tr>\n"; + + } + + +echo "</TABLE><BR><BR>\n"; + + +##### vicidial agent outbound user manual calls for this time period ##### + +echo "<B>MANUAL SAINTE CALLS FOR THIS TIME PERIOD: (10000 record limit)</B>\n"; +echo "<TABLE width=750 cellspacing=0 cellpadding=1>\n"; +echo "<tr><td><font size=1># </td><td><font size=2>DATE/TIME </td><td align=left><font size=2> CALL TYPE</td><td align=left><font size=2> SERVER</td><td align=left><font size=2> PHONE</td><td align=right><font size=2> DIALED</td><td align=right><font size=2> LEAD</td><td align=right><font size=2> CALLERID</td><td align=right><font size=2> ALIAS</td></tr>\n"; + + $stmt="select call_date,call_type,server_ip,phone_number,number_dialed,lead_id,callerid,group_alias_id from user_call_log where user='" . mysql_real_escape_string($user) . "' and call_date >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and call_date <= '" . mysql_real_escape_string($end_date) . " 23:59:59' order by call_date desc limit 10000;"; + $rslt=mysql_query($stmt, $link); + $logs_to_print = mysql_num_rows($rslt); + + $u=0; + while ($logs_to_print > $u) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $u)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $u++; + echo "<tr $bgcolor>"; + echo "<td><font size=1>$u</td>"; + echo "<td><font size=2>$row[0]</td>"; + echo "<td align=left><font size=2> $row[1]</td>\n"; + echo "<td align=left><font size=2> $row[2]</td>\n"; + echo "<td align=left><font size=2> $row[3] </td>\n"; + echo "<td align=right><font size=2> $row[4] </td>\n"; + echo "<td align=right><font size=2> <A HREF=\"admin_modify_lead.php?lead_id=$row[5]\" target=\"_blank\">$row[5]</A> </td>\n"; + echo "<td align=right><font size=2> $row[6] </td>\n"; + echo "<td align=right><font size=2> $row[7] </td></tr>\n"; + + } + + +echo "</TABLE><BR><BR>\n"; + + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n<br><br><br>\n\n"; + + +echo "<font size=0>\n\n\n<br><br><br>\nScript runtime: $RUNtime seconds</font>"; + + +?> + + +</TD></TR><TABLE> +</body> +</html> + +<?php + +exit; + + + +?> + + + + + diff --git a/LANG_www/vicidial_br/user_status.php b/LANG_www/vicidial_br/user_status.php new file mode 100644 index 00000000..aea5732d --- /dev/null +++ b/LANG_www/vicidial_br/user_status.php @@ -0,0 +1,677 @@ +<?php +# user_status.php +# +# Copyright (C) 2009 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2 +# +# CHANGES +# +# 60619-1738 - Added variable filtering to eliminate SQL injection attack threat +# 80603-1452 - Added manager timeclock force login/logout of user +# 81118-1034 - Disabled change campaign because it does not work +# 90208-0511 - Added link to user multi-day status report +# 90310-0741 - Added admin header +# 90508-0644 - Changed to PHP long tags +# 91012-0536 - Added selected territories display +# 91130-2039 - Added user closer log manager flag display +# 91212-0656 - Added more complete logging of Emergency Logout process +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["begin_date"])) {$begin_date=$_GET["begin_date"];} + elseif (isset($_POST["begin_date"])) {$begin_date=$_POST["begin_date"];} +if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];} + elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin,webroot_writable,outbound_autodial_active,user_territories_active FROM system_settings;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$qm_conf_ct = mysql_num_rows($rslt); +if ($qm_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $non_latin = $row[0]; + $webroot_writable = $row[1]; + $SSoutbound_autodial_active = $row[2]; + $user_territories_active = $row[3]; + } +##### END SETTINGS LOOKUP ##### +########################################### + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$StarTtimE = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$ip = getenv("REMOTE_ADDR"); + +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7 and view_reports='1';"; +if ($non_latin > 0) { $rslt=mysql_query("SET NAMES 'UTF8'");} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + +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 "Nome ou Senha inválidos: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } +else + { + if($auth>0) + { + $stmt="SELECT full_name,change_agent_campaign,modify_timeclock_log from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname = $row[0]; + $change_agent_campaign = $row[1]; + $modify_timeclock_log = $row[2]; + if ($webroot_writable > 0) + { + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + } + else + { + if ($webroot_writable > 0) + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + echo "Nome ou Senha inválidos: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + } + + $stmt="SELECT full_name,user_group from vicidial_users where user='" . mysql_real_escape_string($user) . "';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $full_name = $row[0]; + $user_group = $row[1]; + + $stmt="SELECT live_agent_id,user,server_ip,conf_exten,extension,status,lead_id,campaign_id,uniqueid,callerid,channel,random_id,last_call_time,last_update_time,last_call_finish,closer_campaigns,call_server_ip,user_level,comments,campaign_weight,calls_today,external_hangup,external_status,external_pause,external_dial,agent_log_id,last_state_change,agent_territories,outbound_autodial,manager_ingroup_set,external_igb_set_user from vicidial_live_agents where user='" . mysql_real_escape_string($user) . "';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $agents_to_print = mysql_num_rows($rslt); + $i=0; + while ($i < $agents_to_print) + { + $row=mysql_fetch_row($rslt); + $Aserver_ip = $row[2]; + $Asession_id = $row[3]; + $Aextension = $row[4]; + $Astatus = $row[5]; + $Acampaign = $row[7]; + $Alast_call = $row[14]; + $Acl_campaigns = $row[15]; + $agent_territories = $row[27]; + $outbound_autodial = $row[28]; + $manager_ingroup_set = $row[29]; + $external_igb_set_user = $row[30]; + $i++; + } + + $stmt="SELECT event_date,status,ip_address from vicidial_timeclock_status where user='" . mysql_real_escape_string($user) . "';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $tc_logs_to_print = mysql_num_rows($rslt); + if ($tc_logs_to_print > 0) + { + $row=mysql_fetch_row($rslt); + $Tevent_date = $row[0]; + $Tstatus = $row[1]; + $Tip_address = $row[2]; + $i++; + } + + } + +$stmt="select campaign_id from vicidial_campaigns;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } + + + +?> +<html> +<head> +<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8"> +<title>ADMINISTRATION: Status do Usuário +<?php + + +##### BEGIN Set variables to make header show properly ##### +$ADD = '3'; +$hh = 'users'; +$LOGast_admin_access = '1'; +$ADMIN = 'admin.php'; +$page_width='770'; +$section_width='750'; +$header_font_size='3'; +$subheader_font_size='2'; +$subcamp_font_size='2'; +$header_selected_bold='<b>'; +$header_nonselected_bold=''; +$users_color = '#FFFF99'; +$users_font = 'BLACK'; +$users_color = '#E6E6E6'; +$subcamp_color = '#C6C6C6'; +##### END Set variables to make header show properly ##### + +require("admin_header.php"); + + + +?> +<TABLE WIDTH=<?php echo $page_width ?> BGCOLOR=#E6E6E6 cellpadding=2 cellspacing=0><TR BGCOLOR=#E6E6E6><TD ALIGN=LEFT><FONT FACE="ARIAL,HELVETICA" SIZE=2><B>   Status do Usuário for <?php echo $user ?></TD><TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA" SIZE=2><B>   </TD></TR> + + + + +<?php + +echo "<TR BGCOLOR=\"#F0F5FE\"><TD ALIGN=LEFT COLSPAN=2><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=3><B>   \n"; + +##### EMERGENCY CAMPAIGN CHANGE FOR AN AGENT ##### +if ($stage == "live_campaign_change") + { + $stmt="UPDATE vicidial_live_agents set campaign_id='" . mysql_real_escape_string($group) . "' where user='" . mysql_real_escape_string($user) . "';"; + $rslt=mysql_query($stmt, $link); + + echo "Agent $user - $full_name changed to $group campaign<BR>\n"; + + exit; + } + +##### EMERGENCY LOGOUT OF AN AGENT ##### +if ($stage == "log_agent_out") + { + $now_date_epoch = date('U'); + $inactive_epoch = ($now_date_epoch - 60); + $stmt = "SELECT user,campaign_id,UNIX_TIMESTAMP(last_update_time) from vicidial_live_agents where user='" . mysql_real_escape_string($user) . "';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "<BR>$stmt\n";} + $vla_ct = mysql_num_rows($rslt); + if ($vla_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VLA_user = $row[0]; + $VLA_campaign_id = $row[1]; + $VLA_update_time = $row[2]; + + if ($VLA_update_time > $inactive_epoch) + { + $lead_active=0; + $stmt = "SELECT agent_log_id,user,server_ip,event_time,lead_id,campaign_id,pause_epoch,pause_sec,wait_epoch,wait_sec,talk_epoch,talk_sec,dispo_epoch,dispo_sec,status,user_group,comments,sub_status,dead_epoch,dead_sec from vicidial_agent_log where user='$VLA_user' order by agent_log_id desc LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "<BR>$stmt\n";} + $val_ct = mysql_num_rows($rslt); + if ($val_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VAL_agent_log_id = $row[0]; + $VAL_user = $row[1]; + $VAL_server_ip = $row[2]; + $VAL_event_time = $row[3]; + $VAL_lead_id = $row[4]; + $VAL_campaign_id = $row[5]; + $VAL_pause_epoch = $row[6]; + $VAL_pause_sec = $row[7]; + $VAL_wait_epoch = $row[8]; + $VAL_wait_sec = $row[9]; + $VAL_talk_epoch = $row[10]; + $VAL_talk_sec = $row[11]; + $VAL_dispo_epoch = $row[12]; + $VAL_dispo_sec = $row[13]; + $VAL_status = $row[14]; + $VAL_user_group = $row[15]; + $VAL_comments = $row[16]; + $VAL_sub_status = $row[17]; + $VAL_dead_epoch = $row[18]; + $VAL_dead_sec = $row[19]; + + if ($DB) {echo "\n<BR>VAL VALUES: $VAL_agent_log_id|$VAL_status|$VAL_lead_id\n";} + + if ( ($VAL_wait_epoch < 1) || ( ($VAL_status == 'PAUSE') && ($VAL_dispo_epoch < 1) ) ) + { + $VAL_pause_sec = ( ($now_date_epoch - $VAL_pause_epoch) + $VAL_pause_sec); + $stmt = "UPDATE vicidial_agent_log SET wait_epoch='$now_date_epoch', pause_sec='$VAL_pause_sec' where agent_log_id='$VAL_agent_log_id';"; + } + else + { + if ($VAL_talk_epoch < 1) + { + $VAL_wait_sec = ( ($now_date_epoch - $VAL_wait_epoch) + $VAL_wait_sec); + $stmt = "UPDATE vicidial_agent_log SET talk_epoch='$now_date_epoch', wait_sec='$VAL_wait_sec' where agent_log_id='$VAL_agent_log_id';"; + } + else + { + $lead_active++; + $status_update_SQL=''; + if ( ( (strlen($VAL_status) < 1) or ($VAL_status == 'NULL') ) and ($VAL_lead_id > 0) ) + { + $status_update_SQL = ", status='PU'"; + $stmt="UPDATE vicidial_list SET status='PU' where lead_id='$VAL_lead_id';"; + if ($DB) {echo "<BR>$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + if ($VAL_dispo_epoch < 1) + { + $VAL_talk_sec = ($now_date_epoch - $VAL_talk_epoch); + $stmt = "UPDATE vicidial_agent_log SET dispo_epoch='$now_date_epoch', talk_sec='$VAL_talk_sec'$status_update_SQL where agent_log_id='$VAL_agent_log_id';"; + } + else + { + if ($VAL_dispo_sec < 1) + { + $VAL_dispo_sec = ($now_date_epoch - $VAL_dispo_epoch); + $stmt = "UPDATE vicidial_agent_log SET dispo_sec='$VAL_dispo_sec' where agent_log_id='$VAL_agent_log_id';"; + } + } + } + } + + if ($DB) {echo "<BR>$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + } + + $stmt="DELETE from vicidial_live_agents where user='" . mysql_real_escape_string($user) . "';"; + if ($DB) {echo "<BR>$stmt\n";} + $rslt=mysql_query($stmt, $link); + + if (strlen($VAL_user_group) < 1) + { + $stmt = "SELECT user_group FROM vicidial_users where user='$VLA_user';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "<BR>$stmt\n";} + $val_ct = mysql_num_rows($rslt); + if ($val_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VAL_user_group = $row[0]; + } + } + + $stmt = "INSERT INTO vicidial_user_log (user,event,campaign_id,event_date,event_epoch,user_group) values('$VLA_user','LOGOUT','$VLA_campaign_id','$NOW_TIME','$now_date_epoch','$VAL_user_group');"; + if ($DB) {echo "<BR>$stmt\n";} + $rslt=mysql_query($stmt, $link); + + + ############################################# + ##### START QUEUEMETRICS LOGGING LOOKUP ##### + $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "<BR>$stmt\n";} + $qm_conf_ct = mysql_num_rows($rslt); + if ($qm_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $enable_queuemetrics_logging = $row[0]; + $queuemetrics_server_ip = $row[1]; + $queuemetrics_dbname = $row[2]; + $queuemetrics_login = $row[3]; + $queuemetrics_pass = $row[4]; + $queuemetrics_log_id = $row[5]; + } + ##### END QUEUEMETRICS LOGGING LOOKUP ##### + ########################################### + if ($enable_queuemetrics_logging > 0) + { + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); + mysql_select_db("$queuemetrics_dbname", $linkB); + + $agents='@agents'; + $agent_logged_in=''; + $time_logged_in=''; + + $stmtB = "SELECT agent,time_id FROM queue_log where agent='Agent/" . mysql_real_escape_string($user) . "' and verb='AGENTLOGIN' order by time_id desc limit 1;"; + $rsltB=mysql_query($stmtB, $linkB); + if ($DB) {echo "<BR>$stmtB\n";} + $qml_ct = mysql_num_rows($rsltB); + if ($qml_ct > 0) + { + $row=mysql_fetch_row($rsltB); + $agent_logged_in = $row[0]; + $time_logged_in = $row[1]; + } + + $time_logged_in = ($now_date_epoch - $time_logged_in); + if ($time_logged_in > 1000000) {$time_logged_in=1;} + + $stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$now_date_epoch',call_id='NONE',queue='NONE',agent='$agent_logged_in',verb='AGENTLOGOFF',serverid='$queuemetrics_log_id',data1='" . mysql_real_escape_string($user) . "$agents',data2='$time_logged_in';"; + if ($DB) {echo "<BR>$stmtB\n";} + $rsltB=mysql_query($stmtB, $linkB); + } + + echo "Agent $user - $full_name has been emergency logged out, make sure they close their web browser<BR>\n"; + } + else + { + echo "Agent $user is not logged in<BR>\n"; + } + + exit; + } + + + + + +##### BEGIN TIMECLOCK LOGOUT OF A USER ##### +if ( ( ($stage == "tc_log_user_OUT") or ($stage == "tc_log_user_IN") ) and ($modify_timeclock_log > 0) ) + { + ### get vicidial_timeclock_status record count for this user + $stmt="SELECT count(*) from vicidial_timeclock_status where user='$user';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $vts_count = $row[0]; + + $LOG_run=0; + $last_action_sec=99; + + if ($vts_count > 0) + { + ### vicidial_timeclock_status record found, grab status and date of last activity + $stmt="SELECT status,event_epoch from vicidial_timeclock_status where user='$user';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $status = $row[0]; + $event_epoch = $row[1]; + $last_action_date = date("Y-m-d H:i:s", $event_epoch); + $last_action_sec = ($StarTtimE - $event_epoch); + + if ($last_action_sec > 0) + { + $totTIME_H = ($last_action_sec / 3600); + $totTIME_H_int = round($totTIME_H, 2); + $totTIME_H_int = intval("$totTIME_H"); + $totTIME_M = ($totTIME_H - $totTIME_H_int); + $totTIME_M = ($totTIME_M * 60); + $totTIME_M_int = round($totTIME_M, 2); + $totTIME_M_int = intval("$totTIME_M"); + $totTIME_S = ($totTIME_M - $totTIME_M_int); + $totTIME_S = ($totTIME_S * 60); + $totTIME_S = round($totTIME_S, 0); + if (strlen($totTIME_H_int) < 1) {$totTIME_H_int = "0";} + if ($totTIME_M_int < 10) {$totTIME_M_int = "0$totTIME_M_int";} + if ($totTIME_S < 10) {$totTIME_S = "0$totTIME_S";} + $totTIME_HMS = "$totTIME_H_int:$totTIME_M_int:$totTIME_S"; + } + else + { + $totTIME_HMS='0:00:00'; + } + } + + else + { + ### No vicidial_timeclock_status record found, insert one + $stmt="INSERT INTO vicidial_timeclock_status set status='START', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $status='START'; + $totTIME_HMS='0:00:00'; + $affected_rows = mysql_affected_rows($link); + print "<!-- NEW vicidial_timeclock_status record inserted for $user: |$affected_rows| -->\n"; + } + + + ##### Run timeclock login queries ##### + if ( ( ($status=='AUTOLOGOUT') or ($status=='START') or ($status=='LOGOUT') ) and ($stage == "tc_log_user_IN") ) + { + ### Add a record to the timeclock log + $stmtA="INSERT INTO vicidial_timeclock_log set event='LOGIN', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip', event_date='$NOW_TIME', manager_user='$PHP_AUTH_USER', manager_ip='$ip', notes='Manager LOGIN of user from user status page';"; + if ($DB) {echo "$stmtA\n";} + $rslt=mysql_query($stmtA, $link); + $affected_rows = mysql_affected_rows($link); + $timeclock_id = mysql_insert_id($link); + print "<!-- NEW vicidial_timeclock_log record inserted for $user: |$affected_rows|$timeclock_id| -->\n"; + + ### Update the user's timeclock status record + $stmtB="UPDATE vicidial_timeclock_status set status='LOGIN', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip' where user='$user';"; + if ($DB) {echo "$stmtB\n";} + $rslt=mysql_query($stmtB, $link); + $affected_rows = mysql_affected_rows($link); + print "<!-- vicidial_timeclock_status record updated for $user: |$affected_rows| -->\n"; + + ### Add a record to the timeclock audit log + $stmtC="INSERT INTO vicidial_timeclock_audit_log set timeclock_id='$timeclock_id', event='LOGIN', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip', event_date='$NOW_TIME';"; + if ($DB) {echo "$stmtC\n";} + $rslt=mysql_query($stmtC, $link); + $affected_rows = mysql_affected_rows($link); + print "<!-- NEW vicidial_timeclock_audit_log record inserted for $user: |$affected_rows| -->\n"; + + ### Add a record to the vicidial_admin_log + $SQL_log = "$stmtA|$stmtB|$stmtC|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$PHP_AUTH_USER', ip_address='$ip', event_section='TIMECLOCK', event_type='LOGIN', record_id='$user', event_code='USER FORCED LOGIN FROM STATUS PAGE', event_sql=\"$SQL_log\", event_notes='Relógio Ponto ID: $timeclock_id|';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "<!-- NEW vicidial_admin_log record inserted for $PHP_AUTH_USER: |$affected_rows| -->\n"; + + $LOG_run++; + $VDdisplayMESSAGE = "You have now logged-in the user: $user - $full_name"; + } + + ##### Run timeclock logout queries ##### + if ( ( ($status=='LOGIN') or ($status=='START') ) and ($stage == "tc_log_user_OUT") ) + { + ### Add a record to the timeclock log + $stmtA="INSERT INTO vicidial_timeclock_log set event='LOGOUT', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip', login_sec='$last_action_sec', event_date='$NOW_TIME', manager_user='$PHP_AUTH_USER', manager_ip='$ip', notes='Manager LOGOUT of user from user status page';"; + if ($DB) {echo "$stmtA\n";} + $rslt=mysql_query($stmtA, $link); + $affected_rows = mysql_affected_rows($link); + $timeclock_id = mysql_insert_id($link); + print "<!-- NEW vicidial_timeclock_log record inserted for $user: |$affected_rows|$timeclock_id| -->\n"; + + ### Update last login record in the timeclock log + $stmtB="UPDATE vicidial_timeclock_log set login_sec='$last_action_sec',tcid_link='$timeclock_id' where event='LOGIN' and user='$user' order by timeclock_id desc limit 1;"; + if ($DB) {echo "$stmtB\n";} + $rslt=mysql_query($stmtB, $link); + $affected_rows = mysql_affected_rows($link); + print "<!-- vicidial_timeclock_log record updated for $user: |$affected_rows| -->\n"; + + ### Update the user's timeclock status record + $stmtC="UPDATE vicidial_timeclock_status set status='LOGOUT', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip' where user='$user';"; + if ($DB) {echo "$stmtC\n";} + $rslt=mysql_query($stmtC, $link); + $affected_rows = mysql_affected_rows($link); + print "<!-- vicidial_timeclock_status record updated for $user: |$affected_rows| -->\n"; + + ### Add a record to the timeclock audit log + $stmtD="INSERT INTO vicidial_timeclock_audit_log set timeclock_id='$timeclock_id', event='LOGOUT', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip', login_sec='$last_action_sec', event_date='$NOW_TIME';"; + if ($DB) {echo "$stmtD\n";} + $rslt=mysql_query($stmtD, $link); + $affected_rows = mysql_affected_rows($link); + print "<!-- NEW vicidial_timeclock_audit_log record inserted for $user: |$affected_rows| -->\n"; + + ### Update last login record in the timeclock audit log + $stmtE="UPDATE vicidial_timeclock_audit_log set login_sec='$last_action_sec',tcid_link='$timeclock_id' where event='LOGIN' and user='$user' order by timeclock_id desc limit 1;"; + if ($DB) {echo "$stmtE\n";} + $rslt=mysql_query($stmtE, $link); + $affected_rows = mysql_affected_rows($link); + print "<!-- vicidial_timeclock_audit_log record updated for $user: |$affected_rows| -->\n"; + + ### Add a record to the vicidial_admin_log + $SQL_log = "$stmtA|$stmtB|$stmtC|$stmtD|$stmtE|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$PHP_AUTH_USER', ip_address='$ip', event_section='TIMECLOCK', event_type='LOGOUT', record_id='$user', event_code='USER FORCED LOGOUT FROM STATUS PAGE', event_sql=\"$SQL_log\", event_notes='Usuário login time: $last_action_sec|Relógio Ponto ID: $timeclock_id|';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "<!-- NEW vicidial_admin_log record inserted for $PHP_AUTH_USER: |$affected_rows| -->\n"; + + $LOG_run++; + $VDdisplayMESSAGE = "You have now logged-out the user: $user - $full_name<BR>Amount of time user was logged-in: $totTIME_HMS"; + } + + if ($LOG_run < 1) + {$VDdisplayMESSAGE = "ERROR: timeclock log problem, could not process: $status|$stage";} + + echo "$VDdisplayMESSAGE\n"; + + exit; + } + +##### END TIMECLOCK LOGOUT OF A USER ##### + +if ($agents_to_print > 0) + { + echo "<BR>\n"; + echo "$user - $full_name \n"; + echo "       GROUP: $user_group <BR>\n"; + + echo "<TABLE CELLPADDING=0 CELLSPACING=0>"; + echo "<TR><TD ALIGN=RIGHT>Agent Logged in at server:</TD><TD ALIGN=LEFT>   $Aserver_ip</TD></TR>\n"; + echo "<TR><TD ALIGN=RIGHT>in session:</TD><TD ALIGN=LEFT>   $Asession_id</TD></TR>\n"; + echo "<TR><TD ALIGN=RIGHT>from phone:</TD><TD ALIGN=LEFT>   $Aextension</TD></TR>\n"; + echo "<TR><TD ALIGN=RIGHT>Agent is in campaign:</TD><TD ALIGN=LEFT>   $Acampaign</TD></TR>\n"; + echo "<TR><TD ALIGN=RIGHT>status:</TD><TD ALIGN=LEFT>   $Astatus</TD></TR>\n"; + echo "<TR><TD ALIGN=RIGHT>hungup last call at:</TD><TD ALIGN=LEFT>   $Alast_call</TD></TR>\n"; + echo "<TR><TD ALIGN=RIGHT>Closer groups:</TD><TD ALIGN=LEFT>   $Acl_campaigns</TD></TR>\n"; + if ($manager_ingroup_set != 'N') + {echo "<TR><TD ALIGN=RIGHT>Manager InGroup Select:</TD><TD ALIGN=LEFT>   YES, by $external_igb_set_user</TD></TR>\n";} + if ($outbound_autodial == 'Y') + {echo "<TR><TD ALIGN=RIGHT>Outbound Auto-Dial:</TD><TD ALIGN=LEFT>   YES</TD></TR>\n";} + if ($user_territories_active > 0) + {echo "<TR><TD ALIGN=RIGHT>Selected Territories:</TD><TD ALIGN=LEFT>   $agent_territories</TD></TR>\n";} + echo "</TABLE>\n<BR>\n"; + + if ($change_agent_campaign > 0) + { + echo "<form action=$PHP_SELF method=POST>\n"; + echo "<input type=hidden name=DB value=\"$DB\">\n"; + echo "<input type=hidden name=user value=\"$user\">\n"; + echo "<input type=hidden name=stage value=\"live_campaign_change\">\n"; + echo "Current Campanha: <SELECT SIZE=1 NAME=group>\n"; + $o=0; + while ($groups_to_print > $o) + { + if ($groups[$o] == "$Acampaign") {echo "<option selected value=\"$groups[$o]\">$groups[$o]</option>\n";} + else {echo "<option value=\"$groups[$o]\">$groups[$o]</option>\n";} + $o++; + } + echo "</SELECT>\n"; + echo "<input type=submit name=submit value=CHANGE disabled><BR></form>\n"; + + echo "<form action=$PHP_SELF method=POST>\n"; + echo "<input type=hidden name=DB value=\"$DB\">\n"; + echo "<input type=hidden name=user value=\"$user\">\n"; + echo "<input type=hidden name=stage value=\"log_agent_out\">\n"; + echo "<input type=submit name=submit value=\"EMERGENCY LOG AGENTE OUT\"><BR></form>\n"; + } + } + +else + { + echo "Agent is not logged in\n<BR>"; + } + +echo "\n<BR>"; + +if ( ($Tstatus == "LOGIN") or ($Tstatus == "START") ) + { + echo "Usuário $user($full_name) - is logged in to the timeclock. <BR>Login time: $Tevent_date from $Tip_address<BR>\n"; + $TC_log_change_stage = 'tc_log_user_OUT'; + $TC_log_change_button = 'TIMECLOCK LOG THIS USER OUT'; + } +else + { + echo "Usuário $user($full_name) - is NOT logged in to the timeclock. <BR>Last logout time: $Tevent_date from $Tip_address<BR>\n"; + $TC_log_change_stage = 'tc_log_user_IN'; + $TC_log_change_button = 'TIMECLOCK LOG THIS USER IN'; + } + +if ($modify_timeclock_log > 0) + { + echo "<BR><BR>\n"; + echo "<form action=$PHP_SELF method=POST>\n"; + echo "<input type=hidden name=DB value=\"$DB\">\n"; + echo "<input type=hidden name=user value=\"$user\">\n"; + echo "<input type=hidden name=stage value=\"$TC_log_change_stage\">\n"; + echo "<input type=submit name=submit value=\"$TC_log_change_button\"><BR></form>\n"; + echo "<BR><BR>\n"; + } + + +$REPORTdate = date("Y-m-d"); +echo "<center>\n"; +echo "<a href=\"./AST_agent_time_sheet.php?agent=$user\">Agent Planilha de Tempo</a>\n"; +echo " | <a href=\"./user_stats.php?user=$user\">Estatísticas de Usuário</a>\n"; +echo " | <a href=\"./admin.php?ADD=3&user=$user\">Alterar Usuário</a>\n"; +echo " | <a href=\"./AST_agent_days_detail.php?user=$user&query_date=$REPORTdate&end_date=$REPORTdate&group[]=--ALL--&shift=ALL\">Usuário multiple day status detail report</a>"; +echo "</center>\n"; + +echo "</B></TD></TR>\n"; +echo "<TR><TD ALIGN=LEFT COLSPAN=2>\n"; + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $StarTtimE); + +echo "\n\n\n<br><br><br>\n\n"; + + +echo "<font size=0>\n\n\n<br><br><br>\nScript runtime: $RUNtime seconds</font>"; + +echo "|$stage|$group|"; + +?> + + +</TD></TR><TABLE> +</body> +</html> + +<?php + +exit; + + + +?> diff --git a/LANG_www/vicidial_br/user_territories.php b/LANG_www/vicidial_br/user_territories.php new file mode 100644 index 00000000..92006655 --- /dev/null +++ b/LANG_www/vicidial_br/user_territories.php @@ -0,0 +1,1089 @@ +<?php +# user_territories.php +# +# Copyright (C) 2009 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2 +# +# This territories script is for use with custom tables in Vtiger which is why +# it is separate from the standard admin.php script. user_territories_active in +# the system_settings table must be active for this script to work. +# +# CHANGES +# 90520-1928 - first build +# 90717-0651 - Added batch +# 90726-2302 - Added vicidial_list user owner update option +# 91012-0310 - Added vicidial_list counts for territory as owner +# + +$version = '2.2.0-4'; +$build = '91012-0310'; + +$MT[0]=''; + +require("dbconnect.php"); + +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["action"])) {$action=$_GET["action"];} + elseif (isset($_POST["action"])) {$action=$_POST["action"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["territory"])) {$territory=$_GET["territory"];} + elseif (isset($_POST["territory"])) {$territory=$_POST["territory"];} +if (isset($_GET["territory_description"])) {$territory_description=$_GET["territory_description"];} + elseif (isset($_POST["territory_description"])) {$territory_description=$_POST["territory_description"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["level"])) {$level=$_GET["level"];} + elseif (isset($_POST["level"])) {$level=$_POST["level"];} +if (isset($_GET["accountid"])) {$accountid=$_GET["accountid"];} + elseif (isset($_POST["accountid"])) {$accountid=$_POST["accountid"];} +if (isset($_GET["batch"])) {$batch=$_GET["batch"];} + elseif (isset($_POST["batch"])) {$batch=$_POST["batch"];} +if (isset($_GET["vl_owner"])) {$vl_owner=$_GET["vl_owner"];} + elseif (isset($_POST["vl_owner"])) {$vl_owner=$_POST["vl_owner"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + + +header ("Content-type: text/html; charset=utf-8"); +header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header ("Pragma: no-cache"); // HTTP/1.0 + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin,user_territories_active,enable_vtiger_integration,outbound_autodial_active,vtiger_server_ip,vtiger_dbname,vtiger_login,vtiger_pass,vtiger_url FROM system_settings;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$ss_conf_ct = mysql_num_rows($rslt); +if ($ss_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $non_latin = $row[0]; + $user_territories_active = $row[1]; + $enable_vtiger_integration = $row[2]; + $SSoutbound_autodial_active = $row[3]; + $vtiger_server_ip = $row[4]; + $vtiger_dbname = $row[5]; + $vtiger_login = $row[6]; + $vtiger_pass = $row[7]; + $vtiger_url = $row[8]; + } +##### END SETTINGS LOOKUP ##### +########################################### + + + +if ($user_territories_active < 1) + { + echo "ERROR: User Territories are not active on this system\n"; + exit; + } + +if ($non_latin < 1) + { + ### Clean Variable Values ### + $DB = ereg_replace("[^0-9]","",$DB); + $action = ereg_replace("[^\_0-9a-zA-Z]","",$action); + $territory = ereg_replace("[^-\_0-9a-zA-Z]","",$territory); + $territory_description = ereg_replace("[^ -\_\.\,0-9a-zA-Z]","",$territory_description); + $user = ereg_replace("[^-\_0-9a-zA-Z]","",$user); + $level = ereg_replace("[^\_A-Z]","",$level); + $old_territory = ereg_replace("[^-\_0-9a-zA-Z]","",$old_territory); + $old_user = ereg_replace("[^-\_0-9a-zA-Z]","",$old_user); + $accountid = ereg_replace("[^-\_0-9a-zA-Z]","",$accountid); + } + +if (eregi("YES",$batch)) + { + $USER='batch'; + $PASS='batch'; + } +else + { + $USER=$_SERVER['PHP_AUTH_USER']; + $PASS=$_SERVER['PHP_AUTH_PW']; + $USER = ereg_replace("[^0-9a-zA-Z]","",$USER); + $PASS = ereg_replace("[^0-9a-zA-Z]","",$PASS); + + $stmt="SELECT count(*) from vicidial_users where user='$USER' and pass='$PASS' and user_level > 7 and modify_users='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($USER)<2) or (strlen($PASS)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$USER|$PASS|\n"; + exit; + } + } + +if ($enable_vtiger_integration > 0) + { + ### connect to your vtiger database + $linkV=mysql_connect("$vtiger_server_ip", "$vtiger_login","$vtiger_pass"); + if (!$linkV) {die("Could not connect: $vtiger_server_ip|$vtiger_dbname|$vtiger_login|$vtiger_pass" . mysql_error());} + mysql_select_db("$vtiger_dbname", $linkV); + } + + +if (strlen($action) < 1) + {$action = 'LIST_ALL_TERRITORIES';} + + + +?> +<html> +<head> +<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8"> +<!-- VERSION: <?php echo $version ?> BUILD: <?php echo $build ?> --> +<title>ADMINISTRATION: User Territories +<?php + + + + + + +### BEGIN change territory owner for one account +if ( ($action == "CHANGE_TERRITORY_OWNER_ACCOUNT") and ($enable_vtiger_integration > 0) ) + { + echo "\n"; + echo "
\n"; + echo ""; + + echo "
Vtiger Change Territory Owner
\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + + echo "\n"; + echo "
Account ID:
New Owner:
Update ViciDial List Owner:
\n"; + exit; + } +### END change territory owner for one account + + +### BEGIN process change territory owner for one account +if ( ($action == "PROCESS_CHANGE_TERRITORY_OWNER_ACCOUNT") and ($enable_vtiger_integration > 0) ) + { + echo "\n"; + + if ( (strlen($accountid)<1) or (strlen($user)<1) ) + { + echo "ERROR: Account ID and User must be filled in
\n"; + } + else + { + if (eregi("YES",$batch)) + {$AID_lookupSQL = "website='$accountid'";} + else + {$AID_lookupSQL = "accountid='$accountid'";} + $stmtV="SELECT tickersymbol,accountid from vtiger_account where $AID_lookupSQL;"; + $rsltV=mysql_query($stmtV, $linkV); + if ($DB) {echo "$stmtV\n";} + $vat_ct = mysql_num_rows($rsltV); + if ($vat_ct > 0) + { + $row=mysql_fetch_row($rsltV); + $territory = $row[0]; + $accountid = $row[1]; + + $stmt="SELECT count(*) from vicidial_user_territories where territory='$territory' and user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] < 1) + { + $stmt="INSERT INTO vicidial_user_territories SET territory='$territory',user='$user',level='STANDARD_AGENT';"; + $rslt=mysql_query($stmt, $link); + + echo "NOTICE: Had to add user territory: $user $territory
\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|$stmtB|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$USER', ip_address='$ip', event_section='TERRITORIES', event_type='ADD', record_id='$territory', event_code='ADMIN ADD USER TERRITORY', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + + $stmtV="SELECT id from vtiger_users where user_name='$user';"; + $rsltV=mysql_query($stmtV, $linkV); + if ($DB) {echo "$stmtV\n";} + $vtu_ct = mysql_num_rows($rsltV); + if ($vtu_ct > 0) + { + $row=mysql_fetch_row($rsltV); + $user_id = $row[0]; + + $stmt="UPDATE vtiger_crmentity SET smownerid='$user_id',smcreatorid='$user_id',modifiedby='$user_id' where crmid='$accountid';"; + $rsltV=mysql_query($stmt, $linkV); + $changed = mysql_affected_rows($linkV); + + $stmtB="UPDATE vtiger_tracker SET user_id='$user_id' where item_id='$accountid';"; + $rsltV=mysql_query($stmtB, $linkV); + + if ( ($vl_owner == 'YES') and ($accountid > 0) ) + { + $stmtB="UPDATE vicidial_list SET owner='$user' where vendor_lead_code='$accountid';"; + $rsltV=mysql_query($stmtB, $link); + } + + echo "Vtiger Territory Owner Changed: $user $territory
\n"; + echo "Records Changed: $changed
\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|$stmtB|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$USER', ip_address='$ip', event_section='VTIGER', event_type='MODIFY', record_id='$accountid', event_code='VTIGER MODIFY TERRITORY OWNER ACCOUNT', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + } + exit; + } +### END process change territory owner for one account + + + + + +##### BEGIN Set variables to make header show properly ##### +$ADD = '0'; +$hh = 'users'; +$LOGast_admin_access = '1'; +$ADMIN = 'admin.php'; +$page_width='770'; +$section_width='750'; +$header_font_size='3'; +$subheader_font_size='2'; +$subcamp_font_size='2'; +$header_selected_bold=''; +$header_nonselected_bold=''; +$users_color = '#FFFF99'; +$users_font = 'BLACK'; +$users_color = '#E6E6E6'; +$subcamp_color = '#C6C6C6'; +##### END Set variables to make header show properly ##### + +require("admin_header.php"); + +$colspan='3'; + +?> + BGCOLOR=#E6E6E6 cellpadding=2 cellspacing=0> + + + + + 0) + { ?> + + + + + +
  ">List Territories   ?action=ADD_TERRITORY">Add Territory   ?action=ADD_USER_TERRITORY">Add User Territory   ?action=CHANGE_TERRITORY_OWNER">Change Vtiger Territory Owner
  \n"; + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_datetime = $STARTtime; + +$ip = getenv("REMOTE_ADDR"); +$date = date("r"); +$browser = getenv("HTTP_USER_AGENT"); +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +$admDIR = "$HTTPprotocol$server_name:$server_port$script_name"; +$admDIR = eregi_replace('audio_store.php','',$admDIR); +$admSCR = 'admin.php'; +$NWB = "   \"HELP\""; + +$secX = date("U"); +$pulldate0 = "$year-$mon-$mday $hour:$min:$sec"; + + + + + + + +### BEGIN change territory owner in the system +if ( ($action == "CHANGE_TERRITORY_OWNER") and ($enable_vtiger_integration > 0) ) + { + echo "
\n"; + echo ""; + + echo "
Vtiger Change Territory Owner\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + echo "
Territory:
New Owner:
Update ViciDial List Owner:
\n"; + } +### END change territory owner in the system + + +### BEGIN process change territory owner in the system +if ( ($action == "PROCESS_CHANGE_TERRITORY_OWNER") and ($enable_vtiger_integration > 0) ) + { + if ( (strlen($territory)<1) or (strlen($user)<1) ) + { + echo "ERROR: Territory and User must be filled in
\n"; + } + else + { + $stmt="SELECT count(*) from vicidial_user_territories where territory='$territory' and user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] < 1) + { + $stmt="INSERT INTO vicidial_user_territories SET territory='$territory',user='$user',level='TOP_AGENT';"; + $rslt=mysql_query($stmt, $link); + + $stmtB="UPDATE vicidial_user_territories SET level='STANDARD_AGENT' where territory='$territory' and user!='$user' and level='TOP_AGENT';"; + $rslt=mysql_query($stmtB, $link); + + echo "NOTICE: Had to add user territory: $user $territory
\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|$stmtB|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$USER', ip_address='$ip', event_section='TERRITORIES', event_type='ADD', record_id='$territory', event_code='ADMIN ADD USER TERRITORY', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + + $stmtV="SELECT id from vtiger_users where user_name='$user';"; + $rsltV=mysql_query($stmtV, $linkV); + if ($DB) {echo "$stmtV\n";} + $vtu_ct = mysql_num_rows($rsltV); + if ($vtu_ct > 0) + { + $row=mysql_fetch_row($rsltV); + $user_id = $row[0]; + + $stmtV="SELECT accountid from vtiger_account where tickersymbol='$territory';"; + $rsltV=mysql_query($stmtV, $linkV); + if ($DB) {echo "$stmtV\n";} + $vat_ct = mysql_num_rows($rsltV); + $account_ids[0]=''; + $p=0; + while ($vat_ct > $p) + { + $row=mysql_fetch_row($rsltV); + $account_ids[$p] = $row[0]; + $p++; + } + + $p=0; + while ($vat_ct > $p) + { + $stmt="UPDATE vtiger_crmentity SET smownerid='$user_id',smcreatorid='$user_id',modifiedby='$user_id' where crmid='$account_ids[$p]';"; + $rsltV=mysql_query($stmt, $linkV); + $changedX = mysql_affected_rows($linkV); + if ($DB) {echo "$stmt|$changedX\n";} + $changed = ($changed + $changedX); + + $stmtV="select activityid from vtiger_seactivityrel where crmid='$account_ids[$p]';"; + $rsltV=mysql_query($stmtV, $linkV); + if ($DB) {echo "$stmtV\n";} + $vact_ct = mysql_num_rows($rsltV); + $activity_ids[0]=''; + $r=0; + while ($vact_ct > $r) + { + $row=mysql_fetch_row($rsltV); + $activity_ids[$r] = $row[0]; + $r++; + } + + $r=0; + while ($vact_ct > $r) + { + $stmt="UPDATE vtiger_crmentity SET smownerid='$user_id' where crmid='$activity_ids[$r]';"; + $rsltV=mysql_query($stmt, $linkV); + $AchangedX = mysql_affected_rows($linkV); + if ($DB) {echo "$stmt|$AchangedX\n";} + $Achanged = ($Achanged + $AchangedX); + $r++; + } + + if ( ($vl_owner == 'YES') and ($account_ids[$p] > 0) ) + { + $stmtB="UPDATE vicidial_list SET owner='$user' where vendor_lead_code='$account_ids[$p]';"; + $rslt=mysql_query($stmtB, $link); + $VchangedX = mysql_affected_rows($link); + if ($DB) {echo "$stmtB|$VchangedX\n";} + $Vchanged = ($Vchanged + $VchangedX); + } + + $p++; + } + + + $stmt="UPDATE vtiger_crmentity SET smownerid='$user_id',smcreatorid='$user_id',modifiedby='$user_id' where crmid IN(SELECT accountid from vtiger_account where tickersymbol='$territory');"; + $rsltV=mysql_query($stmt, $linkV); + $Cchanged = mysql_affected_rows($linkV); + if ($DB) {echo "$stmt|$Cchanged\n";} + + $stmtB="UPDATE vtiger_tracker vt, vtiger_account va SET user_id='$user_id' where vt.item_id=va.accountid and va.tickersymbol='$territory';"; + $rsltV=mysql_query($stmtB, $linkV); + + echo "Vtiger Territory Owner Changed: $user $territory       Records Changed: $changed - $Achanged - $Cchanged - $Vchanged
\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|$stmtB|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$USER', ip_address='$ip', event_section='VTIGER', event_type='MODIFY', record_id='$territory', event_code='VTIGER MODIFY TERRITORY OWNER', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + $action = "MODIFY_TERRITORY"; + } +### END process change territory owner in the system + + + + + +### BEGIN add user territory page +if ($action == "ADD_USER_TERRITORY") + { + echo "
\n"; + echo ""; + + echo "
Add User Territory\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Agent:
Territory:
Level:
\n"; + } +### END add user territory page + + +### BEGIN process add user territory page +if ($action == "PROCESS_ADD_USER_TERRITORY") + { + if ( (strlen($territory)<1) or (strlen($user)<1) or (strlen($level)<1) ) + { + echo "ERROR: Territory, User and Level must be filled in
\n"; + } + else + { + $stmt="SELECT count(*) from vicidial_user_territories where territory='$territory' and user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + { + echo "ERROR: this territory user is already in the system
\n"; + } + else + { + $stmt="INSERT INTO vicidial_user_territories SET territory='$territory',user='$user',level='$level';"; + $rslt=mysql_query($stmt, $link); + + if ($level == "TOP_AGENT") + { + $stmtB="UPDATE vicidial_user_territories SET level='STANDARD_AGENT' where territory='$territory' and user!='$user' and level='TOP_AGENT';"; + $rslt=mysql_query($stmtB, $link); + } + + echo "User Territory Added: $user $territory
\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|$stmtB|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$USER', ip_address='$ip', event_section='TERRITORIES', event_type='ADD', record_id='$territory', event_code='ADMIN ADD USER TERRITORY', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + $action = "MODIFY_TERRITORY"; + } +### END process add user territory page + + +### BEGIN process modify user territory page +if ($action == "PROCESS_MODIFY_USER_TERRITORY") + { + if ( (strlen($territory)<1) or (strlen($user)<1) or (strlen($level)<1) ) + { + echo "ERROR: Territory, User and Level must be filled in
\n"; + } + else + { + $stmt="SELECT count(*) from vicidial_user_territories where territory='$territory' and user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] < 0) + { + echo "ERROR: this territory user is not in the system
\n"; + } + else + { + $stmt="UPDATE vicidial_user_territories SET level='$level' where territory='$territory' and user='$user';"; + $rslt=mysql_query($stmt, $link); + + if ($level == "TOP_AGENT") + { + $stmtB="UPDATE vicidial_user_territories SET level='STANDARD_AGENT' where territory='$territory' and user!='$user' and level='TOP_AGENT';"; + $rslt=mysql_query($stmtB, $link); + } + + echo "User Territory Modified: $user $territory
\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|$stmtB|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$USER', ip_address='$ip', event_section='TERRITORIES', event_type='MODIFY', record_id='$territory', event_code='ADMIN MODIFY USER TERRITORY', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + $action = "MODIFY_TERRITORY"; + } +### END process modify user territory page + + +### BEGIN delete user territory page +if ($action == "DELETE_USER_TERRITORY") + { + if ( (strlen($territory)<1) or (strlen($user)<1) ) + { + echo "ERROR: Territory and User must be filled in
\n"; + } + else + { + $stmt="SELECT count(*) from vicidial_user_territories where territory='$territory' and user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] < 0) + { + echo "ERROR: this territory user is not in the system
\n"; + } + else + { + $stmt="DELETE from vicidial_user_territories where territory='$territory' and user='$user';"; + $rslt=mysql_query($stmt, $link); + + echo "User Territory Deleted: $user $territory
\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|$stmtB|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$USER', ip_address='$ip', event_section='TERRITORIES', event_type='DELETE', record_id='$territory', event_code='ADMIN DELETE USER TERRITORY', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + $action = "MODIFY_TERRITORY"; + } +### END delete user territory page + + + + + + +### BEGIN add territory page +if ($action == "ADD_TERRITORY") + { + echo "\n"; echo "\n"; +echo "
\n"; + echo ""; + + echo "
Add Territory\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Territory:
Territory Description:
\n"; + } +### END add territory page + + +### BEGIN process add territory page +if ($action == "PROCESS_ADD_TERRITORY") + { + if ( (strlen($territory)<1) or (strlen($territory_description)<1) ) + { + echo "ERROR: Territory and Territory Description must be filled in
\n"; + } + else + { + $stmt="SELECT count(*) from vicidial_territories where territory='$territory';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + { + echo "ERROR: there is already a territory in the system with this name
\n"; + } + else + { + $stmt="INSERT INTO vicidial_territories SET territory='$territory',territory_description='$territory_description';"; + $rslt=mysql_query($stmt, $link); + + echo "Territory Added: $territory
\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$USER', ip_address='$ip', event_section='TERRITORIES', event_type='ADD', record_id='$territory', event_code='ADMIN ADD TERRITORY', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + $action = "LIST_ALL_TERRITORIES"; + } +### END process add territory page + + +### BEGIN delete territory page +if ($action == "DELETE_TERRITORY") + { + if (strlen($territory)<1) + { + echo "ERROR: Territory must be filled in
\n"; + } + else + { + $stmt="SELECT count(*) from vicidial_territories where territory='$territory';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] < 0) + { + echo "ERROR: This territory is not in the system with this name
\n"; + } + else + { + $stmt="DELETE from vicidial_territories where territory='$territory';"; + $rslt=mysql_query($stmt, $link); + + echo "Territory Deleted: $territory
\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$USER', ip_address='$ip', event_section='TERRITORIES', event_type='DELETE', record_id='$territory', event_code='ADMIN DELETE TERRITORY', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + $action = "LIST_ALL_TERRITORIES"; + } +### END delete territory page + + +### BEGIN process modify territory page +if ($action == "PROCESS_MODIFY_TERRITORY") + { + if ( (strlen($territory)<1) or (strlen($territory_description)<1) ) + { + echo "ERROR: Territory and Territory Description must be filled in
\n"; + } + else + { + $stmt="SELECT count(*) from vicidial_territories where territory='$territory';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] < 1) + { + echo "ERROR: This territory is not in the system with this name
\n"; + } + else + { + $stmt="UPDATE vicidial_territories SET territory_description='$territory_description' where territory='$territory';"; + $rslt=mysql_query($stmt, $link); + + echo "Territory Modified: $territory
\n"; + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$USER', ip_address='$ip', event_section='TERRITORIES', event_type='MODIFY', record_id='$territory', event_code='ADMIN MODIFY TERRITORY', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + $action = "MODIFY_TERRITORY"; + } +### END process modify territory page + + +### BEGIN modify territory page +if ($action == "MODIFY_TERRITORY") + { + $stmt="SELECT territory,territory_description from vicidial_territories where territory='$territory';"; + $rslt=mysql_query($stmt, $link); + $territories_to_print = mysql_num_rows($rslt); + if ($territories_to_print > 0) + { + $rowx=mysql_fetch_row($rslt); + + echo "\n"; echo "\n"; +echo "
\n"; + echo ""; + + echo "
Modify Territory\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + + $stmt = "SELECT count(*) FROM vicidial_user_territories where territory='$territory';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $vut_ct = mysql_num_rows($rslt); + if ($vut_ct > 0) + { + $row=mysql_fetch_row($rslt); + $user_count = $row[0]; + } + echo ""; + + $owner_count=0; + $stmt = "SELECT count(*) FROM vicidial_list where owner='$territory';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VLo_ct = mysql_num_rows($rslt); + if ($VLo_ct > 0) + { + $row=mysql_fetch_row($rslt); + $owner_count = $row[0]; + } + echo ""; + + if ($enable_vtiger_integration > 0) + { + $stmtV = "SELECT count(*) FROM vtiger_account where tickersymbol='$territory';"; + $rsltV=mysql_query($stmtV, $linkV); + if ($DB) {echo "$stmtV\n";} + $vta_ct = mysql_num_rows($rsltV); + if ($vta_ct > 0) + { + $row=mysql_fetch_row($rsltV); + $vtiger_count = $row[0]; + } + echo ""; + } + echo "\n"; + echo "
Territory: $rowx[0]
Territory Description:
Agents: $user_count
Accounts: $owner_count
Vtiger Accounts: $vtiger_count
\n"; + echo "

\n"; + + echo "\n"; + + $stmt="SELECT vut.user,level,full_name from vicidial_user_territories vut,vicidial_users vu where vut.territory='$territory' and vut.user=vu.user order by vu.user;"; + $rslt=mysql_query($stmt, $link); + $territories_to_print = mysql_num_rows($rslt); + $o=0; + while ($territories_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $Tuser[$o] = $rowx[0]; + $Tlevel[$o] = $rowx[1]; + $Tfull_name[$o] = $rowx[2]; + $o++; + } + $o=0; + while ($territories_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $p++; + + if (eregi("1$|3$|5$|7$|9$", $p)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + if ($enable_vtiger_integration > 0) + { + $stmtV="SELECT id from vtiger_users where user_name='$Tuser[$o]';"; + $rsltV=mysql_query($stmtV, $linkV); + if ($DB) {echo "$stmtV\n";} + $vtu_ct = mysql_num_rows($rsltV); + if ($vtu_ct > 0) + { + $row=mysql_fetch_row($rsltV); + $user_id = $row[0]; + + $stmtV = "SELECT count(*) FROM vtiger_account where tickersymbol='$territory' and accountid IN(SELECT crmid from vtiger_crmentity where smownerid='$user_id');"; + $rsltV=mysql_query($stmtV, $linkV); + if ($DB) {echo "$stmtV\n";} + $vca_ct = mysql_num_rows($rsltV); + if ($vca_ct > 0) + { + $row=mysql_fetch_row($rsltV); + echo ""; + } + } + } + + # $owner_count=0; + # $stmt = "SELECT count(*) FROM vicidial_list where owner='$territory';"; + # $rslt=mysql_query($stmt, $link); + # if ($DB) {echo "$stmt\n";} + # $VLo_ct = mysql_num_rows($rslt); + # if ($VLo_ct > 0) + # { + # $row=mysql_fetch_row($rslt); + # $owner_count = $row[0]; + # } + # echo ""; + + echo ""; + echo ""; + echo "\n"; + $o++; + } + + echo "
Users in this Territory:
$p$Tuser[$o]$Tfull_name[$o]VT Accounts: $row[0]Accounts: $owner_count"; + echo "
"; + echo ""; + echo ""; + echo ""; + echo " "; + echo ""; + echo "
"; + echo "
DELETE
\n"; + echo "


\n"; + + echo "Delete This Territory\n"; + echo "

\n"; + } + else + { + echo "ERROR: Territory not found: $territory
\n"; + } + } +### END modify territory page + + + + + +### BEGIN list all territories in the system +if ($action == "LIST_ALL_TERRITORIES") + { + echo " +
\n"; + echo ""; + echo "
List All Territories:\n"; + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + if ($enable_vtiger_integration > 0) + { + echo "\n"; + } + echo "\n"; + + $stmt = "SELECT territory_id,territory,territory_description FROM vicidial_territories order by territory;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $vt_ct = mysql_num_rows($rslt); + $i=0; + while ($vt_ct > $i) + { + $row=mysql_fetch_row($rslt); + $Lterritory_id[$i] = $row[0]; + $Lterritory[$i] = $row[1]; + $Lterritory_description[$i] = $row[2]; + $i++; + } + $i=0; + while ($vt_ct > $i) + { + $stmt = "SELECT count(*) FROM vicidial_user_territories where territory='$Lterritory[$i]';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $vut_ct = mysql_num_rows($rslt); + if ($vut_ct > 0) + { + $row=mysql_fetch_row($rslt); + $Lterritory_count[$i] = $row[0]; + } + + $stmt = "SELECT count(*) FROM vicidial_list where owner='$Lterritory[$i]';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VLo_ct = mysql_num_rows($rslt); + if ($VLo_ct > 0) + { + $row=mysql_fetch_row($rslt); + $Lterritory_owner_count[$i] = $row[0]; + } + + if ($enable_vtiger_integration > 0) + { + $stmtV = "SELECT count(*) FROM vtiger_account where tickersymbol='$Lterritory[$i]';"; + $rsltV=mysql_query($stmtV, $linkV); + if ($DB) {echo "$stmtV\n";} + $va_ct = mysql_num_rows($rsltV); + if ($va_ct > 0) + { + $row=mysql_fetch_row($rsltV); + $Lvtiger_count[$i] = $row[0]; + } + } + + if (eregi("1$|3$|5$|7$|9$", $i)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + if ($enable_vtiger_integration > 0) + { + echo ""; + } + echo "\n"; + + $i++; + } + echo "
#IDTERRITORYDESCRIPTIONAGENTSACCOUNTSVT ACCOUNTS
$i $Lterritory_id[$i] $Lterritory[$i] $Lterritory_description[$i] $Lterritory_count[$i] $Lterritory_owner_count[$i] $Lvtiger_count[$i]


\n"; + echo "\n"; + echo "
\n"; + } +### END list all territories in the system + + + + + + + + +?> + + + +
User Territories     VERSION:     BUILD:    
diff --git a/LANG_www/vicidial_br/vdremote.php b/LANG_www/vicidial_br/vdremote.php new file mode 100644 index 00000000..21bbc65d --- /dev/null +++ b/LANG_www/vicidial_br/vdremote.php @@ -0,0 +1,591 @@ + LICENSE: AGPLv2 +# +# Changes +# 50307-1721 - First version +# 51123-1502 - removed requirement of PHP Globals=on +# 60421-1229 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60619-1603 - Added variable filtering to eliminate SQL injection attack threat +# 90508-0644 - Changed to PHP long tags +# 91129-2249 - Replaced SELECT STAR in SQL queries, formatting fixes +# + +$version = '2.2.0'; +$build = '91129-2249'; + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["ADD"])) {$ADD=$_GET["ADD"];} + elseif (isset($_POST["ADD"])) {$ADD=$_POST["ADD"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["force_logout"])) {$force_logout=$_GET["force_logout"];} + elseif (isset($_POST["force_logout"])) {$force_logout=$_POST["force_logout"];} +if (isset($_GET["groups"])) {$groups=$_GET["groups"];} + elseif (isset($_POST["groups"])) {$groups=$_POST["groups"];} +if (isset($_GET["remote_agent_id"])) {$remote_agent_id=$_GET["remote_agent_id"];} + elseif (isset($_POST["remote_agent_id"])) {$remote_agent_id=$_POST["remote_agent_id"];} +if (isset($_GET["user_start"])) {$user_start=$_GET["user_start"];} + elseif (isset($_POST["user_start"])) {$user_start=$_POST["user_start"];} +if (isset($_GET["number_of_lines"])) {$number_of_lines=$_GET["number_of_lines"];} + elseif (isset($_POST["number_of_lines"])) {$number_of_lines=$_POST["number_of_lines"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["groups"])) {$groups=$_GET["groups"];} + elseif (isset($_POST["groups"])) {$groups=$_POST["groups"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} + +if (!isset($force_logout)) {$force_logout = 0;} + +if ($force_logout) + { + if( (strlen($PHP_AUTH_USER)>0) or (strlen($PHP_AUTH_PW)>0) ) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + } + echo "Voce efetuou logout. Obrigado\n"; + exit; + } + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + +$popup_page = './closer_popup.php'; +$STARTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 3;"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + +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 "Nome ou Senha inválidos: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } +else + { + header ("Content-type: text/html; charset=utf-8"); + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + + $stmt="SELECT count(*) from vicidial_remote_agents where user_start='$PHP_AUTH_USER';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $authx=$row[0]; + + if($authx>0) + { + $stmt="SELECT remote_agent_id,server_ip,number_of_lines from vicidial_remote_agents where user_start='$PHP_AUTH_USER';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $remote_agent_id=$row[0]; + $server_ip=$row[1]; + if (!$number_of_lines) {$number_of_lines=$row[2];} + + fwrite ($fp, "VDremote|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VDremote|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + echo "This remote agent does not exist: |$PHP_AUTH_USER|\n"; + exit; + } + } + else + { + fwrite ($fp, "VDremote|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +echo "\n"; +echo "\n"; +echo "\n"; +if ($ADD==61111) + { + echo"\n"; + } +echo "\n"; +?> + +AGENTES REMOTOS: $LOGfullname - $PHP_AUTH_USER "; + +if (!$ADD) {$ADD="31111";} +if ($ADD==31111) {echo "Alterar Agentes Remotos";} +if ($ADD==41111) {echo "Alterar Agentes Remotos";} +if ($ADD==61111) {echo "Remote Agent Status";} +if ($ADD==71111) {echo "Remote Agent Closer Stats";} + + +if (strlen($ADD)>4) + { + ##### get server listing for dynamic pulldown + $stmt="SELECT server_ip,server_description from servers order by server_ip"; + $rslt=mysql_query($stmt, $link); + $servers_to_print = mysql_num_rows($rslt); + $servers_list=''; + + $o=0; + while ($servers_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $servers_list .= "\n"; + $o++; + } + + ##### get campaigns listing for dynamic pulldown + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $campaigns_to_print = mysql_num_rows($rslt); + $campaigns_list=''; + + $o=0; + while ($campaigns_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $campaigns_list .= "\n"; + $o++; + } + + ##### get inbound groups listing for checkboxes + if ( (($ADD==31111) or ($ADD==31111)) and (count($groups)<1) ) + { + $stmt="SELECT closer_campaigns from vicidial_remote_agents where remote_agent_id='" . mysql_real_escape_string($remote_agent_id) . "';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $closer_campaigns = $row[0]; + $closer_campaigns = preg_replace("/ -$/","",$closer_campaigns); + $groups = explode(" ", $closer_campaigns); + } + + $stmt="SELECT group_id,group_name from vicidial_inbound_groups order by group_id"; + $rslt=mysql_query($stmt, $link); + $groups_to_print = mysql_num_rows($rslt); + $groups_list=''; + $groups_value=''; + + $o=0; + while ($groups_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $group_id_value = $rowx[0]; + $group_name_value = $rowx[1]; + $groups_list .= "2) {$groups_value .= " -";} + } + +?> + + + +
+ + + + +
  AGENTES REMOTOS:   Sair  
  ALTERAR | ">STATUS | ">ESTATÍSTICAS DE ENTRADA
+"; + + $stmt="SELECT remote_agent_id,user_start,number_of_lines,server_ip,conf_exten,status,campaign_id,closer_campaigns from vicidial_remote_agents where remote_agent_id='" . mysql_real_escape_string($remote_agent_id) . "';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $remote_agent_id = $row[0]; + $user_start = $row[1]; + $number_of_lines = $row[2]; + $server_ip = $row[3]; + $conf_exten = $row[4]; + $status = $row[5]; + $campaign_id = $row[6]; + + echo "
ALTERAR AGENTES REMOTOS: $row[0]
\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Início do ID do Usuário: $user_start
Número de linhas: (somente números)
IP do Servidor: $row[3]
Extensão Externa: (number dialed to reach agents [i.e. 913125551212])
Status:
Campanha: $campaign_id
Grupos de Entrada: \n"; + echo "$groups_list"; + echo "
\n"; + echo "AVISO: Pode demorar até 30 segundos para que as alterações enviadas por essa tela se tornem ativas\n"; + } + + + +###################### +# ADD=41111 modify remote agents info in the system +###################### + +if ($ADD==41111) + { + echo ""; + + if ( (strlen($number_of_lines) < 1) or (strlen($conf_exten) < 2) ) + {echo "
AGENTES REMOTOS NÃO ALTERADOS - Por favor volte e verifique os dados digitados\n";} + else + { + $stmt="UPDATE vicidial_remote_agents set number_of_lines='" . mysql_real_escape_string($number_of_lines) . "', conf_exten='" . mysql_real_escape_string($conf_exten) . "', status='" . mysql_real_escape_string($status) . "', closer_campaigns='" . mysql_real_escape_string($groups_value) . "' where remote_agent_id='" . mysql_real_escape_string($remote_agent_id) . "';"; + $rslt=mysql_query($stmt, $link); + +# echo "$stmt\n"; + echo "
AGENTES REMOTOS ALTERADOS\n"; + + ### LOG CHANGES TO LOG FILE ### + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY AGENTES REMOTOS ENTRY |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + + $stmt="SELECT remote_agent_id,user_start,number_of_lines,server_ip,conf_exten,status,campaign_id,closer_campaigns from vicidial_remote_agents where remote_agent_id='" . mysql_real_escape_string($remote_agent_id) . "';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $remote_agent_id = $row[0]; + $user_start = $row[1]; + $number_of_lines = $row[2]; + $server_ip = $row[3]; + $conf_exten = $row[4]; + $status = $row[5]; + $campaign_id = $row[6]; + + echo "
ALTERAR AGENTES REMOTOS: $row[0]\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Início do ID do Usuário: $user_start
Número de linhas: (somente números)
IP do Servidor: $row[3]
Extensão Externa: (number dialed to reach agents [i.e. 913125551212])
Status:
Campanha: $campaign_id
Grupos de Entrada: \n"; + echo "$groups_list"; + echo "
\n"; + echo "AVISO: Pode demorar até 30 segundos para que as alterações enviadas por essa tela se tornem ativas\n"; + } + + + +###################### +# ADD=61111 status of remote agent in the system and active calls and queue +###################### + +if ($ADD==61111) + { + echo "
";
+
+	if ( (strlen($server_ip) < 2) or (strlen($user) < 2) )
+		{echo "
ERRO DE AGENTES REMOTOS – Por favor volte e verifique os dados digitados \n";} + else + { + $users_list = ''; + $k=0; + while($k < $number_of_lines) + { + $nextuser=($user + $k); + $users_list .= "'" . mysql_real_escape_string($nextuser) . "',"; + $k++; + } + $users_list = preg_replace("/.$/","",$users_list); + + echo "Remote Agent Time On Calls $NOW_TIME\n\n"; + echo "+------------|--------+--------------+------------+--------+---------------------+---------+\n"; + echo "| STATION | USER | LEADID | CHANNEL | STATUS | START TIME | MINUTES |\n"; + echo "+------------|--------+--------------+------------+--------+---------------------+---------+\n"; + + + $stmt="select extension,user,lead_id,channel,status,last_call_time,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish) from vicidial_live_agents where status NOT IN('PAUSED') and server_ip='" . mysql_real_escape_string($server_ip) . "' and user IN($users_list) order by extension;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $talking_to_print = mysql_num_rows($rslt); + if ($talking_to_print > 0) + { + $i=0; + while ($i < $talking_to_print) + { + $leadlink=0; + $row=mysql_fetch_row($rslt); + if (eregi("READY|PAUSED",$row[4])) + { + $row[3]=''; + $row[5]='- AGUARDANDO -'; + $row[6]=$row[7]; + } + $extension = sprintf("%-10s", $row[0]); + $user = sprintf("%-6s", $row[1]); + $leadid = sprintf("%-12s", $row[2]); + if ($row[2] > 0) + { + $leadidLINK=$row[2]; + $leadlink++; + if ( eregi("QUEUE",$row[4]) ) {$row[6]=$STARTtime;} + $leadid = "$leadid"; + } + $channel = sprintf("%-10s", $row[3]); + $cc=0; + while ( (strlen($channel) > 10) and ($cc < 100) ) + { + $channel = eregi_replace(".$","",$channel); + $cc++; + if (strlen($channel) <= 10) {$cc=101;} + } + $status = sprintf("%-6s", $row[4]); + $start_time = sprintf("%-19s", $row[5]); + $call_time_S = ($STARTtime - $row[6]); + + $call_time_M = ($call_time_S / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $call_time_MS = sprintf("%7s", $call_time_MS); + $G = ''; $EG = ''; + if ($call_time_M_int >= 5) {$G=''; $EG='';} + if ($call_time_M_int >= 10) {$G=''; $EG='';} + + echo "| $G$extension$EG | $G$user$EG | $G$leadid$EG | $G$channel$EG | $G$status$EG | $G$start_time$EG | $G$call_time_MS$EG |\n"; + + $i++; + } + + echo "+------------|--------+--------------+------------+--------+---------------------+---------+\n"; + echo " $i agentes conectados ao servidor $server_ip\n\n"; + + echo " - Acima de 5 minutos em chamada\n"; + echo " - Acima de 10 minutos em chamada\n"; + } + else + { + echo "**************************************************************************************\n"; + echo "*********************************AGENTES SEM CHAMADAS*********************************\n"; + echo "**************************************************************************************\n"; + } + } + + echo "
\n\n"; + } + + +###################### +# ADD=71111 stats for remote agents from closer logs(vicidial_closer_log) +###################### + +if ($ADD==71111) + { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n\n"; + echo "
";
+
+	if ( (strlen($server_ip) < 2) or (strlen($user) < 2) )
+		{echo "
ERRO DE AGENTES REMOTOS – Por favor volte e verifique os dados digitados \n";} + else + { + $users_list = ''; + $k=0; + while($k < $number_of_lines) + { + $nextuser=($user + $k); + $users_list .= "'$nextuser',"; + $k++; + } + $users_list = preg_replace("/.$/","",$users_list); + + $stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and user IN($users_list);"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $in_calls = $row[0]; + $in_time = $row[1]; + $in_time_M = ($in_time / 60); + $in_time_M = round($in_time_M, 2); + $in_time_M_int = intval("$in_time_M"); + $in_time_SEC = ($in_time_M - $in_time_M_int); + $in_time_SEC = ($in_time_SEC * 60); + $in_time_SEC = round($in_time_SEC, 0); + if ($in_time_SEC < 10) {$in_time_SEC = "0$in_time_SEC";} + $in_time_MS = "$in_time_M_int:$in_time_SEC"; + $in_time_MS = sprintf("%7s", $in_time_MS); + + echo "Estatísticas de entrada para Agentes Remotos $NOW_TIME\n\n"; + echo "\n"; + echo "Chamadas totais atendidas $query_date: $in_calls\n"; + echo "Tempo total de conversação $query_date: $in_time_MS (minutes:seconds)\n"; + echo "\n"; + echo "\n"; + echo "Lista de chamadas para $query_date:\n"; + echo "+----------+------------+----------------+------------+--------+---------------------+---------+\n"; + echo "| USER | LEADID | GROUP | PHONE NUM | STATUS | CALL TIME | MINUTES |\n"; + echo "+----------+------------+----------------+------------+--------+---------------------+---------+\n"; + + + $stmt="select user,lead_id,campaign_id,phone_number,status,call_date,length_in_sec from vicidial_closer_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and user IN($users_list) order by call_date;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $talking_to_print = mysql_num_rows($rslt); + if ($talking_to_print > 0) + { + $i=0; + while ($i < $talking_to_print) + { + $row=mysql_fetch_row($rslt); + $user = sprintf("%-8s", $row[0]); + $leadid = sprintf("%-10s", $row[1]); + $group = sprintf("%-14s", $row[2]); + $phone = sprintf("%-10s", $row[3]); + $status = sprintf("%-6s", $row[4]); + $start_time = sprintf("%-19s", $row[5]); + $call_time_S = $row[6]; + + $call_time_M = ($call_time_S / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $call_time_MS = sprintf("%7s", $call_time_MS); + $G = ''; $EG = ''; + # if ($call_time_M_int >= 5) {$G=''; $EG='';} + # if ($call_time_M_int >= 10) {$G=''; $EG='';} + + echo "| $G$user$EG | $G$leadid$EG | $G$group$EG | $G$phone$EG | $G$status$EG | $G$start_time$EG | $G$call_time_MS$EG |\n"; + + $i++; + } + + echo "+----------+------------+----------------+------------+--------+---------------------+---------+\n"; +# echo " $i agents logged in on server $server_ip\n\n"; + +# echo " - 5 minutes or more on call\n"; +# echo " - Over 10 minutes on call\n"; + } + else + { + echo "**************************************************************************************\n"; + echo "*********************************NENHUMA CHAMADA HOJE*******************************\n"; + echo "**************************************************************************************\n"; + } + } + + echo "
\n\n"; + } + + + + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nScript runtime: $RUNtime seconds
"; + + +?> + + +
+ + + + + diff --git a/LANG_www/vicidial_br/vicidial_admin_web_logo.gif b/LANG_www/vicidial_br/vicidial_admin_web_logo.gif new file mode 100644 index 00000000..8c5a9d22 Binary files /dev/null and b/LANG_www/vicidial_br/vicidial_admin_web_logo.gif differ diff --git a/LANG_www/vicidial_br/vicidial_admin_web_logo_small.gif b/LANG_www/vicidial_br/vicidial_admin_web_logo_small.gif new file mode 100644 index 00000000..95738d49 Binary files /dev/null and b/LANG_www/vicidial_br/vicidial_admin_web_logo_small.gif differ diff --git a/LANG_www/vicidial_br/vicidial_sales_viewer.php b/LANG_www/vicidial_br/vicidial_sales_viewer.php new file mode 100644 index 00000000..2ffcb03b --- /dev/null +++ b/LANG_www/vicidial_br/vicidial_sales_viewer.php @@ -0,0 +1,258 @@ + LICENSE: AGPLv2 +# +# CHANGES +# 80310-1500 - first build +# 90310-2135 - Added admin header +# 90508-0644 - Changed to PHP long tags +# + +if (isset($_GET["dcampaign"])) {$dcampaign=$_GET["dcampaign"];} + elseif (isset($_POST["dcampaign"])) {$dcampaign=$_POST["dcampaign"];} +if (isset($_GET["submit_report"])) {$submit_report=$_GET["submit_report"];} + elseif (isset($_POST["submit_report"])) {$submit_report=$_POST["submit_report"];} +if (isset($_GET["list_ids"])) {$list_ids=$_GET["list_ids"];} + elseif (isset($_POST["list_ids"])) {$list_ids=$_POST["list_ids"];} +if (isset($_GET["sales_number"])) {$sales_number=$_GET["sales_number"];} + elseif (isset($_POST["sales_number"])) {$sales_number=$_POST["sales_number"];} +if (isset($_GET["sales_time_frame"])) {$sales_time_frame=$_GET["sales_time_frame"];} + elseif (isset($_POST["sales_time_frame"])) {$sales_time_frame=$_POST["sales_time_frame"];} +if (isset($_GET["forc"])) {$forc=$_GET["forc"];} + elseif (isset($_POST["forc"])) {$forc=$_POST["forc"];} + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; + +$PHP_AUTH_PW = ereg_replace("'|\"|\\\\|;","",$PHP_AUTH_PW); +$PHP_AUTH_USER = ereg_replace("'|\"|\\\\|;","",$PHP_AUTH_USER); + +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7 and view_reports='1';"; +if ($DB) {echo "|$stmt|\n";} +$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 "Nome ou Senha inválidos or no export report permission: |$PHP_AUTH_USER|\n"; + exit; + } + + +?> + + +Recent Sales Lookup + + + + + +
"; +?> + +
+ + + + + + + + + + + + + + + + + + + + + +
Vicidial SAINTE recent sales report               Back to Admin +
+ + + + + + + + + + +
Select a campaign:
Select list ID(s) # (optional):
+
View sales made within the last OR...View the last sales**
(If you enter values in both fields, the results will be limited by the first criteria met)
Campanha is:    Transfer  Non-transfer
** - sorted by call date
+
+0)) { $list_id_clause.="$lists[$i], "; } + } + $list_id_clause=substr($list_id_clause, 0, -2); + $list_id_clause.=")"; + + if ($sales_number && $sales_number>0) { + $sales_number=eregi_replace("[^0-9]", "", $sales_number); + $limit_clause="limit $sales_number"; + } else { + $sales_number=0; + $limit_clause=""; + } + if ($sales_time_frame && $sales_time_frame>0) { + $hours=$sales_time_frame/60; + $timestamp=date("YmdHis", mktime(date("H"),(date("i")-$sales_time_frame),date("s"),date("m"),date("d"),date("Y"))); + } else { + $timestamp=date("YmdHis", mktime(date("H"),date("i"),date("s"),date("m"),(date("d")-1),date("Y"))); + $hours=24; + } + print "
"; + print ""; + $i=0; + + $dfile=fopen("discover_stmts.txt", "w"); + if ($forc=="C") { + $stmt="select v.first_name, v.last_name, v.phone_number, vl.call_date, v.lead_id, u.full_name from vicidial_users u, vicidial_list v, vicidial_log vl where vl.call_date>='$timestamp' and vl.lead_id=v.lead_id and v.status='SALE' $list_id_clause and vl.user=u.user order by call_date desc $limit_clause"; + } else { + $stmt="select v.first_name, v.last_name, v.phone_number, vl.call_date, v.lead_id, vl.user, vl.closer from vicidial_list v, vicidial_xfer_log vl where vl.call_date>='$timestamp' and vl.lead_id=v.lead_id and v.status='SALE' $list_id_clause order by call_date desc $limit_clause"; + } + fwrite($dfile, "$stmt\n"); + $rslt=mysql_query($stmt, $link); + $q=0; + print "\n"; + print "\n"; + print "\t\n"; + print "\t\n"; + print "\t\n"; + print "\t\n"; + print "\t\n"; + print "\n"; + while ($row=mysql_fetch_row($rslt)) { + $rec_stmt="select max(recording_id) from recording_log where lead_id='$row[4]'"; + $rec_rslt=mysql_query($rec_stmt, $link); + $rec_row=mysql_fetch_row($rec_rslt); + + if ($forc=="F") { + $rep_stmt="select full_name from vicidial_users where user='$row[5]'"; + $rep_rslt=mysql_query($rep_stmt, $link); + $fr_row=mysql_fetch_array($rep_rslt); + + $rep_stmt="select full_name from vicidial_users where user='$row[6]'"; + $rep_rslt=mysql_query($rep_stmt, $link); + $cl_row=mysql_fetch_array($rep_rslt); + + $rep_name="$fr_row[full_name]/$cl_row[full_name]"; + } else { + $rep_name=$row[5]; + } + + if ($i%2==0) {$bgcolor="#999999";} else {$bgcolor="#CCCCCC";} + print "\n"; + print "\t\n"; + print "\t\n"; + print "\t\n"; + print "\t\n"; + print "\t\n"; + print "\n"; + flush(); + } + print "
Last ".mysql_num_rows($rslt)." sales made
Sales Rep(s)Customer NamePhoneRecording IDTimestamp
$rep_name$row[0] $row[1]$row[2]$rec_row[0]$row[3]
"; + passthru("$WeBServeRRooT/vicidial/spreadsheet_sales_viewer.pl $list_ids $sales_number $timestamp $forc $now $dcampaign"); +# print "\n\n
$WeBServeRRooT/vicidial/spreadsheet_sales_viewer.pl $list_ids $sales_number $timestamp $forc $now $dcampaign
\n"; + flush(); + print ""; + if ($forc=="F") { + print ""; + } + print ""; + print "
View complete Excel fronter report for this shiftView complete Excel sales report for this shift
"; +} +?> + +
+ + + + diff --git a/LANG_www/vicidial_br/vtiger_search.php b/LANG_www/vicidial_br/vtiger_search.php new file mode 100644 index 00000000..6636a431 --- /dev/null +++ b/LANG_www/vicidial_br/vtiger_search.php @@ -0,0 +1,885 @@ + LICENSE: AGPLv2 +# +# This page does a search against a standard vtiger CRM system. If the record +# is not present, it will create a new one and send the agent's screen to that new page. +# +# This code is tested against vtiger 5.0.4 and 5.1.0 +# +# CHANGES +# 60719-1615 - First version +# 60801-2304 - Added mysql debug and auto-forward +# 60802-1111 - Added insertion of not-found record into vtiger system +# 71220-0000 - Modified by I. Taushanov for VTiger 5.03- search/create lead +# 80120-1934 - Added changes for compatibility with vtiger 5.0.3 +# 81229-1017 - Added usage of system_settings connection settings for vtiger database +# 81229-1441 - Added options for searching by ACCTID, ACCOUNT, VENDOR and LEAD +# 90111-1451 - Added logging of call as activity for account/lead +# 90112-0336 - Added create call and create lead options +# 90323-2104 - Added deleted account/lead check and reactivation from campaign option +# 91228-1751 - Added UNIFIED_CONTACT search option +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];} + elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];} +if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["channel_group"])) {$channel_group=$_GET["channel_group"];} + elseif (isset($_POST["channel_group"])) {$channel_group=$_POST["channel_group"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["customer_zap_channel"])) {$customer_zap_channel=$_GET["customer_zap_channel"];} + elseif (isset($_POST["customer_zap_channel"])) {$customer_zap_channel=$_POST["customer_zap_channel"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];} + elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];} + elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];} + elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["security"])) {$security=$_GET["security"];} + elseif (isset($_POST["security"])) {$security=$_POST["security"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];} + elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];} + elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} + elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} +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"];} + +#$DB = '1'; # DEBUG override +$US = '_'; +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$HHMMnow = date("H:i"); +$minute_old = mktime(date("H"), date("i")+5, date("s"), date("m"), date("d"), date("Y")); +$HHMMend = date("H:i",$minute_old); +$NOW_TIME = date("Y-m-d H:i:s"); +$REC_TIME = date("Ymd-His"); +$FILE_datetime = $STARTtime; +$parked_time = $STARTtime; + +############################################################### +##### START SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP ##### +$stmt = "SELECT enable_vtiger_integration,vtiger_server_ip,vtiger_dbname,vtiger_login,vtiger_pass,vtiger_url FROM system_settings;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$ss_conf_ct = mysql_num_rows($rslt); +if ($ss_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $enable_vtiger_integration = $row[0]; + $vtiger_server_ip = $row[1]; + $vtiger_dbname = $row[2]; + $vtiger_login = $row[3]; + $vtiger_pass = $row[4]; + $vtiger_url = $row[5]; + } +##### END SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP ##### +############################################################# + + +echo "\n"; +echo "\n"; +echo "VICIDIAL Vtiger Lookup\n"; +echo "\n"; + + +if ($enable_vtiger_integration < 1) + { + echo "ERROR! - Vtiger integration is disabled in the VICIDIAL system_settings"; + exit; + } + +$stmt = "SELECT vtiger_search_category,vtiger_create_call_record,vtiger_create_lead_record,vtiger_search_dead FROM vicidial_campaigns where campaign_id='$campaign';"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$vtc_conf_ct = mysql_num_rows($rslt); +if ($vtc_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $vtiger_search_category = $row[0]; + $vtiger_create_call_record = $row[1]; + $vtiger_create_lead_record = $row[2]; + $vtiger_search_dead = $row[3]; + } +if (strlen($vtiger_search_category)<1) + {$vtiger_search_category = 'LEAD';} + +### connect to your vtiger database +$linkV=mysql_connect("$vtiger_server_ip", "$vtiger_login","$vtiger_pass"); +if (!$linkV) {die("Could not connect: $vtiger_server_ip|$vtiger_dbname|$vtiger_login|$vtiger_pass" . mysql_error());} +echo 'Connected successfully'; +mysql_select_db("$vtiger_dbname", $linkV); + +# Methods of searching for records: +# +# ACCTID: +# $stmt="SELECT count(*) from vtiger_account where accountid='$vendor_id';"; +# +# ACCOUNT: +# $stmt="SELECT count(*) from vtiger_account where phone='$phone' or otherphone='$phone' or fax='$phone';"; +# $stmt="SELECT count(*) from vtiger_contactdetails where phone='$phone' or mobile='$phone' or fax='$phone';"; +# $stmt="SELECT count(*) from vtiger_contactsubdetails where homephone='$phone' or otherphone='$phone' or assistantphone='$phone';"; +# +# VENDOR: +# $stmt="SELECT count(*) from vtiger_vendor where phone='$phone';"; +# +# LEAD: +# $stmt="SELECT count(*) from vtiger_leadaddress where phone='$phone' or mobile='$phone' or fax='$phone';"; + +$lead_search=0; $account_search=0; $vendor_search=0; $acctid_search=0; $unified_contact=0; + +if (ereg('ACCTID',$vtiger_search_category)) {$acctid_search=1;} +if (ereg('ACCOUNT',$vtiger_search_category)) {$account_search=1;} +if (ereg('VENDOR',$vtiger_search_category)) {$vendor_search=1;} +if (ereg('LEAD',$vtiger_search_category)) {$lead_search=1;} +if (ereg('UNIFIED_CONTACT',$vtiger_search_category)) {$unified_contact=1;} + + + +########################################################################## +##### BEGIN - UNIFIED_CONTACT - Search using beta 5.1.0 unified search feature +########################################################################## +if ($unified_contact > 0) + { + $unified_contact_URL = "$vtiger_url/index.php?action=UnifiedSearch&module=Home&search_module=Contacts&query_string=$phone&_service=vicidial"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + + echo "
";
+	echo "Forwarding to Vtiger Unified Contact Search page...\n";
+	echo "phone number:   $phone\n";
+	echo "

"; + exit; + } +########################################################################## +##### END - UNIFIED_CONTACT +########################################################################## + + + +########################################################################## +##### BEGIN - ACCTID - Search in the account records for accountid number +########################################################################## +if ($acctid_search > 0) + { + $stmt="SELECT count(*) from vtiger_account where accountid='$vendor_id';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $found_count = $row[0]; + + if ($DB) {echo "
\nACCTID|$vendor_id|$found_count|\n";} + + if ($found_count < 1) + { + echo "\n"; + } + else + { + $stmt="SELECT count(*) from vtiger_crmentity where crmid='$vendor_id' and deleted='1';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $deleted_count = $row[0]; + if ( ($deleted_count > 0) and (ereg('DISABLED',$vtiger_search_dead)) ) + { + echo "\n"; + } + else + { + if ( ($deleted_count > 0) and ( (ereg('RESURRECT',$vtiger_search_dead)) or (ereg('ASK',$vtiger_search_dead)) ) ) + { + # un-delete the record + $stmt="UPDATE vtiger_crmentity SET deleted='0' where crmid='$vendor_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + echo "\n"; + } + + if (ereg('Y',$vtiger_create_call_record)) + { + ### Log the call in Vtiger + + #Get logged in user ID + $stmt="SELECT id from vtiger_users where user_name='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + $row=mysql_fetch_row($rslt); + $user_id = $row[0]; + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + # Get next aviable id from vtiger_crmentity_seq to use as activityid in vtiger_crmentity + $stmt="SELECT id from vtiger_crmentity_seq ;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + $row=mysql_fetch_row($rslt); + $activityid = ($row[0] + 1); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + # Increase next aviable crmid with 1 so next record gets proper id + $stmt="UPDATE vtiger_crmentity_seq SET id = '$activityid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #Insert values into vtiger_salesmanactivityrel + $stmt = "INSERT INTO vtiger_salesmanactivityrel SET smid='$user_id',activityid='$activityid';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "|$leadid|\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #Insert values into vtiger_seactivityrel + $stmt = "INSERT INTO vtiger_seactivityrel SET crmid='$vendor_id',activityid='$activityid';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "|$leadid|\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #Insert values into vtiger_crmentity + $stmt = "INSERT INTO vtiger_crmentity (crmid, smcreatorid, smownerid, modifiedby, setype, description, createdtime, modifiedtime, viewedtime, status, version, presence, deleted) VALUES ('$activityid', '$user_id', '$user_id','$user_id', 'Calendar', 'VICIDIAL Call user $user', '$NOW_TIME', '$NOW_TIME', '$NOW_TIME', NULL, '0', '1', '0');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "|$leadid|\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #Insert values into vtiger_activity + $stmt = "INSERT INTO vtiger_activity SET activityid='$activityid',subject='VICIDIAL Account call $vendor_id',activitytype='Call',date_start='$TODAY',due_date='$TODAY',time_start='$HHMMnow',time_end='$HHMMend',sendnotification='0',duration_hours='0',duration_minutes='1',status='',eventstatus='Held',priority='Medium',location='VICIDIAL User $user',notime='0',visibility='Public',recurringtype='--None--';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "|$leadid|\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + # http://mysite.com/vtigercrm/index.php?module=Calendar&action=EditView&return_module=Accounts&return_action=DetailView&record=16&activity_mode=Events&return_id=9&parenttab=Sales + $account_URL = "$vtiger_url/index.php?module=Calendar&action=EditView&return_module=Accounts&return_action=DetailView&record=$activityid&activity_mode=Events&return_id=$vendor_id&parenttab=Sales"; + } + else + { + # http://mysite.com/vtigercrm/index.php?module=Accounts&action=DetailView&record=2&parenttab=Sales + $account_URL = "$vtiger_url/index.php?module=Accounts&action=DetailView&record=$vendor_id&parenttab=Sales"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + + echo "
";
+			echo "account found! ACCTID\n";
+			echo "accountid:   $vendor_id\n";
+			echo "

"; + exit; + } + } + } +########################################################################## +##### END - ACCTID - Search in the account records for accountid number +########################################################################## + + +########################################################################## +##### BEGIN - ACCOUNT - Search in the account records for phone number +########################################################################## +if ($account_search > 0) + { + $stmt="SELECT count(*) from vtiger_account where phone='$phone' or otherphone='$phone' or fax='$phone';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $found_count = $row[0]; + + if ($DB) {echo "
\nACCOUNT|$phone|$found_count|vtiger_account\n";} + + if ($found_count < 1) + { + echo "\n"; + + $stmt="SELECT count(*) from vtiger_contactdetails where phone='$phone' or mobile='$phone' or fax='$phone';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $found_count = $row[0]; + + if ($DB) {echo "
\nACCOUNT|$phone|$found_count|vtiger_contactdetails\n";} + + if ($found_count < 1) + { + echo "\n"; + + $stmt="SELECT count(*) from vtiger_contactsubdetails where homephone='$phone' or otherphone='$phone' or assistantphone='$phone';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $found_count = $row[0]; + + if ($DB) {echo "
\nACCOUNT|$phone|$found_count|vtiger_contactsubdetails\n";} + + if ($found_count < 1) + { + echo "\n"; + } + else + { + # find vtiger_contact + $stmt="SELECT contactsubscriptionid from vtiger_contactsubdetails where homephone='$phone' or otherphone='$phone' or assistantphone='$phone';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $contactid = $row[0]; + + # find vtiger_account + $stmt="SELECT accountid from vtiger_contactdetails where contactid='$contactid';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $accountid = $row[0]; + } + } + else + { + # find vtiger_account + $stmt="SELECT accountid from vtiger_contactdetails where phone='$phone' or mobile='$phone' or fax='$phone';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $accountid = $row[0]; + } + } + else + { + # find vtiger_account + $stmt="SELECT accountid from vtiger_account where phone='$phone' or otherphone='$phone' or fax='$phone';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $accountid = $row[0]; + } + if (strlen($accountid) > 0) + { + $stmt="SELECT count(*) from vtiger_crmentity where crmid='$accountid' and deleted='1';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $deleted_count = $row[0]; + if ( ($deleted_count > 0) and (ereg('DISABLED',$vtiger_search_dead)) ) + { + echo "\n"; + } + else + { + if ( ($deleted_count > 0) and ( (ereg('RESURRECT',$vtiger_search_dead)) or (ereg('ASK',$vtiger_search_dead)) ) ) + { + # un-delete the record + $stmt="UPDATE vtiger_crmentity SET deleted='0' where crmid='$accountid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + echo "\n"; + } + if (ereg('Y',$vtiger_create_call_record)) + { + ### Log the call in Vtiger + + #Get logged in user ID + $stmt="SELECT id from vtiger_users where user_name='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + $row=mysql_fetch_row($rslt); + $user_id = $row[0]; + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + # Get next aviable id from vtiger_crmentity_seq to use as activityid in vtiger_crmentity + $stmt="SELECT id from vtiger_crmentity_seq ;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + $row=mysql_fetch_row($rslt); + $activityid = ($row[0] + 1); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + # Increase next aviable crmid with 1 so next record gets proper id + $stmt="UPDATE vtiger_crmentity_seq SET id = '$activityid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #Insert values into vtiger_salesmanactivityrel + $stmt = "INSERT INTO vtiger_salesmanactivityrel SET smid='$user_id',activityid='$activityid';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "|$leadid|\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #Insert values into vtiger_seactivityrel + $stmt = "INSERT INTO vtiger_seactivityrel SET crmid='$accountid',activityid='$activityid';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "|$leadid|\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #Insert values into vtiger_crmentity + $stmt = "INSERT INTO vtiger_crmentity (crmid, smcreatorid, smownerid, modifiedby, setype, description, createdtime, modifiedtime, viewedtime, status, version, presence, deleted) VALUES ('$activityid', '$user_id', '$user_id','$user_id', 'Calendar', 'VICIDIAL Call user $user', '$NOW_TIME', '$NOW_TIME', '$NOW_TIME', NULL, '0', '1', '0');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "|$leadid|\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #Insert values into vtiger_activity + $stmt = "INSERT INTO vtiger_activity SET activityid='$activityid',subject='VICIDIAL Account call $phone',activitytype='Call',date_start='$TODAY',due_date='$TODAY',time_start='$HHMMnow',time_end='$HHMMend',sendnotification='0',duration_hours='0',duration_minutes='1',status='',eventstatus='Held',priority='Medium',location='VICIDIAL User $user',notime='0',visibility='Public',recurringtype='--None--';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "|$leadid|\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + # http://mysite.com/vtigercrm/index.php?module=Calendar&action=EditView&return_module=Accounts&return_action=DetailView&record=16&activity_mode=Events&return_id=9&parenttab=Sales + $account_URL = "$vtiger_url/index.php?module=Calendar&action=EditView&return_module=Accounts&return_action=DetailView&record=$activityid&activity_mode=Events&return_id=$accountid&parenttab=Sales"; + } + else + { + # http://mysite.com/vtigercrm/index.php?module=Accounts&action=DetailView&record=2&parenttab=Sales + $account_URL = "$vtiger_url/index.php?module=Accounts&action=DetailView&record=$accountid&parenttab=Sales"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + + echo "
";
+			echo "account found! ACCOUNT\n";
+			echo "accountid:   $accountid\n";
+			echo "phone:       $phone\n";
+			echo "

"; + exit; + } + } + } +########################################################################## +##### END - ACCOUNT - Search in the account records for phone number +########################################################################## + + +########################################################################## +##### BEGIN - VENDOR - Search in the vendor records for phone number +########################################################################## +if ($vendor_search > 0) + { + $stmt="SELECT count(*) from vtiger_vendor where phone='$phone';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $found_count = $row[0]; + + if ($DB) {echo "
\nVENDOR|$phone|$found_count|\n";} + + if ($found_count < 1) + { + echo "\n"; + } + else + { + # find vtiger_vendor + $stmt="SELECT vendorid from vtiger_vendor where phone='$phone';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $vendorid = $row[0]; + + # http://mysite.com/vtigercrm/index.php?module=Vendors&action=DetailView&record=2&parenttab=Inventory + $account_URL = "$vtiger_url/index.php?module=Vendors&action=DetailView&record=$vendorid&parenttab=Inventory"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + + echo "
";
+		echo "account found! VENDOR\n";
+		echo "vendorid:   $vendorid\n";
+		echo "phone:       $phone\n";
+		echo "

"; + exit; + } + } +########################################################################## +##### END - VENDOR - Search in the vendor records for phone number +########################################################################## + + +########################################################################## +##### BEGIN - LEAD - Search in the leads records for phone number +########################################################################## +if ($lead_search > 0) + { + $stmt="SELECT count(*) from vtiger_leadaddress where phone='$phone' or mobile='$phone' or fax='$phone';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $found_count = $row[0]; + + if ($DB) {echo "
\nLEAD|$phone|$found_count|\n";} + + if ($found_count < 1) + { + echo "\n"; + if (ereg('Y',$vtiger_create_lead_record)) + { + echo "\n"; + echo "\n"; + echo "
\n"; + echo "$phone not found, creating account...\n"; + + $DB=1; + + #Get logged in user ID + if ($DB) {echo "
";}
+			$stmt="SELECT id from vtiger_users where user_name='$user';";
+			if ($DB) {echo "$stmt\n";}
+			$rslt=mysql_query($stmt, $linkV);
+			$row=mysql_fetch_row($rslt);
+			$user_id = $row[0];
+			if (!$rslt) {die('Could not execute: ' . mysql_error());}
+			
+			#Vtiger no longer use auto increment for vtiger_crmentity crmid, vtiger_crmentity_seq is used instead to list next aviable entity ID
+			# Get next aviable id to use as  crmid in vtiger_crmentity	
+			$stmt="SELECT id from vtiger_crmentity_seq ;";
+			if ($DB) {echo "$stmt\n";}
+			$rslt=mysql_query($stmt, $linkV);
+			$row=mysql_fetch_row($rslt);
+			$leadid = ($row[0] + 1);
+			if (!$rslt) {die('Could not execute: ' . mysql_error());}
+
+			# Increase 	next aviable crmid with 1 so next record gets proper id
+			$stmt="UPDATE vtiger_crmentity_seq SET id = '$leadid';";
+			if ($DB) {echo "$stmt\n";}
+			$rslt=mysql_query($stmt, $linkV);
+			if (!$rslt) {die('Could not execute: ' . mysql_error());}
+			
+			#Insert values into vtiger_crmentity
+			$stmt = "INSERT INTO vtiger_crmentity (crmid, smcreatorid, smownerid, modifiedby, setype, description, createdtime, modifiedtime, viewedtime, status, version, presence, deleted) VALUES ('$leadid', '$user_id', '$user_id','$user_id', 'Leads', '(Memo)', '$NOW_TIME', '$NOW_TIME', '$NOW_TIME', NULL, '0', '1', '0');";
+			if ($DB) {echo "|$stmt|\n";}
+			$rslt=mysql_query($stmt, $linkV);
+			if ($DB) {echo "|$leadid|\n";}
+			if (!$rslt) {die('Could not execute: ' . mysql_error());}
+
+			#Insert values into vtiger_leaddetails	
+			$stmt = "INSERT INTO vtiger_leaddetails (leadid,firstname,lastname,company) values('$leadid','$first_name','$last_name','$first_name $last_name');";
+			if ($DB) {echo "|$stmt|\n";}
+			$rslt=mysql_query($stmt, $linkV);
+			if (!$rslt) {die('Could not execute: ' . mysql_error());}
+
+			#Insert values into vtiger_leaddetails
+			$stmt = "INSERT INTO vtiger_leadaddress (leadaddressid,city,code,state,country,phone,mobile,lane) values('$leadid','$city','$postal_code','$province','$country','$phone','$alt_phone','$address1 $address2');";
+			if ($DB) {echo "|$stmt|\n";}
+			$rslt=mysql_query($stmt, $linkV);
+			if (!$rslt) {die('Could not execute: ' . mysql_error());}
+
+			#Insert values into vtiger_leadsubdetails	
+			$stmt = "INSERT INTO vtiger_leadsubdetails (leadsubscriptionid) VALUES ('$leadid');";
+			if ($DB) {echo "|$stmt|\n";}
+			$rslt=mysql_query($stmt, $linkV);
+			if (!$rslt) {die('Could not execute: ' . mysql_error());}
+			
+			#Insert values into vtiger_leadscf, these are custom created fields example	
+			$stmt = "INSERT INTO vtiger_leadscf (leadid) VALUES ('$leadid');";
+			if ($DB) {echo "|$stmt|\n";}
+			$rslt=mysql_query($stmt, $linkV);
+			if (!$rslt) {die('Could not execute: ' . mysql_error());}
+
+			if ($DB) {echo "DONE creating lead records\n";}
+
+			if (ereg('Y',$vtiger_create_call_record))
+				{
+				### Log the call in Vtiger
+
+				#Get logged in user ID
+				$stmt="SELECT id from vtiger_users where user_name='$user';";
+				if ($DB) {echo "$stmt\n";}
+				$rslt=mysql_query($stmt, $linkV);
+				$row=mysql_fetch_row($rslt);
+				$user_id = $row[0];
+				if (!$rslt) {die('Could not execute: ' . mysql_error());}
+				
+				# Get next aviable id from vtiger_crmentity_seq to use as activityid in vtiger_crmentity	
+				$stmt="SELECT id from vtiger_crmentity_seq ;";
+				if ($DB) {echo "$stmt\n";}
+				$rslt=mysql_query($stmt, $linkV);
+				$row=mysql_fetch_row($rslt);
+				$activityid = ($row[0] + 1);
+				if (!$rslt) {die('Could not execute: ' . mysql_error());}
+
+				# Increase next aviable crmid with 1 so next record gets proper id
+				$stmt="UPDATE vtiger_crmentity_seq SET id = '$activityid';";
+				if ($DB) {echo "$stmt\n";}
+				$rslt=mysql_query($stmt, $linkV);
+				if (!$rslt) {die('Could not execute: ' . mysql_error());}
+				
+				#Insert values into vtiger_salesmanactivityrel
+				$stmt = "INSERT INTO vtiger_salesmanactivityrel SET smid='$user_id',activityid='$activityid';";
+				if ($DB) {echo "|$stmt|\n";}
+				$rslt=mysql_query($stmt, $linkV);
+				if ($DB) {echo "|$leadid|\n";}
+				if (!$rslt) {die('Could not execute: ' . mysql_error());}
+				
+				#Insert values into vtiger_seactivityrel
+				$stmt = "INSERT INTO vtiger_seactivityrel SET crmid='$leadid',activityid='$activityid';";
+				if ($DB) {echo "|$stmt|\n";}
+				$rslt=mysql_query($stmt, $linkV);
+				if ($DB) {echo "|$leadid|\n";}
+				if (!$rslt) {die('Could not execute: ' . mysql_error());}
+				
+				#Insert values into vtiger_crmentity
+				$stmt = "INSERT INTO vtiger_crmentity (crmid, smcreatorid, smownerid, modifiedby, setype, description, createdtime, modifiedtime, viewedtime, status, version, presence, deleted) VALUES ('$activityid', '$user_id', '$user_id','$user_id', 'Calendar', 'VICIDIAL Call user $user', '$NOW_TIME', '$NOW_TIME', '$NOW_TIME', NULL, '0', '1', '0');";
+				if ($DB) {echo "|$stmt|\n";}
+				$rslt=mysql_query($stmt, $linkV);
+				if ($DB) {echo "|$leadid|\n";}
+				if (!$rslt) {die('Could not execute: ' . mysql_error());}
+
+				#Insert values into vtiger_activity
+				$stmt = "INSERT INTO vtiger_activity SET activityid='$activityid',subject='VICIDIAL Lead call $phone',activitytype='Call',date_start='$TODAY',due_date='$TODAY',time_start='$HHMMnow',time_end='$HHMMend',sendnotification='0',duration_hours='0',duration_minutes='1',status='',eventstatus='Held',priority='Medium',location='VICIDIAL user $user',notime='0',visibility='Public',recurringtype='--None--';";
+				if ($DB) {echo "|$stmt|\n";}
+				$rslt=mysql_query($stmt, $linkV);
+				if ($DB) {echo "|$leadid|\n";}
+				if (!$rslt) {die('Could not execute: ' . mysql_error());}
+
+
+				# http://mysite.com/vtigercrm/index.php?module=Calendar&action=EditView&return_module=Accounts&return_action=DetailView&record=16&activity_mode=Events&return_id=9&parenttab=Sales
+				$account_URL = "$vtiger_url/index.php?module=Calendar&action=EditView&return_module=Leads&return_action=DetailView&record=$activityid&activity_mode=Events&return_id=$leadid&parenttab=Sales";
+				}
+			else
+				{
+				# http://mysite.com/vtigercrm/index.php?module=Accounts&action=EditView&record=2&parenttab=Sales
+				$account_URL = "$vtiger_url/index.php?module=Leads&action=EditView&record=$leadid&parenttab=Sales";
+				}
+
+			echo "\n";
+			echo "\n";
+			echo "\n";
+			echo "
\n"; + + echo "
";
+			echo "account created! LEAD\n";
+			echo "leadid:   $leadid\n";
+			echo "phone:       $phone\n";
+			echo "

"; + exit; + } + } + else + { + $stmt="SELECT leadaddressid from vtiger_leadaddress where phone='$phone' or mobile='$phone' or fax='$phone';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $leadid = $row[0]; + + $stmt="SELECT count(*) from vtiger_crmentity where crmid='$leadid' and deleted='1';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $deleted_count = $row[0]; + if ( ($deleted_count > 0) and (ereg('DISABLED',$vtiger_search_dead)) ) + { + echo "\n"; + } + else + { + if ( ($deleted_count > 0) and ( (ereg('RESURRECT',$vtiger_search_dead)) or (ereg('ASK',$vtiger_search_dead)) ) ) + { + # un-delete the record + $stmt="UPDATE vtiger_crmentity SET deleted='0' where crmid='$leadid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + echo "\n"; + } + + if (ereg('Y',$vtiger_create_call_record)) + { + ### Log the call in Vtiger + + #Get logged in user ID + $stmt="SELECT id from vtiger_users where user_name='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + $row=mysql_fetch_row($rslt); + $user_id = $row[0]; + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + # Get next aviable id from vtiger_crmentity_seq to use as activityid in vtiger_crmentity + $stmt="SELECT id from vtiger_crmentity_seq ;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + $row=mysql_fetch_row($rslt); + $activityid = ($row[0] + 1); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + # Increase next aviable crmid with 1 so next record gets proper id + $stmt="UPDATE vtiger_crmentity_seq SET id = '$activityid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #Insert values into vtiger_salesmanactivityrel + $stmt = "INSERT INTO vtiger_salesmanactivityrel SET smid='$user_id',activityid='$activityid';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "|$leadid|\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #Insert values into vtiger_seactivityrel + $stmt = "INSERT INTO vtiger_seactivityrel SET crmid='$leadid',activityid='$activityid';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "|$leadid|\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #Insert values into vtiger_crmentity + $stmt = "INSERT INTO vtiger_crmentity (crmid, smcreatorid, smownerid, modifiedby, setype, description, createdtime, modifiedtime, viewedtime, status, version, presence, deleted) VALUES ('$activityid', '$user_id', '$user_id','$user_id', 'Calendar', 'VICIDIAL Call user $user', '$NOW_TIME', '$NOW_TIME', '$NOW_TIME', NULL, '0', '1', '0');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "|$leadid|\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + #Insert values into vtiger_activity + $stmt = "INSERT INTO vtiger_activity SET activityid='$activityid',subject='VICIDIAL Lead call $phone',activitytype='Call',date_start='$TODAY',due_date='$TODAY',time_start='$HHMMnow',time_end='$HHMMend',sendnotification='0',duration_hours='0',duration_minutes='1',status='',eventstatus='Held',priority='Medium',location='VICIDIAL user $user',notime='0',visibility='Public',recurringtype='--None--';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "|$leadid|\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + + # http://mysite.com/vtigercrm/index.php?module=Calendar&action=EditView&return_module=Accounts&return_action=DetailView&record=16&activity_mode=Events&return_id=9&parenttab=Sales + $account_URL = "$vtiger_url/index.php?module=Calendar&action=EditView&return_module=Leads&return_action=DetailView&record=$activityid&activity_mode=Events&return_id=$leadid&parenttab=Sales"; + } + else + { + # http://mysite.com/vtigercrm/index.php?module=Accounts&action=DetailView&record=2&parenttab=Sales + $account_URL = "$vtiger_url/index.php?module=Leads&action=DetailView&record=$leadid&parenttab=Sales"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + + echo "
";
+			echo "lead found! LEAD\n";
+			echo "leadid:   $leadid\n";
+			echo "phone:       $phone\n";
+			echo "

"; + exit; + } + } + } +########################################################################## +##### END - LEAD - Search in the leads records for phone number +########################################################################## + + + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n
$phone NOT FOUND

\n\n"; +echo "Click here to go to the Vtiger home page\n"; + +# echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + + +?> + + + + + + + + + + + diff --git a/LANG_www/vicidial_br/vtiger_user.php b/LANG_www/vicidial_br/vtiger_user.php new file mode 100644 index 00000000..f53a989a --- /dev/null +++ b/LANG_www/vicidial_br/vtiger_user.php @@ -0,0 +1,317 @@ + LICENSE: AGPLv2 +# +# CHANGES +# 81231-1307 - First build +# 90228-2152 - Added Groups support +# 90508-0644 - Changed to PHP long tags +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; + + +#$DB = '1'; # DEBUG override +$US = '_'; +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$REC_TIME = date("Ymd-His"); +$FILE_datetime = $STARTtime; +$parked_time = $STARTtime; + +############################################################### +##### START SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP ##### +$stmt = "SELECT enable_vtiger_integration,vtiger_server_ip,vtiger_dbname,vtiger_login,vtiger_pass,vtiger_url FROM system_settings;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$ss_conf_ct = mysql_num_rows($rslt); +if ($ss_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $enable_vtiger_integration = $row[0]; + $vtiger_server_ip = $row[1]; + $vtiger_dbname = $row[2]; + $vtiger_login = $row[3]; + $vtiger_pass = $row[4]; + $vtiger_url = $row[5]; + } +##### END SYSTEM_SETTINGS VTIGER CONNECTION INFO LOOKUP ##### +############################################################# + +echo "\n"; +echo "\n"; +echo "VICIDIAL Vtiger user synchronization utility\n"; +echo "\n"; + +if ($enable_vtiger_integration < 1) + { + echo "ERROR! - Vtiger integration is disabled in the VICIDIAL system_settings"; + exit; + } + +##### grab the existing user_groups in the vicidial_user_groups table +$stmt="SELECT user_group,group_name FROM vicidial_user_groups;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$VD_groups_ct = mysql_num_rows($rslt); +$i=0; +while ($i < $VD_groups_ct) + { + $row=mysql_fetch_row($rslt); + $UGid[$i] = $row[0]; + $UGname[$i] = $row[1]; + $i++; + } + +##### grab the existing users in the vicidial_users table +$stmt="SELECT user,pass,full_name,user_level,active,user_group FROM vicidial_users;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$VD_users_ct = mysql_num_rows($rslt); +$i=0; +while ($i < $VD_users_ct) + { + $row=mysql_fetch_row($rslt); + $user[$i] = $row[0]; + $pass[$i] = $row[1]; + $full_name[$i] = $row[2]; while (strlen($full_name[$i])>30) {$full_name[$i] = eregi_replace(".$",'',$full_name[$i]);} + $user_level[$i] = $row[3]; + $active[$i] = $row[4]; + $user_group[$i] = $row[5]; + $i++; + } + + +### connect to your vtiger database +$linkV=mysql_connect("$vtiger_server_ip", "$vtiger_login","$vtiger_pass"); +if (!$linkV) {die("Could not connect: $vtiger_server_ip|$vtiger_dbname|$vtiger_login|$vtiger_pass" . mysql_error());} +echo "Connected successfully\n
\n"; +mysql_select_db("$vtiger_dbname", $linkV); + + +########################## +### BEGIN Group export +$i=0; +while ($i < $VD_groups_ct) + { + $VTgroup_name = $UGid[$i]; + $VTgroup_description = $UGname[$i]; + + $stmt="SELECT count(*) from vtiger_groups where groupname='$VTgroup_name';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $group_found_count = $row[0]; + + ### group exists in vtiger, grab groupid, update description + if ($group_found_count > 0) + { + $stmt="SELECT groupid from vtiger_groups where groupname='$VTgroup_name';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $groupid = $row[0]; + $VTugID[$i] = $groupid; + + $stmtA = "UPDATE vtiger_groups SET description='$VTgroup_description' where groupid='$groupid';"; + if ($DB) {echo "|$stmtA|\n";} + $rslt=mysql_query($stmtA, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + echo "GROUP- $VTgroup_name: $groupid
\n"; + echo "
\n"; + } + + ### group doesn't exist in vtiger, insert it + else + { + #### BEGIN CREATE NEW GROUP RECORD IN VTIGER + + # Get next available id from vtiger_users_seq to use as groupid + $stmt="SELECT id from vtiger_users_seq;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + $row=mysql_fetch_row($rslt); + $groupid = ($row[0] + 1); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $VTugID[$i] = $groupid; + + # Increase next available groupid with 1 so next record gets proper id + $stmt="UPDATE vtiger_users_seq SET id = '$groupid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtA = "INSERT INTO vtiger_groups SET groupid='$groupid',groupname='$VTgroup_name',description='$VTgroup_description';"; + if ($DB) {echo "|$stmtA|\n";} + $rslt=mysql_query($stmtA, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + echo "GROUP- $VTgroup_name: $groupid
\n"; + echo "
\n"; + #### END CREATE NEW GROUP RECORD IN VTIGER + } + $i++; + } +### END Group export +########################## + + + +########################## +### BEGIN User export +$i=0; +while ($i < $VD_users_ct) + { + $user_name = $user[$i]; + $VUgroup = $user_group[$i]; + $user_password = $pass[$i]; + $last_name = $full_name[$i]; + $is_admin = 'off'; + $roleid = 'H5'; + $status = 'Active'; + $groupid = '1'; + if ($user_level[$i] >= 7) {$roleid = 'H4';} + if ($user_level[$i] >= 8) {$roleid = 'H3';} + if ($user_level[$i] >= 9) {$roleid = 'H2';} + if ($user_level[$i] >= 9) {$is_admin = 'on';} + if (ereg('N',$active[$i])) {$status = 'Inactive';} + $salt = substr($user_name, 0, 2); + $salt = '$1$' . $salt . '$'; + $encrypted_password = crypt($user_password, $salt); + $i++; + + $j=0; + $all_VICIDIAL_groups_SQL=''; + while ($j < $VD_groups_ct) + { + if ( (eregi("$UGid[$j]",$VUgroup)) and ( (strlen($UGid[$j]))==(strlen($VUgroup)) ) ) + { + $groupid = $VTugID[$j]; + $VTgroup_name = $UGid[$j]; + $VTgroup_description = $UGname[$j]; + } + else + {$all_VICIDIAL_groups_SQL .= "'$VTugID[$j]',";} + $j++; + } + $all_VICIDIAL_groups_SQL = preg_replace("/.$/",'',$all_VICIDIAL_groups_SQL); + + $stmt="SELECT count(*) from vtiger_users where user_name='$user_name';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $found_count = $row[0]; + + ### user exists in vtiger, update it + if ($found_count > 0) + { + $stmt="SELECT id from vtiger_users where user_name='$user_name';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $userid = $row[0]; + + $stmt="SELECT count(*) from vtiger_users2group WHERE userid='$userid' and groupid='$groupid';"; + $rslt=mysql_query($stmt, $linkV); + if ($DB) {echo "$stmt\n";} + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $row=mysql_fetch_row($rslt); + $usergroupcount = $row[0]; + + $stmtA = "UPDATE vtiger_users SET user_password='$encrypted_password',last_name='$last_name',is_admin='$is_admin',status='$status' where id='$userid';"; + if ($DB) {echo "|$stmtA|\n";} + $rslt=mysql_query($stmtA, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtB = "UPDATE vtiger_user2role SET roleid='$roleid' where userid='$userid';"; + if ($DB) {echo "|$stmtB|\n";} + $rslt=mysql_query($stmtB, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + if ($usergroupcount < 1) + { + $stmtC = "DELETE FROM vtiger_users2group WHERE userid='$userid' and groupid IN($all_VICIDIAL_groups_SQL);"; + if ($DB) {echo "|$stmtC|\n";} + $rslt=mysql_query($stmtC, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtD = "INSERT INTO vtiger_users2group SET userid='$userid',groupid='$groupid';"; + if ($DB) {echo "|$stmtC|\n";} + $rslt=mysql_query($stmtD, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + } + else + {$stmtC='';} + + echo "$user_name: $userid
\n"; + echo "$stmtA
\n"; + echo "$stmtB
\n"; + echo "$stmtC
\n"; + echo "$stmtD
\n"; + echo "
\n"; + + } + + ### user doesn't exist in vtiger, insert it + else + { + #### BEGIN CREATE NEW USER RECORD IN VTIGER + $stmtA = "INSERT INTO vtiger_users SET user_name='$user_name',user_password='$encrypted_password',last_name='$last_name',is_admin='$is_admin',status='$status',date_format='yyyy-mm-dd',first_name='',reports_to_id='',description='',title='',department='',phone_home='',phone_mobile='',phone_work='',phone_other='',phone_fax='',email1='',email2='',yahoo_id='',signature='',address_street='',address_city='',address_state='',address_country='',address_postalcode='',user_preferences='',imagename='';"; + if ($DB) {echo "|$stmtA|\n";} + $rslt=mysql_query($stmtA, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + $userid = mysql_insert_id($linkV); + + $stmtB = "INSERT INTO vtiger_user2role SET userid='$userid',roleid='$roleid';"; + if ($DB) {echo "|$stmtB|\n";} + $rslt=mysql_query($stmtB, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtC = "INSERT INTO vtiger_users2group SET userid='$userid',groupid='$groupid';"; + if ($DB) {echo "|$stmtC|\n";} + $rslt=mysql_query($stmtC, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + $stmtD = "UPDATE vtiger_users_seq SET id='$userid';"; + if ($DB) {echo "|$stmtD|\n";} + $rslt=mysql_query($stmtD, $linkV); + if (!$rslt) {die('Could not execute: ' . mysql_error());} + + echo "$user_name:
\n"; + echo "$stmtA
\n"; + echo "$stmtB
\n"; + echo "$stmtC
\n"; + echo "$stmtD
\n"; + echo "
\n"; + #### END CREATE NEW USER RECORD IN VTIGER + } + + + } +### END User export +########################## + + + + + +echo "DONE\n"; + +exit; + + diff --git a/LANG_www/vicidial_br/welcome.php b/LANG_www/vicidial_br/welcome.php new file mode 100644 index 00000000..5eeba0ad --- /dev/null +++ b/LANG_www/vicidial_br/welcome.php @@ -0,0 +1,26 @@ + LICENSE: AGPLv2 +# + +echo "ViciDial Bem vindo\n"; +echo "\n"; +echo "\n"; +echo "




"; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Bemvindo
 
Agent Login
 
Relógio Ponto
 
Administration
 
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; + +?> \ No newline at end of file diff --git a/LANG_www/vicidial_br/welcome_demo.php b/LANG_www/vicidial_br/welcome_demo.php new file mode 100644 index 00000000..238cf5cf --- /dev/null +++ b/LANG_www/vicidial_br/welcome_demo.php @@ -0,0 +1,88 @@ + LICENSE: GPLv2 +# +header ("Content-type: text/html; charset=utf-8"); + +echo "ViciDial Welcome\n"; +echo "\n"; +echo "\n"; +echo "



"; +echo ""; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Welcome! Bienvenue!   Willkommen! Benvenuto! Υποδοχή!
 
\n"; + +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
"; +echo "   English Agent Login"; +echo "
"; +echo "   Spanish Agent Login"; +echo "
"; +echo "   German Agent Login"; +echo "
"; +echo "   Italian Agent Login"; +echo "
"; +echo "   Greek Agent Login"; +echo "
"; +echo "   French Agent Login"; +echo "
"; +echo "   Brazillian Portuguese Agent Login"; +echo "
"; +echo "   Portuguese Agent Login"; +echo "
"; +echo "   Polish Agent Login"; +echo "
"; +echo "   Slovak Agent Login"; +echo "
"; +echo "   Russian Agent Login"; +echo "
"; +echo "   Dutch Agent Login"; +echo "
"; +echo "   Chinese(T) Agent Login"; +echo "
\n"; + +echo "
\n"; + +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
"; +echo "   English Administration"; +echo "
"; +echo "   Spanish Administration"; +echo "
"; +echo "   German Administration"; +echo "
"; +echo "   Italian Administration"; +echo "
"; +echo "   Greek Administration"; +echo "
"; +echo "   French Administration"; +echo "
\n"; +echo "
 
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; + +?> \ No newline at end of file diff --git a/LANG_www/vicidial_br/welcome_languages.php b/LANG_www/vicidial_br/welcome_languages.php new file mode 100644 index 00000000..d53707a9 --- /dev/null +++ b/LANG_www/vicidial_br/welcome_languages.php @@ -0,0 +1,88 @@ + LICENSE: GPLv2 +# +header ("Content-type: text/html; charset=utf-8"); + +echo "ViciDial Welcome\n"; +echo "\n"; +echo "\n"; +echo "



"; +echo ""; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Welcome! Bienvenue!   Willkommen! Benvenuto! Υποδοχή!
 
\n"; + +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
"; +echo "   English Agent Login"; +echo "
"; +echo "   Spanish Agent Login"; +echo "
"; +echo "   German Agent Login"; +echo "
"; +echo "   Italian Agent Login"; +echo "
"; +echo "   Greek Agent Login"; +echo "
"; +echo "   French Agent Login"; +echo "
"; +echo "   Brazillian Portuguese Agent Login"; +echo "
"; +echo "   Portuguese Agent Login"; +echo "
"; +echo "   Polish Agent Login"; +echo "
"; +echo "   Slovak Agent Login"; +echo "
"; +echo "   Russian Agent Login"; +echo "
"; +echo "   Dutch Agent Login"; +echo "
"; +echo "   Chinese(T) Agent Login"; +echo "
\n"; + +echo "
\n"; + +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
"; +echo "   English Administration"; +echo "
"; +echo "   Spanish Administration"; +echo "
"; +echo "   German Administration"; +echo "
"; +echo "   Italian Administration"; +echo "
"; +echo "   Greek Administration"; +echo "
"; +echo "   French Administration"; +echo "
\n"; +echo "
 
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; + +?> \ No newline at end of file diff --git a/www/agc/images/se.gif b/www/agc/images/se.gif new file mode 100644 index 00000000..9f329d65 Binary files /dev/null and b/www/agc/images/se.gif differ diff --git a/www/vicidial/welcome_demo.php b/www/vicidial/welcome_demo.php index 3175fa64..3b48ee07 100644 --- a/www/vicidial/welcome_demo.php +++ b/www/vicidial/welcome_demo.php @@ -56,6 +56,9 @@ echo "  
"; echo "   Chinese(T) Agent Login"; +echo "
"; +echo "   Swedish Agent Login"; echo "
\n"; echo "
\n"; diff --git a/www/vicidial/welcome_languages.php b/www/vicidial/welcome_languages.php index 75b9382e..4fe6d387 100644 --- a/www/vicidial/welcome_languages.php +++ b/www/vicidial/welcome_languages.php @@ -56,6 +56,9 @@ echo "  
"; echo "   Chinese(T) Agent Login"; +echo "
"; +echo "   Swedish Agent Login"; echo "
\n"; echo "
\n";